ertekkeszlet_model.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. class ertekkeszlet_model extends Model {
  3. public function get_kategoria_list($kategoria='') {
  4. $result = $this->query("SELECT * FROM products_temp WHERE category<>'' GROUP BY category;");
  5. return $result;
  6. }
  7. public function get_mezo_list($kategoria='',$mezo='') {
  8. if ($kategoria=='Notebook') {
  9. $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
  10. . "TABLE_NAME='product_notebooks_temp' AND "
  11. . "COLUMN_COMMENT<>'';");
  12. return $result;
  13. }
  14. elseif ($kategoria=='Desktop') {
  15. $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
  16. . "TABLE_NAME='product_desktops_temp' AND "
  17. . "COLUMN_COMMENT<>'';");
  18. return $result;
  19. }
  20. elseif ($kategoria=='Tablets') {
  21. $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
  22. . "TABLE_NAME='product_tablets_temp' AND "
  23. . "COLUMN_COMMENT<>'';");
  24. return $result;
  25. }
  26. elseif ($kategoria=='Servers') {
  27. $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
  28. . "TABLE_NAME='product_servers_temp' AND "
  29. . "COLUMN_COMMENT<>'';");
  30. return $result;
  31. }
  32. else {
  33. return false;
  34. }
  35. }
  36. public function get_ertekkeszlet_list($kategoria,$mezo) {
  37. if ($kategoria=='Notebook' || $kategoria=='Desktop' || $kategoria=='Tablets' || $kategoria=='Servers') {
  38. $postfix = "";
  39. if ($mezo!='') $postfix = " AND mezo='".$mezo."'";
  40. $results = $this->query("SELECT * FROM azonics_codomains WHERE "
  41. . "kategoria='".$kategoria."'".$postfix." AND status='1';");
  42. return $results;
  43. }
  44. else {
  45. $results = $this->query("SELECT * FROM azonics_codomains WHERE status='1';");
  46. return $results;
  47. }
  48. }
  49. public function insert_ertek($data) {
  50. $data = $this->escapeArray($data);
  51. $this->execute("INSERT INTO azonics_codomains SET "
  52. . "kategoria='".$data['new_kategoria']."', "
  53. . "mezo='".$data['new_mezo']."', "
  54. . "ertek='".$data['new_ertek']."';");
  55. return true;
  56. }
  57. public function select_mezo($kategoria='') {
  58. if ($kategoria=='Notebook') {
  59. $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
  60. . "TABLE_NAME='product_notebooks_temp' AND "
  61. . "COLUMN_COMMENT<>'';");
  62. $temp = '<option value="0" disabled selected>Mező</option>';
  63. foreach ($result as $row) {
  64. $temp.= '<option value="'.$row->mezo.'">'.$row->cimke.'</option>';
  65. }
  66. return $temp;
  67. }
  68. else {
  69. return false;
  70. }
  71. }
  72. public function delete_row($id) {
  73. if ($id!='') {
  74. $id = $this->escapeString($id);
  75. $check = $this->query("SELECT * FROM azonics_codomains WHERE id='".$id."';");
  76. $this->execute("DELETE FROM azonics_compliances WHERE ertek='".$check[0]->ertek."';");
  77. $this->execute("DELETE FROM azonics_codomains WHERE id='".$id."';");
  78. }
  79. else {
  80. return false;
  81. }
  82. }
  83. public function update_row($value,$id) {
  84. $id = $this->escapeString($id);
  85. $value = $this->escapeString($value);
  86. $this->execute("UPDATE azonics_codomains SET ertek='".$value."' WHERE id='".$id."';");
  87. return true;
  88. }
  89. public function update_field($field,$value,$id) {
  90. $id = $this->escapeString($id);
  91. $value = $this->escapeString($value);
  92. $field = $this->escapeString($field);
  93. $this->execute("UPDATE azonics_codomains SET ".$field."='".$value."' WHERE id='".$id."';");
  94. return true;
  95. }
  96. public function get_tultip_list($kategoria,$mezo) {
  97. if ($kategoria!=='' && $mezo!=='') {
  98. $table = $this->get_category_table($kategoria);
  99. $field_hash = $mezo.'_full_name';
  100. $result = $this->query("SELECT * FROM ".$table." AS products "
  101. . "LEFT JOIN azonics_compliances ON products.".$field_hash."=azonics_compliances.bazis "
  102. . "LEFT JOIN products_temp ON products.parent_product_id=products_temp.id "
  103. . "WHERE products.".$field_hash."<>'' AND products.status='1' GROUP BY products.".$field_hash.";");
  104. return $result;
  105. }
  106. else {
  107. return false;
  108. }
  109. }
  110. public function get_category_table($category) {
  111. if ($category!=='') {
  112. $res = $this->query("SELECT * FROM category_tables WHERE category_name='".$category."' AND status='1';");
  113. if (sizeof($res)>0) {
  114. return $res[0]->table_name;
  115. }
  116. else {
  117. return false;
  118. }
  119. }
  120. else {
  121. return false;
  122. }
  123. }
  124. public function check_for_exists_azonositas($bazis) {
  125. if ($bazis!=='') {
  126. $check = $this->query("SELECT * FROM azonics_compliances WHERE bazis='".$bazis."' AND status='1';");
  127. if (sizeof($check)>0) {
  128. return true;
  129. }
  130. else {
  131. return false;
  132. }
  133. }
  134. else {
  135. return false;
  136. }
  137. }
  138. public function update_azonositas($bazis,$ertek) {
  139. if ($bazis!=='' && $ertek!=='') {
  140. $bazis = $this->escapeString($bazis);
  141. $ertek = $this->escapeString($ertek);
  142. if ($this->check_for_exists_azonositas($bazis)) {
  143. $this->execute("UPDATE azonics_compliances SET "
  144. . "ertek='".$ertek."' "
  145. . "WHERE bazis='".$bazis."' AND status='1';");
  146. }
  147. else {
  148. $this->execute("INSERT INTO azonics_compliances SET "
  149. . "bazis='".$bazis."', "
  150. . "ertek='".$ertek."', "
  151. . "status='1';");
  152. }
  153. return true;
  154. }
  155. else {
  156. return false;
  157. }
  158. }
  159. }