Ejemplo n.º 1
0
function getContact($callerid, $customer_id = 0, $campaignid = 0, $diallistid = 0, $srcname = null)
{
    global $db, $locate, $config;
    $mycallerid = $callerid;
    $objResponse = new xajaxResponse();
    if ($callerid == '') {
        $objResponse->addALert($locate->Translate('Caller number cannot be empty'));
        return $objResponse;
    }
    $objResponse->addAssign("iptCallerid", "value", $callerid);
    if ($config['system']['trim_prefix'] != '') {
        $prefix = split(",", $config['system']['trim_prefix']);
        foreach ($prefix as $myprefix) {
            if (substr($mycallerid, 0, 1) == $myprefix) {
                $mycallerid = substr($mycallerid, 1);
                break;
            }
        }
    }
    //check contact table first
    if ($config['system']['enable_contact'] == '0' && $customer_id == '') {
        if ($config['system']['detail_level'] == 'all') {
            $row = astercrm::getContactByCallerid($mycallerid);
        } else {
            $row = astercrm::getContactByCallerid($mycallerid, $_SESSION['curuser']['groupid']);
        }
    }
    if ($row['id'] == '' || $config['system']['enable_contact'] == '0') {
        //no match
        //	print 'no match in contact list';
        //try get customer
        if ($config['system']['detail_level'] == 'all') {
            $customerid = astercrm::getCustomerByCallerid($mycallerid);
        } else {
            $customerid = astercrm::getCustomerByCallerid($mycallerid, $_SESSION['curuser']['groupid']);
        }
        if ($customerid == '') {
            //$objResponse->addScript('xajax_add(\'' . $callerid . '\');');
            if ($config['system']['enable_formadd_popup']) {
                $html = Table::Top($locate->Translate("add_record"), "formDiv");
                // <-- Set the
                $html .= Customer::formAdd($callerid, 0, 0, $campaignid, $diallistid, '', $srcname);
                $html .= Table::Footer();
                $objResponse->addAssign("formDiv", "style.visibility", "visible");
                $objResponse->addAssign("formDiv", "innerHTML", $html);
            }
            // callerid smart match
            if ($config['system']['smart_match_remove']) {
                if ($config['system']['detail_level'] == 'all') {
                    $contact_res = astercrm::getContactSmartMatch($mycallerid);
                    $customer_res = astercrm::getCustomerSmartMatch($mycallerid);
                } else {
                    $contact_res = astercrm::getContactSmartMatch($mycallerid, $_SESSION['curuser']['groupid']);
                    $customer_res = astercrm::getCustomerSmartMatch($mycallerid, $_SESSION['curuser']['groupid']);
                }
                $smartcount = 0;
                while ($customer_res->fetchInto($row)) {
                    $smartcount++;
                    $smartmatch_html .= '<a href="###" onclick="xajax_showCustomer(\'' . $row['id'] . '\',\'customer\',' . $callerid . ');showMsgBySmartMatch(\'customer\',\'' . $row['customer'] . '\');">' . $locate->Translate("customer") . ':&nbsp;' . $row['customer'] . '<br>' . $locate->Translate("phone") . ':' . $row['phone'] . '</a><hr>';
                }
                while ($contact_res->fetchInto($row)) {
                    $smartcount++;
                    $smartmatch_html .= '<a href="###" onclick="xajax_showContact(\'' . $row['id'] . '\');showMsgBySmartMatch(\'contact\',\'' . $row['contact'] . '\');">' . $locate->Translate("contact") . ':&nbsp;' . $row['contact'] . '<br>' . $locate->Translate("phone") . ':' . $row['phone'] . '&nbsp;&nbsp;' . $row['phone1'] . '&nbsp;&nbsp;' . $row['phone2'] . '</a><hr>';
                }
                if ($smartcount < 3) {
                    $objResponse->addAssign("smartMsgDiv", "style.height", '');
                    $objResponse->addAssign("SmartMatchDiv", "style.height", '');
                } else {
                    $objResponse->addAssign("smartMsgDiv", "style.height", '160px');
                    $objResponse->addAssign("SmartMatchDiv", "style.height", '240px');
                }
                if ($smartcount) {
                    $objResponse->addAssign("smartMsgDiv", "innerHTML", $smartmatch_html);
                    $objResponse->addScript('getSmartMatchMsg();');
                }
            }
        } else {
            if ($config['system']['enable_formadd_popup']) {
                $html = Table::Top($locate->Translate("add_record"), "formDiv");
                // <-- Set the title for your form.
                $html .= Customer::formAdd($callerid, $customerid, 0, $campaignid, $diallistid, '', $srcname);
                // <-- Change by your method
                $html .= Table::Footer();
                $objResponse->addAssign("formDiv", "style.visibility", "visible");
                $objResponse->addAssign("formDiv", "innerHTML", $html);
            }
            $objResponse->addScript('xajax_showCustomer(\'' . $customerid . '\',\'customer\',' . $callerid . ');');
            if ($config['system']['auto_note_popup']) {
                $objResponse->addScript('xajax_showNote(\'' . $customerid . '\',\'customer\');');
            }
        }
    } else {
        // one match
        if ($customer_id == '') {
            $customerid = $row['customerid'];
        } else {
            $customerid = $customer_id;
        }
        $contactid = $row['id'];
        if ($config['system']['enable_formadd_popup']) {
            $html = Table::Top($locate->Translate("add_record"), "formDiv");
            // <-- Set the title for your form.
            $html .= Customer::formAdd($callerid, $customerid, $contactid, $campaignid, $diallistid);
            // <-- Change by your method
            $html .= Table::Footer();
            $objResponse->addAssign("formDiv", "style.visibility", "visible");
            $objResponse->addAssign("formDiv", "innerHTML", $html);
        }
        $objResponse->addScript('xajax_showContact(\'' . $contactid . '\');');
        if ($customerid != 0) {
            $objResponse->addScript('xajax_showCustomer(\'' . $customerid . '\',\'customer\',' . $callerid . ');');
            if ($config['system']['auto_note_popup']) {
                $objResponse->addScript('xajax_showNote(\'' . $customerid . '\',\'customer\');');
            }
        } else {
            if ($config['system']['auto_note_popup']) {
                $objResponse->addScript('xajax_showNote(\'' . $contactid . '\',\'contact\');');
            }
        }
    }
    //echo $campaignid.$diallistid;exit;
    return $objResponse;
}
Ejemplo n.º 2
0
function hangup($channel)
{
    global $config, $locate;
    $myAsterisk = new Asterisk();
    $objResponse = new xajaxResponse();
    if (trim($channel) == '') {
        return $objResponse;
    }
    $myAsterisk->config['asmanager'] = $config['asterisk'];
    $res = $myAsterisk->connect();
    if (!$res) {
        $objResponse->addALert("action Huangup failed");
        return $objResponse;
    }
    $myAsterisk->Hangup($channel);
    return $objResponse;
}
Ejemplo n.º 3
0
/**
*  hangup a channel
*  @param	channel			string		channel name
*  @return	object						xajax response object
*/
function hangup($channel)
{
    global $config;
    $myAsterisk = new Asterisk();
    $objResponse = new xajaxResponse();
    if (trim($channel) == '') {
        return $objResponse;
    }
    $myAsterisk->config['asmanager'] = $config['asterisk'];
    $res = $myAsterisk->connect();
    if (!$res) {
        $objResponse->addALert("action Huangup failed");
        return $objResponse;
    }
    $myAsterisk->Hangup($channel);
    //$objResponse->addAssign("btnHangup", "disabled", true);
    $objResponse->addAssign("divMsg", "style.visibility", "hidden");
    return $objResponse;
}
Ejemplo n.º 4
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db, $config;
    //根据后台设置导出的customer字段,来导出diallist关联的customer数据
    $customerField = '';
    if ($config['system']['export_customer_fields_in_dialedlist'] != '') {
        $relateCustomerFieldArr = explode(',', $config['system']['export_customer_fields_in_dialedlist']);
        foreach ($relateCustomerFieldArr as $tmp) {
            $customerField .= 'customer.' . $tmp . ',';
        }
    }
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $exportFlag = $searchFormValue['exportFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    if ($optionFlag == "export" || $optionFlag == "exportcsv") {
        $joinstr = astercrm::createSqlWithStype($searchField, $searchContent, $searchType, 'campaigndialedlist');
        $joinstr = ltrim($joinstr, 'AND');
        if ($customerField != '') {
            $sql = "SELECT campaigndialedlist.dialednumber,customer.customer,campaigndialedlist.customername,campaigndialedlist.dialtime,campaigndialedlist.answertime,campaigndialedlist.duration,campaigndialedlist.billsec,campaigndialedlist.billsec_leg_a as total_billsec,campaigndialedlist.campaignresult,campaigndialedlist.response,campaigndialedlist.detect,campaigndialedlist.transfertime,campaigndialedlist.transfertarget,campaigndialedlist.resultby,campaigndialedlist.dialedby, groupname, campaignname,campaigndialedlist.dialedtime," . rtrim($customerField, ',') . " FROM campaigndialedlist LEFT JOIN astercrm_accountgroup ON astercrm_accountgroup.groupid = campaigndialedlist.groupid LEFT JOIN campaign ON campaign.id = campaigndialedlist.campaignid LEFT JOIN customer ON customer.id = campaigndialedlist.customerid ";
        } else {
            $sql = "SELECT campaigndialedlist.dialednumber,customer.customer,campaigndialedlist.customername,campaigndialedlist.dialtime,campaigndialedlist.answertime,campaigndialedlist.duration,campaigndialedlist.billsec,campaigndialedlist.billsec_leg_a as total_billsec,campaigndialedlist.campaignresult,campaigndialedlist.response,campaigndialedlist.detect,campaigndialedlist.transfertime,campaigndialedlist.transfertarget,campaigndialedlist.resultby,campaigndialedlist.dialedby, groupname, campaignname,campaigndialedlist.dialedtime FROM campaigndialedlist LEFT JOIN astercrm_accountgroup ON astercrm_accountgroup.groupid = campaigndialedlist.groupid LEFT JOIN campaign ON campaign.id = campaigndialedlist.campaignid LEFT JOIN customer ON customer.id = campaigndialedlist.customerid ";
        }
        if ($joinstr != '') {
            $sql .= " WHERE " . $joinstr;
        }
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addAssign("maintable", "value", 'campaigndialedlist');
        //赋值隐含域
        $objResponse->addAssign("exporttype", "value", $optionFlag);
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($optionFlag == "delete") {
        astercrm::deletefromsearch($searchContent, $searchField, $searchType, 'campaigndialedlist');
        $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], '', '', '', $divName, "", '');
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    } elseif ($optionFlag == "recycle") {
        $num = Customer::recyclefromsearch($searchContent, $searchField, $searchType, 'campaigndialedlist');
        $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], '', '', $order, $divName, $ordering, '');
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addALert($num . " " . $locate->Translate("number have been recycled"));
        $objResponse->addAssign($divName, "innerHTML", $html);
        $noanswer = Customer::getNoanswerCallsNumber();
        $objResponse->addAssign("spanRecycleUp", "innerHTML", "No answer calls and never recycle: {$noanswer}");
        $objResponse->addAssign("spanRecycleDown", "innerHTML", "No answer calls and never recycle: {$noanswer}");
    } else {
        if ($type == "delete") {
            $res = Customer::deleteRecord($id, 'campaigndialedlist');
            if ($res) {
                $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $order, $divName, $ordering, $searchType);
                $objResponse = new xajaxResponse();
                $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("delete_rec"));
            } else {
                $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_delete"));
            }
        } else {
            $html = createGrid($numRows, $limit, $searchField, $searchContent, $order, $divName, $ordering, $searchType);
        }
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}