sms for lead

This commit is contained in:
venbatechnologies@gmail.com 2018-10-12 15:26:59 +05:30
parent fe920a55fc
commit acdb0e36f7
3 changed files with 136 additions and 5 deletions

View File

@ -119,10 +119,13 @@ class Call_Tracking_Controller extends REST_Controller {
$tracking_followup_details['StatusName'] = $this->post('status');
$tracking_followup_details['AssignedStaff'] = $this->post('assignedTo');
$message = $this->post('msgactivity');
// echo $message;die();
$leadDetails = $this->Calltracking_model->addleadDetails($lead_details,$tracking_details,$tracking_followup_details);// Check if the users data store contains users (in case the database result returns NULL)
$leadDetails = $this->Calltracking_model->addleadDetails($lead_details,$tracking_details,$tracking_followup_details,$message);// Check if the users data store contains users (in case the database result returns NULL)
if ($leadDetails)
{
$leadDetails['status'] = REST_Controller::HTTP_OK;

View File

@ -312,8 +312,11 @@ class Calltracking_model extends CI_Model {
* created by kms
* */
public function addleadDetails($lead_Details=null,$track_Details=null,$followup_Details=null)
public function addleadDetails($lead_Details=null,$track_Details=null,$followup_Details=null,$messagecheck=null)
{
// print_r($lead_Details);die();
$this->db->insert(LEAD_DETAILS, $lead_Details);
// this if for insert lead details
if($this->db->affected_rows() == '1'){
@ -325,10 +328,72 @@ class Calltracking_model extends CI_Model {
$followup_Details['TrackingID']=$this->db->insert_id();
$this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details);
// this if for insert follow up details
if($this->db->affected_rows() == '1'){
if($this->db->affected_rows() == '1')
{
if($messagecheck !=0)
{
$number = $lead_Details['MobileNumber'];
$name = $lead_Details['LeadName'];
$CourseName = $track_Details['Course'];
$Email = $track_Details['EmailID'];
// $msg='Dear '.$name.', Thank for Enquiring with Apollo Distance Education College for the course '.$CourseName.'. Pls Feel free to call us for more information 9962012985,9962012982.Thanks.';
$msg='Dear '.$name.', Thank you for enquiring with Apollo Distance Education College for the course '.$CourseName.'. Pls feel free to call us for more information at 9962012985 or 9962012982.';
$messa = urlencode($msg);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=" . $number . "&SenderID=APODEC&Message=" . $messa . "&ServiceName=TEMPLATE_BASED");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($ch);
curl_close($ch);
$arrss = explode('<br>', $output);
$time = date('Y-m-d H:i:s');
$dateTime = $time;
$msgGroup = date('YmdHis');
for ($i = 0, $c = count($arrss);$i < $c;$i++)
{
if ($arrss[$i] === '')
{
break;
}
else
{
$a = explode(':', $arrss[$i]);
$msgIdState = $a[0];
$msgId = $a[1];
$msgNumb = $a[2];
$msgStatus = $a[4];
$data[] = array('MsgId' => $msgId, 'MobileNumber' => $msgNumb, 'MsgBody' => $messa, 'Status' => $msgStatus, 'CreatedOn' => $dateTime,'MsgGroup' => $msgGroup);
continue;
}
}
$this->mailsend($Email, $msg);
$this->db->insert_batch('T_BroadcastStatus', $data);
}
$result['leadStatus'] = true;
$result['message'] = "Successfully lead details added";
}
}
else{
$result['leadStatus'] = false;
$result['message'] = "Something went wrong.please try again";
@ -351,6 +416,57 @@ class Calltracking_model extends CI_Model {
}
public function mailsend($mail, $msg) {
// $list = implode(',', $mail);
$list = $mail;
$sub = 'Enquiry Details';
//Load email library
$this->load->library('email');
//SMTP & mail configuration
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.sendgrid.net',
'smtp_port' => 587,
'smtp_user' => 'apikey',
'smtp_pass' => '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',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->email->initialize($config);
$this->email->set_mailtype("html");
$this->email->set_newline("\r\n");
// print_r($this->email);exit();
//Email content
// $htmlContent = '<h1>Sending email via SMTP server</h1>';
$htmlContent = $msg;
// Email body load the html template
// $body = $this->load->view('emails/anillabs.php',$data,TRUE);
$this->email->to($list);
$this->email->from('noreply@apollodec.com','Apollo');
$subj = $sub;
$this->email->subject($subj);
$this->email->message($htmlContent);
//Send email 1
$result = $this->email->send();
// echo $this->email->print_debugger(); exit();
return $result;
}
/*
* get all tracked details
* created by kms

View File

@ -241,7 +241,18 @@ app.controller('callTrackingCtrl', ["$scope","$rootScope","toaster", "$filter",
$scope.trackForm = {
submit: function (form, myModel,loading) {
console.log(myModel.activity.activityName);
var string = myModel.activity.activityName;
var Upperstring = string.toUpperCase();
var checkresult = Upperstring.search("STATUS");
var msgactivity = 0;
if(checkresult != -1)
{
msgactivity = 1;
}
// console.log(msgactivity)
// return false;
if(isNaN(myModel.date)){
$scope.nextFollowupDate = myModel.date;
@ -309,7 +320,8 @@ app.controller('callTrackingCtrl', ["$scope","$rootScope","toaster", "$filter",
emailId:myModel.emailId,
enquiryStatus:myModel.enquiryStatus,
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
msgactivity:msgactivity
}
};