%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php class Subscribed_model extends CI_Model { public function __construct() { parent::__construct(); } public function deleteProduct($id) { $this->db->trans_begin(); $this->db->where('id', $id); if (!$this->db->delete('user_booking')) { log_message('error', print_r($this->db->error(), true)); } if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); show_error(lang('database_error')); } else { $this->db->trans_commit(); } } public function productsCount($search_title = null, $category = null) { if ($search_title != null) { $search_title = trim($this->db->escape_like_str($search_title)); $this->db->where("(subscribed.email LIKE '%$search_title%')"); } return $this->db->count_all_results('subscribed'); } public function getProducts($limit, $page, $search_title = null, $orderby = null) { if ($search_title != null) { $search_title = trim($this->db->escape_like_str($search_title)); $this->db->where("(subscribed.email LIKE '%$search_title%')"); } if ($orderby !== null) { $ord = explode('=', $orderby); if (isset($ord[0]) && isset($ord[1])) { $this->db->order_by('subscribed.' . $ord[0], $ord[1]); } } else { $this->db->order_by('id', 'desc'); } $query = $this->db->select('id,email,time')->get('subscribed', $page); return $query->result(); } public function getAllProducts(){ $this->db->where('shop_categorie', '2'); $query = $this->db->select('id,name,email,created_at')->get('subscribed'); return $query->result(); } public function numShopProducts() { { return $this->db->count_all_results('subscribed'); } public function getOneProduct($id) { $this->db->select('subscribed.name as vendor_name, subscribed.id as vendor_id, products.*'); $this->db->where('products.id', $id); $this->db->join('subscribed', 'subscribed.id = products.vendor_id', 'left'); $query = $this->db->get('products'); if ($query->num_rows() > 0) { return $query->row_array(); } else { return false; } } public function productStatusChange($id, $to_status) { $this->db->where('id', $id); $result = $this->db->update('subscribed', array('visibility' => $to_status)); return $result; } public function setProduct($post, $id = 0) { if (!isset($post['brand_id'])) { $post['brand_id'] = null; } if (!isset($post['virtual_products'])) { $post['virtual_products'] = null; } $this->db->trans_begin(); $is_update = false; if ($id > 0) { $is_update = true; if (!$this->db->where('id', $id)->update('products', array( 'image' => $post['image'] != null ? $_POST['image'] : $_POST['old_image'], 'shop_categorie' => $post['shop_categorie'], 'quantity' => $post['quantity'], 'in_slider' => $post['in_slider'], 'position' => $post['position'], 'virtual_products' => $post['virtual_products'], 'brand_id' => $post['brand_id'], 'time_update' => time() ))) { log_message('error', print_r($this->db->error(), true)); } } else { /* * Lets get what is default tranlsation number * in titles and convert it to url * We want our plaform public ulrs to be in default * language that we use */ $i = 0; foreach ($_POST['translations'] as $translation) { if ($translation == MY_DEFAULT_LANGUAGE_ABBR) { $myTranslationNum = $i; } $i++; } if (!$this->db->insert('products', array( 'image' => $post['image'], 'shop_categorie' => $post['shop_categorie'], 'quantity' => $post['quantity'], 'in_slider' => $post['in_slider'], 'position' => $post['position'], 'virtual_products' => $post['virtual_products'], 'folder' => $post['folder'], 'brand_id' => $post['brand_id'], 'time' => time() ))) { log_message('error', print_r($this->db->error(), true)); } $id = $this->db->insert_id(); $this->db->where('id', $id); if (!$this->db->update('products', array( 'url' => except_letters($_POST['title'][$myTranslationNum]) . '_' . $id ))) { log_message('error', print_r($this->db->error(), true)); } } $this->setProductTranslation($post, $id, $is_update); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); show_error(lang('database_error')); } else { $this->db->trans_commit(); } } private function setProductTranslation($post, $id, $is_update) { $i = 0; $current_trans = $this->getTranslations($id); foreach ($post['translations'] as $abbr) { $arr = array(); $emergency_insert = false; if (!isset($current_trans[$abbr])) { $emergency_insert = true; } $post['title'][$i] = str_replace('"', "'", $post['title'][$i]); $post['tag_line'][$i] = str_replace(' ', '', $post['tag_line'][$i]); $post['price'][$i] = str_replace(' ', '', $post['price'][$i]); $post['price'][$i] = str_replace(',', '', $post['price'][$i]); $arr = array( 'title' => $post['title'][$i], 'tag_line' => $post['tag_line'][$i], 'recommended_for' => $post['recommended_for'][$i], 'gender' => $post['gender'][$i], 'reporting_time' => $post['reporting_time'][$i], 'fasting_time' => $post['fasting_time'][$i], 'precautions' => $post['precautions'][$i], 'basic_description' => $post['basic_description'][$i], 'description' => $post['description'][$i], 'price' => $post['price'][$i], 'old_price' => $post['old_price'][$i], 'abbr' => $abbr, 'for_id' => $id ); if ($is_update === true && $emergency_insert === false) { $abbr = $arr['abbr']; unset($arr['for_id'], $arr['abbr'], $arr['url']); if (!$this->db->where('abbr', $abbr)->where('for_id', $id)->update('products_translations', $arr)) { log_message('error', print_r($this->db->error(), true)); } } else { if (!$this->db->insert('products_translations', $arr)) { log_message('error', print_r($this->db->error(), true)); } } $i++; } } public function getTranslations($id) { $this->db->where('for_id', $id); $query = $this->db->get('products_translations'); $arr = array(); foreach ($query->result() as $row) { $arr[$row->abbr]['title'] = $row->title; $arr[$row->abbr]['tag_line'] = $row->tag_line; $arr[$row->abbr]['fasting_time'] = $row->fasting_time; $arr[$row->abbr]['reporting_time'] = $row->reporting_time; $arr[$row->abbr]['gender'] = $row->gender; $arr[$row->abbr]['recommended_for'] = $row->recommended_for; $arr[$row->abbr]['precautions'] = $row->precautions; $arr[$row->abbr]['basic_description'] = $row->basic_description; $arr[$row->abbr]['description'] = $row->description; $arr[$row->abbr]['price'] = $row->price; $arr[$row->abbr]['old_price'] = $row->old_price; } return $arr; } }