%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 React extends MY_Controller { function __construct() { parent::__construct(); $this->load->model("react_model", "react"); $this->load->model("social_model", "social"); } function leadsN(){ $res=['code'=>SCODE, 'msg'=>'']; $res['result']=$this->react->leadsN(); jsonData($res); } function mastersForLeads(){ $res=['code' => SCODE, 'message'=>'']; $res['result']=[ 'states'=>$this->db->select("id, title name")->get_where("master_states", ['status'=>1])->result_array(), 'programs'=>$this->db->select("id, title name")->get_where("master_programs", ['status'=>1])->result_array(), //'users'=>$this->db->select("id, name, type")->get_where("users", ['status'=>1])->result_array(), 'utm_groups'=>$this->db->select("DISTINCT grp name", false)->get_where("master_utm_sources", ['grp!='=>''])->result_array(), 'utm_sources'=>$this->db->select("id, grp, title name", false)->get_where("master_utm_sources")->result_array(), 'superbot_dispositions'=>$this->db->select("DISTINCT disposition name", false)->from("superbot_response")->get()->result_array(), 'acs'=>$this->db->select("id, title name")->get("master_academic_careers")->result_array(), 'disciplines'=>$this->db->select("id, title name")->get("master_disciplines")->result_array(), 'schools'=>$this->db->select("id, title name")->get("master_schools")->result_array(), 'remarks'=>$this->db->select("id, cat_id, title name")->from("master_lead_remarks")->where("status",1)->order_by("cat_id")->order_by("disp_odr")->get()->result_array(), 'lpages'=>$this->db->select("id, title name")->get("landing_pages")->result_array() ]; jsonData($res); } function superbotCampaigns(){ $this->checkAccess('superbot_campaign'); $res=['code'=>SCODE, 'msg'=>'']; $res['result']=$this->react->superbotCampaigns(); jsonData($res); } function saveSuperbotCampaigns(){ $this->checkAccess('superbot_campaign'); $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $id=$post['id']=intval($post['id']); $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Campaign Name', "required", $this->req); $this->form_validation->set_rules('superbot_campaign_id', 'Superbot Campaign', "required", $this->req); try{ if(@$this->form_validation->run() == FALSE){ $res['errors']=$this->form_validation->get_errors(); $res['message']=reset($res['errors']); }else{ $data=filterValue($post, ['id', 'name', 'superbot_campaign_id']); if($this->dba->save("superbot_campaigns", $data)){ $res['code']=SCODE; $res['message']='Campaign '.($id?' updated':'created').' successfully'; } } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } function deleteSuperbotCampaign(){ $this->checkAccess('superbot_campaign'); $res=['code'=>ECODE, 'message'=>'Error!']; $id=intval($this->input->post('id')); if($this->react->deleteSuperbotCampaign($id)){ $res['code']=SCODE; $res['message']="Deleted successfully"; } jsonData($res); } function getSuperbotComingLeadsFilterData(){ $res=['code'=>SCODE, 'msg'=>'']; $dtl=$this->db->get_where("superbot_campaigns", ['type'=>'ComingLeads'])->row_array("superbot_campaign_id, leads_filter, status"); if($dtl){ $res['result']=[ 'superbot_campaign_id'=>$dtl['superbot_campaign_id'], 'leads_filter'=>$dtl['leads_filter']?unserialize($dtl['leads_filter']):null, 'status'=>$dtl['status'] ]; }else{ $res['result']=['superbot_campaign_id'=>'', 'leads_filter'=>null, 'status'=>'Draft']; } jsonData($res); } function saveSuperbotComingLeadsFilterData(){ $this->checkAccess('superbot_campaign'); $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $id=$post['id']=intval($post['id']); $this->load->library('form_validation'); $this->form_validation->set_rules('superbot_campaign_id', 'Superbot Campaign ID', "required", $this->req); $this->form_validation->set_rules('status', 'Status', "required", $this->req); try{ if(@$this->form_validation->run() == FALSE){ $res['errors']=$this->form_validation->get_errors(); $res['message']=reset($res['errors']); }else{ $dtl=$this->db->get_where("superbot_campaigns", ['type'=>'ComingLeads'])->row_array("leads_filter"); $data=[ 'id'=>$dtl?$dtl['id']:0, 'type'=>'ComingLeads', 'name'=>'Coming Leads', 'superbot_campaign_id'=>$post['superbot_campaign_id'], 'leads_filter'=>is_array($post['filters'])?serialize($post['filters']):'', 'status'=>$post['status'] ]; if($this->dba->save("superbot_campaigns", $data)){ $res['code']=SCODE; $res['message']='Saved successfully'; } } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } function addLeadsToSuperbotCampaign(){ ini_set('memory_limit', '-1'); set_time_limit(0); $this->checkAccess('superbot_campaign'); $this->load->model("Superbot_model", "superbot"); $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $this->load->library('form_validation'); $this->form_validation->set_rules('campaign_id', 'Campaign', "required", $this->req); try{ if(@$this->form_validation->run() == FALSE){ $res['errors']=$this->form_validation->get_errors(); $res['message']=reset($res['errors']); }else{ if(!is_array($post['leads'])){ throw new Exception("Invalid data (Leads)!"); } if(count($post['leads'])<1){ throw new Exception("Leads required!"); } if(count($post['leads'])>=2000){ throw new Exception("Leads count must be less than 2000!"); } $dtl=$this->db->get_where("superbot_campaigns", ['id'=>$post['campaign_id']])->row_array(); if(!$dtl){ throw new Exception("Invalid data (Campaign)!"); } if($dtl['status']==='Published'){ throw new Exception("This Campaign is already published!"); } $this->db->delete("superbot_campaign_leads", ['campaign_id'=>$post['campaign_id']]); $data=[]; $numbers=[]; foreach($post['leads'] as $a){ $data[]=[ 'campaign_id'=>$post['campaign_id'], 'app_id'=>$a['id'], 'created'=>currentDT(), ]; $numbers[]=[ 'reference_id'=>$a['reference_id'], 'phone'=>$a['phone'], 'parameters'=>[ 'name'=>$a['name'], 'location'=>$a['location'], 'course'=>$a['course'], ], ]; } if($numbers){ $res['superbot']=$this->superbot->sendDataToSuperbot($dtl['superbot_campaign_id'], $numbers); } $this->db->insert_batch("superbot_campaign_leads", $data); $d=[ 'id'=>$post['campaign_id'], 'status'=>'Published', 'leads_count'=>count($post['leads']), 'leads_filter'=>is_array($post['filters'])?serialize($post['filters']):'' ]; $this->dba->save("superbot_campaigns", $d); $res['code']=SCODE; $res['message']='Leads added and sent to superbot successfully'; } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } function superbotCampaignLeads($superbot_campaign_id=0){ $res=['code'=>SCODE, 'msg'=>'']; $res['result']=$this->react->leadsN($superbot_campaign_id); jsonData($res); } function superbotRespondedLeads($all=''){ $res=['code'=>SCODE, 'message'=>'']; $res['result']=$this->react->superbotRespondedLeads($all==='ALL'); jsonData($res); } /** */ function socialCampaigns(){ $this->checkAccess('social_campaign'); $res=['code'=>SCODE, 'msg'=>'']; $res['result']=$this->react->socialCampaigns(); jsonData($res); } function saveSocialCampaign(){ $this->checkAccess('social_campaign'); $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $id=$post['id']=intval($post['id']); $this->load->library('form_validation'); $this->form_validation->set_rules('type', 'Campaign Type', "required", $this->req); $this->form_validation->set_rules('name', 'Campaign Name', "required", $this->req); $this->form_validation->set_rules('template_id', 'Template', "required", $this->req); try{ if(@$this->form_validation->run() == FALSE){ $res['errors']=$this->form_validation->get_errors(); $res['message']=reset($res['errors']); }else{ $data=filterValue($post, ['id', 'type', 'name', 'template_id', 'sender_name', 'sender_email', 'reply_to']); if($res['id']=$this->dba->save("social_campaigns", $data)){ $res['code']=SCODE; $res['message']='Campaign '.($id?' updated':'created').' successfully'; } } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } function deleteSocialCampaign(){ $this->checkAccess('social_campaign'); $res=['code'=>ECODE, 'message'=>'Error!']; $id=intval($this->input->post('id')); if($this->react->deleteSocialCampaign($id)){ $res['code']=SCODE; $res['message']="Deleted successfully"; } jsonData($res); } function addLeadsToSocialCampaign($testing=''){ ini_set('memory_limit', '-1'); set_time_limit(0); $this->checkAccess('social_campaign'); $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $lpages=key_val_array($this->db->select("id,title")->get("landing_pages")->result_array(), 'id', 'title'); $this->load->library('form_validation'); $this->form_validation->set_rules('campaign_id', 'Campaign', "required", $this->req); try{ if(@$this->form_validation->run() == FALSE){ $res['errors']=$this->form_validation->get_errors(); $res['message']=reset($res['errors']); }else{ if(!is_array($post['leads'])){ throw new Exception("Invalid data (Leads)!"); } if(count($post['leads'])<1){ throw new Exception("Leads required!"); } if(count($post['leads'])>=50000){ throw new Exception("Leads count must be less than 50000!"); } $dtl=$this->db->get_where("social_campaigns", ['id'=>$post['campaign_id']])->row_array(); if(!$dtl){ throw new Exception("Invalid data (Campaign)!"); } if($dtl['status']==='Published'){ throw new Exception("This Campaign is already published!"); } if($testing!=='T'){ $this->db->delete("social_campaign_leads", ['campaign_id'=>$post['campaign_id']]); $data=[]; $numbers=[]; foreach($post['leads'] as $a){ $data[]=[ 'campaign_id'=>$post['campaign_id'], 'app_id'=>$a['app_id'], 'created'=>currentDT(), ]; } $this->db->insert_batch("social_campaign_leads", $data); } $data=[]; foreach($post['leads'] as $a){ $a['mob']=str_replace('+91', '', $a['mob']); $lpage=$lpages[$a['lpage_id']]; $data[]=[ 'app_id'=>$a['app_id'], 'mob'=>$a['mob'], 'email'=>$a['email'], 'name'=>$a['name'], 'state'=>$a['state'], 'program'=>$a['program'], 'plan'=>$a['plan'], 'system_id'=>$a['system_id'], 'login_url'=>generate_login_url($lpage, $a['mob']), ]; } //$res['data']=$data; if($dtl['type']==='Email'){ $this->social->sendDataToEmailCampaign(['campaign_id'=>$post['campaign_id'], 'leads'=>$data, 'testing'=>$testing]); } if($dtl['type']==='SMS'){ $this->social->sendDataToSMSCampaign(['campaign_id'=>$post['campaign_id'], 'leads'=>$data]); } if($testing!=='T'){ $d=[ 'id'=>$post['campaign_id'], 'status'=>'Published', 'leads_count'=>count($post['leads']), 'leads_filter'=>is_array($post['filters'])?serialize($post['filters']):'' ]; $this->dba->save("social_campaigns", $d); } $res['code']=SCODE; $res['message']='Leads added and sent to campaign successfully'; } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } function socialCampaignLeads($campaign_id=0){ $res=['code'=>SCODE, 'msg'=>'']; $_POST['social']=1; $res['result']=$this->react->leadsN('', $campaign_id); jsonData($res); } function socialTemplates(){ $this->checkAccess('social_campaign'); $res=['code'=>SCODE, 'msg'=>'']; $res['result']=$this->react->socialTemplates(); jsonData($res); } function saveSocialTemplate(){ $this->checkAccess('social_campaign'); $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $id=$post['id']=intval($post['id']); $this->load->library('form_validation'); $this->form_validation->set_rules('type', 'Template Type', "required", $this->req); $this->form_validation->set_rules('name', 'Template Name', "required", $this->req); if($post['type']==='Email'){ $this->form_validation->set_rules('subject', 'Subject', "required", $this->req); }else{ $post['subject']=''; } $this->form_validation->set_rules('body', 'Body', "required", $this->req); try{ if(@$this->form_validation->run() == FALSE){ $res['errors']=$this->form_validation->get_errors(); $res['message']=reset($res['errors']); }else{ $data=filterValue($post, ['id', 'type', 'name', 'subject', 'body', 'media_file_id', 'status']); if(!$data['media_file_id']){ $data['media_file_id']=null; } if($this->dba->save("social_templates", $data)){ $res['code']=SCODE; $res['message']='Template '.($id?' updated':'created').' successfully'; } } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } function deleteSocialTemplate(){ $this->checkAccess('social_campaign'); $res=['code'=>ECODE, 'message'=>'Error!']; $id=intval($this->input->post('id')); if($this->react->deleteSocialTemplate($id)){ $res['code']=SCODE; $res['message']="Deleted successfully"; } jsonData($res); } /** */ function multisourceLeads($all=''){ $res=['code'=>SCODE, 'message'=>'']; $res['result']=$this->react->multisourceLeads($all==='ALL'); jsonData($res); } function multisourceLeadsReport(){ ini_set('memory_limit', '-1'); set_time_limit(0); $res=['code'=>SCODE, 'message'=>'']; $res['result']=$this->react->multisourceLeadsReport(); jsonData($res); } } //EOF