Esempio n. 1
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null, $order = '')
{
    global $locate, $db;
    #print_r($searchFormValue);exit;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $searchType = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    //搜索方式 数组
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    $allOrAnswer = $searchFormValue['allOrAnswer'];
    #选中的radio值
    if ($optionFlag == "export" || $optionFlag == "exportcsv") {
        $fieldArray = array('mycdr.*', 'astercrm_accountgroup.groupname', 'astercrm_account.username');
        $leftjoinArray = array('astercrm_accountgroup' => array('astercrm_accountgroup.id', 'mycdr.astercrm_groupid'), 'astercrm_account' => array('astercrm_account.id', 'mycdr.accountid'));
        if ($searchFormValue['allOrAnswer'] == 'answered') {
            $searchContent[] = '0';
            $searchField[] = 'billsec';
            $searchType[] = 'more';
        }
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'mycdr', $fieldArray, $leftjoinArray);
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addAssign("exporttype", "value", $optionFlag);
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } else {
        if ($type == "delete") {
            $res = Customer::deleteRecord($id, 'account');
            if ($res) {
                $html = createGrid('', '', $searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $order, $divName, $ordering, $searchType, $allOrAnswer);
                $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, $allOrAnswer);
        }
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}
Esempio n. 2
0
function searchFormSubmit($searchFormValue, $numRows, $limit, $id, $type)
{
    global $locate, $db, $config;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    //搜索方式 数组
    $divName = "grid";
    if ($optionFlag == "export") {
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'clid');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($optionFlag == "delete") {
        if (empty($_SESSION['curuser']['usertype'])) {
            $objResponse->addAlert($locate->Translate("Session time out,please try again"));
            return $objResponse->getXML();
        }
        if ($_SESSION['curuser']['usertype'] == 'groupadmin') {
            $searchContent[] = $_SESSION['curuser']['groupid'];
            $searchField[] = 'groupid';
            $searchType[] = 'equal';
        } elseif ($_SESSION['curuser']['usertype'] == 'reseller') {
            $searchContent[] = $_SESSION['curuser']['resellerid'];
            $searchField[] = 'resellerid';
            $searchType[] = 'equal';
        }
        if ($config['synchronize']['delete_by_use_history']) {
            astercrm::deleteToHistoryFromSearch($searchContent, $searchField, $searchType, 'clid');
        } else {
            astercrm::deletefromsearch($searchContent, $searchField, $searchType, 'clid');
        }
        $html = createGrid($numRows, $limit, '', '', '', $divName, "", $searchType);
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    } elseif ($type == "delete") {
        if (empty($_SESSION['curuser']['usertype'])) {
            $objResponse->addAlert($locate->Translate("Session time out,please try again"));
            return $objResponse->getXML();
        }
        if ($config['synchronize']['delete_by_use_history']) {
            $res = Customer::deleteRecordToHistory('id', $id, 'clid');
        } else {
            $res = Customer::deleteRecord($id, 'clid');
        }
        if ($res) {
            $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $searchField, $divName, "", $searchType);
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("record deleted"));
            $objResponse->addAssign($divName, "innerHTML", $html);
        } else {
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("record cannot be deleted"));
        }
    } else {
        $html = createGrid($numRows, $limit, $searchField, $searchContent, $searchField, $divName, "", $searchType);
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}
Esempio n. 3
0
/**
*  update ticketcategory record
*  @param	f			array		account record
*  @return	objResponse	object		xajax response object
*/
function update($f)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    if (trim($f['ticketcategoryid']) == 0 || trim($f['ticketid']) == 0 || trim($f['customerid']) == 0) {
        $objResponse->addAlert($locate->Translate("obligatory_fields"));
        return $objResponse->getXML();
    }
    $validParentTicket = true;
    if ($f['parent_id'] != '') {
        if (!preg_match('/^[\\d]*$/', $f['parent_id'])) {
            $objResponse->addAlert($locate->Translate("Parent TicketDetail ID must be integer"));
            return $objResponse->getXML();
        }
        //验证写入的parent_id 是否存在
        $validParentTicket = Customer::validParentTicketId($f['parent_id']);
    }
    $oriResult = Customer::getOriResult($f['id']);
    //if ( $f['usertype'] == 'admin' ) $f['groupid'] = 0;
    // check over
    $respOk = Customer::updateTicketDetail($f);
    if ($respOk) {
        if (!$validParentTicket) {
            $objResponse->addAlert($locate->Translate("Update Success,but Parent TicketDetail ID is not exists"));
        }
        $new_assign = '';
        if ($f['assignto'] != 0) {
            $new_assign = Customer::getAssignToName($f['assignto']);
        }
        $ori_assign = '';
        if ($oriResult['assignto'] != 0) {
            $ori_assign = Customer::getAssignToName($oriResult['assignto']);
        }
        // track the ticket_op_logs
        if ($oriResult['status'] != $f['status']) {
            Customer::ticketOpLogs('update', 'status', $oriResult['status'], $f['status'], $new_assign, $f['groupid']);
        }
        if ($oriResult['assignto'] != $f['assignto']) {
            Customer::ticketOpLogs('update', 'assignto', $ori_assign, $new_assign, $new_assign, $f['groupid']);
        }
        $html = createGrid(0, ROWSXPAGE);
        $objResponse->addAssign("grid", "innerHTML", $html);
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("update_rec"));
        $objResponse->addAssign("formDiv", "style.visibility", "hidden");
    } else {
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_update"));
    }
    return $objResponse->getXML();
}
Esempio n. 4
0
function saveCustomerLeadNote($f)
{
    global $locate;
    $objResponse = new xajaxResponse();
    $respOk = Customer::saveCustomerLeadNote($f);
    if ($respOk) {
        $objResponse->addAssign("formNoteInfo", "style.visibility", "hidden");
        $objResponse->addClear("formNoteInfo", "innerHTML");
        $html = createGrid(0, ROWSXPAGE);
        $objResponse->addAssign("grid", "innerHTML", $html);
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("a_new_note_added"));
    } else {
        $objResponse->addAlert('can not add note');
    }
    return $objResponse;
}
Esempio n. 5
0
function searchFormSubmit($searchFormValue, $numRows, $limit, $id, $type)
{
    global $locate, $db, $config;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    //搜索方式 数组
    $divName = "grid";
    if ($optionFlag == "export") {
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'accountgroup');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($type == "delete") {
        if ($config['synchronize']['delete_by_use_history']) {
            $res = Customer::deleteRecordToHistory('groupid', $id, 'clid');
            $res = Customer::deleteRecordToHistory('groupid', $id, 'myrate');
            $res = Customer::deleteRecordToHistory('groupid', $id, 'callshoprate');
            $res = Customer::deleteRecordToHistory('groupid', $id, 'account');
            $res = Customer::deleteRecordToHistory('id', $id, 'accountgroup');
        } else {
            $res = Customer::deleteRecords('groupid', $id, 'clid');
            $res = Customer::deleteRecords('groupid', $id, 'myrate');
            $res = Customer::deleteRecords('groupid', $id, 'callshoprate');
            $res = Customer::deleteRecords('groupid', $id, 'account');
            $res = Customer::deleteRecord($id, 'accountgroup');
        }
        if ($res) {
            $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $searchField, $divName, "", $searchType);
            $objResponse = new xajaxResponse();
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("delete_rec"));
            $objResponse->addClear("msgZone", "innerHTML");
            $objResponse->addAssign($divName, "innerHTML", $html);
        } else {
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_delete"));
        }
    } else {
        $html = createGrid($numRows, $limit, $searchField, $searchContent, $searchField, $divName, "", $searchType);
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}
Esempio n. 6
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    if ($optionFlag == "export") {
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'worktimes');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($type == "delete") {
        $row = Customer::getRecordByField('worktime_id', $id, 'worktimepackage_worktimes');
        if ($row['id'] != '') {
            $objResponse->addAlert($locate->Translate("this worktime in one or more package, can not delete"));
            return $objResponse->getXML();
        }
        $res = Customer::deleteRecord($id, 'worktimes');
        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"));
            $objResponse->addAssign($divName, "innerHTML", $html);
        } 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();
}
Esempio n. 7
0
/**
*  update ticketcategory record
*  @param	f			array		account record
*  @return	objResponse	object		xajax response object
*/
function update($f)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    if (trim($f['templatetitle']) == '') {
        $objResponse->addAlert($locate->Translate("obligatory_fields"));
        return $objResponse->getXML();
    }
    $respOk = Customer::updateSmsTemplates($f);
    if ($respOk) {
        $html = createGrid(0, ROWSXPAGE);
        $objResponse->addAssign("grid", "innerHTML", $html);
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("update_rec"));
        $objResponse->addAssign("formDiv", "style.visibility", "hidden");
    } else {
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_update"));
    }
    return $objResponse->getXML();
}
Esempio n. 8
0
/**
*  update ticketcategory record
*  @param	ticketid	int			ticket id
*  @return	objResponse	object		xajax response object
*/
function delete($sms_sentsId = null)
{
    global $locate;
    $res = Customer::deleteRecord($sms_sentsId, 'sms_sents');
    if ($res) {
        $html = createGrid(0, ROWSXPAGE);
        $objResponse = new xajaxResponse();
        $objResponse->addAssign("grid", "innerHTML", $html);
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("delete_rec"));
    } else {
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_delete"));
    }
    return $objResponse->getXML();
}
Esempio n. 9
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $exportFlag = $searchFormValue['exportFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    $searchType = $searchFormValue['searchType'];
    if ($optionFlag == "export" || $optionFlag == "exportcsv") {
        $sql =& Customer::getOnlineSql($searchContent, $searchField, $searchType, 'astercrm_account', array('username', '(UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(last_login_time))' => 'onlinetime', 'last_login_time'));
        //得到要导出的sql语句
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addAssign("exporttype", "value", $optionFlag);
        $objResponse->addAssign("maintable", "value", "note_leads");
        //传递主表名,防止groupid等字段在各表中重复
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } else {
        $html = createGrid($numRows, $limit, $searchField, $searchContent, $order, $divName, $ordering, $searchType);
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}
Esempio n. 10
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $exportFlag = $searchFormValue['exportFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $divName = "grid";
    $searchType = $searchFormValue['searchType'];
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    if ($exportFlag == "1" || $optionFlag == "export") {
        // 需要特殊处理
        //		$sql = astercrm::getSql($searchContent,$searchField,$searchType,'surveyresult'); //得到要导出的sql语句
        $joinstr = astercrm::createSqlWithStype($searchField, $searchContent, $searchType, 'surveyresult');
        $objResponse->addAssign("hidSql", "value", $joinstr);
        //赋值隐含域
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($optionFlag == "delete") {
        astercrm::deletefromsearch($searchContent, $searchField, $searchType, 'surveyresult');
        $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], '', '', $order, $divName, $ordering, 1, 1, '');
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    } else {
        if ($type == "delete") {
            $res = Customer::deleteRecord($id, 'surveyresult');
            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 = new xajaxResponse();
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}
Esempio n. 11
0
function customerLeadsAction($leadType, $f, $searchFormValue)
{
    $objResponse = new xajaxResponse();
    if (is_array($f['ckb'])) {
        foreach ($f['ckb'] as $vaule) {
            $res_contact = astercrm::insertNewCustomerLead($vaule, $leadType, true);
        }
    }
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $numRows = $searchFormValue['numRows'];
    $limit = $searchFormValue['limit'];
    $html = createGrid($numRows, $limit, $searchField, $searchContent, '', 'grid');
    $objResponse->addAssign('grid', "innerHTML", $html);
    return $objResponse->getXML();
}
Esempio n. 12
0
function multiEditUpdate($searchContent = array(), $searchField = array(), $searchType = array(), $table, $f)
{
    global $db, $locate;
    $objResponse = new xajaxResponse();
    $searchContent = split(',', $searchContent);
    $searchField = split(',', $searchField);
    $searchType = split(',', $searchType);
    $i = 0;
    foreach ($searchField as $field) {
        if (trim($searchType[$i]) != '' && trim($searchContent[$i]) != '') {
            if ($field == 'resellername' && trim($searchType[$i]) != '' && trim($searchContent[$i]) != '') {
                if (trim($searchType[$i]) == "like") {
                    $whereResellername .= "AND resellername LIKE '%" . $searchContent[$i] . "%' ";
                } elseif (trim($searchType[$i]) == "equal") {
                    $whereResellername .= "AND resellername = '" . $searchContent[$i] . "' ";
                } elseif (trim($searchType[$i]) == "more") {
                    $whereResellername .= "AND resellername > '" . $searchContent[$i] . "' ";
                } elseif (trim($searchType[$i]) == "less") {
                    $whereResellername .= "AND resellername < '" . $searchContent[$i] . "' ";
                }
                $searchField[$i] = '';
            } elseif ($field == 'groupname') {
                if (trim($searchType[$i]) == "like") {
                    $whereGroupname .= "AND groupname like '%" . $searchContent[$i] . "%' ";
                } elseif (trim($searchType[$i]) == "equal") {
                    $whereGroupname .= "AND groupname = '" . $searchContent[$i] . "' ";
                } elseif (trim($searchType[$i]) == "more") {
                    $whereGroupname .= "AND groupname > '" . $searchContent[$i] . "' ";
                } elseif (trim($searchType[$i]) == "less") {
                    $whereGroupname .= "AND groupname < '" . $searchContent[$i] . "' ";
                }
                $searchField[$i] = '';
            }
            $i++;
        }
    }
    if ($whereResellername != '') {
        $sql = "SELECT id FROM resellergroup WHERE 1 " . $whereResellername;
        $resellerRes =& $db->query($sql);
        while ($resellerRes->fetchInto($row)) {
            $resellerJoinStr .= "AND resellerid = " . $row['id'] . " ";
        }
    }
    if ($whereGroupname != '') {
        $sql = "SELECT id FROM accountgroup WHERE 1 " . $whereGroupname;
        $groupRes =& $db->query($sql);
        while ($groupRes->fetchInto($row)) {
            $groupJoinStr .= "AND groupid = " . $row['id'] . " ";
        }
    }
    $joinstr = astercrm::createSqlWithStype($searchField, $searchContent, $searchType);
    list($field, $fieldType) = split(',', $f['multieditField']);
    $sucessNum = 0;
    if ($f['multioption'] == 'modify') {
        $query = "SELECT id," . trim($field) . " FROM " . $table . " WHERE 1 " . $joinstr . $groupJoinStr . $resellerJoinStr;
        astercrm::events($query);
        $res = $db->query($query);
        while ($res->fetchInto($row)) {
            if ($f['multieditcontent'] != '') {
                if ($f['multieditType'] == 'to') {
                    if ($fieldType == 'int' || $fieldType == 'real') {
                        if (!is_numeric($f['multieditcontent'])) {
                            $objResponse->addAlert($locate->Translate("Must fill number in blank for field") . ":" . $field);
                            return $objResponse;
                        }
                    }
                    $newValue = $f['multieditcontent'];
                } else {
                    if (!is_numeric($f['multieditcontent'])) {
                        $objResponse->addAlert($locate->Translate("Must fill number in blank for field") . ":" . $field);
                        return $objResponse;
                    }
                    if ($f['multieditType'] == 'plus') {
                        $newValue = $row[$field] + $f['multieditcontent'];
                    } elseif ($f['multieditType'] == 'minus') {
                        $newValue = $row[$field] - $f['multieditcontent'];
                    } elseif ($f['multieditType'] == 'multiply') {
                        $newValue = $row[$field] * $f['multieditcontent'];
                    }
                }
                $updateSql = "UPDATE " . $table . " SET " . trim($field) . " = '" . $newValue . "'";
                if ($f['resellerid'] != '') {
                    $updateSql .= ", resellerid =" . $f['resellerid'] . ", groupid =" . $f['groupid'];
                }
                $updateSql .= ",addtime = now() WHERE id = " . $row['id'];
            } else {
                if ($f['resellerid'] != '') {
                    $updateSql = "UPDATE " . $table . " SET resellerid =" . $f['resellerid'] . ", groupid =" . $f['groupid'] . ",addtime = now() WHERE id = " . $row['id'];
                } else {
                    $objResponse->addAlert($locate->Translate("No Option"));
                    return $objResponse;
                }
            }
            astercrm::events($updateSql);
            $updateRes = $db->query($updateSql);
            if ($updateRes === 1) {
                $sucessNum++;
            }
        }
        $objResponse->addAlert($sucessNum . $locate->Translate("records have been changed"));
    } elseif ($f['multioption'] == 'duplicate') {
        $query = "SELECT * FROM " . $table . " WHERE 1 " . $joinstr . $groupJoinStr . $resellerJoinStr;
        astercrm::events($query);
        $res =& $db->query($query);
        while ($res->fetchInto($row)) {
            $insertField = '';
            $insertValue = '';
            if ($f['multieditcontent'] != '') {
                if ($f['multieditType'] == 'to') {
                    if ($fieldType == 'int' || $fieldType == 'real') {
                        if (!is_numeric($f['multieditcontent'])) {
                            $objResponse->addAlert($locate->Translate("Must fill number in blank for field") . ":" . $field);
                            return $objResponse;
                        }
                    }
                    $newValue = $f['multieditcontent'];
                } else {
                    if (!is_numeric($f['multieditcontent'])) {
                        $objResponse->addAlert($locate->Translate("Must fill number in blank for field") . ":" . $field);
                        return $objResponse;
                    }
                    if ($f['multieditType'] == 'plus') {
                        $newValue = $row[$field] + $f['multieditcontent'];
                    } elseif ($f['multieditType'] == 'minus') {
                        $newValue = $row[$field] - $f['multieditcontent'];
                    } elseif ($f['multieditType'] == 'multiply') {
                        $newValue = $row[$field] * $f['multieditcontent'];
                    }
                }
                foreach ($row as $key => $value) {
                    if (!preg_match("/id\$/", $key) && $key != 'addtime') {
                        $insertField .= $key . ",";
                        if ($key != $field) {
                            $insertValue .= "'" . $value . "',";
                        } else {
                            $insertValue .= "'" . $newValue . "',";
                        }
                    }
                }
                $insertField .= "resellerid,groupid";
                if ($f['resellerid'] != '') {
                    $insertValue .= $f['resellerid'] . "," . $f['groupid'];
                } else {
                    $insertValue .= $row['resellerid'] . "," . $row['groupid'];
                }
            } else {
                foreach ($row as $key => $value) {
                    if (!preg_match("/id\$/", $key) && $key != 'addtime') {
                        $insertField .= $key . ",";
                        $insertValue .= "'" . $value . "',";
                    }
                }
                if ($f['resellerid'] != '') {
                    $insertField .= " resellerid,groupid";
                    $insertValue .= $f['resellerid'] . "," . $f['groupid'];
                } else {
                    $objResponse->addAlert($locate->Translate("No Option"));
                    return $objResponse;
                }
            }
            $insertField = "(" . $insertField . ",addtime)";
            $insertValue = "(" . $insertValue . ",now())";
            $insertSql = "INSERT INTO " . $table . " " . $insertField . " VALUES " . $insertValue;
            //echo $insertSql;exit;
            astercrm::events($insertSql);
            $insertRes = $db->query($insertSql);
            if ($insertRes === 1) {
                $sucessNum++;
            }
        }
        $objResponse->addAlert($sucessNum . $locate->Translate("records have been added"));
    }
    $html = createGrid(0, 25, $searchField, $searchContent, $searchField, 'grid', "", 1, 1, $searchType, $f['displaymode']);
    $objResponse->addClear("msgZone", "innerHTML");
    $objResponse->addAssign('grid', "innerHTML", $html);
    return $objResponse;
}
Esempio n. 13
0
function searchFormSubmit($searchFormValue, $numRows, $limit, $id = '', $type = '')
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $searchType = array();
    $customerid = $searchFormValue['customerid'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    //搜索方式 数组
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    if ($type == "delete") {
        $res = Customer::deleteRecord($id, 'account');
        if ($res) {
            $html = createGrid($customerid, $searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $searchField, $divName, "", $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($customerid, $numRows, $limit, $searchField, $searchContent, $order, $divName, $ordering, $searchType);
    }
    $html .= Table::Footer();
    $objResponse->addClear("msgZone", "innerHTML");
    $objResponse->addAssign($divName, "innerHTML", $html);
    return $objResponse->getXML();
}
Esempio n. 14
0
function archiveCDR($archiveDate)
{
    global $db, $locate, $config;
    $objResponse = new xajaxResponse();
    $date = date("Y-m-d");
    $end_date = date("Y-m-d", strtotime("{$date} - {$archiveDate} month"));
    if ($config['system']['useHistoryCdr'] == 1) {
        $table = 'historycdr';
    } else {
        $table = 'mycdr';
    }
    $sql = "SELECT calldate FROM {$table} WHERE calldate < '" . $end_date . "' ORDER BY calldate ASC LIMIT 1";
    $start_date = $db->getOne($sql);
    if ($start_date == '') {
        $objResponse->addAlert($locate->Translate('no cdr data early than') . " " . $archiveDate . " " . $locate->Translate('months'));
        $objResponse->addAssign("divMsg", "style.visibility", "hidden");
        $objResponse->addClear("msgZone", "innerHTML");
        return $objResponse->getXML();
    }
    $file_dir = $config['system']['upload_file_path'] . "cdr_archive";
    if (!is_dir($file_dir)) {
        if (!mkdir($file_dir)) {
            $objResponse->addAlert($locate->Translate('cant create archive directory'));
            $objResponse->addAssign("divMsg", "style.visibility", "hidden");
            $objResponse->addClear("msgZone", "innerHTML");
            return $objResponse->getXML();
        }
    }
    $start_date = split('\\ ', $start_date);
    $start_date = $start_date['0'];
    $file_name = $start_date . "_to_" . $end_date;
    if (!($handle = fopen($file_dir . "/" . $file_name . ".csv", 'x'))) {
        $objResponse->addAlert($locate->Translate('cant create archive file'));
        $objResponse->addAssign("divMsg", "style.visibility", "hidden");
        $objResponse->addClear("msgZone", "innerHTML");
        return $objResponse->getXML();
    }
    $sql = "SELECT * FROM {$table} WHERE calldate < '" . $end_date . "' ORDER BY calldate ASC";
    $archiveData = astercrm::exportDataToCSV($sql);
    if (!fwrite($handle, $archiveData)) {
        $objResponse->addAlert($locate->Translate('cant create archive file'));
        $objResponse->addAssign("divMsg", "style.visibility", "hidden");
        $objResponse->addClear("msgZone", "innerHTML");
        return $objResponse->getXML();
    }
    fclose($handle);
    system("tar zcf " . $file_dir . "/" . $file_name . ".tar.gz " . $file_dir . "/" . $file_name . ".csv", $r);
    if ($r === false) {
        $final_file = $file_dir . "/" . $file_name . ".csv";
    } else {
        $final_file = $file_dir . "/" . $file_name . ".tar.gz";
        unlink($file_dir . "/" . $file_name . ".csv");
    }
    $objResponse->addAlert($locate->Translate('archive success') . ", " . $locate->Translate('file save in') . ": " . $final_file);
    $sql = "DELETE FROM {$table} WHERE calldate < '" . $end_date . "'";
    $res = $db->query($sql);
    if ($res == 1) {
        $objResponse->addAlert($locate->Translate('clear cdr date success'));
    } else {
        $objResponse->addAlert($locate->Translate('clear cdr date failed'));
    }
    $html = createGrid(0, ROWSXPAGE);
    $objResponse->addAssign("divMsg", "style.visibility", "hidden");
    $objResponse->addClear("msgZone", "innerHTML");
    $objResponse->addAssign("grid", "innerHTML", $html);
    return $objResponse->getXML();
    //echo $file_name;exit;
}
Esempio n. 15
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    if ($optionFlag == "export" || $optionFlag == "exportcsv") {
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'astercrm_account');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addAssign("maintable", "value", 'astercrm_account');
        //赋值隐含域
        $objResponse->addAssign("exporttype", "value", $optionFlag);
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($optionFlag == "delete") {
        astercrm::deletefromsearch($searchContent, $searchField, $searchType, 'astercrm_account');
        $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], '', '', $order, $divName, $ordering, '');
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    } elseif ($type == "delete") {
        $myrow = astercrm::getRecordByField('username', $_SESSION['curuser']['username'], 'astercrm_account');
        $myid = $myrow['id'];
        //echo $myid;exit;
        if ($myid == $id) {
            $objResponse->addAlert($locate->Translate("Can not delete your own account"));
            return $objResponse->getXML();
        }
        $res = Customer::deleteRecord($id, 'astercrm_account');
        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"));
            $objResponse->addAssign($divName, "innerHTML", $html);
        } 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();
}
Esempio n. 16
0
function searchFormSubmit($searchFormValue, $numRows, $limit, $id, $type)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $deleteFlag = $searchFormValue['deleteFlag'];
    $exportFlag = $searchFormValue['exportFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    //搜索方式 数组
    $divName = "grid";
    if ($exportFlag == "1" || $optionFlag == "export") {
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'curcdr');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($deleteFlag == "1" || $optionFlag == "delete") {
        Customer::deleteFromSearch($searchContent, $searchField, $searchType, 'curcdr');
        $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], '', '', '', $divName, "", 1, $searchType);
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    } else {
        if ($type == "delete") {
            $res = Customer::deleteRecord($id, 'curcdr');
            if ($res) {
                $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $searchField, $divName, "", 1, $searchType);
                $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("record deleted"));
            } else {
                $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("record cannot be deleted"));
            }
        } else {
            $html = createGrid($numRows, $limit, $searchField, $searchContent, $searchField, $divName, "", 1, $searchType);
        }
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    }
    return $objResponse->getXML();
}
Esempio n. 17
0
function showGrid($start = 0, $limit = 1, $filter = null, $content = null, $order = null, $divName = "grid", $ordering = "")
{
    $html = createGrid($start, $limit, $filter, $content, $order, $divName, $ordering);
    $objResponse = new xajaxResponse();
    $objResponse->addClear("msgZone", "innerHTML");
    $objResponse->addAssign($divName, "innerHTML", $html);
    return $objResponse->getXML();
}
Esempio n. 18
0
function deleteByButton($f, $searchFormValue)
{
    $objResponse = new xajaxResponse();
    if (is_array($f['ckb'])) {
        foreach ($f['ckb'] as $vaule) {
            $res_customer = astercrm::deleteRecord($vaule, 'diallist');
        }
    }
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $numRows = $searchFormValue['numRows'];
    $limit = $searchFormValue['limit'];
    $html = createGrid($numRows, $limit, $searchField, $searchContent, $searchField, 'grid');
    $objResponse->addAssign('grid', "innerHTML", $html);
    return $objResponse->getXML();
}
Esempio n. 19
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    if ($optionFlag == "export" || $optionFlag == "exportcsv") {
        $fields = array();
        $fields[] = 'campaignresult.id';
        $fields[] = 'campaignresult.resultname';
        $fields[] = 'campaignresult.resultnote';
        $fields[] = 'campaignresult.status';
        $fields[] = 'presult.resultname AS parentresult';
        $fields[] = 'groupname';
        $fields[] = 'campaignname';
        $sql =& Customer::getRecordsFilteredMorewithstype('', '', $searchField, $searchContent, $searchType, $order, $table, $fields, 'export');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addAssign("exporttype", "value", $optionFlag);
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($type == "delete") {
        $res = Customer::deleteRecord($id, 'campaignresult');
        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"));
            $objResponse->addAssign($divName, "innerHTML", $html);
        } 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();
}
Esempio n. 20
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db, $config;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    $divName = "grid";
    if ($type == "delete") {
        if ($config['system']['portal_display_type'] == "note") {
            $res = Customer::deleteRecord($id, 'note');
        } else {
            $res = Customer::deleteRecord($id, 'customer');
        }
        if ($res) {
            $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $searchField, $divName, "");
            $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, $searchField, $divName, "", $searchType);
    }
    $objResponse->addClear("msgZone", "innerHTML");
    $objResponse->addAssign($divName, "innerHTML", $html);
    return $objResponse->getXML();
}
Esempio n. 21
0
function addGridToDB($data)
{
    $gridname = $data['grid_step1_name'];
    $description = $data['grid_step1_description'];
    $createdby = $_SESSION['username'];
    $createon = time();
    $criteria = array($gridname, $description, $createdby, $createon);
    $gridId = createGrid($criteria);
    $i = 1;
    $total = sizeof($data) - 3;
    $count = 1;
    for ($count = 1; $count < $total; $count += 3) {
        if (isset($data["grid_step2_column" . $i . "_name"]) && $data["grid_step2_column" . $i . "_name"] != null && strcmp($data["grid_step2_column" . $i . "_name"], "") != 0) {
            $columnname = $data["grid_step2_column" . $i . "_name"];
            $columndatatype = $data["grid_step2_column" . $i . "_datatype"];
            $columndesc = $data["grid_step2_column" . $i . "_description"];
            $criteria = array($gridId, $columnname, $columndesc, $columndatatype);
            $columnid = createColumn($criteria);
            $columndata = $data["grid_step2_column" . $i . "_data"];
            if (strcmp($columndatatype, "text") == 0) {
                $length = $columndata["grid_step2_column" . $i . "_text_size"];
                $allow_empty = $columndata["grid_step2_column" . $i . "_text_allow_empty"];
                if ($allow_empty == "") {
                    $allow_empty = 'N';
                } else {
                    $allow_empty = 'Y';
                }
                $isunique = $columndata["grid_step2_column" . $i . "_text_unique"];
                if ($isunique == "") {
                    $isunique = 'N';
                } else {
                    $isunique = 'Y';
                }
                $criteria = array($columnid, $length, $allow_empty, $isunique);
                createColumnText($criteria);
            } else {
                if (strcmp($columndatatype, "textarea") == 0) {
                    $size = $columndata["grid_step2_column" . $i . "_textarea_size"];
                    $criteria = array($columnid, $size);
                    createColumnTextarea($criteria);
                }
            }
            $insertid = "";
        }
        $i++;
    }
}
Esempio n. 22
0
function searchFormSubmit($searchFormValue, $numRows = null, $limit = null, $id = null, $type = null)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    $searchField = array();
    $searchContent = array();
    $optionFlag = $searchFormValue['optionFlag'];
    $searchContent = $searchFormValue['searchContent'];
    //搜索内容 数组
    $searchField = $searchFormValue['searchField'];
    //搜索条件 数组
    $searchType = $searchFormValue['searchType'];
    $ordering = $searchFormValue['ordering'];
    $order = $searchFormValue['order'];
    $divName = "grid";
    if ($optionFlag == "export") {
        $sql = astercrm::getSql($searchContent, $searchField, $searchType, 'astercrm_account');
        //得到要导出的sql语句
        $_SESSION['export_sql'] = $sql;
        $objResponse->addAssign("hidSql", "value", $sql);
        //赋值隐含域
        $objResponse->addScript("document.getElementById('exportForm').submit();");
    } elseif ($optionFlag == "delete") {
        astercrm::deletefromsearch($searchContent, $searchField, $searchType, 'astercrm_account');
        $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], '', '', $order, $divName, $ordering, '');
        $objResponse->addClear("msgZone", "innerHTML");
        $objResponse->addAssign($divName, "innerHTML", $html);
    } elseif ($type == "delete") {
        $arreglo =& Customer::getAllRecords($start, $limit, $order, $_SESSION['curuser']['groupid']);
        $content = '';
        foreach ($arreglo as $agents) {
            if ($agents['agent'] == $id) {
                continue;
            } else {
                $addstr = "\nagent => " . trim($agents['agent']) . ',' . trim($agents['password']) . ',' . trim($agents['name']);
            }
            $content .= $addstr;
        }
        $agentsfile = '/etc/asterisk/agents_astercc.conf';
        if ($fhandle = fopen($agentsfile, 'w')) {
            fwrite($fhandle, $content);
            $html = createGrid($searchFormValue['numRows'], $searchFormValue['limit'], $searchField, $searchContent, $order, $divName, $ordering, $searchType);
            $objResponse = new xajaxResponse();
            $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("delete_rec"));
            $objResponse->addAssign($divName, "innerHTML", $html);
        } 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();
}
Esempio n. 23
0
/**
*  update ticketcategory record
*  @param	f			array		account record
*  @return	objResponse	object		xajax response object
*/
function update($f)
{
    global $locate, $db;
    $objResponse = new xajaxResponse();
    if (trim($f['ticketname']) == '') {
        $objResponse->addAlert($locate->Translate("obligatory_fields"));
        return $objResponse->getXML();
    }
    if (trim($f['usertype']) != 'admin' && trim($f['groupid']) == '') {
        $objResponse->addAlert($locate->Translate("please add group first"));
        return $objResponse->getXML();
    }
    $respOk = Customer::updateTCategoryRecord($f);
    if ($respOk) {
        $html = createGrid(0, ROWSXPAGE);
        $objResponse->addAssign("grid", "innerHTML", $html);
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("update_rec"));
        $objResponse->addAssign("formDiv", "style.visibility", "hidden");
    } else {
        $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_update"));
    }
    return $objResponse->getXML();
}