%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 Agent_model extends CI_Model { public function __construct() { parent::__construct(); } public function getVendorInfoFromEmail($email) { $this->db->where('email', $email); $result = $this->db->get('vendors'); return $result->row_array(); } public function getVendorByUrlAddress($urlAddr) { $this->db->where('url', $urlAddr); $result = $this->db->get('vendors'); return $result->row_array(); } public function saveNewVendorDetails($post, $vendor_id) { if (!$this->db->where('id', $vendor_id)->update('vendors', array( 'name' => $post['vendor_name'], 'url' => $post['vendor_url'], 'phone' => $post['vendor_phone'] ))) { //print_r($this->db->error(), true);die; log_message('error', print_r($this->db->error(), true)); } //echo $this->db->last_query();die; } public function isVendorUrlFree($vendorUrl) { $this->db->where('phone', $vendorUrl); $num = $this->db->count_all_results('vendors'); if ($num > 0) { return false; } else { return true; } } public function getDailycalls($vendor_id) { $role=$this->getRole($vendor_id); if($role[0]['role']=='agent'){ $this->db->where('agent_id', $vendor_id); } //$this->db->where('created_on', date('Y-m-d')); $query = $this->db->select('COUNT(*) as num')->get('booking_enquiry'); //echo $this->db->last_query();die; return $query->row_array(); } public function getOrdersByMonth($vendor_id) { $role=$this->getRole($vendor_id); if($role[0]['role']=='agent'){ $this->db->where('agent_id',$vendor_id); } $this->db->where(DATE_FORMAT('created_on', '%Y'),date('Y')); $this->db->group_by("DATE_FORMAT('created_on', '%Y'), DATE_FORMAT('created_on', '%m') ASC"); if (!$result = $this->db->query("SELECT DATE_FORMAT(created_on, '%Y') as year, Month(created_on) AS month, COUNT(id) as num FROM booking_enquiry")) { log_message('error', print_r($this->db->error(), true)); } //echo $this->db->last_query(); $result = $result->result_array(); $orders = array(); $years = array(); foreach ($result as $res) { if (!isset($orders[$res['year']])) { for ($i = 1; $i <= 12; $i++) { $orders[$res['year']][$i] = 0; } } $years[] = $res['year']; $orders[$res['year']][$res['month']] = $res['num']; } return array( 'years' => array_unique($years), 'orders' => $orders ); } public function getLeadsByMonth($vendor_id) { /*$role=$this->getRole($vendor_id); if($role[0]['role']=='agent'){ $this->db->where('agent_id',$vendor_id); }*/ $this->db->group_by("DATE_FORMAT('created_on', '%Y'), DATE_FORMAT('created_on', '%m') ASC"); if(!$result = $this->db->select("DATE_FORMAT(created_on, '%Y') as year, Month(created_on) AS month, COUNT(id) as num")->get('booking_enquiry')){ print_r($this->db->error(), true); log_message('error', print_r($this->db->error(), true)); } /*if (!$result = $this->db->query("SELECT DATE_FORMAT(created_on, '%Y') as year, Month(created_on) AS month, COUNT(id) as num FROM booking_enquiry")) { log_message('error', print_r($this->db->error(), true)); }*/ //echo $this->db->last_query(); $result = $result->result_array(); $orders = array(); $years = array(); foreach ($result as $res) { if (!isset($orders[$res['year']])) { for ($i = 1; $i <= 12; $i++) { $orders[$res['year']][$i] = 0; } } $years[] = $res['year']; $orders[$res['year']][$res['month']] = $res['num']; } return array( 'years' => array_unique($years), 'orders' => $orders ); } public function callsCount($source, $from_date, $to_date, $search_title, $vendor_id) { $role=$this->getRole($vendor_id); if($source!=null){ $this->db->where('source', $source); } if($from_date!=null){ $this->db->where('created_on <=', $from_date.'00:00:00'); } if($from_date!=null && $to_date!=null){ $this->db->where('created_on >=', $to_date.'00:00:00'); } if($search_title!=null){ $this->db->where('phone', $search_title); } $this->db->order_by('id', 'desc'); if($role[0]['role']=='agent'){ $this->db->where('agent_id', $vendor_id); } $this->db->where('agent_id', $vendor_id); return $this->db->count_all_results('booking_enquiry'); } //Get Agent's Call public function getCalls($limit, $page, $source, $from_date, $to_date, $search_title, $vendor_id) { $role=$this->getRole($vendor_id); if($source!=null){ $this->db->where('source', $source); } if($from_date!=null){ $this->db->where('created_on <=', $from_date.' 00:00:00'); } if($from_date!=null && $to_date!=null){ $this->db->where('created_on >=', $to_date.' 00:00:00'); } if($search_title!=null){ $this->db->where('phone', $search_title); } $this->db->order_by('id', 'desc'); if($role[0]['role']=='agent'){ $this->db->where('agent_id', $vendor_id); } $query = $this->db->select('id,uid,call_summary,duration,title,full_name,email,phone,phone2,dob,Age,gender,info_source,remarks,address,state,city,order_id,complaint_type,remarks_complain,remarks_status,created_on,update_date')->get('booking_enquiry', $limit, $page); //echo $this->db->last_query();die; return $query->result(); } public function getRole($vendor_id) { $this->db->where('id', $vendor_id); $query = $this->db->select('role')->get('vendors'); //echo $this->db->last_query();die; return $query->result_array(); } }