Example #1
0
/**
 * adds params on to an existing query string
 *
 * @param string $url 
 * @param array $additional_params 
 * @return string
 * @author Craig Ulliott
 */
function http_add_params($url, $additional_params)
{
    // break apart the original url
    $url_r = parse_url($url);
    // parse and combine two query strings
    $new_query_string = qs(array_val($url_r, 'query', ''), $additional_params);
    return (isset($url_r['scheme']) ? $url_r['scheme'] . '://' : '') . (isset($url_r['user']) ? $url_r['user'] . (isset($url_r['pass']) ? ':' . $url_r['pass'] : '') . '@' : '') . (isset($url_r['host']) ? $url_r['host'] : '') . (isset($url_r['port']) ? ':' . $url_r['port'] : '') . (isset($url_r['path']) ? $url_r['path'] : '') . '?' . $new_query_string . (isset($url_r['fragment']) ? '#' . $url_r['fragment'] : '');
}
 public static function CheckMainUserId($user_id)
 {
     $res = qs("SELECT id,pd_id FROM pd_users WHERE pd_id = '{$user_id}'");
     if (!empty($res)) {
         return $res["id"];
     } else {
         return "";
     }
 }
 public function getAgentByDealSource($source_id)
 {
     $data = qs("select * from call_list_by_source where pd_source_id = '{$source_id}' ");
     $agents = $data['pd_user_id'];
     if ($agents) {
         $agents = json_decode($agents, true);
         $agents_condition = "'" . implode("','", $agents) . "'";
         $phones = q("select * from pd_users where pd_id in ({$agents_condition}) ");
         $phones_data = array();
         foreach ($phones as $each_phone) {
             $phones_data[] = $each_phone['phone'];
         }
         $phones_data = array_filter($phones_data);
         return $phones_data;
     }
     return array();
 }
 public function click_to_call($click_to_call_id = 0)
 {
     $account_sid = ACCOUNT_SID;
     $auth_token = AUTH_TOKEN;
     $click_to_call = qs("select * from click_to_call where id='{$click_to_call_id}'");
     if (empty($click_to_call)) {
         return '';
     }
     $url_agent_calling = _U . "click_to_call_complete?";
     $url_agent_received = _U . "click_to_call_first?";
     $params = "agent_number=" . $click_to_call['agent_phone'] . "&click_to_call_id=" . $click_to_call_id . "&dealId=" . $click_to_call['deal_id'] . "&phone_value=" . $click_to_call['customer_phone'];
     $url_agent_calling .= $params;
     $url_agent_received .= $params;
     include _PATH . "/Services/Twilio.php";
     $client = new Services_Twilio($account_sid, $auth_token);
     $call = $client->account->calls->create(TWILIO_PHONE_NUMBER, $click_to_call['agent_phone'], $url_agent_received, array("Method" => "GET", "StatusCallback" => $url_agent_calling, "StatusCallbackMethod" => "POST", "Timeout" => "25"));
     return $call->sid;
 }
Example #5
0
function qs($a, $low, $high)
{
    if ($low == $high || $low > $high) {
        return $a;
    } else {
        $flag1 = false;
        $flag2 = false;
        $pivot = $a[$low];
        for ($i = $low + 1, $j = $high;;) {
            if ($j < $i) {
                break;
            }
            if ($flag1 == true && $flag2 == true) {
                $temp = $a[$i];
                $a[$i] = $a[$j];
                $a[$j] = $temp;
                $i++;
                $j--;
                $flag1 = false;
                $flag2 = false;
            } else {
                if ($a[$i] < $pivot && $flag1 == false) {
                    $i++;
                } else {
                    $flag1 = true;
                }
                if ($a[$j] > $pivot && $flag2 == false) {
                    $j--;
                } else {
                    $flag2 = true;
                }
            }
        }
        $temp = $a[$low];
        $a[$low] = $a[$i - 1];
        $a[$i - 1] = $temp;
        $a = qs($a, $low, $i - 1);
        $a = qs($a, $i, $high);
        return $a;
    }
}
<?php

