PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/reports/ebpls_comparative_business.php

http://ebpls.googlecode.com/
PHP | 259 lines | 200 code | 22 blank | 37 comment | 14 complexity | af4097454c771662be556ffa682dae46 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.$owner_last.$bus_name.$trans.$bus_nature.$cap_inv.$last_yr;
  10. class PDF extends FPDF
  11. {
  12. var $prov;
  13. var $lgu;
  14. var $office;
  15. var $yearnow;
  16. var $yearnext;
  17. var $yearnextnext;
  18. var $y0;
  19. function setLGUinfo($p='', $l='', $o='') {
  20. $this->prov = $p;
  21. $this->lgu = $l;
  22. $this->office = $o;
  23. // echo 'setLGUinfo'.$this->prov;
  24. }
  25. function setYears($x='', $y='', $z='') {
  26. $this->yearnow = $x;
  27. $this->yearnext = $y;
  28. $this->yearnextnext = $z;
  29. // echo 'setLGUinfo'.$this->prov;
  30. }
  31. function AcceptPageBreak()
  32. {
  33. //Method accepting or not automatic page break
  34. if($this->y<2)
  35. {
  36. //Set ordinate to top
  37. $this->SetY($this->y0);
  38. //Keep on page
  39. return false;
  40. }
  41. else
  42. {
  43. return true;
  44. }
  45. }
  46. //Page header
  47. function Header()
  48. {
  49. //Logo
  50. //$this->Image('logo_pb.png',10,8,33);
  51. //Arial bold 15
  52. $this->Image('../images/ebpls_logo.jpg',10,8,33);
  53. $this->SetFont('Arial','B',12);
  54. $this->Cell(340,5,'Republic of the Philippines',0,1,'C');
  55. /* =====================================================================
  56. frederick >>> change this. SEE correction made on line# 116 & 118
  57. also added the words "Province of & MUNICIPALITY OF"
  58. $this->Cell(340,5,$this->lgu,0,1,'C');
  59. $this->Cell(340,5,$this->prov,0,2,'C');
  60. =========================================================================*/
  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. $this->SetFont('Arial','B',14);
  64. $this->Cell(340,5,$this->office,0,2,'C');
  65. $this->Cell(340,5,'',0,2,'C');
  66. $this->SetFont('Arial','B',16);
  67. $this->Cell(340,5,'ANNUAL COMPARATIVE STATEMENT OF BUSINESS ESTABLISHMENTS',0,1,'C');
  68. $this->SetFont('Arial','B',14);
  69. $this->Cell(340,5,'REGISTERED AND RENEWED',0,1,'C');
  70. $this->SetFont('Arial','B',14);
  71. $this->Cell(340,5,'FOR THE YEARS '.$this->yearnow.', '.$this->yearnext.' & '.$this->yearnextnext,0,1,'C');
  72. $this->SetFont('Arial','BU',12);
  73. $this->Ln(22);
  74. }
  75. //Page footer
  76. function Footer()
  77. {
  78. //Position at 1.5 cm from bottom
  79. $this->SetY(-15);
  80. //Arial italic 8
  81. $this->SetFont('Arial','I',8);
  82. //Page number
  83. $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
  84. }
  85. } // end of PDF class
  86. $e = strrpos($date_from,"-");//$owner_last is date
  87. $l =strlen($date_from);
  88. $dateprev = substr($date_from,0,4);
  89. $dateprev = $dateprev;
  90. $datenext = $dateprev + 1;
  91. $datenextnext = $dateprev + 2;
  92. $result=mysql_query("select lguname, lguprovince, lguoffice from ebpls_buss_preference")
  93. or die(mysql_error());
  94. $resulta=mysql_fetch_row($result);
  95. //taxes
  96. //$pdf=new FPDF('L','mm','Legal');
  97. $pdf=new PDF('L','mm','Legal');
  98. $getlgu = @mysql_query("select city_municipality_desc from ebpls_city_municipality where city_municipality_code = '$resulta[0]'");
  99. $getlgu = @mysql_fetch_row($getlgu);
  100. $getprov = @mysql_query("select province_desc from ebpls_province where province_code = '$resulta[1]'");
  101. $getprov = @mysql_fetch_row($getprov);
  102. /*=======================================================
  103. frederick >>> change this; incorrect arrangement of variable
  104. >> SEE: function setLGUinfo (line # 22)
  105. $pdf->setLGUinfo($getlgu[0],$getprov[0],$resulta[2]);
  106. ===========================================================*/
  107. $pdf->setLGUinfo($getprov[0],$getlgu[0],$resulta[2]);
  108. $pdf->setYears($dateprev,$datenext,$datenextnext);
  109. $pdf->AddPage();
  110. $pdf->AliasNbPages();
  111. $getnat = @mysql_query("select * from ebpls_buss_nature");
  112. $Y_Label_position = 50;
  113. $Y_Table_Position = 55;
  114. //header
  115. $dateprinted = date('Y-m-d');
  116. $pdf->SetFont('Arial','B',6);
  117. $pdf->SetY($Y_Label_position);
  118. $pdf->SetX(5);
  119. $pdf->Cell(340,5,$dateprinted,0,1,'R');
  120. $pdf->SetFont('Arial','B',6);
  121. $pdf->SetY($Y_Label_position + 10);
  122. $pdf->SetX(5);
  123. $pdf->Cell(100,10,'LINE OF BUSINESS',1,0,'C');
  124. $pdf->SetX(105);
  125. $pdf->Cell(60,5,$dateprev,1,0,'C');
  126. $pdf->SetX(165);
  127. $pdf->Cell(60,5,$datenext,1,0,'C');
  128. $pdf->SetX(225);
  129. $pdf->Cell(60,5,$datenextnext,1,0,'C');
  130. $pdf->SetY($Y_Label_position + 15);
  131. $pdf->SetX(5);
  132. $pdf->Cell(100,5,'',0,0,'C');
  133. $pdf->SetX(105);
  134. $pdf->Cell(30,5,'New',1,0,'C');
  135. $pdf->SetX(135);
  136. $pdf->Cell(30,5,'Renew',1,0,'C');
  137. $pdf->SetX(165);
  138. $pdf->Cell(30,5,'New',1,0,'C');
  139. $pdf->SetX(195);
  140. $pdf->Cell(30,5,'Renew',1,0,'C');
  141. $pdf->SetX(225);
  142. $pdf->Cell(30,5,'New',1,0,'C');
  143. $pdf->SetX(255);
  144. $pdf->Cell(30,5,'Renew',1,1,'C');
  145. $yloop = 0;
  146. while ($getnats = @mysql_fetch_assoc($getnat))
  147. {
  148. $pdf->SetY($Y_Label_position + 20 + $yloop);
  149. $pdf->SetX(5);
  150. $pdf->Cell(100,5,$getnats[naturedesc],1,0,'L');
  151. $get1new = @mysql_query("select * from tempbusnature a, ebpls_business_enterprise_permit b
  152. where a.bus_nature = '$getnats[naturedesc]' and a.business_id = b.business_id and a.owner_id = b.owner_id and
  153. b.for_year = '$dateprev' and a.transaction = 'New' and b.transaction='New'");
  154. $get1renew = @mysql_query("select * from tempbusnature a, ebpls_business_enterprise_permit b
  155. where a.bus_nature = '$getnats[naturedesc]' and a.business_id = b.business_id and a.owner_id = b.owner_id and
  156. b.for_year = '$dateprev' and a.transaction = 'Renew' and b.transaction='Renew'");
  157. $get1new = @mysql_num_rows($get1new);
  158. $get1renew = @mysql_num_rows($get1renew);
  159. if ($get1new == "") {
  160. $get1new = '0';
  161. }
  162. if ($get1renew == "") {
  163. $get1renew = '0';
  164. }
  165. $pdf->Cell(30,5,$get1new,1,0,'R');
  166. $pdf->Cell(30,5,$get1renew,1,0,'R');
  167. $get2new = @mysql_query("select * from tempbusnature a, ebpls_business_enterprise_permit b
  168. where a.bus_nature = '$getnats[naturedesc]' and a.business_id = b.business_id and a.owner_id = b.owner_id and
  169. b.for_year = '$datenext' and a.transaction = 'New' and b.transaction='New'");
  170. $get2renew = @mysql_query("select * from tempbusnature a, ebpls_business_enterprise_permit b
  171. where a.bus_nature = '$getnats[naturedesc]' and a.business_id = b.business_id and a.owner_id = b.owner_id and
  172. b.for_year = '$datenext' and a.transaction = 'Renew' and b.transaction='Renew'");
  173. $get2new = @mysql_num_rows($get2new);
  174. $get2renew = @mysql_num_rows($get2renew);
  175. if ($get2new == "") {
  176. $get2new = '0';
  177. }
  178. if ($get2renew == "") {
  179. $get2renew = '0';
  180. }
  181. $pdf->Cell(30,5,$get2new,1,0,'R');
  182. $pdf->Cell(30,5,$get2renew,1,0,'R');
  183. $get3new = @mysql_query("select * from tempbusnature a, ebpls_business_enterprise_permit b
  184. where a.bus_nature = '$getnats[naturedesc]' and a.business_id = b.business_id and a.owner_id = b.owner_id and
  185. b.for_year = '$datenextnext' and a.transaction = 'New' and b.transaction='New'");
  186. $get3renew = @mysql_query("select * from tempbusnature a, ebpls_business_enterprise_permit b
  187. where a.bus_nature = '$getnats[naturedesc]' and a.business_id = b.business_id and a.owner_id = b.owner_id and
  188. b.for_year = '$datenextnext' and a.transaction = 'Renew' and b.transaction='Renew'");
  189. $get3new = @mysql_num_rows($get3new);
  190. $get3renew = @mysql_num_rows($get3renew);
  191. if ($get3new == "") {
  192. $get3new = '0';
  193. }
  194. if ($get3renew == "") {
  195. $get3renew = '0';
  196. }
  197. $pdf->Cell(30,5,$get3new,1,0,'R');
  198. $pdf->Cell(30,5,$get3renew,1,0,'R');
  199. $yloop = $yloop + 5;
  200. }
  201. $pdf->Cell(270,5,'',0,1,'C');
  202. $pdf->Cell(270,5,'',0,1,'C');
  203. $pdf->Cell(270,5,'',0,1,'C');
  204. $pdf->Cell(270,5,'',0,1,'C');
  205. //$pdf->SetY(-18);
  206. $pdf->SetX(5);
  207. $pdf->SetFont('Arial','B',10);
  208. $pdf->Cell(172,5,'Prepared By :',0,0,'L');
  209. $pdf->Cell(172,5,'Noted By :',0,1,'L');
  210. $pdf->Cell(270,5,'',0,1,'C');
  211. $pdf->Cell(270,5,'',0,1,'C');
  212. $getuser = @mysql_query("select * from ebpls_user where username = '$usernm'") or die(mysql_error());
  213. $getuser = @mysql_fetch_array($getuser);
  214. $getsignatories = @mysql_query("select * from report_signatories where report_file='Business Establishment Comparative' and sign_type='3'");
  215. $getsignatories1 = @mysql_fetch_array($getsignatories);
  216. $getsignatories = @mysql_query("select * from global_sign where sign_id='$getsignatories1[sign_id]'");
  217. $getsignatories1 = @mysql_fetch_array($getsignatories);
  218. $pdf->SetX(5);
  219. $pdf->SetFont('Arial','B',10);
  220. $pdf->Cell(172,5,$getuser[firstname].' '.$getuser[lastname],0,0,'L');
  221. $pdf->Cell(172,5,$getsignatories1[gs_name],0,1,'L');
  222. $pdf->SetFont('Arial','B',10);
  223. $pdf->SetX(5);
  224. $pdf->Cell(172,5,'',0,0,'C');
  225. $pdf->Cell(172,5,$getsignatories1[gs_pos],0,1,'L');
  226. //$pdf->SetX(5);
  227. //$pdf->SetFont('Arial','BU',10);
  228. //$pdf->Cell(172,5,'',1,0,'C');
  229. //$pdf->Cell(172,5,$resulta[0],1,1,'C');
  230. //$pdf->SetFont('Arial','B',10);
  231. //$pdf->SetX(5);
  232. //$pdf->Cell(172,5,'',1,0,'C');
  233. //$pdf->Cell(172,5,$resulta[2],1,0,'C');
  234. $report_desc='Comparative Annual Report';
  235. //include '../report_signatories_footer1.php';
  236. $pdf->Output();
  237. ?>