/** * save group record * @param f array group record * @return objResponse object xajax response object */ function save($f) { global $locate, $db, $config; $objResponse = new xajaxResponse(); if (trim($f['groupname']) == '' || trim($f['resellerid']) == 0) { $objResponse->addAlert('*' . $locate->Translate("obligatory fields")); return $objResponse; } if ($config['synchronize']['id_autocrement_byset']) { $local_lastid = astercrm::getLocalLastId('accountgroup'); $f['id'] = intval($local_lastid + 1); } $f['creditlimit'] = trim($f['creditlimit']); if ($f['creditlimit'] == '' or !is_numeric($f['creditlimit'])) { $f['creditlimit'] = 0; } $id = astercrm::checkValues("accountgroup", "groupname", $f['groupname']); if ($id != '') { $objResponse->addAlert($locate->Translate("Groupname Duplicate")); return $objResponse->getXML(); } $respOk = Customer::insertNewAccountgroup($f); // add a new group if ($respOk) { $html = createGrid(0, ROWSXPAGE); $objResponse->addAssign("grid", "innerHTML", $html); $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("add_group")); $objResponse->addAssign("formDiv", "style.visibility", "hidden"); $objResponse->addClear("formDiv", "innerHTML"); } else { $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_insert")); } return $objResponse->getXML(); }
/** * save account record * @param f array account record * @return objResponse object xajax response object */ function save($f) { global $locate, $db, $config; $objResponse = new xajaxResponse(); //check clid could only be numuric if (!is_numeric($f['clid'])) { $objResponse->addAlert("clid must be numeric"); return $objResponse; } if (trim($f['pin']) == '') { $objResponse->addAlert("pin field cant be null"); return $objResponse; } if ($f['groupid'] == 0 || $f['resellerid'] == 0) { $objResponse->addAlert($locate->Translate("Please choose reseller and group")); return $objResponse->getXML(); } if ($config['synchronize']['id_autocrement_byset']) { $local_lastid = astercrm::getLocalLastId('clid'); $f['id'] = intval($local_lastid + 1); } // check if clid duplicate $res = astercrm::checkValues("clid", "clid", $f['clid']); if ($res != '') { $objResponse->addAlert($locate->Translate("clid duplicate")); return $objResponse->getXML(); } if ($f['display'] == '') { $f['display'] = $f['clid']; } // check if pin duplicate $res = astercrm::checkValues("clid", "pin", $f['pin']); if ($res != '') { $objResponse->addAlert($locate->Translate("pin duplicate")); return $objResponse->getXML(); } $respOk = Customer::insertNewClid($f); // add a new account if ($respOk) { $html = createGrid(0, ROWSXPAGE); $objResponse->addAssign("grid", "innerHTML", $html); $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("add_clid")); $objResponse->addAssign("formDiv", "style.visibility", "hidden"); $objResponse->addClear("formDiv", "innerHTML"); } else { $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_insert")); } return $objResponse->getXML(); }
function importResource($filePath, $order, $tableName, $tableStructure, $dialListField, $date, $groupid, $resellerid) { global $db, $config; $arrData = getSourceData($filePath); if ($config['synchronize']['id_autocrement_byset']) { $local_lastid = astercrm::getLocalLastId($tableName); if (empty($local_lastid)) { $local_lastid = $config['local_host']['minId']; } } $tableAffectRows = 0; foreach ($arrData as $arrRow) { if ($config['synchronize']['id_autocrement_byset']) { $local_lastid++; array_unshift($arrRow, $local_lastid); } $arrRes = parseRowToSql($arrRow, $order, $dialListField, $tableStructure, $tableName, $date, $groupid, $resellerid); $strSql = $arrRes['strSql']; //得到插入选择表的sql语句 if ($tableName != '' && $strSql != '') { $res = $db->query($strSql); $tableAffectRows += $db->affectedRows(); //得到影响的数据条数 } } return $tableAffectRows; }
/** * save account record * @param f array account record * @return objResponse object xajax response object */ function save($f) { global $locate, $db, $config; $objResponse = new xajaxResponse(); if ($config['synchronize']['id_autocrement_byset']) { $local_lastid = astercrm::getLocalLastId('account'); $f['id'] = intval($local_lastid + 1); } $f['username'] = trim($f['username']); $f['password'] = trim($f['password']); if ($f['username'] == '' || $f['password'] == '') { $objResponse->addAlert($locate->Translate("Please enter the username and password")); return $objResponse->getXML(); } if ($f['usertype'] == '') { $objResponse->addAlert($locate->Translate("Please select usertype")); return $objResponse->getXML(); } if ($f['resellerid'] == 0 && $f['usertype'] == 'reseller') { $objResponse->addAlert($locate->Translate("Please choose a reseller")); return $objResponse->getXML(); } if (($f['groupid'] == 0 || $f['resellerid'] == 0) && ($f['usertype'] == 'groupadmin' || $f['usertype'] == 'operator')) { $objResponse->addAlert($locate->Translate("Please choose reseller and group")); return $objResponse->getXML(); } $id = astercrm::checkValues("account", "username", $f['username']); if ($id != '') { $objResponse->addAlert($locate->Translate("Username Duplicate")); return $objResponse->getXML(); } $respOk = Customer::insertNewAccount($f); // add a new account if ($respOk) { $html = createGrid(0, ROWSXPAGE); $objResponse->addAssign("grid", "innerHTML", $html); $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("add_account")); $objResponse->addAssign("formDiv", "style.visibility", "hidden"); $objResponse->addClear("formDiv", "innerHTML"); } else { $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_insert")); } return $objResponse->getXML(); }
/** * save account record * @param f array account record * @return objResponse object xajax response object */ function save($f) { global $locate, $config; $objResponse = new xajaxResponse(); // check if clid duplicate $res = astercrm::checkRateDuplicate("callshoprate", $f, "insert"); if ($res != '') { $objResponse->addAlert("rate duplicate"); return $objResponse->getXML(); } if ($config['synchronize']['id_autocrement_byset']) { $local_lastid = astercrm::getLocalLastId('callshoprate'); $f['id'] = intval($local_lastid + 1); } $respOk = Customer::insertNewRate($f); // add a new account if ($respOk) { $html = createGrid(0, ROWSXPAGE); $objResponse->addAssign("grid", "innerHTML", $html); $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("Rate Added")); $objResponse->addAssign("formDiv", "style.visibility", "hidden"); $objResponse->addClear("formDiv", "innerHTML"); } else { $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("can not insert rate")); } return $objResponse->getXML(); }
/** * save group record * @param f array group record * @return objResponse object xajax response object */ function save($f) { global $locate, $db, $config; $objResponse = new xajaxResponse(); //print_r($f);exit; if (trim($f['resellername']) == '') { $objResponse->addAlert($locate->Translate("please enter the resellername")); return $objResponse; } $f['creditlimit'] = trim($f['creditlimit']); if ($f['creditlimit'] == '' or !is_numeric($f['creditlimit'])) { $f['creditlimit'] = 0; } //print_r($f);exit; // if($f['routetype'] == 'customize') { // $f['trunkname'] = trim($f['trunkname']); // if($f['trunkname'] == '') { // $objResponse->addAlert($locate->Translate("please enter the trunkname")); // return $objResponse; // } // $f['detail'] = trim($f['detail']); // if($f['detail'] == '') { // $objResponse->addAlert($locate->Translate("please enter the detail")); // return $objResponse; // } // if(trim($f['timeout']) == '') { // $f['timeout'] = 0; // } // $pin = Customer::generateUniquePin(10); // $n = array('trunkname'=>$f['trunkname'],'trunkprotocol'=>$f['protocoltype'],'registrystring'=>$f['registrystring'],'detail'=>$f['detail'],'timeout'=>$f['timeout'],'trunkprefix'=>$f['trunkprefix'],'removeprefix'=>$f['removeprefix'],'trunkidentity'=>$pin); // $resTrunk = Customer::insertNewTrunk($n); // $f['trunk_id'] = $resTrunk; // } else if($f['routetype'] == 'default') { //$f['trunk_id'] = -1; // } else if($f['routetype'] == 'auto'){ //$f['trunk_id'] = 0; // } if ($f['trunk1_id'] != $f['tmptrunk1id'] && $f['tmptrunk1id'] > 0) { Customer::deleteRecord($f['tmptrunk1id'], 'trunks'); } if ($f['trunk2_id'] != $f['tmptrunk2id'] && $f['tmptrunk2id'] > 0) { Customer::deleteRecord($f['tmptrunk2id'], 'trunks'); } if ($config['synchronize']['id_autocrement_byset']) { $local_lastid = astercrm::getLocalLastId('resellergroup'); $f['id'] = intval($local_lastid + 1); } $respOk = Customer::insertNewResellergroup($f); // add a new group if ($respOk) { $html = createGrid(0, ROWSXPAGE); $objResponse->addAssign("grid", "innerHTML", $html); $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("Add Reseller")); $objResponse->addAssign("formDiv", "style.visibility", "hidden"); $objResponse->addClear("formDiv", "innerHTML"); } else { $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("rec_cannot_insert")); } //generate include file if ($_SESSION['curuser']['usertype'] == 'admin') { astercc::generateResellerFile(); } return $objResponse->getXML(); }