header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$apiPD = new apiPipeDrive();
$deal_source = qs("select pd_source_id from pd_sources where source_name like 'Hot Lead 2'");
$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>
 public static function Getdata()
 {
     return qs("SELECT * FROM config");
 }
Example #8
0
        
        <div class="nav">
            <? 
            if($page > 1) { 
                ?><a href="<?php 
echo qs(array('page' => $page - 1));
?>
" id="prev">Prev</a><?
            } else {
                ?><span>Prev</span><?
            } 
            ?> 
            <? 
            if($page < floor($loans->paging->pages)) {
                ?><a href="<?php 
echo qs(array('page' => $page + 1));
?>
" id="next">Next</a><?
            } else {
                ?><span>Next</span><?
            } 
            ?> 
        </div>
        <? } ?> 
        <script>
        /* -= Nav bar magic =- */
        (function(){
            var showSpinner = function() {
                document.getElementById("spinner").style.visibility = 'visible';
                return true;
            }
Example #9
0
 public static function GetManifestUserInfo($user_id)
 {
     return qs("SELECT * FROM manifest_user WHERE id = '{$user_id}'");
 }
<?php

$conv_fields = array();
$conv_fields['message_id'] = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
$conv_fields['text'] = isset($_REQUEST['text']) ? _escape($_REQUEST['text']) : '';
$conv_fields['sender'] = isset($_REQUEST['sender']) ? $_REQUEST['sender'] : '';
$conv_fields['sender_last10'] = isset($_REQUEST['sender']) ? last10Char($_REQUEST['sender']) : '';
$last_conv = qs("select * from text_conversation where receiver_last10='{$conv_fields['sender_last10']}' order by id desc limit 0,1");
$conv_fields['deal_id'] = isset($last_conv['deal_id']) ? $last_conv['deal_id'] : "-";
$conv_fields['type'] = 'RECEIVED';
$conv_fields['messageTime'] = _mysqlDate();
$conv_fields['receiver'] = isset($_REQUEST['receiver']) ? $_REQUEST['receiver'] : '';
$conv_fields['receiver_last10'] = isset($_REQUEST['receiver']) ? last10Char($_REQUEST['receiver']) : '';
qi("text_conversation", $conv_fields);
die;
Example #11
0
function getTripLatestStatus($tripCode)
{
    $return = array("tripstatus" => "UNW", 'statustime' => date("Y-m-d"));
    $data = qs(" select * from tripstatuslogs where tripcode = '{$tripCode}' order  by id desc limit 0,1 ");
    return !empty($data) ? $data : $return;
}
            $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 : '';
        $org_name = isset($deal_data->data->org_name) ? $deal_data->data->org_name : '';
        $created_at = qs("select created_at from agent_call_dialed where deal_id='{$each_deal['deal_id']}' order by id asc limit 0,1");
        $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'] = $each_deal['deal_id'];
        $call_detail_fields['deal_added'] = $add_time;
        $call_detail_fields['created_at'] = $created_at['created_at'];
        $call_detail_id = qu('call_detail', _escapeArray($call_detail_fields), "deal_id='{$each_deal['deal_id']}'");
        $call_detail_id = qu('agent_call_dialed', array("is_updated" => '1'), "deal_id='{$each_deal['deal_id']}'");
    }
}
<?php

