PageRenderTime 28ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/ebpls-php-lib/ebpls.reportgenerator.funcs.php

http://ebpls.googlecode.com/
PHP | 457 lines | 226 code | 217 blank | 14 comment | 24 complexity | a5ab6a6c95a38674ee0e2bae89611035 MD5 | raw file
  1. <?
  2. function reports_get_barangays( $params )
  3. {
  4. $clsSysRef = new EBPLSSysRef( $params, EBPLS_BARANGAY, $params["bDebug"] );
  5. $records = $clsSysRef->select();
  6. if ( is_array($records) && count($records["result"])>0 ) {
  7. $res = $records["result"];
  8. for ( $i = 0; $i < count(res); $i++ ) {
  9. $key = $res[$i]->getCode();
  10. $desc = $res[$i]->getDescription();
  11. $elems[$key] = $desc;
  12. }
  13. return $elems;
  14. }
  15. return NULL;
  16. }
  17. function reports_get_category( $params )
  18. {
  19. $clsSysRef = new EBPLSSysRef( $params, EBPLS_BUSINESS_NATURE, $params["bDebug"] );
  20. $records = $clsSysRef->select();
  21. if ( is_array($records) && count($records["result"])>0 ) {
  22. $res = $records["result"];
  23. for ( $i = 0; $i < count($res); $i++ ) {
  24. $key = $res[$i]->getCode();
  25. $desc = $res[$i]->getDescription();
  26. $elems[$key] = $desc;
  27. }
  28. return $elems;
  29. }
  30. return NULL;
  31. }
  32. /****************************************************************
  33. *
  34. * Application Module Reports
  35. *
  36. ****************************************************************/
  37. function get_bus_establshment_by_barangay( $dbLink, $post )
  38. {
  39. $clsSysRef = new EBPLSSysRef( $dbLink, EBPLS_BARANGAY, $params["bDebug"] );
  40. $records = $clsSysRef->select( $post["barangay"] );
  41. if ( is_array($records) && count($records["result"])>0 ) {
  42. $res = $records["result"];
  43. $brgy_desc = $res[0]->getDescription();
  44. } else {
  45. $brgy_desc = $post["barangay"];
  46. }
  47. $sqlSelect = "SELECT b.business_permit_code, a.business_name, a.business_category_code, d.business_nature_code as business_nature, concat( e.owner_first_name, ' ', e.owner_last_name ) as business_owner, a.business_phone_no, d.capital_investment as business_capital_investment, c.barangay_desc FROM ebpls_business_enterprise as a left join ebpls_business_enterprise_permit as b on a.business_id = b.business_id left join ebpls_barangay as c on a.business_barangay_code = c.barangay_code left join ebpls_business_enterprise_nature as d on a.business_id = d.business_id left join ebpls_owner as e on a.owner_id = e.owner_id WHERE a.business_barangay_code = '" . $post["barangay"] . "' and '" . $post["start_date"] . "' <= b.application_date and b.application_date <= '" . $post["end_date"] . "' and b.business_permit_code != ''";
  48. //echo("SQL ($dbLink, $post) : $sqlSelect<BR>");
  49. $res = mysql_query( $sqlSelect, $dbLink );
  50. if ( $res ) {
  51. $records = NULL;
  52. while( $row = mysql_fetch_array($res) ) {
  53. $records[] = $row;
  54. }
  55. return $records;
  56. }
  57. return NULL;
  58. }
  59. function get_bus_establshment_by_category( $dbLink, $post )
  60. {
  61. $sqlSelect = "SELECT year(curdate()) as cur_year, b.business_permit_code, concat( a.business_lot_no, ' ', a.business_street, ' ', a.business_zone_code, ' ', a.business_city_code ) as business_address, a.business_phone_no, a.business_name, a.business_category_code, e.business_nature_code, f.business_nature_desc as category, concat( d.owner_first_name, ' ', d.owner_last_name) as business_owner, a.business_phone_no, e.capital_investment, c.barangay_desc FROM ebpls_business_enterprise as a left join ebpls_business_enterprise_permit as b on a.business_id = b.business_id left join ebpls_barangay as c on a.business_barangay_code = c.barangay_code left join ebpls_owner as d on a.owner_id = d.owner_id left join ebpls_business_enterprise_nature as e on a.business_id = e.business_id left join ebpls_business_nature as f on e.business_nature_code = f.business_nature_code WHERE '" . $post["start_date"] . "' <= b.application_date and b.application_date <= '" . $post["end_date"] . "' and e.business_nature_code = '" . $post["nature_code"] . "' group by e.capital_investment";
  62. //echo "SQL $sqlSelect<BR>";
  63. $res = mysql_query( $sqlSelect, $dbLink );
  64. if ( $res ) {
  65. $records = NULL;
  66. while( $row = mysql_fetch_array($res) ) {
  67. $records[] = $row;
  68. }
  69. return $records;
  70. }
  71. return NULL;
  72. }
  73. function get_bus_establshment_by_owner( $dbLink, $post )
  74. {
  75. $sqlSelect = "SELECT year(curdate()) as year_value, b.owner_first_name, b.owner_middle_name, b.owner_last_name, concat( b.owner_house_no, ' ', b.owner_street, ' ', b.owner_barangay_code, ' ', b.owner_zone_code ) as owner_address, b.owner_citizenship, b.owner_gender, b.owner_birth_date, a.business_name, d.business_nature_code, d.capital_investment, c.business_permit_code FROM ebpls_business_enterprise as a left join ebpls_owner as b on a.owner_id = b.owner_id left join ebpls_business_enterprise_permit as c on a.business_id = c.business_permit_id left join ebpls_business_enterprise_nature as d on a.business_id = d.business_id";
  76. //echo "SQL $sqlSelect<BR>";
  77. $res = mysql_query( $sqlSelect, $dbLink );
  78. if ( $res ) {
  79. $records = NULL;
  80. while( $row = mysql_fetch_array($res) ) {
  81. $records[] = $row;
  82. }
  83. return $records;
  84. }
  85. return NULL;
  86. }
  87. function get_bus_establshment_by_capital( $dbLink, $post )
  88. {
  89. $sqlSelect = "SELECT year(curdate()) as cur_year, b.business_permit_code, concat( a.business_lot_no, ' ', a.business_street, ' ', a.business_zone_code, ' ', a.business_city_code ) as business_address, a.business_name, a.business_category_code, e.business_nature_code, concat( d.owner_first_name, ' ', d.owner_last_name) as business_owner, a.business_phone_no, e.capital_investment, c.barangay_desc FROM ebpls_business_enterprise as a left join ebpls_business_enterprise_permit as b on a.business_id = b.business_id left join ebpls_barangay as c on a.business_barangay_code = c.barangay_code left join ebpls_owner as d on a.owner_id = d.owner_id left join ebpls_business_enterprise_nature as e on a.business_id = e.business_id WHERE '" . $post["start_date"] . "' <= b.application_date and b.application_date <= '" . $post["end_date"] . "' group by e.capital_investment";
  90. //echo "SQL $sqlSelect<BR>";
  91. $res = mysql_query( $sqlSelect, $dbLink );
  92. if ( $res ) {
  93. $records = NULL;
  94. while( $row = mysql_fetch_array($res) ) {
  95. $records[] = $row;
  96. }
  97. return $records;
  98. }
  99. return NULL;
  100. }
  101. /****************************************************************
  102. *
  103. * Assessment Module Reports
  104. *
  105. ****************************************************************/
  106. function get_list_exempted_establishments_full( $dbLink, $post )
  107. {
  108. $sqlSelect = "";
  109. echo "SQL $sqlSelect<BR>";
  110. $res = mysql_query( $sqlSelect, $dbLink );
  111. if ( $res ) {
  112. $records = NULL;
  113. while( $row = mysql_fetch_array($res) ) {
  114. $records[] = $row;
  115. }
  116. return $records;
  117. }
  118. return NULL;
  119. }
  120. function get_list_establishments_without_permit( $dbLink, $post )
  121. {
  122. $sqlSelect = "";
  123. echo "SQL $sqlSelect<BR>";
  124. $res = mysql_query( $sqlSelect, $dbLink );
  125. if ( $res ) {
  126. $records = NULL;
  127. while( $row = mysql_fetch_array($res) ) {
  128. $records[] = $row;
  129. }
  130. return $records;
  131. }
  132. return NULL;
  133. }
  134. function get_list_exempted_establishments_partial( $dbLink, $post )
  135. {
  136. $sqlSelect = "";
  137. echo "SQL $sqlSelect<BR>";
  138. $res = mysql_query( $sqlSelect, $dbLink );
  139. if ( $res ) {
  140. $records = NULL;
  141. while( $row = mysql_fetch_array($res) ) {
  142. $records[] = $row;
  143. }
  144. return $records;
  145. }
  146. return NULL;
  147. }
  148. function get_list_establishments( $dbLink, $post )
  149. {
  150. $sqlSelect = "";
  151. echo "SQL $sqlSelect<BR>";
  152. $res = mysql_query( $sqlSelect, $dbLink );
  153. if ( $res ) {
  154. $records = NULL;
  155. while( $row = mysql_fetch_array($res) ) {
  156. $records[] = $row;
  157. }
  158. return $records;
  159. }
  160. return NULL;
  161. }
  162. function get_bus_establshment_materlist ( $dbLink, $post ) {
  163. $sqlSelect = "SELECT 'permit' as permit_no, a.business_name, concat( a.business_lot_no, ' ', a.business_street, ' ', a.business_barangay_code, ' ', a.business_zone_code ) as business_address, b.capital_investment, c.business_nature_desc, concat(d.owner_first_name, ' ' , d.owner_last_name ) as owner_name FROM ebpls_business_enterprise as a inner join ebpls_business_enterprise_nature as b on a.business_id = b.business_id left join ebpls_business_nature as c on b.business_nature_code = c.business_nature_code left join ebpls_owner as d on a.owner_id = d.owner_id";
  164. echo "SQL $sqlSelect<BR>";
  165. $res = mysql_query( $sqlSelect, $dbLink );
  166. if ( $res ) {
  167. $records = NULL;
  168. while( $row = mysql_fetch_array($res) ) {
  169. $records[] = $row;
  170. }
  171. return $records;
  172. }
  173. return NULL;
  174. }
  175. function get_list_buspermit_application( $dbLink, $post ) {
  176. $sqlSelect = "SELECT b.business_name, concat( b.business_lot_no, ' ', b.business_street, ' ', b.business_barangay_code, ' ', b.business_zone_code ) as business_address, concat( c.owner_first_name, ' ' , c.owner_last_name ) as owner_name, a.trans_application_date, a.trans_application_status from ebpls_transaction as a left join ebpls_business_enterprise as b on a.business_id = b.business_id left join ebpls_owner as c on a.owner_id = c.owner_id WHERE a.permit_type = 'BUS' and a.trans_status = 'APPLICATION'";
  177. echo "SQL $sqlSelect<BR>";
  178. $res = mysql_query( $sqlSelect, $dbLink );
  179. if ( $res ) {
  180. $records = NULL;
  181. while( $row = mysql_fetch_array($res) ) {
  182. $records[] = $row;
  183. }
  184. return $records;
  185. }
  186. return NULL;
  187. }
  188. function get_list_fishery_application( $dbLink, $post ) {
  189. $sqlSelect = "SELECT b.fishery_business_name, concat( c.owner_first_name, ' ' , c.owner_last_name ) as owner_name, concat( c.owner_house_no, ' ', c.owner_street, ' ', c.owner_barangay_code, ' ', c.owner_zone_code ) as business_address, a.trans_application_date, a.trans_application_status from ebpls_transaction as a left join ebpls_fishery_operators as b on a.owner_id = b.owner_id left join ebpls_owner as c on a.owner_id = c.owner_id WHERE a.permit_type = 'FIS' and a.trans_status = 'APPLICATION'";
  190. echo "SQL $sqlSelect<BR>";
  191. $res = mysql_query( $sqlSelect, $dbLink );
  192. if ( $res ) {
  193. $records = NULL;
  194. while( $row = mysql_fetch_array($res) ) {
  195. $records[] = $row;
  196. }
  197. return $records;
  198. }
  199. return NULL;
  200. }
  201. function get_list_occupational_application( $dbLink, $post ) {
  202. $sqlSelect = "SELECT concat( c.owner_first_name, ' ', c.owner_last_name) as owner_name, b.occ_position_applied, b.occ_permit_application_date, b.occ_employer, concat(b.occ_employer_lot_no, ' ', b.occ_employer_street, ' ', b.occ_employer_barangay_code, ' ', b.occ_employer_zone_code ) as employer_address from ebpls_transaction as a left join ebpls_occupational_permit as b on a.owner_id = b.owner_id left join ebpls_owner as c on a.owner_id = c.owner_id WHERE a.permit_type = 'OCC' and a.trans_status = 'APPLICATION'";
  203. echo "SQL $sqlSelect<BR>";
  204. $res = mysql_query( $sqlSelect, $dbLink );
  205. if ( $res ) {
  206. $records = NULL;
  207. while( $row = mysql_fetch_array($res) ) {
  208. $records[] = $row;
  209. }
  210. return $records;
  211. }
  212. return NULL;
  213. }
  214. function get_list_motorized_application( $dbLink, $post ) {
  215. $sqlSelect = "SELECT concat( c.owner_first_name, ' ', c.owner_last_name) as owner_name, b.motorized_operator_permit_application_date, concat(c.owner_house_no, ' ', c.owner_street, ' ', c.owner_barangay_code, ' ', c.owner_zone_code) as owner_address, e.motorized_motor_model, e.motorized_motor_no, e.motorized_chassis_no, e.motorized_plate_no, e.motorized_body_no from ebpls_transaction as a left join ebpls_motorized_operator_permit as b on a.owner_id = b.owner_id left join ebpls_owner as c on a.owner_id = c.owner_id left join ebpls_motorized_operators as d on b.motorized_operator_id = d.motorized_operator_id left join ebpls_motorized_vehicles as e on b.motorized_operator_id = e.motorized_operator_id WHERE a.permit_type = 'MOT' and a.trans_status = 'APPLICATION'";
  216. echo "SQL $sqlSelect<BR>";
  217. $res = mysql_query( $sqlSelect, $dbLink );
  218. if ( $res ) {
  219. $records = NULL;
  220. while( $row = mysql_fetch_array($res) ) {
  221. $records[] = $row;
  222. }
  223. return $records;
  224. }
  225. return NULL;
  226. }
  227. function get_list_peddlers_application( $dbLink, $post ) {
  228. $sqlSelect = "SELECT concat( c.owner_first_name, ' ', c.owner_last_name) as owner_name, b.application_date, b.merchandise_sold, concat(c.owner_house_no, ' ',c.owner_street, ' ' , c.owner_barangay_code) as owner_address from ebpls_transaction as a left join ebpls_peddlers_permit as b on a.owner_id = b.owner_id left join ebpls_owner as c on a.owner_id = c.owner_id WHERE a.permit_type = 'PED' and a.trans_status = 'APPLICATION'";
  229. echo "SQL $sqlSelect<BR>";
  230. $res = mysql_query( $sqlSelect, $dbLink );
  231. if ( $res ) {
  232. $records = NULL;
  233. while( $row = mysql_fetch_array($res) ) {
  234. $records[] = $row;
  235. }
  236. return $records;
  237. }
  238. return NULL;
  239. }
  240. ?>