| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?php
- class ertekkeszlet_model extends Model {
-
-
- public function get_kategoria_list($kategoria='') {
- $result = $this->query("SELECT * FROM products_temp WHERE category<>'' GROUP BY category;");
- return $result;
- }
-
-
- public function get_mezo_list($kategoria='',$mezo='') {
- if ($kategoria=='Notebook') {
- $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
- . "TABLE_NAME='product_notebooks_temp' AND "
- . "COLUMN_COMMENT<>'';");
- return $result;
- }
- elseif ($kategoria=='Desktop') {
- $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
- . "TABLE_NAME='product_desktops_temp' AND "
- . "COLUMN_COMMENT<>'';");
- return $result;
- }
- elseif ($kategoria=='Tablets') {
- $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
- . "TABLE_NAME='product_tablets_temp' AND "
- . "COLUMN_COMMENT<>'';");
- return $result;
- }
- elseif ($kategoria=='Servers') {
- $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
- . "TABLE_NAME='product_servers_temp' AND "
- . "COLUMN_COMMENT<>'';");
- return $result;
- }
- else {
- return false;
- }
- }
-
-
- public function get_ertekkeszlet_list($kategoria,$mezo) {
- if ($kategoria=='Notebook' || $kategoria=='Desktop' || $kategoria=='Tablets' || $kategoria=='Servers') {
- $postfix = "";
-
- if ($mezo!='') $postfix = " AND mezo='".$mezo."'";
-
- $results = $this->query("SELECT * FROM azonics_codomains WHERE "
- . "kategoria='".$kategoria."'".$postfix." AND status='1';");
-
- return $results;
- }
- else {
- $results = $this->query("SELECT * FROM azonics_codomains WHERE status='1';");
- return $results;
- }
- }
-
-
- public function insert_ertek($data) {
- $data = $this->escapeArray($data);
- $this->execute("INSERT INTO azonics_codomains SET "
- . "kategoria='".$data['new_kategoria']."', "
- . "mezo='".$data['new_mezo']."', "
- . "ertek='".$data['new_ertek']."';");
- return true;
- }
-
-
- public function select_mezo($kategoria='') {
- if ($kategoria=='Notebook') {
- $result = $this->query("SELECT COLUMN_NAME AS mezo, COLUMN_COMMENT AS cimke FROM INFORMATION_SCHEMA.COLUMNS WHERE "
- . "TABLE_NAME='product_notebooks_temp' AND "
- . "COLUMN_COMMENT<>'';");
-
- $temp = '<option value="0" disabled selected>Mező</option>';
-
- foreach ($result as $row) {
- $temp.= '<option value="'.$row->mezo.'">'.$row->cimke.'</option>';
- }
-
- return $temp;
- }
- else {
- return false;
- }
- }
-
-
- public function delete_row($id) {
- if ($id!='') {
- $id = $this->escapeString($id);
- $check = $this->query("SELECT * FROM azonics_codomains WHERE id='".$id."';");
- $this->execute("DELETE FROM azonics_compliances WHERE ertek='".$check[0]->ertek."';");
- $this->execute("DELETE FROM azonics_codomains WHERE id='".$id."';");
- }
- else {
- return false;
- }
- }
-
-
- public function update_row($value,$id) {
- $id = $this->escapeString($id);
- $value = $this->escapeString($value);
- $this->execute("UPDATE azonics_codomains SET ertek='".$value."' WHERE id='".$id."';");
- return true;
- }
- public function update_field($field,$value,$id) {
- $id = $this->escapeString($id);
- $value = $this->escapeString($value);
- $field = $this->escapeString($field);
- $this->execute("UPDATE azonics_codomains SET ".$field."='".$value."' WHERE id='".$id."';");
- return true;
- }
-
-
- public function get_tultip_list($kategoria,$mezo) {
- if ($kategoria!=='' && $mezo!=='') {
- $table = $this->get_category_table($kategoria);
- $field_hash = $mezo.'_full_name';
- $result = $this->query("SELECT * FROM ".$table." AS products "
- . "LEFT JOIN azonics_compliances ON products.".$field_hash."=azonics_compliances.bazis "
- . "LEFT JOIN products_temp ON products.parent_product_id=products_temp.id "
- . "WHERE products.".$field_hash."<>'' AND products.status='1' GROUP BY products.".$field_hash.";");
- return $result;
- }
- else {
- return false;
- }
- }
-
-
- public function get_category_table($category) {
- if ($category!=='') {
- $res = $this->query("SELECT * FROM category_tables WHERE category_name='".$category."' AND status='1';");
- if (sizeof($res)>0) {
- return $res[0]->table_name;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- public function check_for_exists_azonositas($bazis) {
- if ($bazis!=='') {
- $check = $this->query("SELECT * FROM azonics_compliances WHERE bazis='".$bazis."' AND status='1';");
- if (sizeof($check)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- public function update_azonositas($bazis,$ertek) {
- if ($bazis!=='' && $ertek!=='') {
- $bazis = $this->escapeString($bazis);
- $ertek = $this->escapeString($ertek);
-
- if ($this->check_for_exists_azonositas($bazis)) {
- $this->execute("UPDATE azonics_compliances SET "
- . "ertek='".$ertek."' "
- . "WHERE bazis='".$bazis."' AND status='1';");
- }
- else {
- $this->execute("INSERT INTO azonics_compliances SET "
- . "bazis='".$bazis."', "
- . "ertek='".$ertek."', "
- . "status='1';");
- }
-
- return true;
- }
- else {
- return false;
- }
- }
-
-
- }
|