if (isset($_REQUEST['call_detail_id']) && $_REQUEST['call_detail_id'] != '') {
    //$call_detail_array = explode("|",$_REQUEST['call_detail_id']);
    $call_data = qs("select * from call_detail where id='{$_REQUEST['call_detail_id']}'");
    echo "<!DOCTYPE html>";
    echo "<html>";
    echo "<body style='padding:10px;'>";
    echo "<div style='padding: 10px; font-family: verdana; font-size: 14px;'>Inbound Call - ";
    //echo ($call_data['recording_duration'] == 0 ? '00:00:00' : (gmdate("H:i:s", $call_data['recording_duration'])));
    echo gmdate("H:i:s", $call_data['recording_duration']);
    echo "</div>";
    if (isset($call_data['recording_url']) && $call_data['recording_url'] != '') {
        echo '<audio controls>';
        echo '<source src="' . $call_data['recording_url'] . '" type="audio/mpeg">';
        echo 'Your browser does not support the audio element.';
        echo '</audio>';
    } else {
        echo "<div style='color:red;padding:0 10px;'>No Recording Found!</div>";
    }
    /*elseif($call_data['status']=='busy') {
          echo "<div style='color:red;'>Customer was busy at that moment!</div>";
      }
      elseif($call_data['status']=='no-answer') {
          echo "<div style='color:red;'>No Answer of the Call!</div>";
      }
      elseif($call_data['status']=='running') {
          echo "<div style='color:green;'>Call is running at this moment!</div>";
      }
      elseif($call_data['status']=='in-progress') {
          echo "<div style='color:green;'>Call is in-progress!</div>";
    $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);
}
$no_visible_elements = TRUE;
_cg("page_title", "Conversation");
$jsInclude = "click_to_call.js.php";
<?php

/**
 * Admin side Login file
 * 
 * 
 * @version 1.0
 * @package lysoft
 * 
 */
//$jsInclude = "home.js.php";
//_R(lr('dashboard'));
$urlArgs = _cg("url_vars");
if (isset($_REQUEST['hid_is_edit'])) {
    qu("config", array("value" => $_REQUEST['txt_api_key']), "id='{$_REQUEST['hid_is_edit']}'");
    $_SESSION['greetings_msg'] = 'Api Key Updated successfully!';
}
$pipedriver_api_key = qs("SELECT * FROM  `config` WHERE  `key` LIKE  'PIPEDRIVER_API_KEY'");
_cg("page_title", "PipeDrive Settings");
Example #16
0
?>
' class=round-button-blue title='Next page'>
	<img src='images/ic_keyboard_arrow_right_white_24px.svg' style='margin-top:12px'>
    </a>
</span>
<span class=align>
    <a href='?<?php 
echo qs();
?>
' class=round-button title='Reload page'>
	<img src='images/ic_refresh_white_24px.svg' style='margin-top:12px'>
    </a>
</span>
<span class=align>
    <a href='?<?php 
echo qs('prev');
?>
' class=round-button-red title='Previous page'>
	<img src='images/ic_keyboard_arrow_left_white_24px.svg' style='margin-top:12px'>
    </a>
</span> 
<span class=cls></span>
</div>

<?php 
foreach (range(0, 4) as $id) {
    ?>
<div id=view<?php 
    echo $id;
    ?>
 align=center style="display:none; margin-top:60px">
             echo "<br>duplicate: " . $each_value;
         } else {
             echo "<br>call to: " . $each_value;
             $new_agent_numbers[] = $each_value;
         }
     }
     if (count($new_agent_numbers) > 0) {
         qu("voice_call", array("in_progress" => "1"), "deal_id='" . $each_call['deal_id'] . "'");
         $apiCall = new callWebhook();
         echo "cust: " . $first_voice_call[0]['customer_phone'] . "<br>";
         echo "Agents: <br>";
         d($new_agent_numbers);
         $apiCall->callNow($first_voice_call[0]['customer_phone'], $new_agent_numbers, $each_call['deal_id'], "1", $cate);
     } else {
         qu("voice_call", array("is_aborted" => "2"), "deal_id='" . $each_call['deal_id'] . "'");
         $data = qs("select * From pd_users where is_active='1' and is_default='1' order by name asc");
         $dealId = $each_call['deal_id'];
         if (!empty($data)) {
             $apiPD = new apiPipeDrive();
             $agent_id = $data['pd_id'];
             $deal_data = json_decode($apiPD->getDealInfo($dealId));
             $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->assignDeal($dealId, $agent_id);
             $apiPD->assignPerson($person_id, $agent_id);
             $apiPD->assignOrganization($org_id, $agent_id);
             die;
         }
     }
     break;
 }
    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;
