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

/reports/ebpls_bus_topestablishment.php

http://ebpls.googlecode.com/
PHP | 417 lines | 275 code | 60 blank | 82 comment | 18 complexity | 226e3e168a517802de65ff2dafab95f5 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. $criteria="$brgy_name $cap_inv $last_yr";
  10. $list_option =$list_option;
  11. class PDF extends FPDF
  12. {
  13. var $prov;
  14. var $lgu;
  15. var $office;
  16. var $y0;
  17. var $list_op;
  18. function setLGUinfo($p='', $l='', $o='',$lop) {
  19. $this->prov = $p;
  20. $this->lgu = $l;
  21. $this->office = $o;
  22. $this->list_op='TOP BUSINESS ESTABLISHMENTS BY '.$lop;
  23. // echo 'setLGUinfo'.$this->prov;
  24. }
  25. function AcceptPageBreak()
  26. {
  27. //Method accepting or not automatic page break
  28. if($this->y<2)
  29. {
  30. //Set ordinate to top
  31. $this->SetY($this->y0);
  32. //Keep on page
  33. return false;
  34. }
  35. else
  36. {
  37. return true;
  38. }
  39. }
  40. //Page header
  41. function Header()
  42. {
  43. //Logo
  44. //$this->Image('logo_pb.png',10,8,33);
  45. //Arial bold 15
  46. $this->Image('../images/ebpls_logo.jpg',10,8,33);
  47. $this->SetFont('Arial','B',12);
  48. /*------------------------------------------------------------------
  49. frederick >>> changed these:
  50. $this->Cell(340,5,'REPUBLIC OF THE PHILIPPINES',0,1,'C');
  51. $this->Cell(340,5,$this->lgu,0,1,'C');
  52. $this->Cell(340,5,$this->prov,0,2,'C');
  53. to these: */
  54. $this->Cell(340,5,'Republic of the Philippines',0,1,'C');
  55. $this->Cell(340,5,'Province of '.$this->prov,0,1,'C');
  56. $this->Cell(340,5,'MUNICIPALITY OF '.strtoupper($this->lgu),0,2,'C');
  57. //SEE: change made on lines 112 & 114
  58. //added blank space
  59. $this->Cell(340,5,'',0,1,'C');
  60. $this->SetFont('Arial','B',14);
  61. // changed to ALL CAPS
  62. // $this->Cell(340,5,$this->office,0,2,'C');
  63. $this->Cell(340,5,strtoupper($this->office),0,2,'C');
  64. //------------------------------------------------------------------
  65. $this->Cell(340,5,'',0,2,'C');
  66. $this->SetFont('Arial','BU',14);
  67. $this->Cell(340,5,$this->list_op,0,1,'C');
  68. $this->SetFont('Arial','BU',12);
  69. $this->Ln(22);
  70. }
  71. //Page footer
  72. function Footer()
  73. {
  74. //Position at 1.5 cm from bottom
  75. $this->SetY(-15);
  76. //Arial italic 8
  77. $this->SetFont('Arial','I',8);
  78. //Page number
  79. $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
  80. }
  81. } // end of PDF class
  82. if ($range2 == "" || $range2 == 0) {
  83. $range2 = 9999999999999;
  84. }
  85. $result=mysql_query("select lguname, lguprovince, lguoffice from ebpls_buss_preference")
  86. or die(mysql_error());
  87. $resulta=mysql_fetch_row($result);
  88. $getlgu = @mysql_query("select city_municipality_desc from ebpls_city_municipality where city_municipality_code = '$resulta[0]'");
  89. $getlgu = @mysql_fetch_row($getlgu);
  90. $getprov = @mysql_query("select province_desc from ebpls_province where province_code = '$resulta[1]'");
  91. $getprov = @mysql_fetch_row($getprov);
  92. //$pdf=new FPDF('L','mm','Legal');
  93. $pdf=new PDF('L','mm','Legal');
  94. /*-------------------------------------------------------------------------------------------
  95. frederick >>> changed this:
  96. $pdf->setLGUinfo($getlgu[0],$getprov[0],'Office of the Treasurer',strtoupper($list_option));
  97. to this: */
  98. $pdf->setLGUinfo($getprov[0],$getlgu[0],'Office of the Treasurer',strtoupper($list_option));
  99. //SEE: function setLGUinfo on line 20
  100. //--------------------------------------------------------------------------------------------
  101. $pdf->AddPage();
  102. $pdf->AliasNbPages();
  103. $pdf->SetFont('Arial','B',10);
  104. $pdf->SetY(40);
  105. $pdf->SetX(10);
  106. $pdf->Cell(25,5,'',0,0,'L');
  107. $pdf->SetX(50);
  108. $pdf->Cell(100,5,'',0,1,'L');
  109. $Y_Label_position = 50;
  110. $Y_Table_Position = 55;
  111. $pdf->SetFont('Arial','B',6);
  112. $pdf->SetY($Y_Label_position-10);
  113. $dateprinted = date('Y-m-d');
  114. $pdf->SetX(5);
  115. $pdf->Cell(340,5,$dateprinted,0,1,'R');
  116. /*==========================================
  117. FREDERICK -> add Y coordinate to adjust
  118. position from top */
  119. $pdf->SetY(50);
  120. //==========================================
  121. $pdf->SetX(5);
  122. $pdf->Cell(10,5,'SEQ. NO.',1,0,'C');
  123. $pdf->SetX(15);
  124. $pdf->Cell(25,5,'PERMIT NO.',1,0,'C');
  125. $pdf->SetX(40);
  126. $pdf->Cell(55,5,'NAME OF OWNER',1,0,'C');
  127. $pdf->SetX(95);
  128. $pdf->Cell(60,5,'BUSINESS NAME',1,0,'C');
  129. $pdf->SetX(155);
  130. $pdf->Cell(90,5,'BUSINESS ADDRESS',1,0,'C');
  131. $pdf->Cell(30,5,strtoupper($list_option),1,0,'C');
  132. $pdf->Cell(30,5,'TAX DUE',1,0,'C');
  133. $pdf->Cell(30,5,'TOTAL PAYMENT',1,0,'C');
  134. $date_from = str_replace("/", "-", $date_from);
  135. $date_to = str_replace("/", "-", $date_to);
  136. if ($brgy_name != "") {
  137. $brgy_name = "$brgy_name";
  138. } else {
  139. $brgy_name = "$brgy_name%";
  140. }
  141. if (strtolower($list_option)=='capital investment') {
  142. $nnquery = "i.cap_inv between '$range1' and '$range2'";
  143. $qorder = "i.cap_inv";
  144. } else {
  145. $nnquery = "i.last_yr between '$range1' and '$range2'";
  146. $qorder = "i.last_yr";
  147. }
  148. $result = mysql_query ("select distinct (c.business_permit_code) as pid, a.business_name, concat(a.business_lot_no, ' ', a.business_street, ' ', f.barangay_desc, ' ',
  149. g.city_municipality_desc, ' ', h.province_desc, ' ', a.business_zip_code) as bus_add,
  150. concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  151. b.owner_id, a.business_id, i.cap_inv, i.last_yr
  152. from ebpls_business_enterprise a, ebpls_owner b, ebpls_business_enterprise_permit c,
  153. ebpls_barangay f , ebpls_city_municipality g , ebpls_province h , tempbusnature i where
  154. a.business_barangay_code = f.barangay_code and g.city_municipality_code = a.business_city_code
  155. and h.province_code = a.business_province_code
  156. and b.owner_id = a.owner_id and a.business_id = c.business_id and
  157. c.active=1 and c.application_date between '$date_from 00:00:00' and '$date_to 23:59:59'
  158. and a.business_barangay_code like '$brgy_name' and i.business_id = a.business_id and i.owner_id = b.owner_id and
  159. $nnquery order by $qorder DESC limit $list_limit");
  160. $i = 1;
  161. $pdf->SetY($Y_Table_Position);
  162. $totinv1 = 0;
  163. while ($resulta=mysql_fetch_assoc($result))
  164. {
  165. $totdue=0;
  166. $totfee=0;
  167. $pdf->SetX(1);
  168. //$pdf->MultiCell(349,5,$i,1);
  169. $pdf->SetX(5);
  170. $pdf->Cell(10,5,$i,1,0,'L');
  171. $pdf->SetX(15);
  172. $pdf->Cell(25,5,$resulta[pid],1,0,'L');
  173. $pdf->SetX(40);
  174. $pdf->Cell(55,5,$resulta[fulln],1,0,'L');
  175. $pdf->SetX(95);
  176. $pdf->Cell(60,5,$resulta[business_name],1,0,'L');
  177. $pdf->SetX(155);
  178. $pdf->Cell(90,5,$resulta[bus_add],1,0,'L');
  179. if (strtolower($list_option)=='capital investment') {
  180. $totinv = $resulta[cap_inv];
  181. } else {
  182. $totinv = $resulta[last_yr];
  183. }
  184. $totinv1 = $totinv1 + $totinv;
  185. $pdf->Cell(30,5,number_format($totinv,2),1,0,'R');
  186. $getlineb = mysql_query("select sum(a.compval) as tax_due
  187. from tempassess a where a.owner_id=$resulta[owner_id] and
  188. a.business_id=$resulta[business_id] and
  189. a.active=1 and natureid<>'' and taxfeeid<>''");
  190. $resultb = mysql_fetch_assoc($getlineb);
  191. $totdue = $resultb[tax_due];
  192. $gtotdue = $gtotdue + $totdue;
  193. $dec= SelectDataWhere($dbtype,$dbLink,"ebpls_buss_preference","");
  194. $sas = FetchArray($dbtype,$dec);
  195. $sas = $sas[sassess];
  196. if ($sas=='') {
  197. $resultf = SelectDataWhere($dbtype,$dbLink,"ebpls_buss_tfo",
  198. "where tfoindicator='1' and tfostatus='A' and taxfeetype<>'1' and
  199. tfodesc not in (select tfodesc from
  200. ebpls_buss_tfo where tfodesc like 'garbage%')");
  201. $cntfee = NumRows($dbtype,$resultf);
  202. $feetype = 1;
  203. while ($getf=FetchRow($dbtype,$resultf))
  204. {
  205. $getex = SelectMultiTable($dbtype,$dbLink,"ebpls_business_enterprise a,
  206. fee_exempt b, ebpls_buss_tfo c","a.*",
  207. "where a.business_id=$resulta[business_id] and
  208. a.business_category_code=b.business_category_code and
  209. c.tfoid=$getf[0] and b.tfoid=$getf[0] and
  210. b.active=1");
  211. $getfeex = NumRows($dbtype,$getex);
  212. if ($getfeex>0) {
  213. $exemptedfee = $exemptedfee + $getf[6];
  214. $usemin = 'Fee Exempted ';
  215. $getf[6]=0;
  216. }
  217. $regfee = $regfee + $getf[6];
  218. $totfee = $totfee+$getf[6];
  219. $usemin='';
  220. }
  221. ///garbage fee in place
  222. $resultf = SelectMultiTable($dbtype,$dbLink,"ebpls_buss_tfo a, ebpls_business_enterprise b,
  223. ebpls_barangay c","a.*",
  224. "where a.tfoindicator='1' and
  225. a.tfostatus='A' and a.taxfeetype='2' and
  226. a.tfodesc like 'garbage%' and
  227. b.business_id=$resulta[business_id] and b.owner_id=$resulta[owner_id] and
  228. b.business_barangay_code=c.barangay_code and
  229. c.g_zone=1");
  230. while ($getf=FetchRow($dbtype,$resultf))
  231. {
  232. $getex = SelectMultiTable($dbtype,$dbLink,"ebpls_business_enterprise a,
  233. fee_exempt b, ebpls_buss_tfo c"," a.*",
  234. "where a.business_id=$resulta[business_id] and
  235. a.business_category_code=b.business_category_code and
  236. c.tfoid=$getf[0] and b.tfoid=$getf[0] and
  237. b.active=1");
  238. $getfeex = NumRows($dbtype,$getex);
  239. if ($getfeex>0) {
  240. $exemptedfee = $exemptedfee + $getf[6];
  241. $usemin = 'Fee Exempted ';
  242. $getf[6]=0;
  243. }
  244. $totfee = $totfee+$getf[6];
  245. $usemin='';
  246. }
  247. $totdue = $totdue + $totfee;
  248. $gtotdue = $gtotdue + $totfee;
  249. }
  250. $pdf->Cell(30,5,number_format($resultb[tax_due] + $totfee ,2),1,0,'R');
  251. $getlineb = mysql_query("select a.transaction
  252. from ebpls_business_enterprise_permit a where a.owner_id=$resulta[owner_id] and
  253. a.business_id=$resulta[business_id] and
  254. a.active=1");
  255. $istat = mysql_fetch_assoc($getlineb);
  256. $istat = $istat[transaction];
  257. $getcas = SelectMultiTable($dbtype,$dbLink,"ebpls_transaction_payment_or a,
  258. ebpls_transaction_payment_or_details b",
  259. "sum(a.total_amount_paid) as tot",
  260. "where a.or_no=b.or_no and b.trans_id=$resulta[owner_id] and
  261. b.or_entry_type='CASH' and
  262. b.payment_id=$resulta[business_id] and b.transaction='$istat'");
  263. $getcash = FetchRow($dbtype,$getcas);
  264. $totcash = $getcash[0];
  265. $getclear = SelectMultiTable($dbtype,$dbLink,"ebpls_transaction_payment_check a,
  266. ebpls_transaction_payment_or b,
  267. ebpls_transaction_payment_or_details c","sum(a.check_amount)",
  268. "where a.or_no=b.or_no and a.or_no=c.or_no and b.or_no=c.or_no and
  269. c.or_entry_type='CHECK' and a.check_status='CLEARED' and
  270. c.transaction='$istat' and
  271. c.trans_id=$resulta[owner_id] and c.payment_id=$resulta[business_id]");
  272. $totcheck = FetchRow($dbtype,$getclear);
  273. $totcheck = $totcheck[0];
  274. $totpay = $totcheck + $totcash;
  275. $gtotpay = $gtotpay + $totpay;
  276. $pdf->Cell(30,5,number_format($totpay,2),1,0,'R');
  277. $i++;
  278. $pdf->SetY($pdf->GetY()+5);
  279. }
  280. /*===============================================
  281. FREDERICK -> removed the following:
  282. these are just empty cells!!
  283. $pdf->SetX(5);
  284. $pdf->Cell(10,5,'',1,0,'L');
  285. $pdf->SetX(15);
  286. $pdf->Cell(25,5,'',1,0,'L');
  287. $pdf->SetX(40);
  288. $pdf->Cell(55,5,'',1,0,'L');
  289. $pdf->SetX(95);
  290. $pdf->Cell(60,5,'',1,0,'L');
  291. $pdf->SetX(155);
  292. $pdf->Cell(90,5,'' ,1,0,'L');
  293. $pdf->Cell(30,5,'',1,0,'R');
  294. $pdf->Cell(30,5,'',1,0,'R');
  295. $pdf->Cell(30,5,'',1,0,'R'); */
  296. //=======================================
  297. $pdf->SetX(5);
  298. /*=======================================
  299. FREDERICK -> removed the following:
  300. these are just empty cells!!
  301. $pdf->Cell(10,5,'',1,0,'L');
  302. $pdf->SetX(15);
  303. $pdf->Cell(25,5,'',1,0,'L');
  304. $pdf->SetX(40);
  305. $pdf->Cell(55,5,'',1,0,'L');
  306. $pdf->SetX(95);
  307. $pdf->Cell(60,5,'',1,0,'L');
  308. $pdf->SetX(155);
  309. and CHANGE CELL WIDTH from 90 to 240:
  310. $pdf->Cell(90,5,'Total ' ,1,0,'R'); */
  311. $pdf->Cell(240,5,'T O T A L ' ,1,0,'R');
  312. //==========================================
  313. $pdf->Cell(30,5,number_format($totinv1,2),1,0,'R');
  314. $pdf->Cell(30,5,number_format($gtotdue,2),1,0,'R');
  315. $pdf->Cell(30,5,number_format($gtotpay,2),1,0,'R');
  316. //new signatories table
  317. // $result=mysql_query("select gs_name, gs_pos, gs_office from global_sign where sign_id =1") or die(mysql_error());
  318. // $resulta=mysql_fetch_row($result);
  319. //$Y_Table_Position = $Y_Table_Position + 20;
  320. $pdf->Cell(270,5,'',0,1,'C');
  321. $pdf->Cell(270,5,'',0,1,'C');
  322. $pdf->Cell(270,5,'',0,1,'C');
  323. //$pdf->SetY(-18);
  324. $pdf->SetX(5);
  325. $pdf->SetFont('Arial','B',10);
  326. $pdf->Cell(172,5,'Prepared By :',0,0,'L');
  327. $pdf->Cell(172,5,'Noted By :',0,1,'L');
  328. $pdf->Cell(270,5,'',0,1,'C');
  329. $pdf->Cell(270,5,'',0,1,'C');
  330. $getuser = @mysql_query("select * from ebpls_user where username = '$usernm'") or die(mysql_error());
  331. $getuser = @mysql_fetch_assoc($getuser);
  332. $getsignatories = @mysql_query("select * from report_signatories where report_file='Top Business Establishment' and sign_type='3'");
  333. $getsignatories1 = @mysql_fetch_assoc($getsignatories);
  334. $getsignatories = @mysql_query("select * from global_sign where sign_id='$getsignatories1[sign_id]'");
  335. $getsignatories1 = @mysql_fetch_assoc($getsignatories);
  336. $pdf->SetX(5);
  337. $pdf->SetFont('Arial','B',10);
  338. $pdf->Cell(172,5,$getuser[firstname].' '.$getuser[lastname],0,0,'L');
  339. $pdf->Cell(172,5,$getsignatories1[gs_name],0,1,'L');
  340. $pdf->SetFont('Arial','B',10);
  341. $pdf->SetX(5);
  342. $pdf->Cell(172,5,'',0,0,'C');
  343. $pdf->Cell(172,5,$getsignatories1[gs_pos],0,1,'L');
  344. $report_desc='Top Business Establishment';
  345. include '../report_signatories_footer1.php';
  346. //$pdf->SetX(5);
  347. //$pdf->SetFont('Arial','BU',10);
  348. //$pdf->Cell(172,5,'',1,0,'C');
  349. //$pdf->Cell(172,5,$resulta[0],1,1,'C');
  350. //$pdf->SetFont('Arial','B',10);
  351. //$pdf->SetX(5);
  352. //$pdf->Cell(172,5,'',1,0,'C');
  353. //$pdf->Cell(172,5,$resulta[2],1,0,'C');
  354. $pdf->Output();
  355. ?>