PageRenderTime 57ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/config/templates/fattura_allegata.php

http://gevion.googlecode.com/
PHP | 226 lines | 186 code | 11 blank | 29 comment | 23 complexity | 8faeb1b93644080738599311f83f85c4 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. /* $Id: fattura_allegata.php,v 1.4 2010/01/01 14:15:18 devincen Exp $
  3. --------------------------------------------------------------------------
  4. Gazie - Gestione Azienda
  5. Copyright (C) 2004-2010 - Antonio De Vincentiis Montesilvano (PE)
  6. (www.devincentiis.it)
  7. <http://gazie.sourceforge.net>
  8. --------------------------------------------------------------------------
  9. Questo programma e` free software; e` lecito redistribuirlo e/o
  10. modificarlo secondo i termini della Licenza Pubblica Generica GNU
  11. come e` pubblicata dalla Free Software Foundation; o la versione 2
  12. della licenza o (a propria scelta) una versione successiva.
  13. Questo programma e` distribuito nella speranza che sia utile, ma
  14. SENZA ALCUNA GARANZIA; senza neppure la garanzia implicita di
  15. NEGOZIABILITA` o di APPLICABILITA` PER UN PARTICOLARE SCOPO. Si
  16. veda la Licenza Pubblica Generica GNU per avere maggiori dettagli.
  17. Ognuno dovrebbe avere ricevuto una copia della Licenza Pubblica
  18. Generica GNU insieme a questo programma; in caso contrario, si
  19. scriva alla Free Software Foundation, Inc., 59
  20. Temple Place, Suite 330, Boston, MA 02111-1307 USA Stati Uniti.
  21. --------------------------------------------------------------------------
  22. */
  23. require("../../library/include/calsca.inc.php");
  24. require('template.php');
  25. class FatturaAllegata extends Template
  26. {
  27. function setTesDoc()
  28. {
  29. $this->tesdoc = $this->docVars->tesdoc;
  30. $this->giorno = substr($this->tesdoc['datfat'],8,2);
  31. $this->mese = substr($this->tesdoc['datfat'],5,2);
  32. $this->anno = substr($this->tesdoc['datfat'],0,4);
  33. $this->data = strftime("%d-%m-%Y", mktime (0,0,0,substr($this->tesdoc['datemi'],5,2),substr($this->tesdoc['datemi'],8,2),substr($this->tesdoc['datemi'],0,4)));
  34. $this->sconto = $this->tesdoc['sconto'];
  35. $this->tipdoc = 'Fattura n.'.$this->tesdoc['numfat'].' Allegata allo scontrino n.'.$this->tesdoc['numdoc'].' del '.$this->data;
  36. }
  37. function newPage() {
  38. $this->AddPage();
  39. $this->SetFont('freesans','',8);
  40. $this->Cell(100);
  41. $this->Cell(62,5,'Agente','LTR',0,'C',1);
  42. $this->Cell(4);
  43. $this->Cell(20,5,'Sconto base','LTR',1,'C',1);
  44. $this->Cell(100);
  45. $this->Cell(62,5,$this->docVars->rs_agente['ragso1'],'LBR');
  46. $this->Cell(4);
  47. $this->Cell(20,5,gaz_format_number($this->sconto).'%','LBR',1,'C');
  48. $this->Ln(2);
  49. $this->SetY(100);
  50. $this->Cell(23,6,'Codice',1,0,'C',1);
  51. $this->Cell(75,6,'Descrizione',1,0,'C',1);
  52. $this->Cell(6, 6,'U.m.',1,0,'C',1);
  53. $this->Cell(14,6,'Quantit? ',1,0,'C',1);
  54. $this->Cell(15,6,'Prezzo',1,0,'C',1);
  55. $this->Cell(7, 6,'%Sc.',1,0,'C',1);
  56. $this->Cell(18,6,'Importo',1,0,'C',1);
  57. $this->Cell(10,6,'%IVA',1,0,'C',1);
  58. $this->Cell(18,6,'Totale',1,1,'C',1);
  59. }
  60. function pageHeader() {
  61. $this->StartPageGroup();
  62. $this->SetFillColor(hexdec(substr($this->colore,0,2)),hexdec(substr($this->colore,2,2)),hexdec(substr($this->colore,4,2)));
  63. $this->newPage();
  64. }
  65. function compose()
  66. {
  67. $this->setTesDoc();
  68. $this->AliasNbPages();
  69. $this->body();
  70. }
  71. function body()
  72. {
  73. $lines = $this->docVars->getTicketRow();
  74. while (list($key, $rigo) = each($lines)) {
  75. if ($this->GetY() >= 195) {
  76. $this->Cell(186,6,'','T',1);
  77. $this->SetFont('freesans','',14);
  78. $this->SetY(225);
  79. $this->Cell(186,12,'>>> --- SEGUE SU PAGINA SUCCESSIVA --- >>> ',1,1,'R');
  80. $this->SetFont('freesans','',9);
  81. $this->newPage();
  82. $this->Cell(186,5,'<<< --- SEGUE DA PAGINA PRECEDENTE --- <<< ',0,1);
  83. }
  84. switch($rigo['tiprig']) {
  85. case "0":
  86. $this->Cell(23, 5, $rigo['codart'],1,0,'L');
  87. $this->Cell(75, 5, $rigo['descri'],1,0,'L');
  88. $this->Cell(6, 5, $rigo['unimis'],1,0,'C');
  89. $this->Cell(14, 5, gaz_format_quantity($rigo['quanti'],1,$this->decimal_quantity),1,0,'R');
  90. $this->Cell(15, 5, number_format($rigo['prelis'],$this->decimal_price,',',''),1,0,'R');
  91. if ($rigo['sconto']>0) {
  92. $this->Cell(7, 5, number_format($rigo['sconto'],1,',',''),1,0,'C');
  93. } else {
  94. $this->Cell(7, 5, '',1,0,'C');
  95. }
  96. $this->Cell(18, 5, gaz_format_number($rigo['importo']),1,0,'R');
  97. $this->Cell(10, 5, gaz_format_number($rigo['pervat']),1,0,'R');
  98. $this->Cell(18, 5, gaz_format_number($rigo['totale']),1,1,'R');
  99. break;
  100. case "1":
  101. $this->Cell(23, 5, $rigo['codart'],1,0,'L');
  102. $this->Cell(75, 5, $rigo['descri'],1,0,'L');
  103. $this->Cell(42, 5, '',1);
  104. $this->Cell(18, 5, gaz_format_number($rigo['importo']),1,0,'R');
  105. $this->Cell(10, 5, gaz_format_number($rigo['pervat']),1,0,'R');
  106. $this->Cell(18, 5, gaz_format_number($rigo['totale']),1,1,'R');
  107. break;
  108. case "2":
  109. $this->Cell(23,5,'','L');
  110. $this->Cell(75,5,$rigo['descri'],'LR',0,'L');
  111. $this->Cell(88,5,'','R',1);
  112. break;
  113. }
  114. }
  115. }
  116. function pageFooter()
  117. {
  118. //effettuo il calcolo degli importi delle scadenze
  119. $ratpag = CalcolaScadenze($this->docVars->totale, $this->giorno, $this->mese, $this->anno, $this->pagame['tipdec'],$this->pagame['giodec'],$this->pagame['numrat'],$this->pagame['tiprat'],$this->pagame['mesesc'],$this->pagame['giosuc']);
  120. if ($ratpag){
  121. //allungo l'array fino alla 4^ scadenza
  122. $ratpag['import'] = array_pad($ratpag['import'],4,'');
  123. $ratpag['giorno'] = array_pad($ratpag['giorno'],4,'');
  124. $ratpag['mese'] = array_pad($ratpag['mese'],4,'');
  125. $ratpag['anno'] = array_pad($ratpag['anno'],4,'');
  126. } else {
  127. for ($i = 0; $i <= 3; $i++) {
  128. $ratpag['import'][$i] = "";
  129. $ratpag['giorno'][$i] = "";
  130. $ratpag['mese'][$i] = "";
  131. $ratpag['anno'][$i] = "";
  132. }
  133. }
  134. //FINE calcolo scadenze
  135. //stampo i totali
  136. $y = $this->GetY();
  137. $this->Rect(10,$y,186,212-$y); //questa marca le linee dx e sx del documento
  138. //stampo il castelletto
  139. $this->SetY(212);
  140. $this->Cell(62,6,'Pagamento','LTR',0,'C',1);
  141. $this->Cell(68,6,'Castelletto I.V.A.','LTR',0,'C',1);
  142. $this->Cell(56,6,'T O T A L E F A T T U R A','LTR',1,'C',1);
  143. $this->SetFont('freesans','',8);
  144. $this->Cell(62,6,$this->pagame['descri'],'LBR',0,'L');
  145. $this->Cell(18,4,'Imponibile','LR',0,'C',1);
  146. $this->Cell(32,4,'Aliquota','LR',0,'C',1);
  147. $this->Cell(18,4,'Imposta','LR',1,'C',1);
  148. foreach ($this->docVars->castel as $v) {
  149. if ($this->tesdoc['id_tes'] > 0) {
  150. $this->Cell(62);
  151. $this->Cell(18, 4, gaz_format_number($v['importo']).' ','LR', 0, 'R');
  152. $this->Cell(32, 4, $v['descri'],0,0,'C');
  153. $this->Cell(18, 4, gaz_format_number($v['iva']).' ','LR',1,'R');
  154. } else {
  155. $this->Cell(62);
  156. $this->Cell(68, 4,'','LR',1);
  157. }
  158. }
  159. $this->SetY(218);
  160. $this->SetFont('freesans','B',16);
  161. $this->Cell(130);
  162. $this->Cell(56,12,'â&#x201A;? '.gaz_format_number($this->docVars->totale),'LR',1,'C');
  163. $this->SetY(224);
  164. $this->SetFont('freesans','',9);
  165. if (!empty($this->banacc['iban'])){
  166. $this->Cell(62, 6, 'Banca d\'accredito','LTR',1,'C',1);
  167. $this->Cell(62, 5, $this->banacc['ragso1'],'LR',1);
  168. $this->Cell(62, 6, 'IBAN '.$this->banacc['iban'],'LRB',1,'C');
  169. } else {
  170. $this->Cell(62, 6, '','LTR',1,'',1);
  171. $this->Cell(62, 6, '','LR',1);
  172. $this->Cell(62, 6, '','LRB',1);
  173. }
  174. $this->Cell(130,6, 'Date di Scadenza e Importo Rate','LTR',1,'C',1);
  175. $this->Cell(32, 6, $ratpag['giorno']['0'].'-'.$ratpag['mese']['0'].'-'.$ratpag['anno']['0'],'LR',0,'C');
  176. $this->Cell(33, 6, $ratpag['giorno']['1'].'-'.$ratpag['mese']['1'].'-'.$ratpag['anno']['1'],'LR',0,'C');
  177. $this->Cell(32, 6, $ratpag['giorno']['2'].'-'.$ratpag['mese']['2'].'-'.$ratpag['anno']['2'],'LR',0,'C');
  178. $this->Cell(33, 6, $ratpag['giorno']['3'].'-'.$ratpag['mese']['3'].'-'.$ratpag['anno']['3'],'LR',1,'C');
  179. if ($ratpag['import']['0'] != 0) {
  180. $this->Cell(32, 6, gaz_format_number($ratpag['import']['0']),'LBR',0,'C');
  181. } else {
  182. $this->Cell(32, 6,'','LBR');
  183. }
  184. if ($ratpag['import']['1'] != 0) {
  185. $this->Cell(33, 6, gaz_format_number($ratpag['import']['1']),'LBR',0,'C');
  186. } else {
  187. $this->Cell(33, 6,'','LBR');
  188. }
  189. if ($ratpag['import']['2'] != 0) {
  190. $this->Cell(32, 6, gaz_format_number($ratpag['import']['2']),'LBR',0,'C');
  191. } else {
  192. $this->Cell(32, 6,'','LBR');
  193. }
  194. if ($ratpag['import']['3'] != 0) {
  195. $this->Cell(33, 6, gaz_format_number($ratpag['import']['3']),'LBR',1,'C');
  196. } else {
  197. $this->Cell(33, 6,'','LBR',1);
  198. }
  199. $this->SetXY(140,230);
  200. $this->SetFont('freesans','',10);
  201. $this->MultiCell(56,30,"\nallegata allo scontrino n.".$this->tesdoc['numdoc'].
  202. " emesso in pari data con misuratore fiscale:\n\n".
  203. $this->docVars->ecr['descri'],'LBR',1,'J');
  204. }
  205. function Footer()
  206. {
  207. //Document footer
  208. $this->SetY(-20);
  209. $this->SetFont('freesans','',8);
  210. $this->MultiCell(184,4,$this->intesta1.' '.$this->intesta2.' '.$this->intesta3.' '.$this->intesta4.' ',0,'C',0);
  211. }
  212. }
  213. ?>