function sendNote($deal_id, $message)
{
    $apiPD = new apiPipeDrive();
    $data['deal_id'] = $deal_id;
    $data['content'] = $message;
    $data = $apiPD->createNote($data);
}
        <div class="columnTitle">
            <span class="columnItem">Leadpropel Intelligence</span>
        </div>
        <div class="fieldsList read collapsed">
            <div class="visible">
                <div class="item read enumField editable">
                    <div class="labelWrap clearfix"></div>
                    
                    <?php 
$dealId = isset($_REQUEST['dealId']) ? $_REQUEST['dealId'] : '';
if ($dealId == '') {
    echo '<div class="valueWrap singleRow clearfix">';
    echo '<div class="enum">No call recording found.<br><br><br></div>';
    echo '</div>';
} else {
    $call_detail = qs("select * from call_detail where deal_id='{$dealId}' order by id desc limit 0,1");
    if (empty($call_detail) || !isset($call_detail['recording_url']) || $call_detail['recording_url'] == '') {
        echo '<div class="valueWrap singleRow clearfix">';
        echo '<div class="enum">No call recording found.<br><br><br></div>';
        echo '</div>';
    } else {
        echo '<div class="valueWrap singleRow clearfix">';
        echo '<div class="enum">Call on ' . date('d F,Y h:i A', strtotime($call_detail['created_at'])) . '</div>';
        echo '<audio style="width: 100%;" controls=""><source type="audio/mpeg" src="' . $call_detail['recording_url'] . '"></source>Your browser does not support the audio element.</audio>';
        echo '</div>';
    }
}
?>
                   
                        
                    <!--<div class="hr-line"></div>
function gcd($int1, $int2)
{
    $int1 = intval($int1) >= 0 ? intval($int1) : intval($int1 * -1);
    $int2 = intval($int2) >= 0 ? intval($int2) : intval($int2 * -1);
    if ($int1 < $int2) {
        qs($int1, $int2);
    }
    while ($int1 > $int2) {
        $factor = intval($int1 / $int2);
        $int1 -= $factor * $int2;
        if ($int1 > 0) {
            qs($int1, $int2);
        }
    }
    return $int2;
}
     $fields['member_name'] = 'Alan Pearce';
     $fields['member_id'] = 'cc1cb543271349f3b1bb2c64fbedd22e';
     $fields['deal_id'] = $each_deal['id'];
     $fields['agent_id'] = $each_deal['user_id']['id'];
     $fields['agent_name'] = $each_deal['user_id']['name'];
     $fields['agent_email'] = $each_deal['user_id']['email'];
     $fields['cust_id'] = $each_deal['person_id']['value'];
     $fields['cust_name'] = $each_deal['person_id']['name'];
     $fields['cust_email'] = $each_deal['person_id']['email'][0]['value'];
     $fields['stage_id'] = $each_deal['stage_id'];
     $fields['source'] = _e($source[$each_deal['c2a6fc3129578b646ae55717ed15f03ce3ee4df0']]['label'], "");
     $fields['status'] = $each_deal['status'];
     $fields['curr_stage'] = $stage[$each_deal['stage_id']]['name'];
     $fields['initial_move_stage'] = $filter_stage_name;
     $fields['stage_order_nr'] = $stage[$each_deal['stage_id']]['order_nr'];
     $duplicate = qs("select * from dashboard_stage_entering_deals where deal_id = '{$fields['deal_id']}' and initial_move_stage = '{$fields['initial_move_stage']}'");
     if (!empty($duplicate)) {
         unset($fields['reference']);
         qu("dashboard_stage_entering_deals", _escapeArray($fields), "deal_id= '{$fields['deal_id']}' and initial_move_stage = '{$fields['initial_move_stage']}'");
         echo "<br> Record Update for deal: " . $fields['deal_id'];
     } else {
         $fields['date'] = _mysqlDate();
         qi("dashboard_stage_entering_deals", _escapeArray($fields));
         echo "<br>Record Insert for deal: " . $fields['reference'];
     }
 }
 echo "new call<Br><Br><br>";
 $start_record_from += $no_of_records;
 $deal_data = array();
 $deal_data = $apiPD->getFilterDeals($filter_id, $start_record_from, $no_of_records);
 $deal_data = json_decode($deal_data, "true");
