%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 Discounts_model extends CI_Model { public function __construct() { parent::__construct(); } public function getDiscountCodeInfo($id) { $this->db->where('id', $id); $result = $this->db->get('discount_codes'); return $result->row_array(); } public function changeCodeDiscountStatus($codeId, $toStatus) { $this->db->where('id', $codeId); if (!$this->db->update('discount_codes', array( 'status' => $toStatus ))) { log_message('error', print_r($this->db->error(), true)); show_error(lang('database_error')); } } public function discountCodesCount() { return $this->db->count_all_results('discount_codes'); } public function getDiscountCodes($limit, $page) { $result = $this->db->get('discount_codes', $limit, $page); return $result->result_array(); } public function setDiscountCode($post) { if (!$this->db->insert('discount_codes', array( 'type' => $post['type'], 'code' => trim($post['code']), 'amount' => $post['amount'], 'valid_from_date' => strtotime($post['valid_from_date']), 'valid_to_date' => strtotime($post['valid_to_date']) ))) { log_message('error', print_r($this->db->error(), true)); show_error(lang('database_error')); } } public function updateDiscountCode($post) { $this->db->where('id', $post['update']); if (!$this->db->update('discount_codes', array( 'type' => $post['type'], 'code' => trim($post['code']), 'amount' => $post['amount'], 'valid_from_date' => strtotime($post['valid_from_date']), 'valid_to_date' => strtotime($post['valid_to_date']) ))) { log_message('error', print_r($this->db->error(), true)); show_error(lang('database_error')); } } public function discountCodeTakenCheck($post) { if ($post['update'] > 0) { $this->db->where('id !=', $post['update']); } $this->db->where('code', $post['code']); $num_rows = $this->db->count_all_results('discount_codes'); if ($num_rows == 0) { return true; } return false; } }