PageRenderTime 59ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/reports/ebpls_bus_masterlist.php

http://ebpls.googlecode.com/
PHP | 287 lines | 211 code | 38 blank | 38 comment | 18 complexity | 4b14f8a6bed4929ca2dc059c1b4e38f4 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(340,5,'Republic of the Philippines',0,1,'C');
  56. /*------------------------------------------------------------
  57. frederick >>> changed these:
  58. $this->Cell(340,5,$this->lgu,0,1,'C');
  59. $this->Cell(340,5,$this->prov,0,2,'C');
  60. to these: */
  61. $this->Cell(340,5,'Province of '.$this->prov,0,1,'C');
  62. $this->Cell(340,5,'MUNICIPALITY OF '.strtoupper($this->lgu),0,2,'C');
  63. //SEE change made on lines 111 & 113
  64. //-------------------------------------------------------------
  65. $this->SetFont('Arial','B',14);
  66. $this->Cell(340,5,$this->office,0,2,'C');
  67. $this->Cell(340,5,'',0,2,'C');
  68. $this->SetFont('Arial','BU',16);
  69. $this->Cell(340,5,'MASTER LIST OF BUSINESS ESTABLISHMENTS',0,1,'C');
  70. $this->SetFont('Arial','B',12);
  71. $this->Cell(340,5,'From : '.$this->datef.' To : '.$this->datet,0,1,'C');
  72. $this->Ln(22);
  73. }
  74. //Page footer
  75. function Footer()
  76. {
  77. //Position at 1.5 cm from bottom
  78. $this->SetY(-15);
  79. //Arial italic 8
  80. $this->SetFont('Arial','I',8);
  81. //Page number
  82. $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
  83. }
  84. } // end of PDF class
  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. if ($cap_inv2 == "" || $cap_inv2 == 0) {
  93. $cap_inv2 = 9999999999999;
  94. }
  95. //$pdf=new FPDF('L','mm','Legal');
  96. $pdf=new PDF('L','mm','Legal');
  97. /*-----------------------------------------------
  98. frederick >> incorrect arrangement, SEE function setLGUinfo on line 30
  99. changed this:
  100. $pdf->setLGUinfo($getlgu[0],$getprov[0],'');
  101. to this: */
  102. $pdf->setLGUinfo($getprov[0],$getlgu[0],'');
  103. //-----------------------------------------------
  104. $pdf->setDateRange($date_from,$date_to);
  105. $pdf->AddPage();
  106. $pdf->AliasNbPages();
  107. $pdf->SetFont('Arial','B',10);
  108. $pdf->SetY(40);
  109. $pdf->SetX(10);
  110. $pdf->Cell(25,5,'',0,0,'L');
  111. $pdf->SetX(50);
  112. $pdf->Cell(100,5,$criteria,0,1,'L');
  113. $Y_Label_position = 45;
  114. $Y_Table_Position = 55;
  115. $dateprinted = date('Y-m-d');
  116. $pdf->SetFont('Arial','B',8);
  117. $pdf->SetY($Y_Label_position);
  118. $pdf->SetX(5);
  119. $pdf->Cell(340,5,'',0,1,'R');
  120. $pdf->SetFont('Arial','B',6);
  121. $pdf->SetX(5);
  122. $pdf->Cell(10,5,'NO.',1,0,'C');
  123. $pdf->Cell(25,5,'PERMIT NO.',1,0,'C');
  124. $pdf->Cell(150,5,'BUSINESS NAME/ADDRESS/OWNER',1,0,'C');
  125. $pdf->Cell(60,5,'LINE OF BUSINESS',1,0,'C');
  126. //$pdf->SetX(270);
  127. $pdf->Cell(35,5,'CAPITAL INVESTMENTS',1,0,'C');
  128. $pdf->Cell(35,5,'ANNUAL GROSS SALES',1,1,'C');
  129. //$pdf->Cell(30,5,'GROSS RECEIPTS',1,0,'C');
  130. //$pdf->SetX(305);
  131. if ($brgy_name == "") {
  132. $brgy_name = "$brgy_name%";
  133. } else {
  134. $brgy_name = "$brgy_name";
  135. }
  136. if ($trans == 'Retire') {
  137. $result = mysql_query ("select distinct (c.business_permit_code) as pid, a.business_name,
  138. concat(a.business_lot_no, ' ', a.business_street, ' ', f.barangay_desc, ' ',
  139. g.city_municipality_desc, ' ', h.province_desc, ' ', a.business_zip_code) as bus_add,
  140. concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  141. b.owner_id, a.business_id
  142. from ebpls_business_enterprise a, ebpls_owner b, ebpls_business_enterprise_permit c,
  143. tempbusnature d, ebpls_buss_nature e , ebpls_barangay f , ebpls_city_municipality g , ebpls_province h where
  144. d.bus_code like '$business_nature_code%'
  145. and d.cap_inv between '$cap_inv1' and '$cap_inv2'
  146. and d.bus_code = e.natureid and a.business_barangay_code = f.barangay_code and g.city_municipality_code = a.business_city_code
  147. and h.province_code = a.business_province_code and e.psiccode like '$psic%'
  148. and b.owner_id = a.owner_id and a.business_id = c.business_id and
  149. b.owner_last_name like '$owner_last%' and
  150. c.transaction like '$trans%' and b.owner_id = d.owner_id and
  151. a.business_id=d.business_id
  152. and c.application_date between '$date_from 00:00:00' and '$date_to 23:59:59'
  153. and a.business_barangay_code like '$brgy_name' order by a.business_name ASC");
  154. } else {
  155. $result = mysql_query ("select distinct (c.business_permit_code) as pid, a.business_name,
  156. concat(a.business_lot_no, ' ', a.business_street, ' ', f.barangay_desc, ' ',
  157. g.city_municipality_desc, ' ', h.province_desc, ' ', a.business_zip_code) as bus_add,
  158. concat(b.owner_first_name, ' ', b.owner_middle_name, ' ', b.owner_last_name) as fulln,
  159. b.owner_id, a.business_id
  160. from ebpls_business_enterprise a, ebpls_owner b, ebpls_business_enterprise_permit c,
  161. tempbusnature d, ebpls_buss_nature e , ebpls_barangay f , ebpls_city_municipality g , ebpls_province h where
  162. d.active=1 and d.bus_code like '$business_nature_code%'
  163. and d.cap_inv between '$cap_inv1' and '$cap_inv2'
  164. and d.bus_code = e.natureid and a.business_barangay_code = f.barangay_code and g.city_municipality_code = a.business_city_code
  165. and h.province_code = a.business_province_code and e.psiccode like '$psic%'
  166. and b.owner_id = a.owner_id and a.business_id = c.business_id and
  167. c.active=1 and b.owner_last_name like '$owner_last%' and
  168. c.transaction like '$trans%' and b.owner_id = d.owner_id and
  169. a.business_id=d.business_id
  170. and c.application_date between '$date_from 00:00:00' and '$date_to 23:59:59'
  171. and a.business_barangay_code like '$brgy_name' order by a.business_name ASC");
  172. }
  173. $i = 1;
  174. $pdf->SetY($Y_Table_Position);
  175. while ($re=mysql_fetch_assoc($result))
  176. {
  177. $pdf->SetX(5);
  178. $pdf->Cell(10,5,$i,1,0,'L');
  179. /*======================================================
  180. frederick >> to view permit number, changed this
  181. $pdf->Cell(25,5,$re[business_permit_code],1,0,'L');
  182. to this: */
  183. $pdf->Cell(25,5,$re[pid],1,0,'L');
  184. //=======================================================
  185. $pdf->Cell(150,5,$re[business_name]."/".$re[bus_add]."/".$re[fulln],1,0,'L');
  186. if ($trans == 'Retire') {
  187. $getline = mysql_query ("select * from tempbusnature a, ebpls_buss_nature b
  188. where a.owner_id='$re[owner_id]' and
  189. a.business_id='$re[business_id]' and a.bus_code=b.natureid and retire ='1'");
  190. } else {
  191. $getline = mysql_query ("select * from tempbusnature a, ebpls_buss_nature b
  192. where a.owner_id='$re[owner_id]' and
  193. a.business_id='$re[business_id]' and a.active=1
  194. and a.bus_code=b.natureid");
  195. }
  196. while ($getl = mysql_fetch_assoc($getline)) {
  197. $pdf->SetX(190);
  198. $pdf->Cell(60,5,$getl[naturedesc],1,0,'L');
  199. if ($getl[transaction]=='New') {
  200. $getcap = mysql_query ("select * from tempbusnature a, ebpls_buss_nature b
  201. where a.owner_id='$re[owner_id]' and
  202. a.business_id='$re[business_id]' and a.bus_code='$getl[bus_code]'
  203. and a.bus_code=b.natureid order by tempid");
  204. $getcap = mysql_fetch_assoc($getcap);
  205. $totcap = $totcap + $getcap[cap_inv];
  206. } else {
  207. $totgross = $totgross + $getl[last_yr];
  208. }
  209. $pdf->Cell(35,5,number_format($getcap[cap_inv],2),1,0,'R');
  210. $pdf->Cell(35,5,number_format($getl[last_yr],2),1,1,'R');
  211. }
  212. $i++;
  213. }
  214. $pdf->SetX(5);
  215. $pdf->Cell(10,5,'',0,0,'L');
  216. $pdf->Cell(25,5,'',0,0,'L');
  217. $pdf->Cell(150,5,'',0,0,'L');
  218. $pdf->Cell(60,5,'Total Investments' ,0,0,'L');
  219. $pdf->Cell(35,5,number_format($totcap,2),0,0,'R');
  220. $pdf->Cell(35,5,number_format($totgross,2),0,0,'R');
  221. //$pdf->SetX(305);
  222. $pdf->Cell(270,5,'',0,1,'C');
  223. $pdf->Cell(270,5,'',0,1,'C');
  224. //$pdf->SetY(-18);
  225. $pdf->SetX(5);
  226. $pdf->SetFont('Arial','B',10);
  227. $pdf->Cell(172,5,'Prepared By :',0,0,'L');
  228. $pdf->Cell(172,5,'Noted By :',0,1,'L');
  229. $pdf->Cell(270,5,'',0,1,'C');
  230. $pdf->Cell(270,5,'',0,1,'C');
  231. $getuser = @mysql_query("select * from ebpls_user where username = '$usernm'") or die(mysql_error());
  232. $getuser = @mysql_fetch_assoc($getuser);
  233. $getsignatories = @mysql_query("select * from report_signatories where report_file='Business Masterlist' and sign_type='3'");
  234. $getsignatories1 = @mysql_fetch_assoc($getsignatories);
  235. $getsignatories = @mysql_query("select * from global_sign where sign_id='$getsignatories1[sign_id]'");
  236. $getsignatories1 = @mysql_fetch_assoc($getsignatories);
  237. $pdf->SetX(5);
  238. $pdf->SetFont('Arial','B',10);
  239. $pdf->Cell(172,5,$getuser[firstname].' '.$getuser[lastname],0,0,'L');
  240. $pdf->Cell(172,5,$getsignatories1[gs_name],0,1,'L');
  241. $pdf->SetFont('Arial','B',10);
  242. $pdf->SetX(5);
  243. $datetoday = date('Y - m - d');
  244. $pdf->Cell(172,5,$datetoday,0,0,'L');
  245. $pdf->Cell(172,5,$getsignatories1[gs_pos],0,1,'L');
  246. $report_desc='Business Establishment';
  247. //include '../report_signatories_footer1.php';
  248. $pdf->Output();
  249. ?>