<?php

//d($_REQUEST);
$urlArgs = _cg("url_vars");
$agent = qs("select pd_id,name from pd_users where phone = '{$urlArgs[0]}'   ");
$agent_id = $agent['pd_id'];
$agent_name = $agent['name'];
$recording_url = isset($_REQUEST['RecordingUrl']) ? $_REQUEST['RecordingUrl'] : '';
$recording_duration = isset($_REQUEST['RecordingDuration']) ? $_REQUEST['RecordingDuration'] : '0';
//qi('config',array("key"=>$agent_id,"value"=>$urlArgs[1]));
$apiPD = new apiPipeDrive();
//$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'));
}
if (isset($_REQUEST['update_call']) && $_REQUEST['update_call'] == 1) {
    //$user_list_update = Call_distribution::AllLeadSorceNull(); //First Null the Call List
    $json_user_list = '';
    $user_list = array();
    if (isset($_REQUEST["user_list"]) && $_REQUEST["user_list"] != '') {
        $user_list = $_REQUEST["user_list"];
    }
    // Conver array to json format //
    if (!empty($user_list) && count($user_list) > 0) {
        $json_user_list = json_encode($user_list);
    }
    $source_pk_id = '';
    $source_pk_id = trim($_REQUEST["source_pk_id"]);
    $source_id_arr = array();
    $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);
<?php

/**
 * Admin side Login file
 * 
 * 
 * @version 1.0
 * @package lysoft
 * 
 */
