From bb394cee116f7e66baa67032dde0732bf053500e Mon Sep 17 00:00:00 2001 From: Basheir Date: Sun, 10 May 2020 02:16:46 +0300 Subject: [PATCH] V1.3.0 --- .idea/webServers.xml | 2 +- .idea/workspace.xml | 66 ++++++++-- .../extension/module/available_on_stores.php | 0 .../extension/module/available_on_stores.php | 3 +- .../module/available_on_stores_append.php | 8 ++ .../extension/module/available_on_stores.php | 1 + .../module/available_on_stores_append.php | 8 ++ .../extension/module/available_on_stores.php | 116 +++++++++--------- .../extension/module/available_on_stores.twig | 0 .../module/available_on_stores_dashboard.twig | 0 .../extension/module/available_on_stores.php | 95 ++++++++++++++ .../extension/module/available_on_stores.php | 106 ---------------- .../xml/available_on_stores.xml | 30 ++--- 13 files changed, 245 insertions(+), 190 deletions(-) rename {upload/admin => admin}/controller/extension/module/available_on_stores.php (100%) rename {upload/admin => admin}/language/ar/extension/module/available_on_stores.php (95%) create mode 100644 admin/language/ar/extension/module/available_on_stores_append.php rename {upload/admin => admin}/language/en-gb/extension/module/available_on_stores.php (99%) create mode 100644 admin/language/en-gb/extension/module/available_on_stores_append.php rename {upload/admin => admin}/model/extension/module/available_on_stores.php (97%) rename {upload/admin => admin}/view/template/extension/module/available_on_stores.twig (100%) rename {upload/admin => admin}/view/template/extension/module/available_on_stores_dashboard.twig (100%) create mode 100644 catalog/controller/extension/module/available_on_stores.php delete mode 100644 upload/catalog/controller/extension/module/available_on_stores.php rename install.xml => vqmod/xml/available_on_stores.xml (87%) diff --git a/.idea/webServers.xml b/.idea/webServers.xml index a7bfddf..fec33e8 100644 --- a/.idea/webServers.xml +++ b/.idea/webServers.xml @@ -3,7 +3,7 @@ diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ce57670..5f0007b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -26,7 +26,18 @@ - + + + + + + + + + + + + + + + + + @@ -56,7 +72,19 @@ - + + + + + + + + + + + + + @@ -68,7 +96,9 @@ @@ -110,6 +146,7 @@ + - - + + + - + - + @@ -135,11 +173,19 @@ - + + + + + - + + + + + diff --git a/upload/admin/controller/extension/module/available_on_stores.php b/admin/controller/extension/module/available_on_stores.php similarity index 100% rename from upload/admin/controller/extension/module/available_on_stores.php rename to admin/controller/extension/module/available_on_stores.php diff --git a/upload/admin/language/ar/extension/module/available_on_stores.php b/admin/language/ar/extension/module/available_on_stores.php similarity index 95% rename from upload/admin/language/ar/extension/module/available_on_stores.php rename to admin/language/ar/extension/module/available_on_stores.php index 195a850..7369c4f 100644 --- a/upload/admin/language/ar/extension/module/available_on_stores.php +++ b/admin/language/ar/extension/module/available_on_stores.php @@ -8,7 +8,7 @@ $_['text_version'] = '1.3.0'; // Heading -$_['heading_title'] = 'Available on Stores'; +$_['heading_title'] = 'Available on Stores - متوفر لدى'; $_['header_customer_message'] = ' اعدادات المستخدم'; @@ -59,3 +59,4 @@ // helper $_['text_help_edit'] = 'انقر هنا لتعديل المسمى'; + diff --git a/admin/language/ar/extension/module/available_on_stores_append.php b/admin/language/ar/extension/module/available_on_stores_append.php new file mode 100644 index 0000000..96f34c8 --- /dev/null +++ b/admin/language/ar/extension/module/available_on_stores_append.php @@ -0,0 +1,8 @@ +db->query( "SELECT * from `" . DB_PREFIX . "available_on_stores` ORDER BY `stores_id` ASC;" )->rows; } public function addStores($name) { - + return $this->db->query( "INSERT INTO " . DB_PREFIX. "available_on_stores (`name`) VALUES ('". $this->db->escape($name) . "')" ); - + } @@ -36,14 +38,14 @@ public function deleteStores($store_id) { $this->db->query( "DELETE from `" . DB_PREFIX . "available_on_stores` WHERE `stores_id` = '". $this->db->escape($store_id). "';" ); $this->db->query( "DELETE from " . DB_PREFIX. "available_on_stores_urls WHERE `stores_id` ='". $this->db->escape($store_id)."' " ); $this->db->query( "DELETE from " . DB_PREFIX. "available_on_stores_dashboard WHERE `stores_id` ='". $this->db->escape($store_id)."' " ); - + return $this->db->countAffected(); - + } - - - - + + + + public function updateStores($name,$id) { @@ -54,7 +56,7 @@ public function updateStores($name,$id) { . "' WHERE `stores_id` = '" . $this->db->escape($id) . "';" ); - + return $this->db->countAffected() ; } @@ -64,11 +66,11 @@ public function updateStores($name,$id) { // ------------------------------------------- - + public function addUrls($url,$product_id ,$stores_id) { - + return $this->db->query( "INSERT INTO " . DB_PREFIX. "available_on_stores_urls (`url`,`product_id`,`stores_id`) VALUES ('". $this->db->escape($url) . "','". $this->db->escape($product_id) . "','". $this->db->escape($stores_id) . "')" ); - + } @@ -77,14 +79,14 @@ public function addUrls($url,$product_id ,$stores_id) { public function getUrls($product_id) { return $this->db->query( "SELECT * from `" . DB_PREFIX . "available_on_stores_urls` WHERE `product_id` ='". $this->db->escape($product_id)."' ;" )->rows; - + } - - + + public function editUrls($url, $product_id,$stores_id) { - + return $this->db->query( "INSERT INTO " . DB_PREFIX. "available_on_stores_urls (`url`,`product_id`,`stores_id`) VALUES ('". $this->db->escape($url) . "','". $this->db->escape($product_id) . "','". $this->db->escape($stores_id) . "')" ); } @@ -94,41 +96,41 @@ public function editUrls($url, $product_id,$stores_id) { public function deleteUrls($product_id) { - + return $this->db->query( "DELETE from " . DB_PREFIX. "available_on_stores_urls WHERE `product_id` ='".$this->db->escape($product_id)."' " ); } - - - + + + //------------------- DashBorad - - - - + + + + public function getDashboardStore($ID) { - + return $this->db->query( "SELECT * from " . DB_PREFIX. "available_on_stores_dashboard WHERE `stores_id` ='".$this->db->escape($ID)."' " ); - + } - - - - + + + + public function deleteDashboard($product_Id) { - + $this->db->query( "DELETE from " . DB_PREFIX. "available_on_stores_dashboard WHERE `product_id` ='".$this->db->escape($product_Id)."' " ); - + return $this->db->countAffected(); - + } - - - - + + + + /** public function getDashboardAllData() { @@ -153,17 +155,17 @@ public function getCountAllRows() { - - - + + + public function getDashboardByPage($page=1, $limit=10) { - + if ($page) { $start = ($page - 1) * $limit; } - + return $this->db->query("SELECT `product_id`,`stores_id`,`stores_id`,`date`,COUNT(`product_id`) as totalClicked from " . DB_PREFIX. "available_on_stores_dashboard group by `product_id`,`stores_id` order by `totalClicked` desc LIMIT " .$this->db->escape($start).",".$this->db->escape($limit))->rows; - + } @@ -175,27 +177,27 @@ public function getDashboardByPage($page=1, $limit=10) { */ public function getDashboardByProductIDAndStoresID($product_id,$stores_id) { - + return $this->db->query( "SELECT count(`product_id`) as Total FROM `" . DB_PREFIX . "available_on_stores_dashboard` WHERE `product_id` ='". $this->db->escape($product_id)."' and `stores_id` ='". $this->db->escape($stores_id) ."';" )->rows[0]['Total']; - - + + } - - - - - - + + + + + + public function getLastProductId() { $query = $this->db->query("SELECT product_id FROM " . DB_PREFIX . "product ORDER BY product_id DESC LIMIT 0,1"); - + return $query->row['product_id']; } - - - - + + + + } diff --git a/upload/admin/view/template/extension/module/available_on_stores.twig b/admin/view/template/extension/module/available_on_stores.twig similarity index 100% rename from upload/admin/view/template/extension/module/available_on_stores.twig rename to admin/view/template/extension/module/available_on_stores.twig diff --git a/upload/admin/view/template/extension/module/available_on_stores_dashboard.twig b/admin/view/template/extension/module/available_on_stores_dashboard.twig similarity index 100% rename from upload/admin/view/template/extension/module/available_on_stores_dashboard.twig rename to admin/view/template/extension/module/available_on_stores_dashboard.twig diff --git a/catalog/controller/extension/module/available_on_stores.php b/catalog/controller/extension/module/available_on_stores.php new file mode 100644 index 0000000..6ce5bbb --- /dev/null +++ b/catalog/controller/extension/module/available_on_stores.php @@ -0,0 +1,95 @@ +config->get('available_on_stores_status'); + + if ($statUS) { + + $this->addClicked(); + } + + } + + + public function addClicked() { + + + $result = false; + + if (isset($this->request->post['product_id']) + and !empty($this->request->post['product_id']) + and $this->request->post['product_id'] != 0 + and isset($this->request->post['stores_id']) + and !empty($this->request->post['stores_id']) + and $this->request->post['stores_id'] != 0 + ) { + + $product_id = (int) $this->request->post['product_id']; + $stores_id = (int) $this->request->post['stores_id']; + $this->db->query("INSERT INTO `".DB_PREFIX + ."available_on_stores_dashboard` (`product_id`,`stores_id`) VALUES ($product_id,$stores_id);"); + $result = $this->db->countAffected(); + + } + + + echo json_encode(['result' => $result]); + + + } + + public function getStoreUrls() { + + + $statUS = $this->config->get('available_on_stores_status'); + $theme = $this->config->get('config_theme'); + + + if ($statUS) { + if (isset($this->request->get['product_id']) + and !empty($this->request->get['product_id']) + and $this->request->get['product_id'] != 0 + ) { + + $id = (int) $this->request->get['product_id']; + $result = $this->db->query("SELECT * + + FROM + `".DB_PREFIX."available_on_stores_urls` `".DB_PREFIX."available_on_stores_urls` + INNER JOIN `oc_available_on_stores` + ON `".DB_PREFIX + ."available_on_stores_urls`.`stores_id` = `".DB_PREFIX."available_on_stores`. + `stores_id` WHERE `product_id` = '$id' ")->rows; + + + if ($this->db->countAffected() > 0) { + $json = ['result' => $result, 'theme' => $theme]; + } else { + $json = ['result' => false, 'theme' => $theme]; + + } + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($json)); + + + } + + } else { + echo 'Module Not enabled'; + } + + + } + + +} diff --git a/upload/catalog/controller/extension/module/available_on_stores.php b/upload/catalog/controller/extension/module/available_on_stores.php deleted file mode 100644 index ef33c84..0000000 --- a/upload/catalog/controller/extension/module/available_on_stores.php +++ /dev/null @@ -1,106 +0,0 @@ -config->get('available_on_stores_status'); - - if ($statUS) { - - $this->addClicked(); - } - - } - - - public function addClicked() - { - - - - $result = false; - - if (isset($this->request->post['product_id']) AND !empty($this->request->post['product_id']) AND $this->request->post['product_id'] != 0 AND isset($this->request->post['stores_id']) AND !empty($this->request->post['stores_id']) AND $this->request->post['stores_id'] != 0) { - - $product_id = (int)$this->request->post['product_id']; - $stores_id = (int)$this->request->post['stores_id']; - $this->db->query("INSERT INTO `" . DB_PREFIX . "available_on_stores_dashboard` (`product_id`,`stores_id`) VALUES ($product_id,$stores_id);"); - $result = $this->db->countAffected(); - - } - - - echo json_encode(array('result' => $result)); - - - } - - public function getStoreUrls(){ - - - - $statUS = $this->config->get('available_on_stores_status'); - $theme = $this->config->get('config_theme') ; - - - if ($statUS) { - if (isset($this->request->get['product_id']) AND !empty($this->request->get['product_id']) and $this->request->get['product_id'] != 0) { - - $id = (int)$this->request->get['product_id']; - $result = $this->db->query("SELECT * - - FROM - `" . DB_PREFIX . "available_on_stores_urls` `" . DB_PREFIX . "available_on_stores_urls` - INNER JOIN `oc_available_on_stores` - ON `" . DB_PREFIX . "available_on_stores_urls`.`stores_id` = `" . DB_PREFIX . "available_on_stores`. - `stores_id` WHERE `product_id` = '$id' ")->rows; - - - - - - if ($this->db->countAffected() > 0) { - $json = array('result' => $result,'theme'=>$theme); - } else { - $json = array('result' => false,'theme'=>$theme); - - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - - - } - - } - - - else { - echo 'Module Not enabled'; - } - - - - - - } - - - - - - - - -} diff --git a/install.xml b/vqmod/xml/available_on_stores.xml similarity index 87% rename from install.xml rename to vqmod/xml/available_on_stores.xml index 076c9a1..5004c98 100644 --- a/install.xml +++ b/vqmod/xml/available_on_stores.xml @@ -16,7 +16,7 @@ ]]> Available on Stores +
  • {{available_on_stores_tab_title}}
  • ]]>
    @@ -47,12 +47,10 @@ {% endif %} - -
    - +
    @@ -89,18 +87,20 @@ load->model('extension/module/available_on_stores'); - $product_id = (int)$this->request->get['product_id']; - $result = $this->model_extension_module_available_on_stores->getUrls($product_id); - $items = array(); - foreach ($result as $key => $value){ - $items[$value['stores_id']] = $value['url']; - } - - $data['rows_available_on_stores_urls'] = $items; - $data['rows_available_on_stores'] = $this->model_extension_module_available_on_stores->getStores(); - - var_dump($data); + if(isset($this->request->get['product_id'])){ + $product_id = (int)$this->request->get['product_id']; + $result = $this->model_extension_module_available_on_stores->getUrls($product_id); + $items = array(); + foreach ($result as $key => $value){ + $items[$value['stores_id']] = $value['url']; + } + $data['rows_available_on_stores_urls'] = $items; + } + + $data['rows_available_on_stores'] = $this->model_extension_module_available_on_stores->getStores(); + $this->load->language('extension/module/available_on_stores_append'); + $data['available_on_stores_tab_title'] = $this->language->get('available_on_stores_tab_title'); ]]>