%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 Cleads extends MY_Controller { function __construct() { parent::__construct(); $this->load->model("cleads_model", "cleads"); $this->load->model("leads_model", "leads"); } function lookups(){ $res=['code'=>SCODE, 'message'=>'']; $res['result']=$this->cleads->lookups(); jsonData($res); } function lists($all=''){ $res=['code'=>SCODE, 'message'=>'']; $res['result']=$this->cleads->lists($all==='ALL'); jsonData($res); } function save(){ $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $id=$post['id']=intval($post['id']); $user_id=USER_ID; if(!IS_CONSULTANT){ jsonData($res); } if($id){ $dtl=$this->db->get_where("consultant_leads", ['id'=>$id, 'consultant_id'=>$user_id])->row_array(); if(!$dtl){ $res['message']="Invalid request!"; jsonData($res); }else{ if($dtl['status']!=='Pending'){ $res['message']="Can not be edited! This lead is already ".$dtl['status']; jsonData($res); } } } $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Name', "required", $this->req); $this->form_validation->set_rules('email', 'Email', "required|valid_email", $this->req); $this->form_validation->set_rules('mob', 'Mobile number', "required|integer|exact_length[10]", $this->req); $this->form_validation->set_rules('gender', 'Gender', "required", $this->req); $this->form_validation->set_rules('state_id', 'State', "required", $this->req); $this->form_validation->set_rules('city', 'City', "required", $this->req); $this->form_validation->set_rules('ac_id', 'Academic career', "required", $this->req); $this->form_validation->set_rules('program_id', 'Program', "required", $this->req); $this->form_validation->set_rules('plan_id', 'Plan/Specialization', "required", $this->req); try{ if(@$this->form_validation->run() == FALSE){ $res['errors']=$this->form_validation->get_errors(); $res['message']=reset($res['errors']); }else{ $cond=['email'=>$post['email'], 'consultant_id'=>$user_id, 'id!='=>$id]; $result=$this->db->get_where("consultant_leads", $cond)->row_array(); if($result){ $res['message']="This email-id is already registered by you!"; jsonData($res); } $cond=['mob'=>$post['mob'], 'consultant_id'=>$user_id, 'id!='=>$id]; $result=$this->db->get_where("consultant_leads", $cond)->row_array(); if($result){ $res['message']="This mobile number is already registered by you!"; jsonData($res); } $data=filterValue($post, ['id', 'name', 'email', 'mob', 'gender', 'state_id', 'city_id', 'city', 'ac_id', 'program_id', 'plan_id']); if(!$data['city_id']){ $data['city_id']=null; } if(!$id){ $data['consultant_id']=$user_id; } $success=$this->dba->save("consultant_leads", $data); if($success){ $res['code']=SCODE; $res['message']='Lead '.($id?'updated':'added').' successfully'; } } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } function delete(){ $res=['code'=>ECODE, 'message'=>'Error!']; $id=intval($this->input->post('id')); $cond=['id'=>$id]; if(IS_CONSULTANT){ $cond['consultant_id']=USER_ID; } $dtl=$this->db->get_where("consultant_leads", $cond)->row_array(); if(!$dtl){ $res['message']="Invalid request!"; jsonData($res); } if($dtl['status']!=='Pending'){ $res['message']="Can not be deleted! This lead is already ".$dtl['status']; jsonData($res); } if($this->cleads->delete($id)){ $res['code']=SCODE; $res['message']="Lead deleted successfully"; } jsonData($res); } function reject(){ $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $id=$post['id']=intval($post['id']); if(IS_CONSULTANT){ jsonData($res); } $this->load->library('form_validation'); $this->form_validation->set_rules('id', 'Lead ID', "required", $this->req); $this->form_validation->set_rules('remarks', 'Remarks', "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("consultant_leads", ['id'=>$id])->row_array(); if(!$dtl){ $res['message']="Invalid request!"; jsonData($res); }else{ if($dtl['status']!=='Pending'){ $res['message']="Can not be edited! This lead is already ".$dtl['status']; jsonData($res); } } $data=[ 'id'=>$id, 'status'=>'Rejected', 'action_by'=>USER_ID, 'action_on'=>currentDT(), 'remarks'=>$post['remarks'] ]; if($this->dba->save("consultant_leads", $data)){ $res['code']=SCODE; $res['message']='Lead rejected'; $res['row_dtl']=$this->cleads->rowDetail($id); } } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } function approve(){ $res=['code'=>ECODE, 'message'=>'Error!']; $post=trimArray($this->input->post()); $id=$post['id']=intval($post['id']); if(IS_CONSULTANT){ jsonData($res); } $this->load->library('form_validation'); $this->form_validation->set_rules('id', 'Lead ID', "required", $this->req); $this->form_validation->set_rules('remarks', 'Remarks', "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("consultant_leads", ['id'=>$id])->row_array(); if(!$dtl){ $res['message']="Invalid request!"; jsonData($res); }else{ if($dtl['status']!=='Pending'){ $res['message']="Can not be edited! This lead is already ".$dtl['status']; jsonData($res); } } $result=$this->db->get_where("applicants", ['email'=>$dtl['email']])->row_array(); if($result){ $res['message']="This email-id is already registered!"; jsonData($res); } $result=$this->db->get_where("applicants", ['mob'=>$dtl['mob']])->row_array(); if($result){ $res['message']="This mobile number is already registered!"; jsonData($res); } $data=[ 'id'=>$id, 'status'=>'Approved', 'action_by'=>USER_ID, 'action_on'=>currentDT(), 'remarks'=>$post['remarks'] ]; if($this->dba->save("consultant_leads", $data)){ $dtl=$this->cleads->rowDetail($id); $data1=filter_value($dtl, ['name', 'email', 'mob', 'gender', 'state_id', 'city_id', 'city', 'created_by', 'updated_by']); $data1['lpage_id']=$this->db->select("id")->get_where("landing_pages", ['isdefault'=>1])->row()->id; $defaultUtmSource=$this->db->from('master_utm_sources')->where(['default_for_admin'=>'1'])->select('id,title')->limit(1)->get()->row_array(); $data1['utm_source_id']=$defaultUtmSource['id']; $data1['utm_source']=$defaultUtmSource['title']; $data2=filter_value($dtl, ['plan_id', 'program_id', 'created_by', 'updated_by']); $prg=$this->db->select("type_id, ac_id, discipline_id, school_id, is_medical, is_phd")->get_where("master_programs", ['id'=>$data2['program_id']])->row_array(); $data2['prg_type_id']=$prg['type_id']; $data2['ac_id']=$prg['ac_id']; $data2['discipline_id']=$prg['discipline_id']; $data2['school_id']=$prg['school_id']; $data2['step_completed']=1; $app_id=$this->leads->save($data1, $data2); $this->dba->save("consultant_leads", ['id'=>$id, 'app_id'=>$app_id]); $res['code']=SCODE; $res['message']='Lead approved'; $res['row_dtl']=$this->cleads->rowDetail($id); } } } catch(Exception $e){ $res['message']= $e->getMessage(); } jsonData($res); } } //EOF