//$jsInclude = "home.js.php";
//_R(lr('dashboard'));
$urlArgs = _cg("url_vars");
if (isset($_REQUEST['hid_sid_id']) && isset($_REQUEST['hid_token_id'])) {
    qu("config", array("value" => $_REQUEST['txt_account_sid']), "id='{$_REQUEST['hid_sid_id']}'");
    qu("config", array("value" => $_REQUEST['txt_auth_token']), "id='{$_REQUEST['hid_token_id']}'");
    $_SESSION['greetings_msg'] = 'Keys Updated successfully!';
}
$TWILIO_ACCOUNT_SID = qs("SELECT * FROM  `config` WHERE  `key` LIKE  'TWILIO_ACCOUNT_SID'");
$TWILIO_AUTH_TOKEN = qs("SELECT * FROM  `config` WHERE  `key` LIKE  'TWILIO_AUTH_TOKEN'");
_cg("page_title", "Twilio Settings");
 echo "<br>Deal Id: " . $each_call['deal_id'];
 echo "<br>Category to call: " . $category;
 echo $category . "-------";
 if ($cat_count == 3 && $category == 'A') {
     $category = 'B';
 } 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;
     }
        $res_arr['call_duration'] = 0;
        $res_arr['days'] = 0;
    }
    json_die(true, $res_arr);
    die;
}
if (isset($_REQUEST['load_detail']) && $_REQUEST['load_detail'] == 1) {
    $start_limit = $_REQUEST['hidLastRecord'];
    $call_list = q("SELECT * FROM `call_detail` cd WHERE 1=1 {$where} order by cd.deal_id desc limit {$start_limit},{$page_size}");
    //sleep(1);
    include _PATH . 'instance/front/tpl/call_report_data.php';
    die;
}
if (isset($_REQUEST['loadTimeLine']) && $_REQUEST['loadTimeLine'] == 1) {
    $dealId = $_REQUEST['dealId'];
    $deal_data = qs("select * from call_detail where deal_id='{$dealId}'");
    $date = date("d M, ", strtotime($deal_data['deal_added'])) . "<br>" . date("Y", strtotime($deal_data['deal_added']));
    $time = date("h:i a", strtotime($deal_data['deal_added']));
    $timeline['date'] = $date;
    $timeline['first_data'] = 'Deal Created';
    $timeline['first_time'] = $time;
    if ($deal_data['org_name'] != '') {
        $timeline['first_data'] .= '<br>Org: ' . $deal_data['org_name'];
    }
    if ($deal_data['customer_name'] != '') {
        $timeline['first_data'] .= '<br>Customer: ' . $deal_data['customer_name'] . (" (" . $deal_data['customer_phone'] . ")");
    }
    $timeline_call = q("select * from agent_call_dialed where deal_id='{$dealId}' order by id asc");
    $call_count = 1;
    foreach ($timeline_call as $each_timeline_call) {
        $time = date("h:i a", strtotime($each_timeline_call['created_at']));
Example #27
0
     message_die(GENERAL_ERROR, "Could not obtain exchange information", '', __LINE__, __FILE__, $sql);
 }
 if (!($row = $db->sql_fetchrow($result))) {
     message_die(GENERAL_MESSAGE, $lang['Exchange_lack_of_currencies']);
 }
 $exchange_data = array();
 do {
     $exchange_data[$row['ex_cash_id1']][$row['ex_cash_id2']] = 1;
 } while ($row = $db->sql_fetchrow($result));
 $exchanger = new cash_user($userdata['user_id'], $userdata);
 if (isset($HTTP_POST_VARS['exchange']) && isset($HTTP_POST_VARS['from_id']) && is_numeric($HTTP_POST_VARS['from_id']) && isset($HTTP_POST_VARS['to_id']) && is_numeric($HTTP_POST_VARS['to_id']) && isset($HTTP_POST_VARS['convert_amount']) && is_numeric($HTTP_POST_VARS['convert_amount'])) {
     $from_id = intval($HTTP_POST_VARS['from_id']);
     $to_id = intval($HTTP_POST_VARS['to_id']);
     $convert_amount = cash_floatval($HTTP_POST_VARS['convert_amount']);
     if ($convert_amount < 0) {
         qs($from_id, $to_id);
         $convert_amount = -$convert_amount;
     }
     if ($to_id != $from_id && $cash->currency_exists($to_id) && $cash->currency_exists($from_id) && isset($exchange_data[$from_id]) && is_array($exchange_data[$from_id]) && isset($exchange_data[$from_id][$to_id]) && $cash->currencies[$from_id]->mask(CURRENCY_ENABLED | CURRENCY_EXCHANGEABLE) && $cash->currencies[$to_id]->mask(CURRENCY_ENABLED | CURRENCY_EXCHANGEABLE)) {
         $c_cur_from = $cash->currency($from_id);
         $c_cur_to = $cash->currency($to_id);
         if ($exchanger->has($c_cur_from->id(), $convert_amount)) {
             $converted_amount = $convert_amount / $c_cur_from->data('cash_exchange') * $c_cur_to->data('cash_exchange');
             $exchanger->remove_by_id_array(array($c_cur_from->id() => $convert_amount));
             $exchanger->give_by_id_array(array($c_cur_to->id() => $converted_amount));
         }
     }
 }
 $template->assign_vars(array('S_EXCHANGE_ACTION' => append_sid("cash.{$phpEx}?mode=exchange"), 'S_HIDDEN_FIELDS' => '<input type="hidden" name="exchange" value="1" />', 'L_EXCHANGE' => $lang['Exchange'], 'L_FROM' => $lang['From'], 'L_TO' => $lang['To'], 'L_CONVERT' => $lang['Convert'], 'L_SELECT_ONE' => $lang['Select_one'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset']));
 $max_columns_per_row = 3;
 $columnwidth = intval(floor(100 / $max_columns_per_row));
        echo "<br>Yes need to redial for deal: " . $each_data['deal_id'];
        qd("deal_sid", "deal_id='{$each_data['deal_id']}'");
        if ($each_data['total_call'] == 1) {
            echo "<br>Total Count:  1<br>";
            $last_updated_record = q("select *,(NOW()  - INTERVAL 5 MINUTE) as ccc,NOW()  from agent_call_dialed where deal_id='{$each_data['deal_id']}' AND modified_at<=NOW()   - INTERVAL 5 MINUTE order by modified_at DESC");
            d($last_updated_record);
            if (count($last_updated_record) == 0) {
                echo "wait to call";
                continue;
            } else {
                echo "dial";
            }
        } else {
            echo "<br>Total Count:  " . $each_data['total_call'];
        }
        $redial_data = qs("select * from agent_call_dialed where deal_id='{$each_data['deal_id']}' order by id ASC");
        $phone_value = $redial_data['customer_phone'];
        $new_agent_numbers = explode(",", $redial_data['agent_numbers']);
        $dealId = $each_data['deal_id'];
        $apiCall = new callWebhook();
        $apiCall->callNow($phone_value, $new_agent_numbers, $dealId, "0");
        echo "<br><br>Call Generated -<br>Agents:";
        d($new_agent_numbers);
        echo "<br>Customer Phone:";
    }
}
$agent_call_detail = q("SELECT deal_id,customer_phone, is_mail_send,COUNT(id) FROM `agent_call_dialed` where is_redial='0'  AND modified_at>=CURRENT_DATE  - INTERVAL 1 DAY GROUP BY deal_id HAVING COUNT(id)>=5");
foreach ($agent_call_detail as $each_data) {
    if ($each_data['is_mail_send'] == '0') {
        $apiPD = new apiPipeDrive();
        $deal_data = json_decode($apiPD->getDealInfo($each_data['deal_id']));
Example #29
0
    ?>
"><i class="visible-xs fa fa-chevron-right" style="width: 10px; float: left; margin-top: 4px;"></i>Logout</a></li>               
                        <?php 
} else {
    ?>
                            <li><a href="<?php 
    l('login_new');
    ?>
"><i class="visible-xs fa fa-chevron-right" style="width: 10px; float: left; margin-top: 4px;"></i>Login</a></li>
                        <?php 
}
?>
                    </ul>
                </li>
                <?php 
$call_status = qs("select *,value as call_status from config where `key` = 'CALL_STATUS'");
if (strtolower($call_status['call_status']) != "on") {
    $status_img = "<i class='fa fa-exclamation-triangle'></i> OFF";
    $current_status = "off";
    $current_style = "background-color:#CC1E1E";
} else {
    $status_img = "<i class='fa fa fa-check'></i> ON";
    $current_status = "on";
    $current_style = "background-color:#39891D";
}
?>
                <li>
                    <div style="font-size: 14px; float: left; padding-top: 15px; color: rgb(110, 86, 86);">&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Call Distributor &nbsp;</div>
                    <!--<img id="call_status_img" onclick="changeCallStatus('<?php 
echo $current_status;
?>
<?php

$agent_numbers = explode(',', $_REQUEST['agent_numbers']);
$dealId = _e($_REQUEST['dealId'], 0);
$phone_value = urlencode($_REQUEST['phone_value']);
$cur_agent = $_REQUEST['cur_agent'];
$agent = qs("select pd_id,name from pd_users where phone = '{$cur_agent}'");
$agent_id = $agent['pd_id'];
$agent_name = $agent['name'];
$apiPD = new apiPipeDrive();
$apiPD->assignDeal($dealId, $agent_id);
$deal_data = json_decode($apiPD->getDealInfo($dealId));
//$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 : '';
$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 : '';
$org_name = isset($deal_data->data->org_name) ? $deal_data->data->org_name : '';
$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;