PageRenderTime 42ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/reports/ebpls_orderpayment.php

http://ebpls.googlecode.com/
PHP | 291 lines | 239 code | 37 blank | 15 comment | 6 complexity | 163fc87c167fa1ec1b37d28a7fdc986e 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. $bgy = mysql_query("select * from ebpls_barangay where barangay_code='$brgy_name'");
  10. $bgy = mysql_fetch_assoc($bgy);
  11. $brgy_name = $bgy[barangay_desc];
  12. $criteria="$brgy_name $owner_last $trans $cap_inv $last_yr";
  13. class PDF extends FPDF
  14. {
  15. var $prov;
  16. var $lgu;
  17. var $office;
  18. var $y0;
  19. var $datef;
  20. var $datet;
  21. function setDateRange($x='', $y='') {
  22. $this->datef = $x;
  23. $this->datet = $y;
  24. // echo 'setLGUinfo'.$this->prov;
  25. }
  26. function setLGUinfo($p='', $l='', $o='') {
  27. $this->prov = $p;
  28. $this->lgu = $l;
  29. $this->office = $o;
  30. // echo 'setLGUinfo'.$this->prov;
  31. }
  32. function AcceptPageBreak()
  33. {
  34. //Method accepting or not automatic page break
  35. if($this->y<2)
  36. {
  37. //Set ordinate to top
  38. $this->SetY($this->y0);
  39. //Keep on page
  40. return false;
  41. }
  42. else
  43. {
  44. return true;
  45. }
  46. }
  47. //Page header
  48. function Header()
  49. {
  50. //Logo
  51. //$this->Image('logo_pb.png',10,8,33);
  52. //Arial bold 15
  53. $this->Image('../images/ebpls_logo.jpg',10,8,33);
  54. $this->SetFont('Arial','B',12);
  55. $this->Cell(200,5,'REPUBLIC OF THE PHILIPPINES',0,1,'C');
  56. $this->Cell(200,5,$this->lgu,0,1,'C');
  57. $this->Cell(200,5,$this->prov,0,2,'C');
  58. $this->SetFont('Arial','B',14);
  59. $this->Cell(200,5,$this->office,0,2,'C');
  60. $this->Cell(200,5,'',0,2,'C');
  61. $this->SetFont('Arial','BU',16);
  62. $this->Cell(200,5,'TAX ORDER OF PAYMENT',0,1,'C');
  63. $this->Ln(22);
  64. }
  65. //Page footer
  66. function Footer()
  67. {
  68. //Position at 1.5 cm from bottom
  69. $this->SetY(-15);
  70. //Arial italic 8
  71. $this->SetFont('Arial','I',8);
  72. //Page number
  73. $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
  74. }
  75. } // end of PDF class
  76. $result=mysql_query("select lguname, lguprovince, lguoffice from ebpls_buss_preference")
  77. or die(mysql_error());
  78. $resulta=mysql_fetch_row($result);
  79. $getlgu = @mysql_query("select city_municipality_desc from ebpls_city_municipality where city_municipality_code = '$resulta[0]'");
  80. $getlgu = @mysql_fetch_row($getlgu);
  81. $getprov = @mysql_query("select province_desc from ebpls_province where province_code = '$resulta[1]'");
  82. $getprov = @mysql_fetch_row($getprov);
  83. //$pdf=new FPDF('L','mm','Legal');
  84. $pdf=new PDF('P','mm','A4');
  85. $pdf->setLGUinfo($getlgu[0],$getprov[0],'');
  86. $pdf->AliasNbPages();
  87. $pdf->SetFont('Arial','B',10);
  88. $pdf->SetY(40);
  89. $pdf->SetX(10);
  90. $pdf->Cell(25,5,'',0,0,'L');
  91. $Y_Label_position = 45;
  92. $Y_Table_Position = 60;
  93. $dateprinted = date('Y-m-d');
  94. $pdf->SetFont('Arial','B',12);
  95. $pdf->SetY($Y_Label_position);
  96. $pdf->SetX(5);
  97. //$pdf->Cell(270,5,$dateprinted,0,1,'R');
  98. $pdf->SetFont('Arial','B',12);
  99. $pdf->SetX(5);
  100. $pdf->Cell(270,5,'',0,1,'C');
  101. $pdf->Cell(270,5,'',0,1,'C');
  102. if ($owner_last_name<>'' and $owner_first_name<>'' and $business_name=='') {
  103. $result = mysql_query ("select concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  104. concat(b.owner_street, ' ', i.barangay_desc, ' ',j.city_municipality_desc, ' ', k.province_desc, ' ',
  105. b.owner_zip_code) as owner_add,
  106. a.business_name, a.owner_id, a.business_id,
  107. concat(a.business_street, ' ', f.barangay_desc, ' ',g.city_municipality_desc, ' ', h.province_desc, ' ',
  108. b.owner_zip_code) as business_add
  109. from ebpls_business_enterprise a, ebpls_owner b,
  110. ebpls_barangay f , ebpls_city_municipality g , ebpls_province h, ebpls_barangay i , ebpls_city_municipality j , ebpls_province k where
  111. a.owner_id=b.owner_id and b.owner_first_name='$owner_first_name' and b.owner_last_name='$owner_last_name'
  112. and i.barangay_code = b.owner_barangay_code and j.city_municipality_code = b.owner_city_code
  113. and k.province_code = b.owner_province_code and
  114. f.barangay_code = a.business_barangay_code and g.city_municipality_code = a.business_city_code
  115. and h.province_code = a.business_province_code ");
  116. } elseif ($owner_last_name<>'' and $owner_first_name=='' and $business_name=='') {
  117. $result = mysql_query ("select concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  118. concat(b.owner_street, ' ', i.barangay_desc, ' ',j.city_municipality_desc, ' ', k.province_desc, ' ',
  119. b.owner_zip_code) as owner_add,
  120. a.business_name, a.owner_id, a.business_id,
  121. concat(a.business_street, ' ', f.barangay_desc, ' ',g.city_municipality_desc, ' ', h.province_desc, ' ',
  122. b.owner_zip_code) as business_add
  123. from ebpls_business_enterprise a, ebpls_owner b,
  124. ebpls_barangay f , ebpls_city_municipality g , ebpls_province h, ebpls_barangay i , ebpls_city_municipality j , ebpls_province k where
  125. a.owner_id=b.owner_id and b.owner_last_name='$owner_last_name'
  126. and i.barangay_code = b.owner_barangay_code and j.city_municipality_code = b.owner_city_code
  127. and k.province_code = b.owner_province_code and
  128. f.barangay_code = a.business_barangay_code and g.city_municipality_code = a.business_city_code
  129. and h.province_code = a.business_province_code ");
  130. } elseif ($owner_last_name=='' and $owner_first_name<>'' and $business_name=='') {
  131. $result = mysql_query ("select concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  132. concat(b.owner_street, ' ', i.barangay_desc, ' ',j.city_municipality_desc, ' ', k.province_desc, ' ',
  133. b.owner_zip_code) as owner_add,
  134. a.business_name, a.owner_id, a.business_id,
  135. concat(a.business_street, ' ', f.barangay_desc, ' ',g.city_municipality_desc, ' ', h.province_desc, ' ',
  136. b.owner_zip_code) as business_add
  137. from ebpls_business_enterprise a, ebpls_owner b,
  138. ebpls_barangay f , ebpls_city_municipality g , ebpls_province h, ebpls_barangay i , ebpls_city_municipality j , ebpls_province k where
  139. a.owner_id=b.owner_id and b.owner_first_name='$owner_first_name'
  140. and i.barangay_code = b.owner_barangay_code and j.city_municipality_code = b.owner_city_code
  141. and k.province_code = b.owner_province_code and
  142. f.barangay_code = a.business_barangay_code and g.city_municipality_code = a.business_city_code
  143. and h.province_code = a.business_province_code ");
  144. } elseif ($owner_last_name=='' and $owner_first_name=='' and $business_name<>'') {
  145. $result = mysql_query ("select concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  146. concat(b.owner_street, ' ', i.barangay_desc, ' ',j.city_municipality_desc, ' ', k.province_desc, ' ',
  147. b.owner_zip_code) as owner_add,
  148. a.business_name, a.owner_id, a.business_id,
  149. concat(a.business_street, ' ', f.barangay_desc, ' ',g.city_municipality_desc, ' ', h.province_desc, ' ',
  150. b.owner_zip_code) as business_add
  151. from ebpls_business_enterprise a, ebpls_owner b,
  152. ebpls_barangay f , ebpls_city_municipality g , ebpls_province h, ebpls_barangay i , ebpls_city_municipality j , ebpls_province k where
  153. a.owner_id=b.owner_id and a.business_name='$business_name'
  154. and i.barangay_code = b.owner_barangay_code and j.city_municipality_code = b.owner_city_code
  155. and k.province_code = b.owner_province_code and
  156. f.barangay_code = a.business_barangay_code and g.city_municipality_code = a.business_city_code
  157. and h.province_code = a.business_province_code ");
  158. } else {
  159. $result = mysql_query ("select concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  160. concat(b.owner_street, ' ', i.barangay_desc, ' ',j.city_municipality_desc, ' ', k.province_desc, ' ',
  161. b.owner_zip_code) as owner_add,
  162. a.business_name, a.owner_id, a.business_id,
  163. concat(a.business_street, ' ', f.barangay_desc, ' ',g.city_municipality_desc, ' ', h.province_desc, ' ',
  164. b.owner_zip_code) as business_add
  165. from ebpls_business_enterprise a, ebpls_owner b,
  166. ebpls_barangay f , ebpls_city_municipality g , ebpls_province h, ebpls_barangay i , ebpls_city_municipality j , ebpls_province k where
  167. a.owner_id=b.owner_id and a.business_name='$business_name' and b.owner_first_name='$owner_first_name' and b.owner_last_name='$owner_last_name'
  168. and i.barangay_code = b.owner_barangay_code and j.city_municipality_code = b.owner_city_code
  169. and k.province_code = b.owner_province_code and
  170. f.barangay_code = a.business_barangay_code and g.city_municipality_code = a.business_city_code
  171. and h.province_code = a.business_province_code ");
  172. }
  173. while ($getd = mysql_fetch_assoc($result)) {
  174. $pdf->AddPage();
  175. $pdf->SetX(10);
  176. $pdf->Cell(25,5,$getd[business_name],0,1,'L');
  177. $pdf->Cell(25,5,$getd[fulln],0,1,'L');
  178. $pdf->Cell(25,5,$getd[owner_add],0,1,'L');
  179. $pdf->Cell(270,5,'',0,1,'C');
  180. $pdf->Cell(25,5,'Please pay the following',0,1,'L');
  181. $pdf->Cell(270,5,'',0,1,'C');
  182. $pdf->SetFont('Arial','BU',12);
  183. $pdf->Cell(25,5,'Business Taxes',0,1,'L');
  184. $pdf->Cell(270,5,'',0,1,'C');
  185. $pdf->SetFont('Arial','',12);
  186. $owner_id = $getd['owner_id'];
  187. $business_id=$getd['business_id'];
  188. $gettemp =mysql_query("select * from tempassess a, ebpls_buss_tfo b where a.owner_id = '$owner_id' and a.business_id='$business_id' and a.tfoid=b.tfoid and b.taxfeetype=1 and date_create like '$yearnow%'");
  189. while ($gettax = mysql_fetch_assoc($gettemp)) {
  190. $pdf->Cell(25,4,$gettax[tfodesc],0,0,'L');
  191. $pdf->Cell(55,4,$gettax[compval],0,1,'R');
  192. $tottax = $tottax + $gettax[compval];
  193. }
  194. $pdf->Cell(270,5,'',0,1,'C');
  195. $pdf->Cell(25,4,'Total Tax',0,0,'L');
  196. $pdf->Cell(55,4, number_format($tottax,2) ,0,1,'R');
  197. $pdf->Cell(270,5,'',0,1,'C');
  198. $pdf->SetFont('Arial','BU',12);
  199. $pdf->Cell(25,5,'Fees/Charges',0,1,'L');
  200. $pdf->SetFont('Arial','',12);
  201. $pdf->Cell(270,5,'',0,1,'C');
  202. $gettemp =mysql_query("select * from tempassess a, ebpls_buss_tfo b where a.owner_id = '$owner_id' and a.business_id='$business_id' and a.tfoid=b.tfoid and b.taxfeetype<>1 and date_create like '$yearnow%'");
  203. while ($getfee = mysql_fetch_assoc($gettemp)) {
  204. $pdf->Cell(25,4,$getfee[tfodesc],0,0,'L');
  205. $pdf->Cell(55,4,$getfee[compval],0,1,'R');
  206. $totfee = $totfee + $getfee[compval];
  207. }
  208. $pdf->Cell(270,5,'',0,1,'C');
  209. $pdf->Cell(25,4,'Total Fee',0,0,'L');
  210. $pdf->Cell(55,4, number_format($totfee,2) ,0,1,'R');
  211. $pdf->Cell(270,5,'',0,1,'C');
  212. $pdf->SetFont('Arial','BU',12);
  213. $pdf->Cell(25,5,'Surcharge',0,1,'L');
  214. $pdf->SetFont('Arial','',12);
  215. $pdf->Cell(270,5,'',0,1,'C');
  216. $gettemp =mysql_query("select * from bus_grandamt a where a.owner_id = '$owner_id' and a.business_id='$business_id' and ts like '$yearnow%'");
  217. $getsi = mysql_fetch_assoc($gettemp);
  218. $pdf->Cell(25,4,'Surcharge',0,0,'L');
  219. $pdf->Cell(55,4,$getsi[totpenamt],0,1,'R');
  220. $pdf->Cell(25,4,'Interest',0,0,'L');
  221. $pdf->Cell(55,4,$getsi[si],0,1,'R');
  222. $pdf->Cell(270,5,'',0,1,'C');
  223. $pdf->Cell(25,4,'Total Surcharge',0,0,'L');
  224. $totsi = $getsi[totpenamt] + $getsi[si] ;
  225. $pdf->Cell(55,4, number_format($totsi,2),0,1,'R');
  226. }
  227. $pdf->Cell(270,5,'',0,1,'C');
  228. $pdf->Cell(270,5,'',0,1,'C');
  229. $pdf->Cell(25,5,'Total',0,0,'L');
  230. $topay = number_format($tottax + $totfee + $totsi,2);
  231. $pdf->Cell(55,4,$topay,0,1,'R');
  232. $pdf->Cell(270,5,'',0,1,'C');
  233. $pdf->Cell(270,5,'',0,1,'C');
  234. $pdf->SetFont('Arial','B',10);
  235. $pdf->Cell(172,5,'Prepared By :',0,0,'L');
  236. $pdf->Cell(270,5,'',0,1,'C');
  237. $pdf->Cell(270,5,'',0,1,'C');
  238. $getuser = @mysql_query("select * from ebpls_user where username = '$usernm'") or die(mysql_error());
  239. $getuser = @mysql_fetch_assoc($getuser);
  240. $getsignatories = @mysql_query("select * from report_signatories where report_file='Business Masterlist' and sign_type='3'");
  241. $getsignatories1 = @mysql_fetch_assoc($getsignatories);
  242. $getsignatories = @mysql_query("select * from global_sign where sign_id='$getsignatories1[sign_id]'");
  243. $getsignatories1 = @mysql_fetch_assoc($getsignatories);
  244. $pdf->SetX(5);
  245. $pdf->SetFont('Arial','B',10);
  246. $pdf->Cell(172,5,$getuser[firstname].' '.$getuser[lastname],0,0,'L');
  247. $pdf->Cell(172,5,$getsignatories1[gs_name],0,1,'L');
  248. $pdf->SetFont('Arial','B',10);
  249. $pdf->SetX(5);
  250. $datetoday = date('Y - m - d');
  251. $pdf->Cell(172,5,$datetoday,0,0,'L');
  252. $pdf->Cell(172,5,$getsignatories1[gs_pos],0,1,'L');
  253. $pdf->Output();
  254. ?>