$source_id_arr = qs("SELECT * FROM pd_sources WHERE id = '{$source_pk_id}'"); $source_id = ''; $source_id = $source_id_arr["pd_source_id"]; if (1 == 1) { unset($fields); $check_source_id = 0; $check_source_id = Call_distribution::CheckSourceID($source_id); if ($check_source_id > 0) { $fields["pd_user_id"] = $json_user_list; $user_list_update = qu("call_list_by_source", $fields, " pd_source_id = '{$source_id}'"); $user_list_update = 1; } else { $user_list_insert = 0; $fields["pd_source_id"] = $source_id; $fields["pd_user_id"] = $json_user_list; $user_list_insert = qi("call_list_by_source", $fields); } } /* if (isset($_REQUEST['fields']) && $_REQUEST['fields'] != '') { if (isset($_REQUEST['fields']['call']) && count($_REQUEST['fields']['call']) > 0) { $call_list = $_REQUEST['fields']['call']; foreach ($call_list as $source_id => $each_call): if (isset($each_call) && count($each_call) > 0) { $json_user_list = ''; $user_list = array(); foreach ($each_call as $user_id => $each_user): $user_list[] = $user_id; endforeach;
<?php $conv_fields = array(); $conv_fields['message_id'] = $_REQUEST['message_id']; $conv_fields['price'] = $_REQUEST['credits_cost']; $conv_fields['status'] = $_REQUEST['status']; sleep(10); // To Remove Duplicate Entry Sleep Is Required - Conversation List Page Also inserting Same Record; $text_conv_list = q("select id from text_conversation where message_id='{$_REQUEST['message_id']}'"); if (count($text_conv_list) == 0) { qi("text_conversation", $conv_fields); } else { qu("text_conversation", $conv_fields, "message_id='{$_REQUEST['message_id']}'"); } die;
<?php // just add an entry - for deal id and call sid // to later hang the call // when the other agent picks up the code if ($_REQUEST['CallStatus'] == 'no-answer' || $_REQUEST['CallStatus'] == 'busy') { header("content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; qu("voice_call", array("in_progress" => "0"), "deal_id='" . $_REQUEST['dealId'] . "'"); //Set in_progress=0 because call process is completed echo "<Response><say>Call Status - {$_REQUEST['CallStatus']}</say></Response>"; die; } else { if ($_REQUEST['CallStatus'] == 'ringing') { $agent_numbers = explode(',', $_REQUEST['agent_numbers']); $rand = mt_rand(1, 1000) . "_" . mt_rand(1, 1000); // for testing - the deal id should be random $dealId = _e($_REQUEST['dealId'], "T{$rand}"); $phone_value = urlencode($_REQUEST['phone_value']); $cur_agent = $_REQUEST['cur_agent']; qi("deal_sid", array("deal_id" => $dealId, "sid" => $_REQUEST['CallSid'])); header("content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; echo "<Response><say>Connecting to customer!</say></Response>"; } else { header("content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; echo "<Response><say>Good Bye</say></Response>"; } } die;
public function callNow($phone_value, $agent_numbers, $dealId, $is_redial = "0", $group = "A") { $account_sid = ACCOUNT_SID; $auth_token = AUTH_TOKEN; //$account_sid = 'AC4878ef9ccad9ce3b980fdd4d1d0f42ca'; //$auth_token = 'ea532dd88a9ee7fb43259da56a40a38f'; $call_status = qs("select *,value as call_status from config where `key` = 'CALL_STATUS'"); if (strtolower($call_status['call_status']) != "on") { qi("test", array("t" => "call distribution is off.", "payload" => "someone is trying to call without permission!!!")); die; } if ($phone_value == '') { qi("activity_log", _escapeArray(array("log" => "Call can not be generated. Phone value is blank", "deal_id" => $dealId))); die; } if (IS_DEV_ENV && $is_redial == "0") { $agent_numbers = array(TOLL_FREE_NO); $phone_value = AGENT_NO; } if (count($agent_numbers) == 0) { return; } include _PATH . "/Services/Twilio.php"; $agent_numbers_arr = $agent_numbers; $agent_numbers = implode(",", $agent_numbers_arr); $agent_numbers_search = implode("','", $agent_numbers_arr); $filter_agent_number = self::filterAgentsByGroup($agent_numbers_search, $group); //d($agent_numbers); //d($filter_agent_number); if (empty($filter_agent_number['agent'])) { qi("activity_log", _escapeArray(array("log" => "We have no agents for group '{$group}' or any lower level. ", "deal_id" => $dealId))); qu("agent_call_dialed", array("is_aborted" => "1"), "deal_id='" . $dealId . "'"); qu("voice_call", array("in_progress" => "0"), "deal_id='" . $dealId . "'"); die; } qi("agent_call_dialed", _escapeArray(array("agent_numbers" => $agent_numbers, "deal_id" => $dealId, "is_redial" => $is_redial, "customer_phone" => $phone_value, "category" => $filter_agent_number['group']))); $client = new Services_Twilio($account_sid, $auth_token); $deal_sid_data = q("select * from deal_sid where status!='R' AND status!='C' AND deal_id='{$dealId}'"); qu("deal_sid", array("status" => "C"), " status!='R' AND status!='C' AND deal_id='{$dealId}'"); foreach ($deal_sid_data as $each_sid) { $call = $client->account->calls->get($each_sid['sid']); $call->update(array("Status" => "completed")); } try { foreach ($filter_agent_number['agent'] as $key => $each_agent) { //foreach ($agent_numbers_arr as $key => $each_agent) { //echo $each_agent."<br>"; $url_agent_calling = _U . "DialingAgent?"; $url_agent_received = _U . "ReceivedAgent?"; $params = "agent_numbers=" . $agent_numbers . "&dealId=" . $dealId . "&phone_value=" . $phone_value . "&cur_agent=" . $each_agent; $url_agent_calling .= $params; $url_agent_received .= $params; $call = $client->account->calls->create(TWILIO_PHONE_NUMBER, $each_agent, $url_agent_received, array("Method" => "GET", "StatusCallback" => $url_agent_calling, "StatusCallbackMethod" => "POST", "StatusCallbackEvent" => array("ringing", "completed"), "Timeout" => "25")); echo $call->sid . "<br>"; //sleep(2); } echo "<br>We are calling on " . $phone_value; die; } catch (Exception $e) { // Failed calls will throw echo $e; die; } }
echo "my test"; $d = q("select * from plecto"); $c = 11; foreach ($d as $a) { for ($i = 0; $i < $a['total']; $i++) { $f = array(); $f['reference'] = $c++; $f['member_name'] = $a['member_name']; $f['member_id'] = $a['member_id']; $f['date'] = $a['date']; $f['stage_id'] = $a['stage_id']; $f['total'] = $a['total']; $f['open'] = $a['open']; $f['won'] = $a['won']; $f['loss'] = $a['loss']; qi("plecto", $f); } } die; _errors_on(); include _PATH . "/Services/Twilio.php"; $account_sid = ACCOUNT_SID; $auth_token = AUTH_TOKEN; $client = new Services_Twilio($account_sid, $auth_token); $each_agent = "919737128291"; $url_agent_calling = _U . "DialingAgent?"; $url_agent_received = _U . "ReceivedAgent?"; try { $call = $client->account->calls->create(TWILIO_PHONE_NUMBER, $each_agent, $url_agent_received, array("Method" => "GET", "StatusCallback" => $url_agent_calling, "StatusCallbackMethod" => "POST", "StatusCallbackEvent" => array("ringing"), "Timeout" => "25")); echo $call->sid . "<br>"; } catch (Exception $e) {
<?php //Twilio Website Number: (516) 210-2005 $apiPD = new apiPipeDrive(); $agent_numbers = $apiPD->getAgentByDealSource(37); $fields['from'] = $_REQUEST['From']; $fields['CallSid'] = $_REQUEST['CallSid']; $insertId = qi("website_number_dials", _escapeArray($fields)); header("content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?> <Response> <?php if (count($agent_numbers) == 0) { ?> <Say>Thank you for calling leadpropel.com</Say> <Say>Sorry, All agents are busy at the moment.</Say> <Say>We will call back later.</Say> <Say>Thank you</Say> <?php } else { ?> <Dial action="<?php echo _U . "website_number_dial_status?params=" . $insertId . "--00--status"; ?> "> <?php foreach ($agent_numbers as $each) { ?> <Number url="<?php
$apiPD->assignPerson($person_id, $agent_id); $apiPD->assignOrganization($org_id, $agent_id); $call_detail_data = q("select * from call_detail where sid='{$_REQUEST['CallSid']}'"); $call_detail_fields['agent_phone'] = $cur_agent; $call_detail_fields['agent_id'] = $agent_id; $call_detail_fields['agent_name'] = $agent_name; $call_detail_fields['status'] = isset($_REQUEST['CallStatus']) ? $_REQUEST['CallStatus'] : ''; $call_detail_fields['customer_phone'] = $phone_value; $call_detail_fields['source_id'] = $source_id; $call_detail_fields['customer_name'] = $cust_name; $call_detail_fields['customer_email'] = $cust_email; $call_detail_fields['org_name'] = $org_name; $call_detail_fields['deal_id'] = $dealId; $call_detail_fields['deal_added'] = $add_time; $call_detail_fields['sid'] = $_REQUEST['CallSid']; $call_detail_id = qi('call_detail', _escapeArray($call_detail_fields)); qu("agent_call_dialed", _escapeArray(array("is_updated" => "1")), "deal_id='" . $dealId . "'"); $fields['subject'] = 'Call'; $fields['done'] = '1'; $fields['type'] = 'call'; $fields['deal_id'] = $dealId; // Test Deal Id - $fields['deal_id'] = '4586'; $fields['person_id'] = $person_id; $fields['org_id'] = $org_id; $param = http_build_query(array('call_detail_id' => $call_detail_id)); //$fields['note'] = "<iframe src='https://www.leadpropel.com/".FOLDER_RUN."playAudio?".$param."' width='380' height='110'></iframe>"; $fields['note'] = "<span call-recording-id-{$call_detail_id}>Call Recording: <br>We are loading call recording.</span>"; $data = $apiPD->createActivity($fields); $activity_data = json_decode($data); if (isset($activity_data->success) && $activity_data->success) { qu('call_detail', array("activity_id" => $activity_data->data->id), "id='{$call_detail_id}'");
<?php /** * Admin side Login file * * * @version 1.0 * @package lysoft * */ //$jsInclude = "home.js.php"; //_R(lr('dashboard')); $urlArgs = _cg("url_vars"); if (isset($_REQUEST['txt_sms'])) { unset($fields); $fields['sms'] = $_REQUEST['txt_sms']; $fields['activity'] = $_REQUEST['ddl_type']; $fields['agent'] = $_REQUEST['ddl_agent']; qi("messages", _escapeArray($fields)); $_SESSION['greetings_msg'] = 'Record Added successfully!'; } $message_list = q("SELECT * FROM `messages`"); _cg("page_title", "SMS Text");
echo _U; ?> ConnectingCustomer" method="GET" numDigits="1"> <Say>You had not press any key.</Say> <Say>Please Press 1 to continue. Press 2 to Repeat. Press any other key to hangup</Say> </Gather> <Redirect method="POST"><?php echo _U . "ConnectingCustomer"; ?> </Redirect> </Response> <?php } else { qu("voice_call", array("in_progress" => "0"), "deal_id='" . $dealId . "'"); //Set in_progress=0 because call process is completed qi("voice_call", array("deal_id" => $dealId, "is_handled" => "0", "curr_agent" => $cur_agent, "all_agents" => $agent_numbers, "customer_phone" => $phone_value)); header("content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?> <Response><Say>Good Buy!</Say></Response> <?php $agent_name = 'agent'; $agent_detail = qs("select * from pd_users where phone like '%" . $cur_agent . "%'"); if (isset($agent_detail)) { $agent_name = $agent_detail['name']; } $message = '<b>Note: </b><br>Call went into voicemail of <b>' . $agent_name . "</b>. System will call again in <b>10 minutes</b>."; sendNote($dealId, $message); } die;
<?php //Update Deal which is not handled by any agents $agent_call_dialed = q("select * from agent_call_dialed where is_updated='0' and created_at < DATE_SUB(NOW(), INTERVAL 2 minute) group by deal_id"); if (count($agent_call_dialed) > 0) { foreach ($agent_call_dialed as $each_deal) { $new_deal = qs("select * from call_detail where deal_id='{$each_deal['deal_id']}'"); if (isset($new_deal) && !empty($new_deal)) { //echo "<br>-" . $each_deal['is_updated'] . "-not-" . $each_deal['deal_id']; } else { $new = array(); $new['customer_phone'] = $each_deal['customer_phone']; $new['deal_id'] = $each_deal['deal_id']; $new['call_handled'] = '0'; $a = qi("call_detail", $new); //echo "<br>-" . $each_deal['is_updated'] . "-added-" . $each_deal['deal_id']; } } $apiPD = new apiPipeDrive(); $agent_call_dialed = q("select * from agent_call_dialed where is_updated='0'"); foreach ($agent_call_dialed as $each_deal) { $deal_data = $apiPD->getDealInfo($each_deal['deal_id']); $deal_data = json_decode($deal_data); //d($deal_data); $person_id = isset($deal_data->data->person_id->value) ? $deal_data->data->person_id->value : ''; $org_id = isset($deal_data->data->org_id->value) ? $deal_data->data->org_id->value : ''; $source_id = isset($deal_data->data->c2a6fc3129578b646ae55717ed15f03ce3ee4df0) ? $deal_data->data->c2a6fc3129578b646ae55717ed15f03ce3ee4df0 : ''; $cust_name = isset($deal_data->data->person_id->name) ? $deal_data->data->person_id->name : ''; $add_time = isset($deal_data->data->add_time) ? $deal_data->data->add_time : ''; $add_time = date("Y-m-d H:i:s", strtotime($add_time) - 3600 * 4); $cust_email = isset($deal_data->data->person_id->email[0]->value) ? $deal_data->data->person_id->email[0]->value : '';
/** * array( 'state' => $each_trip['tripState'], 'name' => $each_trip['driverName'], 'number' => $each_trip['driverNumber'], 'tripTime' => $each_trip['tripTime'], 'wakeUpTime' => $newTime ) * @param type $data */ function doScheduleNightBeforeText($data) { $existingData = qs("select * from manualtextscheduler where tripCode = '{$data['tripCode']}' AND sentTime != '0000-00-00 00:00:00' "); if (!empty($existingData)) { _l(" Day Prior Text is already sent.. so not logging the Day Prior Text"); return; } _l(" Logging the Day Prior Text "); //Hi Hung, tomorrow your wakeup text will arrive at 4:45am for garage out at 7:15am. Please reply promptly $textArriveTime = date("m/d h:ia", strtotime($data['wakeUpTime'])); $tripTime = date("m/d h:ia", strtotime($data['tripTime'])); //$text = "Hi {$data['name']}, your wakeup text will arrive at {$textArriveTime} for garage out at {$tripTime}. Please reply promptly"; // New text from danielle 07/02/2015 // "Good Evening. Your scheduled "Garage Out" time is scheduled for _____ . Please report to base 10 minutes prior for pre-flight inspection. Your wake up text is scheduled for ______. Thank you and have a safe trip!" $text = "Good Evening. Your scheduled Garage Out time is scheduled for {$tripTime} . Please report to base 10 minutes prior for pre-flight inspection. Your wake up text is scheduled for {$textArriveTime}. Thank you and have a safe trip!"; $timeZone = resolveTimeZoneFromState($data['state']); $dayBeforeTime = resolveDayBeforeTime($data['tripTime']); qi('manualtextscheduler', array('textMessage' => _escape($text), 'textNumber' => $data['number'], 'tripCode' => $data['tripCode'], 'textTime' => $dayBeforeTime, 'sentTime' => '0000-00-00 00:00:00', 'textTimeZone' => $timeZone), 'REPLACE'); }
<?php if (isset($_REQUEST['click_to_call']) && $_REQUEST['click_to_call'] == 1) { $fields['deal_id'] = $_REQUEST['dealId']; $fields['agent_phone'] = removeCellFormat($_REQUEST['agent_phone']); $fields['agent_name'] = $_REQUEST['agent_name']; $fields['customer_phone'] = removeCellFormat($_REQUEST['customer_phone']); $click_to_call_id = qi("click_to_call", $fields); $callWebhook = new callWebhook(); $sid = $callWebhook->click_to_call($click_to_call_id); $data = array("id" => $click_to_call_id, "sid" => $sid); json_die(true, $data); } $dealId = $_REQUEST['dealId']; $phone_count = $_REQUEST['phone_count']; $contact_list = array(); $is_cust_number = 0; for ($index = 1; $index <= $phone_count; $index++) { $is_cust_number = 1; $contact_list[] = removeCellFormat($_REQUEST['phone_' . $index]); } $conversation_list = q("select * from text_conversation where deal_id='{$dealId}' order by messageTime asc"); $agent_name = $_REQUEST['agent_name']; $agent = qs("select * from pd_users where name='{$agent_name}'"); if (empty($agent) || $agent['phone'] == '' && $agent['cell'] == '') { $is_agent_number = 0; } else { $is_agent_number = 1; $agent_no = $agent['phone'] == '' ? $agent['cell'] : $agent['phone']; $agent_no = formatCellDash($agent_no); }
foreach ($source_list_arr as $each_source) { $source_id = ''; $source_id = trim($each_source["id"]); if ($source_id != '') { $check_source_id = array(); $check_source_id = Call_distribution::CheckMainSourceId($source_id); echo $check_source_id . "****" . $each_source["label"]; echo "<br/>"; $data_insert = 1; if (!empty($check_source_id)) { if ($check_source_id["id"] != '') { unset($fields); $fields["source_name"] = trim($each_source["label"]); $fields["is_deleted"] = 0; $fields = _escapeArray($fields); qu("pd_sources", $fields, " id = '{$check_source_id}' "); $data_insert = 0; } } if ($data_insert == 1) { $fields["pd_source_id"] = trim($each_source["id"]); $fields["source_name"] = trim($each_source["label"]); $fields["is_deleted"] = 0; $fields = _escapeArray($fields); qi("pd_sources", $fields); } } } } echo "<br/><br/>===================Script Is Done================"; die;
$person_id = $data['current']['person_id']; $person_data = $apiPD->getPersonInfo($person_id); $person_data = json_decode($person_data, true); $message = $data['current']['note']; $deal_id = $data['current']['deal_id']; $org_id = $data['current']['org_id']; $subject = $data['current']['subject']; $subject = preg_replace("/[^0-9]/", "", $subject); $activityLogArray = array(); if (strlen($subject) < 10) { $phone_value = isset($person_data['data']['phone'][0]['value']) ? $person_data['data']['phone'][0]['value'] : '-1'; } else { $phone_value = $subject; $activityLogArray['number_from_subject'] = '1'; } $activityLogArray['payload'] = $payload; $activityLogArray['activity_id'] = $activity_id; $activityLogArray['person_id'] = $person_id; $activityLogArray['deal_id'] = $deal_id; $activityLogArray['org_id'] = $org_id; if ($phone_value == '-1' || $phone_value == '') { $activityLogArray['log'] = "Phone value is blank"; qi('activity_log', $activityLogArray); } else { $activityLogArray['log'] = "Message sending on " . $phone_value; $activityLogArray['phone_value'] = $phone_value = $apiCall->ValidateNumber($phone_value); $activityLogArray['phone_last10'] = last10Char($phone_value); qi('activity_log', $activityLogArray); $apiCall->messageNow($phone_value, $message); } die;
} elseif ($cat_count == 3 && $category == 'B') { $category = 'C'; } elseif ($cat_count == 3 && $category == 'C') { qi("activity_log", _escapeArray(array("log" => "We had tried 3 times call for group-C.", "deal_id" => $each_call['deal_id']))); continue; } if ($category != 'A' && $category != 'B' && $category != 'C') { $category = 'A'; } $query = "select count(*) as count from agent_call_dialed where deal_id='" . $each_call['deal_id'] . "' AND DATE(`created_at`) = CURDATE() AND created_at>NOW() - INTERVAL 1 MINUTE order by created_at desc"; $last_call = qs($query); echo $query; d($last_call); if ($last_call['count'] > 0) { echo "call in progress"; qi("activity_log", _escapeArray(array("log" => "we can try only after 5 minutes.", "deal_id" => $each_call['deal_id']))); continue; } else { echo "call need to dial"; echo "<Br>" . $last_agent_call_dial[0]['customer_phone']; $apiCall = new callWebhook(); $all_agent_arr_unique = explode(",", $last_agent_call_dial[0]['agent_numbers']); $new_agent_numbers = array(); foreach ($all_agent_arr_unique as $each_value) { $new_agent_numbers[] = $each_value; } d($new_agent_numbers); $apiCall->callNow($last_agent_call_dial[0]['customer_phone'], $new_agent_numbers, $each_call['deal_id'], "1", $category); die; } }
//$apiPD->assignDeal($urlArgs[1], $agent_id); $call_detail_data = q("select * from call_detail where sid='{$_REQUEST['CallSid']}'"); $call_detail_fields['agent_phone'] = $urlArgs[0]; $call_detail_fields['agent_id'] = $agent_id; $call_detail_fields['agent_name'] = $agent_name; $call_detail_fields['status'] = isset($_REQUEST['DialCallStatus']) ? $_REQUEST['DialCallStatus'] : ''; $call_detail_fields['recording_duration'] = $recording_duration; $call_detail_fields['recording_url'] = $recording_url; $call_detail_fields['customer_phone'] = urlencode($urlArgs[2]); $call_detail_fields['deal_id'] = $urlArgs[1]; if (count($call_detail_data) > 0) { $call_detail_id = $call_detail_data[0]['id']; qu('call_detail', $call_detail_fields, "id='{$call_detail_data[0]['id']}'"); } else { $call_detail_fields['sid'] = $_REQUEST['CallSid']; $call_detail_id = qi('call_detail', $call_detail_fields); } $deal_data = json_decode($apiPD->getDealInfo($urlArgs[1])); //$deal_data = json_decode($apiPD->getDealInfo('4586')); //$deal_data = json_decode($apiPD->getDealInfo('4586')); $person_id = isset($deal_data->data->person_id->value) ? $deal_data->data->person_id->value : ''; $org_id = isset($deal_data->data->org_id->value) ? $deal_data->data->org_id->value : ''; //$apiPD->assignPerson($person_id, $agent_id); //$apiPD->assignOrganization($org_id, $agent_id); $fields['subject'] = 'Call'; $fields['done'] = '1'; $fields['type'] = 'call'; $fields['deal_id'] = $urlArgs[1]; // Test Deal Id - $fields['deal_id'] = '4586'; $fields['person_id'] = $person_id; $fields['org_id'] = $org_id;
$agent_numbers = $apiPD->getAgentByDealSource($deal_source['pd_source_id']); if (count($agent_numbers) == 0) { ?> <Response> <Say>Thank you for calling Lysoft dot Com. We are sorry for can't handle your call. Please Try Later.</Say> </Response> <?php } else { ?> <Response> <Say>Thank you for calling Lysoft dot Com.</Say> <Say>We are connecting to our agents. Please wait a moment.</Say> <Dial> <?php foreach ($agent_numbers as $each_agent) { ?> <Number><?php echo $each_agent; ?> </Number> <?php } ?> </Dial> </Response> <?php } $payload = file_get_contents('php://input'); qi("test", array("payload" => _escape($payload))); die;
<?php $call_status = qs("select *,value as call_status from config where `key` = 'CALL_STATUS'"); if (strtolower($call_status['call_status']) != "on") { qi("test", array("t" => "call distribution is off.")); die; } _errors_on(); # Get Pipedrive API object $apiPD = new apiPipeDrive(); $apiCall = new callWebhook(); # Set default timezone date_default_timezone_set('America/New_York'); # receive the payload $payload = file_get_contents('php://input'); $data = json_decode(@$payload, true); //Getting Deal Info and change stage if pipeline id is '1' (i.e. for "Leads") $deal_info = $apiPD->getDealInfo($data['current']['id']); $deal_info = json_decode($deal_info, TRUE); if ($deal_info['data']['pipeline_id'] == "1") { $deal_info = $apiPD->modifyDeal($data['current']['id'], array("stage_id" => "1")); } // store into the database //qi("pd_push_notification_log", array("payload" => _escape($payload))); # now, identify if that is hot lead then get the number of customer and start calling the customer # c2a6fc3129578b646ae55717ed15f03ce3ee4df0 - this is key for custom attribute/field - "Source" $deal_source = $data['current']['c2a6fc3129578b646ae55717ed15f03ce3ee4df0']; if (in_array($deal_source, array('37')) || 1) { # Get Person ID $person_id = $data['current']['person_id']; # Get Deal ID
if ($user_id != '') { $check_user_id = array(); $check_user_id = Call_distribution::CheckMainUserId($user_id); echo $check_user_id . "****" . $each_user["name"]; echo "<br/>"; unset($fields); $fields["name"] = $each_user["name"]; $fields["email"] = $each_user["email"]; $fields["phone"] = $each_user["phone"]; $fields["is_deleted"] = '0'; if ($each_user['active_flag']) { $fields["is_active"] = '1'; } else { $fields["phone"] = ''; $fields["is_active"] = '0'; } if ($check_user_id != '') { $fields = _escapeArray($fields); if ($each_user['active_flag']) { unset($fields['phone']); } qu("pd_users", $fields, " id = '{$check_user_id}' "); } else { $fields["pd_id"] = $user_id; $fields = _escapeArray($fields); qi("pd_users", $fields); } } } } die;
<?php //Test Mode - Live Server Comment following 2 line. //$_REQUEST['From']="+918460422312"; //$_REQUEST['Body']="Test Static Data"; $apiPD = new apiPipeDrive(); $apiCall = new apiCall(); $phone_value = urldecode($_REQUEST['From']); $phone_value = last10Char($phone_value); $payload = file_get_contents('php://input'); $activity_data = qs("select * from activity_log where phone_last10 like '%{$phone_value}%' order by id desc"); if (isset($activity_data)) { $fields['subject'] = 'SMS - Replied By Customer'; $fields['done'] = '1'; $fields['type'] = 'text'; $fields['deal_id'] = $activity_data['deal_id']; // Test Deal Id - $fields['deal_id'] = '4586'; $fields['person_id'] = $activity_data['person_id']; $fields['org_id'] = $activity_data['org_id']; $fields['note'] = _escape(urldecode($_REQUEST['Body'])); $data = $apiPD->createActivity($fields); qi('test', array('payload' => $data)); } qi('test', array('payload' => $payload, 't' => $_REQUEST['From'])); die;