PageRenderTime 39ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/reports/ebpls_abstractcoll.php

http://ebpls.googlecode.com/
PHP | 259 lines | 171 code | 46 blank | 42 comment | 8 complexity | 178f798d05be864c66af3c33206b7cec MD5 | raw file
  1. <?php
  2. require_once("../lib/ebpls.utils.php");
  3. define('FPDF_FONTPATH','font/');
  4. require('../ebpls-php-lib/html2pdf_lib/fpdf.php');
  5. include("../lib/phpFunctions-inc.php");
  6. include("../includes/variables.php");
  7. include("../lib/multidbconnection.php");
  8. $dbLink =Open($dbtype,$connecttype,$dbhost,$dbuser,$dbpass,$dbname);
  9. class PDF extends FPDF
  10. {
  11. var $prov;
  12. var $lgu;
  13. var $office;
  14. var $y0;
  15. function setLGUinfo($p='', $l='', $o='') {
  16. $this->prov = $p;
  17. $this->lgu = $l;
  18. $this->office = $o;
  19. // echo 'setLGUinfo'.$this->prov;
  20. }
  21. function AcceptPageBreak()
  22. {
  23. //Method accepting or not automatic page break
  24. if($this->y<2)
  25. {
  26. //Set ordinate to top
  27. $this->SetY($this->y0);
  28. //Keep on page
  29. return false;
  30. }
  31. else
  32. {
  33. return true;
  34. }
  35. }
  36. //Page header
  37. function Header()
  38. {
  39. //Logo
  40. //$this->Image('logo_pb.png',10,8,33);
  41. //Arial bold 15
  42. $this->Image('../images/ebpls_logo.jpg',10,8,33);
  43. $this->SetFont('Arial','B',12);
  44. $this->Cell(680,5,'REPUBLIC OF THE PHILIPPINES',0,1,'C');
  45. $this->Cell(680,5,$this->lgu,0,1,'C');
  46. $this->Cell(680,5,$this->prov,0,2,'C');
  47. $this->SetFont('Arial','B',12);
  48. $this->Cell(680,5,$this->office,0,2,'C');
  49. $this->Cell(680,5,'',0,2,'C');
  50. $this->SetFont('Arial','BU',16);
  51. $this->Cell(680,5,'ABSTRACT OF COLLECTION REPORT' ,0,1,'C');
  52. $this->Ln(22);
  53. }
  54. //Page footer
  55. function Footer()
  56. {
  57. //Position at 1.5 cm from bottom
  58. $this->SetY(-15);
  59. //Arial italic 8
  60. $this->SetFont('Arial','I',8);
  61. //Page number
  62. $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
  63. }
  64. } // end of PDF class
  65. $result=mysql_query("select lguname, lguprovince, lguoffice from ebpls_buss_preference")
  66. or die(mysql_error());
  67. $resulta=mysql_fetch_row($result);
  68. $getlgu = @mysql_query("select city_municipality_desc from ebpls_city_municipality where city_municipality_code = '$resulta[0]'");
  69. $getlgu = @mysql_fetch_row($getlgu);
  70. $getprov = @mysql_query("select province_desc from ebpls_province where province_code = '$resulta[1]'");
  71. $getprov = @mysql_fetch_row($getprov);
  72. //$pdf=new FPDF('L','mm','Legal');
  73. $pdf=new PDF('L','mm','ledger');
  74. $pdf->setLGUinfo($getlgu[0],$getprov[0],'');
  75. $pdf->AddPage();
  76. $pdf->AliasNbPages();
  77. $Y_Label_position = 42;
  78. $Y_Table_Position = 46;
  79. $pdf->SetFont('Arial','B',12);
  80. $pdf->SetY($Y_Label_position);
  81. $pdf->SetX(5);
  82. $pdf->Cell(680,5,'From '.$date_from. ' to '.$date_to ,0,1,'C');
  83. $Y_Label_position = 50;
  84. $Y_Table_Position = 55;
  85. $pdf->SetFont('Arial','B',10);
  86. $pdf->SetY($Y_Label_position);
  87. $pdf->SetX(5);
  88. $pdf->Cell(50,5,'NAME OF PAYOR',1,0,'C');
  89. $pdf->Cell(240,5,'BUSINESS/ADDRESS/NATURE',1,0,'C');
  90. $pdf->Cell(40,5,'OR #',1,0,'C');
  91. // $pdf->SetX(55);
  92. // $v = 0;
  93. // $xx = 55;
  94. $staxfee = SelectMultiTable($dbtype,$dbLink,"ebpls_buss_preference",
  95. "staxesfees","");
  96. $prefset = FetchArray($dbtype,$staxfee);
  97. // $result = mysql_query("select tfodesc from ebpls_buss_tfo limit 8")
  98. $sassess = $prefset[staxesfees];
  99. $result = mysql_query("select a.tfoid, a.tfodesc from ebpls_buss_tfo a, rpt_temp_abs b
  100. where a.tfoid=b.tfoid ") ;
  101. while ($resulta=mysql_fetch_row($result))
  102. {
  103. $v++;
  104. $tfoid[$v] = $resulta[0];
  105. $pdf->Cell(30,5,$resulta[1],1,0,'C'); //tax/fee name
  106. }
  107. $pdf->Cell(10,5,'',0,1,'C') ;
  108. $result = mysql_query ("select concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  109. concat(b.owner_street, ' ', i.barangay_desc, ' ',j.city_municipality_desc, ' ', k.province_desc, ' ',
  110. b.owner_zip_code) as owner_add,
  111. a.business_name, a.owner_id, a.business_id,
  112. concat(a.business_street, ' ', f.barangay_desc, ' ',g.city_municipality_desc, ' ', h.province_desc, ' ',
  113. b.owner_zip_code) as business_add
  114. from ebpls_business_enterprise a, ebpls_owner b,
  115. ebpls_barangay f , ebpls_city_municipality g , ebpls_province h, ebpls_barangay i , ebpls_city_municipality j , ebpls_province k where
  116. a.owner_id=b.owner_id
  117. and i.barangay_code = b.owner_barangay_code and j.city_municipality_code = b.owner_city_code
  118. and k.province_code = b.owner_province_code and
  119. f.barangay_code = a.business_barangay_code and g.city_municipality_code = a.business_city_code
  120. and h.province_code = a.business_province_code ");
  121. while ($gd = mysql_fetch_assoc($result)) {
  122. $owner_id = $gd['owner_id'];
  123. $business_id=$gd['business_id'];
  124. //check if line is paid
  125. $lp = mysql_query("select * from ebpls_transaction_payment_or_details a, ebpls_transaction_payment_or b where a.trans_id='$owner_id' and a.payment_id='$business_id' and a.ts between '$date_from 00:00:00' and '$date_to 23:59:59' and a.or_no = b.or_no");
  126. //echo "select * from tempbusnature where owner_id='$owner_id' and business_id='$business_id' and recpaid='1'";
  127. //$lp = mysql_query("select * from tempbusnature a, ebpls_buss_nature b, ebpls_transaction_payment_or_details c where owner_id='$owner_id' and business_id='$business_id' and recpaid='1' and a.bus_code=b.natureid and
  128. //a.owner_id=c.trans_id and a.business_id=c.payment_id and c.ts between '$date_from 00:00:00' and '$date_to 23:59:59'");
  129. while ($gp = mysql_fetch_assoc($lp)) {
  130. //get details
  131. $f=0;
  132. $pdf->SetX(5);
  133. $pdf->Cell(50,5,$gd[fulln],1,0,'C');
  134. $pdf->Cell(240,5,$gd[business_name]."/".$gd[business_add],1,0,'L');
  135. //get or
  136. $getor = mysql_query("select * from ebpls_transaction_payment_or_details a, ebpls_transaction_payment_or b where a.trans_id='$owner_id' and a.payment_id='$business_id' and a.or_no=b.or_no");
  137. $getor = mysql_fetch_assoc($getor);
  138. $RX = $pdf->GetX();
  139. $pdf->Cell(40,5,'',1,0,'C');
  140. //$pdf->Cell(40,5,$getor[or_no],1,0,'C');
  141. //get paytax/fee
  142. $gettax = mysql_Query("select * from tempassess a where a.owner_id='$owner_id' and a.business_id='$business_id'");
  143. $dfv = 0;
  144. while ($gett = mysql_fetch_assoc($gettax)) {
  145. //while ($dfv < $v) {
  146. $dfv++;
  147. //display
  148. $f++;
  149. $disp = mysql_Query("select sum(amount) from ebpls_payment_details a, rpt_temp_abs b where a.owner_id='$owner_id' and a.business_id='$business_id' and a.tfoid='$tfoid[$f]' and a.tfoid = b.tfoid and or_no = '$gp[payment_code]' order by or_no asc");
  150. //echo "select * from ebpls_payment_details a where a.owner_id='$owner_id' and a.business_id='$business_id' and a.tfoid='$tfoid[$f]' <br>";
  151. //$disp = mysql_Query("select * from tempassess a where a.owner_id='$owner_id' and a.business_id='$business_id' and a.natureid='$gp[bus_code]' and a.tfoid='$tfoid[$f]'");
  152. $cntm = mysql_num_rows($disp);
  153. if ($tfoid[$f]<>'') {
  154. if ($cntm==0 and $sassess==1) {
  155. //reg fee
  156. $disp = mysql_Query("select sum(amount) from ebpls_payment_details a, rpt_temp_abs b where a.owner_id='$owner_id' and a.business_id='$business_id' and a.tfoid='$tfoid[$f]' and a.tfoid = b.tfoid and or_no = '$gp[payment_code]' order by or_no asc");
  157. //$disp = mysql_Query("select * from tempassessz a where a.owner_id='$owner_id' and a.business_id='$business_id' and a.tfoid='$tfoid[$f]'");
  158. }
  159. $dis = mysql_fetch_row($disp);
  160. $pdf->Cell(30,5,number_format($dis[0],2),1,0,'R'); //tax/fee name
  161. $newv[$f] = $newv[$f] + $dis[0];
  162. }
  163. }
  164. $pdf->SetX($RX);
  165. $pdf->Cell(40,5,$gp[payment_code],0,0,'C');
  166. $pdf->Cell(10,5,'',0,1,'C') ;
  167. }
  168. }
  169. $pdf->SetX(5);
  170. $pdf->Cell(50,5,'',1,0,'C');
  171. $pdf->Cell(240,5,'',1,0,'L');
  172. $pdf->Cell(40,5,'Total',1,0,'L');
  173. $r = 0;
  174. while ($r < $v) {
  175. $r++;
  176. $pdf->Cell(30,5,number_format($newv[$r],2),1,0,'R'); //tax/fee name
  177. }
  178. $pdf->Cell(10,5,'',0,1,'C') ;
  179. //$pdf->SetY(-18);
  180. $pdf->SetX(5);
  181. $pdf->Cell(10,5,'',0,1,'C') ;
  182. $pdf->SetFont('Arial','B',10);
  183. $pdf->Cell(472,5,'Prepared By :',0,0,'L');
  184. $pdf->Cell(172,5,'Noted By :',0,1,'L');
  185. $pdf->Cell(270,5,'',0,1,'C');
  186. $pdf->Cell(270,5,'',0,1,'C');
  187. $getuser = @mysql_query("select * from ebpls_user where username = '$usernm'") or die(mysql_error());
  188. $getuser = @mysql_fetch_array($getuser);
  189. $getsignatories = @mysql_query("select * from report_signatories where report_file='Top Business Establishment' and sign_type='3'");
  190. $getsignatories1 = @mysql_fetch_array($getsignatories);
  191. $getsignatories = @mysql_query("select * from global_sign where sign_id='$getsignatories1[sign_id]'");
  192. $getsignatories1 = @mysql_fetch_array($getsignatories);
  193. $pdf->SetX(5);
  194. $pdf->SetFont('Arial','B',10);
  195. $pdf->Cell(172,5,$getuser[firstname].' '.$getuser[lastname],0,0,'L');
  196. $pdf->Cell(172,5,$getsignatories1[gs_name],0,1,'L');
  197. $pdf->SetFont('Arial','B',10);
  198. $pdf->SetX(5);
  199. $pdf->Cell(472,5,'',0,0,'C');
  200. $pdf->Cell(172,5,$getsignatories1[gs_pos],0,1,'L');
  201. $report_desc='Abstract of Collection';
  202. //include 'report_signatories_footer1.php';
  203. //Robert
  204. //$pdf->SetX(5);
  205. //$pdf->SetFont('Arial','BU',10);
  206. //$pdf->Cell(172,5,'',1,0,'C');
  207. //$pdf->Cell(172,5,$resulta[0],1,1,'C');
  208. //$pdf->SetFont('Arial','B',10);
  209. //$pdf->SetX(5);
  210. //$pdf->Cell(172,5,'',1,0,'C');
  211. //$pdf->Cell(172,5,$resulta[2],1,0,'C');
  212. $pdf->Output();
  213. ?>