PageRenderTime 53ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/config/templates/fattura_acquisto.php

http://gevion.googlecode.com/
PHP | 305 lines | 262 code | 13 blank | 30 comment | 45 complexity | 86301f1ad2222993fd72035183a3244a MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. /* $Id: fattura_acquisto.php,v 1.16 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 FatturaAcquisto 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->nomemese = ucwords(strftime("%B", mktime (0,0,0,substr($this->tesdoc['datfat'],5,2),1,0)));
  34. $this->sconto = $this->tesdoc['sconto'];
  35. $this->trasporto = $this->tesdoc['traspo'];
  36. if ($this->tesdoc['tipdoc'] == 'ADT') {
  37. $descri='Ricevuto DdT d\'acquisto n.';
  38. } elseif ($this->tesdoc['tipdoc'] == 'AFA') {
  39. $descri='Ricevuta Fattura d\'acquisto n.';
  40. } elseif ($this->tesdoc['tipdoc'] == 'AFC') {
  41. $descri='Ricevuta Nota di credito n.';
  42. } elseif ($this->tesdoc['tipdoc'] == 'AFD') {
  43. $descri='Ricevuta Nota di debito n.';
  44. } else {
  45. $descri='** documento sconosciuto **';
  46. }
  47. $this->tipdoc=$descri.$this->tesdoc['numfat'].'/'.$this->tesdoc['seziva'].' del '.$this->giorno.' '.$this->nomemese.' '.$this->anno;
  48. }
  49. function newPage() {
  50. $this->AddPage();
  51. $this->SetFont('freesans','',9);
  52. $this->SetY(100);
  53. $this->Cell(25,6,'Codice',1,0,'C',1);
  54. $this->Cell(80,6,'Descrizione',1,0,'C',1);
  55. $this->Cell(7, 6,'U.m.',1,0,'C',1);
  56. $this->Cell(16,6,'Quantit? ',1,0,'C',1);
  57. $this->Cell(18,6,'Prezzo',1,0,'C',1);
  58. $this->Cell(8, 6,'%Sc.',1,0,'C',1);
  59. $this->Cell(20,6,'Importo',1,0,'C',1);
  60. $this->Cell(12,6,'%IVA',1,1,'C',1);
  61. }
  62. function pageHeader() {
  63. $this->StartPageGroup();
  64. $this->SetFillColor(hexdec(substr($this->colore,0,2)),hexdec(substr($this->colore,2,2)),hexdec(substr($this->colore,4,2)));
  65. $this->newPage();
  66. }
  67. function compose()
  68. {
  69. $this->body();
  70. }
  71. function body()
  72. {
  73. $lines = $this->docVars->getRigo();
  74. while (list($key, $rigo) = each($lines)) {
  75. if ($this->GetY() >= 185) {
  76. $this->Cell(186,6,'','T',1);
  77. $this->SetFont('freesans', '', 20);
  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(25, 6, $rigo['codart'],1,0,'L');
  87. $this->Cell(80, 6, $rigo['descri'],1,0,'L');
  88. $this->Cell(7, 6, $rigo['unimis'],1,0,'C');
  89. $this->Cell(16, 6, gaz_format_quantity($rigo['quanti'],1,$this->decimal_quantity),1,0,'R');
  90. $this->Cell(18, 6, number_format($rigo['prelis'],$this->decimal_price,',',''),1,0,'R');
  91. if ($rigo['sconto']>0) {
  92. $this->Cell(8, 6, number_format($rigo['sconto'],1,',',''),1,0,'C');
  93. } else {
  94. $this->Cell(8, 6, '',1,0,'C');
  95. }
  96. $this->Cell(20, 6, gaz_format_number($rigo['importo']),1,0,'R');
  97. $this->Cell(12, 6, gaz_format_number($rigo['pervat']),1,1,'R');
  98. break;
  99. case "1":
  100. $this->Cell(25, 6, $rigo['codart'],1,0,'L');
  101. $this->Cell(80, 6, $rigo['descri'],1,0,'L');
  102. $this->Cell(49, 6, '',1);
  103. $this->Cell(20, 6, gaz_format_number($rigo['importo']),1,0,'R');
  104. $this->Cell(12, 6, gaz_format_number($rigo['pervat']),1,1,'R');
  105. break;
  106. case "2":
  107. $this->Cell(25,6,'','L');
  108. $this->Cell(80,6,$rigo['descri'],'LR',0,'L');
  109. $this->Cell(81,6,'','R',1);
  110. break;
  111. case "3":
  112. $this->Cell(25,6,'',1,0,'L');
  113. $this->Cell(80,6,$rigo['descri'],'B',0,'L');
  114. $this->Cell(49,6,'','B',0,'L');
  115. $this->Cell(20,6,gaz_format_number($rigo['prelis']),1,0,'R');
  116. $this->Cell(12,6,'',1,1,'R');
  117. break;
  118. case "6":
  119. $this->writeHtmlCell(186,6,10,$this->GetY(),$rigo['descri'],1,1);
  120. break;
  121. case "7";
  122. $this->writeHtmlCell(186,6,10,$this->GetY(),$rigo['descri'],1,1);
  123. break;
  124. }
  125. }
  126. }
  127. function pageFooter()
  128. {
  129. $this->Cell(186,6,'','T',1);
  130. //stampo il castelletto
  131. $this->SetY(180);
  132. $this->SetFont('freesans','B',48);
  133. $this->SetTextColor(255,150,150);
  134. $this->Cell(186,20,'N O N F I S C A L E',0,1,'C');
  135. $this->SetTextColor(0,0,0);
  136. $this->SetY(212);
  137. $this->SetFont('freesans','',8);
  138. $this->Cell(62,6,'Pagamento','LTR',0,'C',1);
  139. $this->Cell(68,6,'Castelletto I.V.A.','LTR',0,'C',1);
  140. $this->Cell(56,6,'T O T A L E F A T T U R A','LTR',1,'C',1);
  141. $this->Cell(62,6,$this->pagame['descri'],'LBR',0,'L');
  142. $this->Cell(18,4,'Imponibile','LR',0,'C',1);
  143. $this->Cell(32,4,'Aliquota','LR',0,'C',1);
  144. $this->Cell(18,4,'Imposta','LR',1,'C',1);
  145. $totTrasporto = $this->tottraspo;
  146. $this->docVars->setTotal($totTrasporto);
  147. foreach ($this->docVars->cast as $key => $value) {
  148. $this->Cell(62);
  149. $this->Cell(18, 4, gaz_format_number($value['impcast']).' ','LR', 0, 'R');
  150. $this->Cell(32, 4, $value['descriz'],0,0,'C');
  151. $this->Cell(18, 4, gaz_format_number($value['ivacast']).' ','LR',1,'R');
  152. }
  153. //azzero il castelletto
  154. foreach ($this->docVars->castel as $i => $value) {
  155. unset($this->docVars->castel[$i]);
  156. }
  157. //azzero il trasporto
  158. $this->tottraspo = 0.00;
  159. $totimpmer = $this->docVars->totimpmer;
  160. $speseincasso = $this->docVars->speseincasso;
  161. $totimpfat = $this->docVars->totimpfat;
  162. $totivafat = $this->docVars->totivafat;
  163. $vettor = $this->docVars->vettor;
  164. $impbol = $this->docVars->impbol;
  165. $totriport = $this->docVars->totriport;
  166. if ($impbol > 0) {
  167. $this->Cell(62);
  168. $this->Cell(18, 4, gaz_format_number($impbol).' ', 0, 0, 'R');
  169. $this->Cell(32, 4, $this->docVars->iva_bollo['descri'], 'LR', 0, 'C');
  170. $this->Cell(18, 4,gaz_format_number($this->docVars->iva_bollo['aliquo']*$impbol).' ',0,1,'R');
  171. }
  172. //effettuo il calcolo degli importi delle scadenze
  173. $totpag = $totimpfat + $impbol + $totriport + $totivafat;
  174. $ratpag = CalcolaScadenze($totpag, $this->giorno, $this->mese, $this->anno, $this->pagame['tipdec'],$this->pagame['giodec'],$this->pagame['numrat'],$this->pagame['tiprat'],$this->pagame['mesesc'],$this->pagame['giosuc']);
  175. if ($ratpag){
  176. //allungo l'array fino alla 4^ scadenza
  177. $ratpag['import'] = array_pad($ratpag['import'],4,'');
  178. $ratpag['giorno'] = array_pad($ratpag['giorno'],4,'');
  179. $ratpag['mese'] = array_pad($ratpag['mese'],4,'');
  180. $ratpag['anno'] = array_pad($ratpag['anno'],4,'');
  181. } else {
  182. for ($i = 0; $i <= 3; $i++) {
  183. $ratpag['import'][$i] = "";
  184. $ratpag['giorno'][$i] = "";
  185. $ratpag['mese'][$i] = "";
  186. $ratpag['anno'][$i] = "";
  187. }
  188. }
  189. //stampo i totali
  190. $this->SetY(200);
  191. $this->SetFillColor(hexdec(substr($this->colore,0,2)),hexdec(substr($this->colore,2,2)),hexdec(substr($this->colore,4,2)));
  192. $this->SetFont('freesans', '', 9);
  193. $this->Cell(36, 6,'Totale merce','LTR',0,'C',1);
  194. $this->Cell(16, 6,'% Sconto','LTR',0,'C',1);
  195. $this->Cell(24, 6,'Spese Incasso','LTR',0,'C',1);
  196. $this->Cell(26, 6,'Trasporto','LTR',0,'C',1);
  197. $this->Cell(36, 6,'Tot.Imponibile','LTR',0,'C',1);
  198. $this->Cell(26, 6,'Tot. I.V.A.','LTR',0,'C',1);
  199. $this->Cell(22, 6,'Bolli','LTR',1,'C',1);
  200. if ($totimpmer > 0) {
  201. $this->Cell(36, 6, gaz_format_number($totimpmer),'LBR',0,'C');
  202. } else {
  203. $this->Cell(36, 6,'','LBR');
  204. }
  205. if ($this->tesdoc['sconto'] > 0) {
  206. $this->Cell(16, 6, gaz_format_number($this->tesdoc['sconto']),'LBR',0,'C');
  207. } else {
  208. $this->Cell(16, 6,'','LBR');
  209. }
  210. if ($speseincasso > 0) {
  211. $this->Cell(24, 6, gaz_format_number($speseincasso),'LBR',0,'C');
  212. } else {
  213. $this->Cell(24, 6,'','LBR');
  214. }
  215. if ($totTrasporto > 0) {
  216. $this->Cell(26, 6, gaz_format_number($totTrasporto),'LBR',0,'C');
  217. } else {
  218. $this->Cell(26, 6,'','LBR');
  219. }
  220. if ($totimpfat > 0) {
  221. $this->Cell(36, 6, gaz_format_number($totimpfat),'LBR',0,'C');
  222. } else {
  223. $this->Cell(36, 6,'','LBR');
  224. }
  225. if ($totivafat > 0) {
  226. $this->Cell(26, 6, gaz_format_number($totivafat),'LBR',0,'C');
  227. } else {
  228. $this->Cell(26, 6,'','LBR');
  229. }
  230. if ($impbol > 0) {
  231. $this->Cell(22, 6, gaz_format_number($impbol),'LBR',1,'C');
  232. } else {
  233. $this->Cell(22, 6,'','LBR');
  234. }
  235. $this->SetY(218);
  236. $this->Cell(130);
  237. $totale = $totimpfat + $totivafat + $impbol;
  238. $this->SetFont('freesans','B',18);
  239. $this->Cell(56, 24, 'â&#x201A;? '.gaz_format_number($totale),'LBR', 1, 'C');
  240. $this->SetY(224);
  241. $this->SetFont('freesans','',9);
  242. $this->Cell(62, 6, 'Banca d\'appoggio','LTR',1,'C',1);
  243. $this->Cell(62, 6, $this->banapp['descri'],'LR',1,'L');
  244. if (!empty($this->banapp['descri'])) {
  245. $this->Cell(62, 6, ' ABI '.sprintf("%05d",$this->banapp['codabi']).' CAB '.$this->banapp['codcab'],'LRB',1,'C');
  246. } else {
  247. $this->Cell(62, 6,'','LRB',1);
  248. }
  249. $this->Cell(130,6, 'Date di Scadenza e Importo Rate','LTR',0,'C',1);
  250. $this->Cell(56, 6, 'Totale dei riporti','LTR',1,'C',1);
  251. $this->Cell(32, 6, $ratpag['giorno']['0'].'-'.$ratpag['mese']['0'].'-'.$ratpag['anno']['0'],'LR',0,'C');
  252. $this->Cell(33, 6, $ratpag['giorno']['1'].'-'.$ratpag['mese']['1'].'-'.$ratpag['anno']['1'],'LR',0,'C');
  253. $this->Cell(32, 6, $ratpag['giorno']['2'].'-'.$ratpag['mese']['2'].'-'.$ratpag['anno']['2'],'LR',0,'C');
  254. $this->Cell(33, 6, $ratpag['giorno']['3'].'-'.$ratpag['mese']['3'].'-'.$ratpag['anno']['3'],'LR',0,'C');
  255. $this->Cell(56, 6, '','R',1,'C');
  256. if ($ratpag['import']['0'] != 0) {
  257. $this->Cell(32, 6, gaz_format_number($ratpag['import']['0']),'LBR',0,'C');
  258. } else {
  259. $this->Cell(32, 6,'','LBR');
  260. }
  261. if ($ratpag['import']['1'] != 0) {
  262. $this->Cell(33, 6, gaz_format_number($ratpag['import']['1']),'LBR',0,'C');
  263. } else {
  264. $this->Cell(33, 6,'','LBR');
  265. }
  266. if ($ratpag['import']['2'] != 0) {
  267. $this->Cell(32, 6, gaz_format_number($ratpag['import']['2']),'LBR',0,'C');
  268. } else {
  269. $this->Cell(32, 6,'','LBR');
  270. }
  271. if ($ratpag['import']['3'] != 0) {
  272. $this->Cell(33, 6, gaz_format_number($ratpag['import']['3']),'LBR',0,'C');
  273. } else {
  274. $this->Cell(33, 6,'','LBR');
  275. }
  276. if ($totriport != 0) {
  277. $this->Cell(56, 6, gaz_format_number($totriport),'BR',1,'C');
  278. } else {
  279. $this->Cell(56, 6,'','BR',1);
  280. }
  281. }
  282. function Footer()
  283. {
  284. //Document footer
  285. $this->SetY(-20);
  286. $this->SetFont('freesans','',8);
  287. $this->MultiCell(184,4,$this->intesta1.' '.$this->intesta2.' '.$this->intesta3.' '.$this->intesta4.' ',0,'C',0);
  288. }
  289. }
  290. ?>