%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 Callcenter_model extends CI_Model { public function __construct() { parent::__construct(); $this->load->library('session'); } public function getOneProduct($id, $vendor_id) { $this->db->where('id', $id); $this->db->where('vendor_id', $vendor_id); $query = $this->db->get('products'); if ($query->num_rows() > 0) { return $query->row_array(); } else { return false; } } public function getMemberdetails($id) { $this->db->select('family_member.member_id,family_member.full_name as full_name, family_member.relation as relation, family_member.mobile_number as contact, family_member.gender as gender, family_member.age as age'); $this->db->where('family_member.member_id', $id); $query = $this->db->get('family_member'); if ($query->num_rows() > 0) { return $query->row_array(); } else { return false; } } public function getExsitingCallerDetails($caller_number) { $this->db->select('*'); $this->db->where('phone', $caller_number); $query = $this->db->get('booking_enquiry'); if ($query->num_rows() > 0) { return $query->row_array(); } else { return false; } } public function getProductDetails($id) { $this->db->select('price,title,old_price,total_tests'); $this->db->where('for_id', $id); $query = $this->db->get('products_translations'); if ($query->num_rows() > 0) { return $query->row_array(); } else { return false; } } public function addCallenquiry($params) { //echo $params[4]; } public function setBooking($post,$id) { $test=array(); $product=array(); $this->db->trans_begin(); $is_update = false; $old_price=0; $price=0; $total_packages=0; $discount = 0; if(!$post['hardCopy']){ $heard_copy_required = '0'; } else{$heard_copy_required=$post['hardCopy'];} // get member id $member_id = $this->getMemberid($id); foreach($post['related_test'] as $test_id){ $test = $this->getProductDetails($test_id); $test['cart_id']=''; $test['user_id']=$id; $test['member_id']=$member_id; $total_packages = $total_packages+1; $price=$price+$test['price']; $old_price=$old_price+$test['old_price']; array_push($product,$test); } $product_array=array($product); //print_r($product_array);die; if($old_price>0 && $price>0){ $discount = round((($old_price-$price)/$old_price)*100); } $post['products']=serialize($product_array); $q = $this->db->query('SELECT MAX(order_id) as order_id FROM orders'); $rr = $q->row_array(); if ($rr['order_id'] == 0) { $rr['order_id'] = date('Y').''.date('m').''.date('d'); } $post['order_id'] = $rr['order_id'] + 1; $post['date'] = date('Y-m-d h:i:s'); if ($id > 0) { $orders = array( 'order_id' => $post['order_id'], 'user_id' => $id, 'products' => $post['products'], 'order_date' => $post['date'], 'total_packages' => $total_packages, 'our_price' => $old_price, 'offer_price' => $price, 'heard_copy_required' => $heard_copy_required, 'clean_referrer' => 'NA', 'referrer' =>$post['vendor_id'], 'booking_enqiry_id' =>$post['booking_enqiry_id'], 'discount' => $discount, 'order_otp' => $post['order_otp'], 'order_status' => '2', 'payment_type' => 'cashOnDelivery', 'payment_status' => '2', 'is_deleted' => '0' ); //orders clients details if (!$this->db->insert('orders', $orders)) { log_message('error', print_r($this->db->error(), true)); } $nameArray = explode(" ",$post['name']); $forId = $this->db->insert_id(); //orders clients details $clients = array( 'for_id' => $forId, 'user_id' => $id, 'first_name' => ucwords(trim($nameArray[0])), 'last_name' => ucwords(trim(str_replace($nameArray[0],"",$post['name']))), 'email' => $post['email'], 'phone' => $post['phone'], 'address' => $post['address'], 'city' => $post['city'], 'booking_date' => $post['booking_date'], 'booking_time' => $post['collection_time'], 'post_code' => '201001' ); //print_r($clients);die; if (!$this->db->insert('orders_clients', $clients)) { print_r($this->db->error(), true);die; log_message('error', print_r($this->db->error(), true)); } //echo $this->db->last_query();die; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return false; } else { return true; $this->db->trans_commit(); } } } public function getProducts($limit, $page, $vendor_id) { $this->db->order_by('orders.id', 'desc'); $this->db->join('users_public', 'users_public.id = orders.user_id'); $this->db->where('orders.referrer', $vendor_id); $query = $this->db->select('users_public.*, orders.*')->get('orders', $limit, $page); //echo $this->db->last_query();die; return $query->result(); } public function productsCount($vendor_id) { $this->db->where('vendor_id', $vendor_id); return $this->db->count_all_results('products'); } public function deleteProduct($id) { $this->db->trans_begin(); $this->db->where('id', $id); $this->db->where('vendor_id', $vendor_id); if (!$this->db->delete('products')) { log_message('error', print_r($this->db->error(), true)); } else { $this->db->where('for_id', $id); if (!$this->db->delete('products_translations')) { 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(); } } //Insert Lead public function setLead($post) { $post['created_on'] = date('Y-m-d h:i:s'); $post['verify_status'] = '1'; $post['is_deleted'] = '0'; if (!$this->db->insert('prescription_requests', $post)) { print_r($this->db->error()); log_message('error', print_r($this->db->error(), true)); show_error(lang('database_error')); } $id = $this->db->insert_id(); return $id; } //Get Vendor's Leads public function getLeads($limit, $page, $vendor_id) { $this->db->order_by('id', 'desc'); $this->db->where('vendor_id', $vendor_id); $query = $this->db->select('id,full_name,mobile_number,email_id,prescription,description,status')->get('prescription_requests', $limit, $page); //echo $this->db->last_query();die; return $query->result(); } //Get Member Id public function getMemberid($id) { $this->db->where('user_id', $id); $query = $this->db->select('member_id')->get('family_member'); //echo $this->db->last_query();die; $row=$query->result_array(); $id=$row[0]['member_id']; return $id; } //Get Tests public function getTest() { $this->db->join('products_translations', 'products_translations.for_id = products.id', 'left'); $this->db->where('products_translations.abbr', MY_DEFAULT_LANGUAGE_ABBR); $this->db->where('products.shop_categorie', '2'); $query = $this->db->select('products.id, products_translations.title')->get('products', $limit, $page); return $query->result(); } //Get Category public function getPacakes() { $this->db->join('products_translations', 'products_translations.for_id = products.id', 'left'); $this->db->where('products_translations.abbr', MY_DEFAULT_LANGUAGE_ABBR); $this->db->where('products.shop_categorie', '3'); $query = $this->db->select('products.id, products_translations.title')->get('products', $limit, $page); return $query->result(); } /* search call-center*/ public function search_Test($searchKEY){ $searchKEY = $searchKEY; $this->db->join('products_translations', 'products_translations.for_id = products.id', 'left'); $this->db->like('products_translations.title', $searchKEY); $query = $this->db->select('products.id, products_translations.title')->get('products'); return $query->result(); //echo $this->db->last_query(); } function add_enquiry($params,$id,$vendorid){ $updatetime = date('Y-m-d h:i:s'); $callers=array(); $caller_summary=json_decode(file_get_contents(base_url('attachments/callcenter_files/api_response.txt')),TRUE); $caller_details = serialize($caller_details['call_flow']); $digits_dialed = serialize($caller_details['digits_dialed']); $uuid = $caller_summary['uuid']; $call_to_numer = $caller_summary['call_to_number']; $caller_id_number = $caller_summary['caller_id_number']; $start_stamp = $caller_summary['start_stamp']; $end_stamp = $caller_summary['end_stamp']; $duration = $caller_summary['duration']; $source = $caller_details['digits_dialed'][1]; $datas = array( 'uid' => '', 'call_follow' => (!empty($caller_details)) ? $caller_details : NULL, 'duration' => '', 'call_start' => '', 'call_end' => '', 'source' => '', 'title' => $params['title'], 'full_name' => $params['full_name'], 'email' => $params['email'], 'phone' => $params['mobile_number'], 'age' => $params['ages'], 'gender' => $params['gender'], 'phone2' => $params['mobile_number2'], 'info_source' => $params['info_source'], 'remarks' => $params['Remarks'], 'address' => $params['address'], 'state' => $params['state'], 'city' => $params['city'], 'update_date' => $updatetime, 'agent_id' => $params['vendorid'], 'status' => '1' ); if(!$id){ return $querys = $this->db->insert('booking_enquiry',$datas); echo $this->db->last_query();die; } else { $this->db->where('id', $id); return $querys = $this->db->update('booking_enquiry', $datas); echo $this->db->last_query(); die; } } public function viewrecord($id) { $this->db->where('id', $id); //$this->db->where('phone', $callno); $query = $this->db->select('*')->get('booking_enquiry'); return $viewdata=$query->result_array(); //echo $this->db->last_query();die; } /********** call history according to vendor login******/ public function Call_History() { $this->db->order_by('id', 'desc'); $query = $this->db->select('uid','call_summary','duration','call_end','call_start','source','call_follow','full_name','agent_id')->get('booking_enquiry'); $calldetail = $query->result_array(); echo $this->db->last_query();die; } /******** update ******/ function getupdatecomplain($getID,$ORDERID,$Order_status,$collection_type,$Remarks,$Remarks_status){ if($Order_status){ $complaindata = array( 'order_id' => $Order_status, 'remarks_status' => $Remarks_status ); } else { $complaindata = array( 'order_id' => $ORDERID, 'complaint_type' => (!empty($collection_type)) ? $collection_type : NULL, 'remarks_complain' => (!empty($Remarks)) ? $Remarks : NULL, ); } $this->db->where('id', $getID); return $compplaindetail = $this->db->update(booking_enquiry, $complaindata); } function getOrdertest($ORDERID){ $ORDERID = $ORDERID; return $test_report = $this->db->query("select * from orders where order_id='".$ORDERID."'")->result_array(); //echo $this->db->last_query(); } function getbook(){ $this->db->select('sample_type'); $res = $this->db->get('products_translations'); return $res->result(); echo $this->db->last_query(); die; } /* * AddEditUser Records */ function registerPatient($post){ $id = ''; if($post['phone']<>'') { $results = array(); $user_id = ''; $query = $this->db->where('phone',$post['phone'])->or_where('email', $post['email'])->where('verify_status','1')->select('id')->get('users_public'); $results = $query->result_array(); $user_id = $results[0]['id']; if($user_id>0) { $id = $user_id; //log_message('error', print_r($this->db->error(), true)); } else { $params = array('name'=>$post['name'], 'phone'=>$post['phone'],'email' => $post['email'],'verify_status' => '1','gender'=>$post['gender'],'created' => date('Y-m-d h:i:s'),'modified_on' => date('Y-m-d h:i:s'),'login_src__id'=>$post['vendor_id']); if(!$this->db->insert('users_public', $params)){ print_r($this->db->error());die; log_message('error', print_r($this->db->error(), true)); } $id = $this->db->insert_id(); // Add User to Family Member Tables $fparams = array(); $fparams = array('user_id'=>$id,'full_name'=>$post['name'],'email_id'=>$post['email'],'relation'=>'Self', 'mobile_number'=>$post['phone'],'gender'=>$post['gender'],'status' => '1','is_deleted' => '0', 'createdon' => date('Y-m-d h:i:s'),'modified_on' => date('Y-m-d h:i:s')); if(!$this->db->insert('family_member', $fparams)){ print_r($this->db->error());die; log_message('error', print_r($this->db->error(), true)); } } return $id; } } /* * Function : getOTP */ function getOTP($size = 6) { $random_number=''; $count=0; while ($count < $size ) { $random_digit = mt_rand(0, 9); $random_number .= $random_digit; $count++; } return $random_number; } function sendSMS($mobile_number, $sms_content){ $feedid = 363901; $senderid = urlencode('shardacom_trans'); $username = "9015129267"; $password = "wgtpt"; $api_url = 'http://bulkpush.mytoday.com/BulkSms/SingleMsgApi'; if(strlen($mobile_number)>=10){ $params_url = ''; //send OTP to user $params_url = 'feedid='.$feedid.'&senderid='.$senderid.'&username='.$username.'&password='.$password.'&To='.$mobile_number.'&Text='.$sms_content; $otpresponse = $this->sendOTP($api_url, $params_url); // Send OTP return $otpresponse; } } function sendOTP($url, $params_url){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$params_url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_HEADER,0); // DO NOT RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // RETURN THE CONTENTS OF THE CALL $return_val = curl_exec($ch); $response = true; //Print error if any if(curl_errno($ch)) { $response = 'error:' . curl_error($ch); } curl_close($ch); return $response; } public function getstate() { $this->db->select('*'); $query = $this->db->get('states'); return $states = $query->result_array(); //echo $this->db->last_query();die; } public function getcity() { $this->db->select('*'); $query = $this->db->get('city'); return $cities = $query->result_array(); //echo $this->db->last_query();die; } }