📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv11.demodesign.com.tr
/
propanel
/
model
/
extension
/
module
📝
askforquote.php
← Geri Dön
<?php class ModelExtensionModuleAskForQuote extends Model { public function getTotalCustomers($store_id=0){ $query = "SELECT COUNT(*) as `count` FROM `" . DB_PREFIX . "askforquote` afq JOIN `" . DB_PREFIX . "product_description` product on afq.product_id = product.product_id WHERE processed=0"; if (!empty($filter_name)) { $query .= " AND product.name LIKE '" . $this->db->escape($filter_name) . "%'"; } $query .=" and language_id = " . (int)$this->config->get('config_language_id') . " AND store_id='".$store_id."'"; $query = $this->db->query($query); return $query->row['count']; } public function getTotalArchivedQuotes($store_id=0, $filter_name=''){ $query = "SELECT COUNT(*) as `count` FROM `" . DB_PREFIX . "askforquote` afq JOIN `" . DB_PREFIX . "product_description` product on afq.product_id = product.product_id WHERE processed=1"; if (!empty($filter_name)) { $query .= " AND product.name LIKE '" . $this->db->escape($filter_name) . "%'"; } $query .=" and language_id = " . (int)$this->config->get('config_language_id') . " AND store_id='".$store_id."'"; $query = $this->db->query($query); return $query->row['count']; } public function getQuotes($store_id=0, $filter_name='', $page=1, $limit=8, $sort="id", $order="DESC") { if ($page) { $start = ($page - 1) * $limit; } $query = "SELECT afq.*, product.name as product_name FROM `" . DB_PREFIX . "askforquote` afq JOIN `" . DB_PREFIX . "product_description` product on afq.product_id = product.product_id WHERE processed=0"; if (!empty($filter_name)) { $query .= " AND product.name LIKE '" . $this->db->escape($filter_name) . "%'"; } $query .=" and language_id = " . (int)$this->config->get('config_language_id') . " AND store_id='".$store_id."' ORDER BY `date_created` DESC LIMIT ".$start.", ".$limit; $query = $this->db->query($query); $sources = array(); foreach ($query->rows as $key => $row) { $option_data = ''; $options = unserialize($row['product_options']); $option_data = $this->getOptionData($options, $row['product_id']); $sources[$key] = array ( "id"=> $row["id"], "product_id"=> $row["product_id"], "product_options"=> $option_data, "name"=> $row["name"], "email"=> $row["email"], "comments"=> htmlspecialchars_decode(trim(preg_replace('/\s+/', ' ', $row["comments"]))), "admin_comments"=> htmlspecialchars_decode(trim(preg_replace('/\s+/', ' ', $row["admin_comments"]))), "processed"=> $row["processed"], "date_created"=> $row["date_created"], "store_id"=> $row["store_id"], "product_name"=> $row["product_name"], "quantity" => $row["quote_quantity"], "privacy_policy" => $row["privacy_policy"] ); } return $sources; } private function getOptionData($option = array(), $product_id) { $option_price = 0; $option_points = 0; $option_weight = 0; $option_data = array(); if (!empty($option)) { foreach ($option as $product_option_id => $value) { $option_query = $this->db->query("SELECT po.product_option_id, po.option_id, od.name, o.type FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_option_id = '" . (int)$product_option_id . "' AND po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "'"); if ($option_query->num_rows) { if ($option_query->row['type'] == 'select' || $option_query->row['type'] == 'radio' || $option_query->row['type'] == 'image') { $option_value_query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.quantity, pov.subtract, pov.price, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_option_value_id = '" . (int)$value . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); if ($option_value_query->num_rows) { if ($option_value_query->row['price_prefix'] == '+') { $option_price += $option_value_query->row['price']; } elseif ($option_value_query->row['price_prefix'] == '-') { $option_price -= $option_value_query->row['price']; } if ($option_value_query->row['points_prefix'] == '+') { $option_points += $option_value_query->row['points']; } elseif ($option_value_query->row['points_prefix'] == '-') { $option_points -= $option_value_query->row['points']; } if ($option_value_query->row['weight_prefix'] == '+') { $option_weight += $option_value_query->row['weight']; } elseif ($option_value_query->row['weight_prefix'] == '-') { $option_weight -= $option_value_query->row['weight']; } $option_data[] = array( 'product_option_id' => $product_option_id, 'product_option_value_id' => $value, 'option_id' => $option_query->row['option_id'], 'option_value_id' => $option_value_query->row['option_value_id'], 'name' => $option_query->row['name'], 'value' => $option_value_query->row['name'], 'type' => $option_query->row['type'], ); } } elseif ($option_query->row['type'] == 'checkbox' && is_array($value)) { foreach ($value as $product_option_value_id) { $option_value_query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.quantity, pov.subtract, pov.price, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); if ($option_value_query->num_rows) { if ($option_value_query->row['price_prefix'] == '+') { $option_price += $option_value_query->row['price']; } elseif ($option_value_query->row['price_prefix'] == '-') { $option_price -= $option_value_query->row['price']; } if ($option_value_query->row['points_prefix'] == '+') { $option_points += $option_value_query->row['points']; } elseif ($option_value_query->row['points_prefix'] == '-') { $option_points -= $option_value_query->row['points']; } if ($option_value_query->row['weight_prefix'] == '+') { $option_weight += $option_value_query->row['weight']; } elseif ($option_value_query->row['weight_prefix'] == '-') { $option_weight -= $option_value_query->row['weight']; } if ($option_value_query->row['subtract'] && (!$option_value_query->row['quantity'] || ($option_value_query->row['quantity'] < $cart['quantity']))) { $stock = false; } $option_data[] = array( 'product_option_id' => $product_option_id, 'product_option_value_id' => $product_option_value_id, 'option_id' => $option_query->row['option_id'], 'option_value_id' => $option_value_query->row['option_value_id'], 'name' => $option_query->row['name'], 'value' => $option_value_query->row['name'], 'type' => $option_query->row['type'], ); } } } elseif ($option_query->row['type'] == 'text' || $option_query->row['type'] == 'textarea' || $option_query->row['type'] == 'file' || $option_query->row['type'] == 'date' || $option_query->row['type'] == 'datetime' || $option_query->row['type'] == 'time') { $option_data[] = array( 'product_option_id' => $product_option_id, 'product_option_value_id' => '', 'option_id' => $option_query->row['option_id'], 'option_value_id' => '', 'name' => $option_query->row['name'], 'value' => $value, 'type' => $option_query->row['type'], ); } } } } return $option_data; } public function getArchive($store_id=0, $filter_name='', $page=1, $limit=8, $sort="id", $order="DESC") { if ($page) { $start = ($page - 1) * $limit; } $query = "SELECT afq.*, product.name as product_name FROM `" . DB_PREFIX . "askforquote` afq JOIN `" . DB_PREFIX . "product_description` product on afq.product_id = product.product_id WHERE processed=1"; if (!empty($filter_name)) { $query .= " AND product.name LIKE '" . $this->db->escape($filter_name) . "%'"; } $query .=" and language_id = " . (int)$this->config->get('config_language_id') . " AND store_id='".$store_id."' ORDER BY `date_created` DESC LIMIT ".$start.", ".$limit; $query = $this->db->query($query); $sources = array(); foreach ($query->rows as $key => $row) { $option_data = ''; $options = unserialize($row['product_options']); $option_data = $this->getOptionData($options, $row['product_id']); $sources[$key] = array ( "id"=> $row["id"], "product_id"=> $row["product_id"], "product_options"=> $option_data, "name"=> $row["name"], "email"=> $row["email"], "comments"=> htmlspecialchars_decode(trim(preg_replace('/\s+/', ' ', $row["comments"]))), "admin_comments"=> htmlspecialchars_decode(trim(preg_replace('/\s+/', ' ', $row["admin_comments"]))), "comments_encoded"=> base64_encode(htmlspecialchars_decode(trim(preg_replace('/\s+/', ' ', $row["comments"])))), "processed"=> $row["processed"], "date_created"=> $row["date_created"], "store_id"=> $row["store_id"], "product_name"=> $row["product_name"], "quantity" => $row["quote_quantity"], "privacy_policy" => $row["privacy_policy"] ); } return $sources; } public function install($moduleName) { $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "askforquote ( `id` int(11) NOT NULL AUTO_INCREMENT, `product_id` int(11) NOT NULL DEFAULT '0', `product_options` text NOT NULL, `quote_quantity` int(11) NOT NULL DEFAULT '0', `name` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `comments` TEXT NULL, `admin_comments` TEXT NULL, `processed` TINYINT(1) DEFAULT 0, `date_created` timestamp NOT NULL DEFAULT NOW(), `store_id` int(11) NOT NULL DEFAULT 0, `privacy_policy` INT(11) NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"); $this->load->model('design/layout'); $layouts = array(); $layouts = $this->model_design_layout->getLayouts(); foreach ($layouts as $layout) { $this->db->query("INSERT INTO " . DB_PREFIX . "layout_module SET layout_id = '" . (int)$layout['layout_id'] . "', code = '" . $this->db->escape($moduleName) . "', position = '" . $this->db->escape('content_bottom') . "', sort_order = '0'"); } } public function uninstall($moduleName) { $this->db->query("DROP TABLE IF EXISTS " . DB_PREFIX . "askforquote"); $this->load->model('design/layout'); $layouts = array(); $layouts = $this->model_design_layout->getLayouts(); foreach ($layouts as $layout) { $this->db->query("DELETE FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout['layout_id'] . "' and code = '" . $this->db->escape($moduleName)."'"); } } } ?>
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula