PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/controller/public-auto-spare-part.php

https://gitlab.com/Chhorvan/autoexpresscambodia_mobile
PHP | 276 lines | 168 code | 71 blank | 37 comment | 21 complexity | 8e1fcb94b3556a878a058ee5b61dd7a7 MD5 | raw file
Possible License(s): MIT, GPL-3.0, Apache-2.0, BSD-3-Clause
  1. <?php
  2. ################################################################################
  3. ### This disclaimer must be kept intact in order to use this product. ###
  4. ################################################################################
  5. ### Project: jT CarFramework [http://intersofts.com]
  6. ### Author: J. Toshio Taniguchi
  7. ### Since: 27.04.2011
  8. ### Version: 1.0.0
  9. ### Copyrights: J. Toshio Taniguchi
  10. ### Contact: j.taniguchi@taniguchi-blog.com
  11. ################################################################################
  12. ### CONTRIBUTORS
  13. ### - none
  14. ################################################################################
  15. include('view/3rdparty/pagination/pagination.php');
  16. class publicAutoSparePart
  17. {
  18. protected $lang;
  19. protected $group = 'public';
  20. protected $slug = 'auto-spare-part';
  21. protected $form_status;
  22. protected $form_message;
  23. protected $form_style;
  24. private $auto_info;
  25. var $total_num_row;
  26. var $pagination_html;
  27. var $current_page;
  28. var $total_page;
  29. /*
  30. * Constructor -------------------------------------------------------------
  31. */
  32. public function publicAutoSparePart($lang=array())
  33. {
  34. $this->lang = $lang;
  35. }
  36. function autoInfoSearch(){
  37. //echo $item.''.$category;
  38. require_once BASE_CLASS . 'class-connect.php';
  39. $cnx = new Connect();
  40. $cnx->open();
  41. $where=" WHERE 1";
  42. if(isset( $_GET['item'])) $item = $_GET['item']; else $item ="";
  43. if(isset( $_GET['make'])) $make = $_GET['make']; else $make ="";
  44. if(isset( $_GET['keyword'])) $keyword = $_GET['keyword']; else $keyword ="";
  45. if(isset( $_GET['category'])) $category = $_GET['category']; else $category ="";
  46. if(!empty($item)){
  47. $where.=" AND `item`='$item'";
  48. }
  49. if(!empty($make)){
  50. $where.=" AND `make`='$make'";
  51. }
  52. if(!empty($keyword)){
  53. $where.=" AND (`category` LIKE '%$keyword%' OR `make` LIKE '%$keyword%' OR `item` LIKE '%$keyword%' )";
  54. }
  55. if(!empty($category)){
  56. $where.=" AND `category`='$category'";
  57. }
  58. ////////
  59. $sql_search="SELECT * from auto_info $where ORDER BY id DESC";
  60. /////PAGINATION PROCESS//////
  61. $sql_count_str=$sql_search;
  62. $sql_count = @mysql_query($sql_count_str);
  63. $this->total_num_row= @mysql_num_rows($sql_count);
  64. $links = new Pagination ($this->total_num_row);
  65. $limit=$links->start_display;
  66. $this->pagination_html= $links->display();
  67. $this->current_page = $links->currentPage();
  68. $this->total_page= $links->numPages();
  69. ///////PAGINATION PROCESS///////
  70. $sql_search.=$limit;
  71. //echo $sql_search;
  72. if( !$sql = @mysql_query($sql_search) ){
  73. require_once BASE_CLASS . 'class-log.php';
  74. LogReport::write('Unable to load car maker list due a query error at ' . __FILE__ . ':' . __LINE__);
  75. $cnx->close();
  76. return;
  77. }
  78. if( @mysql_num_rows($sql) < 1 ){
  79. $cnx->close();
  80. }
  81. $this->auto_info = array();
  82. while( $r = @mysql_fetch_assoc($sql)){
  83. array_push($this->auto_info, $r);
  84. }
  85. @mysql_free_result($sql);
  86. $cnx->close();
  87. return $this->auto_info;
  88. }
  89. function loadAutoInfo(){
  90. require_once BASE_CLASS . 'class-connect.php';
  91. $cnx = new Connect();
  92. $cnx->open();
  93. $sql_search="SELECT * from auto_info ORDER BY id DESC ";
  94. if( !$sql = @mysql_query($sql_search) ){
  95. require_once BASE_CLASS . 'class-log.php';
  96. LogReport::write('Unable to load car maker list due a query error at ' . __FILE__ . ':' . __LINE__);
  97. $cnx->close();
  98. return;
  99. }
  100. if( @mysql_num_rows($sql) < 1 ){
  101. $cnx->close();
  102. }
  103. $auto_info = array();
  104. while( $r = @mysql_fetch_assoc($sql)){
  105. array_push($auto_info, $r);
  106. }
  107. @mysql_free_result($sql);
  108. $cnx->close();
  109. return $auto_info;
  110. }
  111. function loadProduct(){
  112. require_once BASE_CLASS . 'class-connect.php';
  113. $cnx = new Connect();
  114. $cnx->open();
  115. $sql_search="SELECT DISTINCT make from product WHERE make <>'' ";
  116. if( !$sql = @mysql_query($sql_search) ){
  117. require_once BASE_CLASS . 'class-log.php';
  118. LogReport::write('Unable to load car maker list due a query error at ' . __FILE__ . ':' . __LINE__);
  119. $cnx->close();
  120. return;
  121. }
  122. if( @mysql_num_rows($sql) < 1 ){
  123. $cnx->close();
  124. }
  125. $auto_info = array();
  126. while( $r = @mysql_fetch_assoc($sql)){
  127. array_push($auto_info, $r);
  128. }
  129. @mysql_free_result($sql);
  130. $cnx->close();
  131. return $auto_info;
  132. }
  133. /*
  134. * Public method: get page content data ------------------------------------
  135. * @return array | false.
  136. */
  137. public function getPageHTML()
  138. {
  139. require_once BASE_ROOT . 'core/class-connect.php';
  140. $cnx = new Connect();
  141. $cnx->open();
  142. if( !$sql = @mysql_query("SELECT * FROM `page` WHERE `page_slug`='$this->slug' AND `page_group`='$this->group' LIMIT 1;") )
  143. {
  144. $cnx->close();
  145. require_once BASE_ROOT . 'core/class-log.php';
  146. LogReport::write('Unable to load page information at ' . __FILE__ . ':' . __LINE__ . '. ' . mysql_error());
  147. $this->form_message = 'Unable to load page content due an internal error.';
  148. $this->form_status = true;
  149. $this->form_style = 'alert-error';
  150. return;
  151. }
  152. if( @mysql_num_rows($sql) != 1 )
  153. {
  154. $cnx->close();
  155. require_once BASE_ROOT . 'core/class-log.php';
  156. LogReport::write('Unable to load page information at ' . __FILE__ . ':' . __LINE__ . '. ' . mysql_error());
  157. $this->form_message = 'Unable to load page content due an internal error.';
  158. $this->form_status = true;
  159. $this->form_style = 'alert-error';
  160. return;
  161. }
  162. $r = @mysql_fetch_assoc($sql);
  163. $result = array();
  164. $result['id'] = $r['id'];
  165. $result['meta_keywords'] = $r['meta_keywords'];
  166. $result['meta_description'] = $r['meta_description'];
  167. $result['meta_robots'] = $r['meta_robots'];
  168. $result['page_title'] = $r['page_title'];
  169. $result['page_slug'] = $r['page_slug'];
  170. $result['page_publish'] = $r['page_publish'];
  171. $result['page_author'] = $r['page_author'];
  172. $result['creation'] = $r['creation'];
  173. $result['editable'] = $r['editable'];
  174. $result['page_group'] = $r['page_group'];
  175. $result['html'] = $r['html'];
  176. @mysql_free_result($sql);
  177. $cnx->close();
  178. return $result;
  179. }
  180. /*
  181. * Public method: get form status ------------------------------------------
  182. * @return bool.
  183. */
  184. public function getFormStatus()
  185. {
  186. return $this->form_status;
  187. }
  188. /*
  189. * Public method: get form message -----------------------------------------
  190. * @return string.
  191. */
  192. public function getFormMessage()
  193. {
  194. return $this->form_message;
  195. }
  196. /*
  197. * Public method: get form style -------------------------------------------
  198. * @return string.
  199. */
  200. public function getFormStyle()
  201. {
  202. return $this->form_style;
  203. }
  204. }
  205. ?>