/** * initialize page elements * */ function init() { $objResponse = new xajaxResponse(); $objResponse->addAssign("divNav", "innerHTML", common::generateManageNav($skin, $_SESSION['curuser']['country'], $_SESSION['curuser']['language'])); $objResponse->addAssign("divCopyright", "innerHTML", common::generateCopyright($skin)); $objResponse->loadXML(initLocate()); $objResponse->loadXML(initIni()); return $objResponse; }
/** * function to init import page * * * @return $objResponse * */ function init($fileName) { global $locate, $config; $objResponse = new xajaxResponse(); $objResponse->addAssign("spanSelectFile", "innerHTML", $locate->Translate("please_select_file")); $file_list = getExistfilelist(); $objResponse->addScript("addOption('filelist','0','" . $locate->Translate('select a existent file') . "');"); foreach ($file_list as $file) { $objResponse->addScript("addOption('filelist','" . $file['fileid'] . "','" . $file['originalname'] . "');"); } $objResponse->addAssign("btnUpload", "value", $locate->Translate("upload")); $objResponse->addAssign("btnImportData", "value", $locate->Translate("import")); $objResponse->addAssign("spanFileManager", "innerHTML", $locate->Translate("file_manager")); $objResponse->addAssign("hidOnUploadMsg", "value", $locate->Translate("uploading")); $objResponse->addAssign("hidOnSubmitMsg", "value", $locate->Translate("data_importing")); if ($_SESSION['curuser']['usertype'] == 'admin') { $tableList = "<select name='sltTable' id='sltTable' onchange='selectTable(this.value);' >\r\n\t\t\t\t\t\t\t<option value=''>" . $locate->Translate("selecttable") . "</option>\r\n\t\t\t\t\t\t\t<option value='resellerrate'>resellerrate</option>\r\n\t\t\t\t\t\t\t<option value='callshoprate'>callshoprate</option>\r\n\t\t\t\t\t\t\t<option value='myrate'>myrate</option>\r\n\t\t\t\t\t\t</select>"; } elseif ($_SESSION['curuser']['usertype'] == 'reseller') { $tableList = "<select name='sltTable' id='sltTable' onchange='selectTable(this.value);' >\r\n\t\t\t\t\t\t\t<option value=''>" . $locate->Translate("selecttable") . "</option>\r\n\t\t\t\t\t\t\t<option value='callshoprate'>callshoprate</option>\r\n\t\t\t\t\t\t\t<option value='myrate'>myrate</option>\r\n\t\t\t\t\t\t</select>"; } elseif ($_SESSION['curuser']['usertype'] == 'groupadmin') { $tableList = "<select name='sltTable' id='sltTable' onchange='selectTable(this.value);' >\r\n\t\t\t\t\t\t\t<option value=''>" . $locate->Translate("selecttable") . "</option>\r\n\t\t\t\t\t\t\t<option value='myrate'>myrate</option>\r\n\t\t\t\t\t\t</select>"; } $objResponse->addAssign("divTables", "innerHTML", $tableList); $objResponse->addAssign("divNav", "innerHTML", common::generateManageNav($skin)); $objResponse->addAssign("divGrid", "innerHTML", ''); //$objResponse->addScript("xajax_showDivMainRight(document.getElementById('hidFileName').value);"); //$objResponse->loadXML(showDivMainRight($fileName)); //$objResponse->addAssign("divDiallistImport", "innerHTML", ''); $objResponse->addAssign("divCopyright", "innerHTML", common::generateCopyright($skin)); $objResponse->loadXML(showDivMainRight($fileName)); if ($_SESSION['curuser']['usertype'] == 'admin') { // add all reseller $res = astercrm::getAll('resellergroup'); $objResponse->addScript("addOption('resellerid','0','" . $locate->Translate("All") . "');"); while ($row = $res->fetchRow()) { if ($config['synchronize']['id_autocrement_byset'] && ($row['id'] < $config['local_host']['minId'] || $row['id'] > $config['local_host']['maxId'])) { continue; } $objResponse->addScript("addOption('resellerid','" . $row['id'] . "','" . $row['resellername'] . "');"); } } elseif ($_SESSION['curuser']['usertype'] == 'reseller') { // add self $objResponse->addScript("addOption('resellerid','" . $_SESSION['curuser']['resellerid'] . "','" . "" . "');"); // add groups $objResponse->addScript("addOption('groupid','0','" . $locate->Translate("All") . "');"); $res = astercrm::getAll('accountgroup', "resellerid", $_SESSION['curuser']['resellerid']); while ($row = $res->fetchRow()) { if ($config['synchronize']['id_autocrement_byset'] && ($row['id'] < $config['local_host']['minId'] || $row['id'] > $config['local_host']['maxId'])) { continue; } $objResponse->addScript("addOption('groupid','" . $row['id'] . "','" . $row['groupname'] . "');"); } } else { // add self $objResponse->addScript("addOption('resellerid','" . $_SESSION['curuser']['resellerid'] . "','" . "" . "');"); $objResponse->addScript("addOption('groupid','" . $_SESSION['curuser']['groupid'] . "','" . "" . "');"); } $objResponse->addScript("setCampaign();"); return $objResponse; }
/** * function to init import page * * * @return $objResponse * */ function init($fileName) { global $locate, $config; $objResponse = new xajaxResponse(); $file_list = getExistfilelist(); $objResponse->addAssign('filelist', 'innerHTML', ''); $objResponse->addScript("addOption('filelist','0','" . $locate->Translate('select a existent file') . "');"); foreach ($file_list as $file) { $objResponse->addScript("addOption('filelist','" . $file['fileid'] . "','" . $file['originalname'] . "');"); } $tableList = "<select name='sltTable' id='sltTable' onchange='selectTable(this.value);' >\n\t\t\t\t\t\t\t\t\t\t\t<option value=''>" . $locate->Translate("selecttable") . "</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value='customer'>customer</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value='contact'>contact</option>\n\t\t\t\t\t\t\t\t\t\t\t<option value='diallist'>diallist</option>\n\t\t\t\t\t\t\t\t\t\t</select>"; $objResponse->addAssign("divTables", "innerHTML", $tableList); $objResponse->addAssign("divNav", "innerHTML", common::generateManageNav($skin, $_SESSION['curuser']['country'], $_SESSION['curuser']['language'])); $objResponse->addAssign("divGrid", "innerHTML", ''); //$objResponse->addScript("xajax_showDivMainRight(document.getElementById('hidFileName').value);"); //$objResponse->loadXML(showDivMainRight($fileName)); //$objResponse->addAssign("divDiallistImport", "innerHTML", ''); $objResponse->addAssign("divCopyright", "innerHTML", common::generateCopyright($skin)); if ($_SESSION['curuser']['usertype'] == 'admin') { // add all group $res = astercrm::getGroups(); while ($row = $res->fetchRow()) { $objResponse->addScript("addOption('groupid','" . $row['groupid'] . "','" . $row['groupname'] . "');"); } } else { // add self $objResponse->addScript("addOption('groupid','" . $_SESSION['curuser']['groupid'] . "','" . $_SESSION['curuser']['group']['groupname'] . "');"); } $objResponse->addScript("setCampaign();"); $objResponse->loadXML(showDivMainRight($fileName)); return $objResponse; }
function showOutput() { $testResponse = new xajaxResponse(); $testResponse->addAlert("Hello"); // $testResponseOutput = htmlspecialchars($testResponse->getXML()); $testResponse2 = new xajaxResponse(); $testResponse2->loadXML($testResponse->getXML()); $testResponse2->addReplace("this", "is", "a", "replacement"); $testResponseOutput = htmlspecialchars($testResponse2->getXML()); $objResponse = new xajaxResponse(); $objResponse->addAssign("submittedDiv", "innerHTML", $testResponseOutput); return $objResponse; }
/** * This is the main communications engine of xajax. The engine handles all * incoming xajax requests, calls the apporiate PHP functions (or * class/object methods) and passes the XML responses back to the * Javascript response handler. If your RequestURI is the same as your Web * page then this function should be called before any headers or HTML has * been sent. */ function processRequests() { $requestMode = -1; $sFunctionName = ""; $bFoundFunction = true; $bFunctionIsCatchAll = false; $sFunctionNameForSpecial = ""; $aArgs = array(); $sPreResponse = ""; $bEndRequest = false; $sResponse = ""; $requestMode = $this->getRequestMode(); if ($requestMode == -1) { return; } if ($requestMode == XAJAX_POST) { $sFunctionName = $_POST["xajax"]; if (!empty($_POST["xajaxargs"])) { $aArgs = $_POST["xajaxargs"]; } } else { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); $sFunctionName = $_GET["xajax"]; if (!empty($_GET["xajaxargs"])) { $aArgs = $_GET["xajaxargs"]; } } // Use xajax error handler if necessary if ($this->bErrorHandler) { $GLOBALS['xajaxErrorHandlerText'] = ""; set_error_handler("xajaxErrorHandler"); } if ($this->sPreFunction) { if (!$this->_isFunctionCallable($this->sPreFunction)) { $bFoundFunction = false; $objResponse = new xajaxResponse(); $objResponse->addAlert("Unknown Pre-Function " . $this->sPreFunction); $sResponse = $objResponse->getXML(); } } //include any external dependencies associated with this function name if (array_key_exists($sFunctionName, $this->aFunctionIncludeFiles)) { ob_start(); include_once $this->aFunctionIncludeFiles[$sFunctionName]; ob_end_clean(); } if ($bFoundFunction) { $sFunctionNameForSpecial = $sFunctionName; if (!array_key_exists($sFunctionName, $this->aFunctions)) { if ($this->sCatchAllFunction) { $sFunctionName = $this->sCatchAllFunction; $bFunctionIsCatchAll = true; } else { $bFoundFunction = false; $objResponse = new xajaxResponse(); $objResponse->addAlert("Unknown Function {$sFunctionName}."); $sResponse = $objResponse->getXML(); } } else { if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode) { $bFoundFunction = false; $objResponse = new xajaxResponse(); $objResponse->addAlert("Incorrect Request Type."); $sResponse = $objResponse->getXML(); } } } if ($bFoundFunction) { for ($i = 0; $i < sizeof($aArgs); $i++) { // If magic quotes is on, then we need to strip the slashes from the args if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) { $aArgs[$i] = stripslashes($aArgs[$i]); } if (stristr($aArgs[$i], "<xjxobj>") != false) { $aArgs[$i] = $this->_xmlToArray("xjxobj", $aArgs[$i]); } else { if (stristr($aArgs[$i], "<xjxquery>") != false) { $aArgs[$i] = $this->_xmlToArray("xjxquery", $aArgs[$i]); } else { if ($this->bDecodeUTF8Input) { $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]); } } } } if ($this->sPreFunction) { $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs)); if (is_array($mPreResponse) && $mPreResponse[0] === false) { $bEndRequest = true; $sPreResponse = $mPreResponse[1]; } else { $sPreResponse = $mPreResponse; } if (is_a($sPreResponse, "xajaxResponse")) { $sPreResponse = $sPreResponse->getXML(); } if ($bEndRequest) { $sResponse = $sPreResponse; } } if (!$bEndRequest) { if (!$this->_isFunctionCallable($sFunctionName)) { $objResponse = new xajaxResponse(); $objResponse->addAlert("The Registered Function {$sFunctionName} Could Not Be Found."); $sResponse = $objResponse->getXML(); } else { if ($bFunctionIsCatchAll) { $aArgs = array($sFunctionNameForSpecial, $aArgs); } $sResponse = $this->_callFunction($sFunctionName, $aArgs); } if (is_a($sResponse, "xajaxResponse")) { $sResponse = $sResponse->getXML(); } if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) { $objResponse = new xajaxResponse(); $objResponse->addAlert("No XML Response Was Returned By Function {$sFunctionName}."); $sResponse = $objResponse->getXML(); } else { if ($sPreResponse != "") { $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities); $sNewResponse->loadXML($sPreResponse); $sNewResponse->loadXML($sResponse); $sResponse = $sNewResponse->getXML(); } } } } $sContentHeader = "Content-type: text/xml;"; if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) { $sContentHeader .= " charset=" . $this->sEncoding; } header($sContentHeader); if ($this->bErrorHandler && !empty($GLOBALS['xajaxErrorHandlerText'])) { $sErrorResponse = new xajaxResponse(); $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']); if ($this->sLogFile) { $fH = @fopen($this->sLogFile, "a"); if (!$fH) { $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile); } else { fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n"); fclose($fH); } } $sErrorResponse->loadXML($sResponse); $sResponse = $sErrorResponse->getXML(); } if ($this->bCleanBuffer) { while (@ob_end_clean()) { } } print $sResponse; if ($this->bErrorHandler) { restore_error_handler(); } if ($this->bExitAllowed) { exit; } }
function skipDiallist($dialnumber, $diallistid) { global $locate; $objResponse = new xajaxResponse(); $row = astercrm::getRecordByID($diallistid, 'diallist'); if ($row['dialnumber'] != '') { $row['callresult'] = 'skip'; astercrm::deleteRecord($row['id'], "diallist"); $row['dialednumber'] = $phoneNum; $row['dialedby'] = $_SESSION['curuser']['extension']; $row['trytime'] = $row['trytime'] + 1; astercrm::insertNewDialedlist($row); } else { $objResponse->addAlert($locate->translate("Option failed")); return $objResponse; } $objResponse->addScript("xajax_clearPopup()"); $objResponse->loadXML(getPrivateDialListNumber($_SESSION['curuser']['extension'])); return $objResponse; }
function pay($form_data) { global $BL, $INVOICE_DATA; prepareFinalData($INVOICE_DATA, $form_data); $objResponse = new xajaxResponse(CHARSET); //$objResponse->addConfirmCommands(1,$BL->props->lang['confirm_submit']); $objResponse->loadXML(reload('step7', 'step7')); return $objResponse; }
function waitingCalls($myValue) { global $db, $config; $locate = new Localization($_SESSION['curuser']['country'], $_SESSION['curuser']['language'], 'portal'); $objResponse = new xajaxResponse(); $curid = trim($myValue['curid']); // to improve system efficiency /************************** **************************/ // modified 2007/10/30 by solo // start //print_r($_SESSION);exit; //if ($_SESSION['curuser']['channel'] == '') $call = asterEvent::checkNewCall($curid, $_SESSION['curuser']['extension'], $_SESSION['curuser']['channel'], $_SESSION['curuser']['agent']); //else // $call = asterEvent::checkNewCall($curid,$_SESSION['curuser']['channel']); // end if ($call['status'] == '') { $title = $locate->Translate("waiting"); $status = 'idle'; //$call['curid'] = $curid; $direction = ''; $info = $locate->Translate("extension") . $_SESSION['curuser']['extension'] . "-" . $locate->Translate("stand_by"); } elseif ($call['status'] == 'incoming') { //incoming calls here $title = $call['callerid']; $stauts = 'ringing'; $direction = 'in'; $info = $locate->Translate("incoming") . ' ' . $call['callerid']; $trunk = split("-", $call['callerChannel']); //print_r($trunk);exit; $trunk_name = split('@', $trunk[0]); $info = $info . ' channel: ' . $trunk_name[0]; // get trunk info $mytrunk = astercrm::getTrunkinfo($trunk[0], $call['didnumber']); if ($mytrunk) { $infomsg = "<strong>" . $mytrunk['trunkname'] . "</strong><br>"; $infomsg .= mb_substr(astercrm::db2html($mytrunk['trunknote']), 0, 10, "UTF-8") . '...'; if ($call['didnumber'] != '') { $infomsg .= " |" . $locate->Translate("Callee id") . " : <b>" . $call['didnumber'] . "</b>"; } $objResponse->addAssign('divTrunkinfo', "innerHTML", $infomsg); } else { $trunk_name = split('@', $trunk[0]); $infomsg = $locate->Translate("no information get for trunk") . ": " . $trunk_name[0]; $objResponse->addAssign('divTrunkinfo', "innerHTML", $infomsg); } $objResponse->addAssign("iptSrcNumber", "value", $call['callerid']); $objResponse->addAssign("iptCallerid", "value", $call['callerid']); $objResponse->addAssign("btnHangup", "disabled", false); if ($config['system']['pop_up_when_dial_in']) { if (strlen($call['callerid']) > $config['system']['phone_number_length'] && $call['callerid'] != '<unknown>') { if ($myValue['popup'] == 'yes') { if ($config['system']['enable_external_crm'] == false) { $objResponse->loadXML(getContact($call['callerid'])); if ($config['system']['browser_maximize_when_pop_up'] == true) { $objResponse->addScript('maximizeWin();'); } } else { //use external link $myurl = $config['system']['external_crm_url']; $myurl = preg_replace("/\\%method/", "dial_in", $myurl); $myurl = preg_replace("/\\%callerid/", $call['callerid'], $myurl); $myurl = preg_replace("/\\%calleeid/", $_SESSION['curuser']['extension'], $myurl); if ($config['system']['open_new_window'] == false) { $mycrm = '<iframe id="mycrm" name="mycrm" src="' . $myurl . '" width="100%" frameBorder=0 scrolling=auto height="100%"></iframe>'; $objResponse->addAssign("divCrm", "innerHTML", $mycrm); } else { $javascript = "openwindow('" . $myurl . "')"; $objResponse->addScript($javascript); } } } } else { } } } elseif ($call['status'] == 'dialout') { //dailing out here $title = $call['callerid']; $status = 'dialing'; $direction = 'out'; $info = $locate->Translate("dial_out") . ' ' . $call['callerid']; $objResponse->addAssign("iptCallerid", "value", $call['callerid']); $objResponse->addAssign("btnHangup", "disabled", false); if ($call['didnumber'] != '') { $didinfo = $locate->Translate("Callee id") . " : " . $call['didnumber']; $objResponse->addAssign('divDIDinfo', 'innerHTML', $didinfo); } if ($config['system']['pop_up_when_dial_out']) { if (strlen($call['callerid']) > $config['system']['phone_number_length']) { if ($myValue['popup'] == 'yes') { if ($config['system']['enable_external_crm'] == false) { $objResponse->loadXML(getContact($call['callerid'])); if ($config['system']['browser_maximize_when_pop_up'] == true) { $objResponse->addScript('maximizeWin();'); } } else { //use external link $myurl = $config['system']['external_crm_url']; $myurl = preg_replace("/\\%method/", "dial_out", $myurl); $myurl = preg_replace("/\\%callerid/", $_SESSION['curuser']['extension'], $myurl); $myurl = preg_replace("/\\%calleeid/", $call['callerid'], $myurl); if ($config['system']['open_new_window'] == false) { $mycrm = '<iframe id="mycrm" name="mycrm" src="' . $myurl . '" width="100%" frameBorder=0 scrolling=auto height="100%"></iframe>'; $objResponse->addAssign("divCrm", "innerHTML", $mycrm); } else { $javascript = "openwindow('" . $myurl . "')"; $objResponse->addScript($javascript); } } } } } } // $objResponse->addScript('document.title='.$title.';'); // $objResponse->addAssign("status","innerHTML", $stauts ); $objResponse->addAssign("extensionStatus", "value", $stauts); //echo $call['uniqueid'];exit; $objResponse->addAssign("uniqueid", "value", $call['uniqueid']); $objResponse->addAssign("callerid", "value", $call['callerid']); $objResponse->addAssign("callerChannel", "value", $call['callerChannel']); $objResponse->addAssign("calleeChannel", "value", $call['calleeChannel']); $objResponse->addAssign("curid", "value", $call['curid']); $objResponse->addAssign("direction", "value", $direction); $objResponse->addAssign("myevents", "innerHTML", $info); return $objResponse; }
function saveDiallistMain($f) { global $locate; $objResponse = new xajaxResponse(); if ($f['dialnumber'] == '' || empty($f['dialnumber'])) { $objResponse->addAlert($locate->Translate("Dialnumber can not be empty")); return $objResponse->getXML(); } if ($f['campaignid'] == '') { $objResponse->addAlert($locate->Translate("Must select a campaign")); return $objResponse->getXML(); } // check if the assign number belong to this group if ($_SESSION['curuser']['usertype'] != 'admin') { $flag = false; if ($_SESSION['curuser']['usertype'] == 'groupadmin') { if ($f['assign'] == '') { $flag = true; } else { foreach ($_SESSION['curuser']['memberExtens'] as $extension) { if ($extension == $f['assign']) { $flag = true; break; } } } } else { if ($_SESSION['curuser']['extension'] == $f['assign']) { $flag = true; } } if (!$flag) { $objResponse->addAlert('"' . $locate->Translate("Cant insert, please confirm the assign number is in your group") . '"'); return $objResponse->getXML(); } } $id = Customer::insertNewDiallist($f); if ($id) { $objResponse->addAlert($locate->Translate("Add diallist succeed")); $objResponse->addAssign("formaddDiallistInfo", "style.visibility", "hidden"); $objResponse->addClear("formaddDiallistInfo", "innerHTML"); $objResponse->addScript("xajax_showDiallist('" . $_SESSION['curuser']['extension'] . "',0,0,5,'','','','formDiallistPannel','','');"); $objResponse->loadXML(getPrivateDialListNumber($_SESSION['curuser']['extension'])); } else { $objResponse->addAlert($locate->Translate("Add diallist failed")); } return $objResponse->getXML(); }