PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/contab/stampa_libgio.php

http://gevion.googlecode.com/
PHP | 160 lines | 122 code | 9 blank | 29 comment | 20 complexity | 0806a2c0afd7bf25d21675c65b87a4ab MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. /*$Id: stampa_libgio.php,v 1.37 2010/03/18 15:53:26 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/datlib.inc.php");
  24. $admin_aziend=checkAdmin();
  25. if (!ini_get('safe_mode')){ //se me lo posso permettere...
  26. ini_set('memory_limit','128M');
  27. set_time_limit (240);
  28. }
  29. if (!isset($_GET['regini']) or !isset($_GET['regfin'])) {
  30. header("Location: select_libgio.php");
  31. exit;
  32. }
  33. $gioini = substr($_GET['regini'],0,2);
  34. $mesini = substr($_GET['regini'],3,2);
  35. $annini = substr($_GET['regini'],6,4);
  36. $utsini= mktime(0,0,0,$mesini,$gioini,$annini);
  37. $giofin = substr($_GET['regfin'],0,2);
  38. $mesfin = substr($_GET['regfin'],3,2);
  39. $annfin = substr($_GET['regfin'],6,4);
  40. $utsfin= mktime(0,0,0,$mesfin,$giofin,$annfin);
  41. $datainizio = date("Ymd",$utsini);
  42. $datafine = date("Ymd",$utsfin);
  43. $title = 'Libro Giornale dal '.date("d-m-Y",$utsini).' al '.date("d-m-Y",$utsfin);
  44. //recupero tutti i movimenti contabili insieme alle relative testate...
  45. /**
  46. * @todo inserire nel libro giornale una query che includa anche i movimenti contabili richiesti da luigina
  47. * fondamentalmente bisogna includere i movimenti contabili di incassata fattura presenti
  48. */
  49. //$result = mergeTable($gTables['rigmoc'],"*",$gTables['tesmov'],"*","id_tes","(datreg between $datainizio and $datafine) AND caucon != 'FAI' and caucon != 'AFA' and caucon != 'AFC' and caucon != 'FNC' and caucon != 'FAD' and caucon != 'VPA' and descri != 'INCASSATA FATTURA' ORDER BY datreg, ".$gTables['rigmoc'].".id_tes,id_rig,codcon");
  50. $result = mergeTable($gTables['rigmoc'],"*",$gTables['tesmov'],"*","id_tes","(datreg between $datainizio and $datafine) AND caucon != 'FAI' and caucon != 'AFA' and caucon != 'AFC' and caucon != 'FNC' and caucon != 'FAD' and caucon != 'VPA' ORDER BY datreg, ".$gTables['rigmoc'].".id_tes,id_rig,codcon");
  51. $cover_descri = 'Libro Giornale dell\'anno '.date("Y",$utsfin);
  52. $tot_avere=number_format($_GET['valave'],2, '.', '');
  53. $tot_dare=number_format($_GET['valdar'],2, '.', '');
  54. $topCarry = array(array('lenght' => 150,'name'=>'da riporto : ','frame' => 'B','fill'=>0,'font'=>8),
  55. array('lenght' => 20,'name'=>'','frame' => 1,'fill'=>0),
  56. array('lenght' => 20,'name'=>'','frame' => 1,'fill'=>0));
  57. $botCarry = array(array('lenght' => 150,'name'=>'a riporto : ','frame' => 'T','fill'=>0,'font'=>8),
  58. array('lenght' => 20,'name'=>'','frame' => 1,'fill'=>1),
  59. array('lenght' => 20,'name'=>'','frame' => 1,'fill'=>1));
  60. $top = array(array('lenght' => 10,'name'=>'Progr.','frame' => 1,'fill'=>1,'font'=>8),
  61. array('lenght' => 18,'name'=>'Data Reg.','frame' => 1,'fill'=>1),
  62. array('lenght' => 60,'name'=>'Descrizione Operazione / Num. e Data Doc.','frame' => 1,'fill'=>1),
  63. array('lenght' => 16,'name'=>'N.Conto','frame' => 1,'fill'=>1),
  64. array('lenght' => 46,'name'=>'Nome Conto','frame' => 1,'fill'=>1),
  65. array('lenght' => 20,'name'=>'Dare','frame' => 1,'fill'=>1),
  66. array('lenght' => 20,'name'=>'Avere','frame' => 1,'fill'=>1));
  67. require("../../config/templates/standard_template.php");
  68. $pdf = new Standard_template();
  69. $n_page = intval($_GET['pagini']);
  70. if (isset($_GET['copert'])) {
  71. $n_page--;
  72. }
  73. $pdf->setVars($admin_aziend,$title,0,array('ini_page'=>$n_page,'year'=>'Pagina '.$annfin));
  74. if (isset($_GET['copert'])) {
  75. $pdf->setCover($cover_descri);
  76. $pdf->AddPage();
  77. }
  78. $pdf->setTopBar($top);
  79. if (($tot_avere+$tot_dare)> 0.01){
  80. $topCarry[1]['name']= gaz_format_number($tot_dare);
  81. $topCarry[2]['name']= gaz_format_number($tot_avere);
  82. $pdf->setTopCarryBar($topCarry);
  83. }
  84. $pdf->AddPage();
  85. $pdf->setFooterMargin(21);
  86. $pdf->setTopMargin(44);
  87. $pdf->SetFont('freesans','',7);
  88. $ctrlmopre = 0;
  89. $numrig=1;
  90. $anagrafica = new Anagrafica();
  91. while ($mov = gaz_dbi_fetch_array($result)) {
  92. $giomov = substr($mov['datreg'],8,2);
  93. $mesmov = substr($mov['datreg'],5,2);
  94. $annmov = substr($mov['datreg'],0,4);
  95. $giodoc = substr($mov['datdoc'],8,2);
  96. $mesdoc = substr($mov['datdoc'],5,2);
  97. $anndoc = substr($mov['datdoc'],0,4);
  98. $clfoco = $anagrafica->getPartner($mov["codcon"]);
  99. $utsmov= mktime(0,0,0,$mesmov,$giomov,$annmov);
  100. $datamov = date("d-m-Y",$utsmov);
  101. $datadoc = $giodoc.'-'.$mesdoc.'-'.$anndoc;
  102. if($mov["darave"] == 'D') {
  103. $dare = gaz_format_number($mov["import"]);
  104. $tot_dare += $mov["import"];
  105. $avere = "";
  106. } else {
  107. $avere = gaz_format_number($mov["import"]);
  108. $tot_avere += $mov["import"];
  109. $dare = "";
  110. }
  111. if ($mov["id_tes"] != $ctrlmopre) {
  112. $pdf->Cell(10,4,$numrig,'LTR',0,'R');
  113. $pdf->Cell(18,4,$datamov,1,0,'L');
  114. $pdf->Cell(60,4,substr($mov['descri'],0,37),1,0,'L');
  115. $pdf->Cell(16,4,$mov['codcon'],'LT',0,'C');
  116. $pdf->Cell(46,4,substr($clfoco['descri'],0,30),'LT',0,'L');
  117. $pdf->Cell(20,4,$dare,'LT',0,'R');
  118. $pdf->Cell(20,4,$avere,'LRT',1,'R');
  119. if(!empty($mov["numdoc"])) {
  120. $pdf->Cell(28);
  121. $pdf->Cell(60,4,"n.".$mov['numdoc']."/".$mov['seziva']." del ".$datadoc,1,0,'L');
  122. $pdf->SetX(10);
  123. }
  124. } else {
  125. $pdf->Cell(10,4,$numrig,'LR',0,'R');
  126. $pdf->Cell(78,4,'',0,0,'L');
  127. $pdf->Cell(16,4,$mov['codcon'],'L',0,'C');
  128. $pdf->Cell(46,4,substr($clfoco['descri'],0,30),'L',0,'L');
  129. $pdf->Cell(20,4,$dare,'L',0,'R');
  130. $pdf->Cell(20,4,$avere,'LR',1,'R');
  131. }
  132. $topCarry[1]['name']= gaz_format_number($tot_dare);
  133. $botCarry[1]['name']= gaz_format_number($tot_dare);
  134. $topCarry[2]['name']= gaz_format_number($tot_avere);
  135. $botCarry[2]['name']= gaz_format_number($tot_avere);
  136. $pdf->setTopCarryBar($topCarry);
  137. $pdf->setBotCarryBar($botCarry);
  138. $ctrlmopre = $mov["id_tes"];
  139. $numrig ++;
  140. }
  141. $pdf->setBotCarryBar('');
  142. $pdf->Cell(150,4,'TOTALI : ',1,0,'L');
  143. $pdf->Cell(20,4,gaz_format_number($tot_dare),1,0,'R',1);
  144. $pdf->Cell(20,4,gaz_format_number($tot_avere),1,0,'R',1);
  145. if (isset($_GET['stadef'])) {
  146. gaz_dbi_put_row($gTables['aziend'],"codice",$admin_aziend['codice'],'upggio', $pdf->getGroupPageNo()+$n_page-1);
  147. }
  148. $pdf->Output();
  149. ?>