function save($f) { $objResponse = new xajaxResponse(); global $locate, $config; $f['customer'] = trim($f['customer']); $f['contact'] = trim($f['contact']); if (empty($f['customer']) && empty($f['contact'])) { return $objResponse; } if (empty($f['customer'])) { $customerID = 0; } else { if ($f['customerid'] == '' || $f['customerid'] == 0) { if ($config['system']['allow_same_data'] == false) { //检查是否有完全匹配的customer记录 $customer = Customer::checkValues("customer", "customer", addslashes($f['customer'])); } else { $customer = ''; } //有完全匹配的话就取这个customerid if ($customer != '') { $respOk = $customer; $objResponse->addAlert($locate->Translate("found_customer_replaced")); } else { $respOk = Customer::insertNewCustomer($f); // insert a new customer record if (!$respOk) { $objResponse->addAlert($locate->Translate("customer_add_error")); return $objResponse; } $chtml = ''; if ($f['customer_leads_check'] != 'on' || $f['customer_leads_check'] == 'on' && $config['system']['customer_leads'] != 'move' && $config['system']['customer_leads'] != 'default_move') { //$objResponse->addScript('xajax_showCustomer(\''.$customerID.'\',\'customer\','.$callerid.');'); $chtml .= Table::Top($locate->Translate("customer_detail"), "formCustomerInfo"); $chtml .= Customer::showCustomerRecord($respOk, 'customer', $f['iptcallerid']); $chtml .= Table::Footer(); } $objResponse->addAlert($locate->Translate("a_new_customer_added")); } } else { $respOk = $f['customerid']; } $customerID = $respOk; } if (empty($f['contact'])) { $contactID = 0; } else { if ($f['contactid'] == '') { if ($config['system']['allow_same_data'] == false) { //检查是否有完全匹配的contact记录 $contact = Customer::checkValues("contact", "contact", $f['contact'], "string", "customerid", $customerID, "int"); } else { $contact = ''; } //有完全匹配的话就取这个contactid if ($contact != '') { $respOk = $contact; $objResponse->addAlert($locate->Translate("found_contact_replaced")); } else { $respOk = Customer::insertNewContact($f, $customerID); // insert a new contact record if (!$respOk) { $objResponse->addAlert($locate->Translate("contact_add_error")); return $objResponse; } $objResponse->addAlert($locate->Translate("a_new_contact_added")); } } else { $respOk = $f['contactid']; $res =& Customer::getContactByID($respOk); if ($res) { $contactCustomerID = $res['customerid']; if ($contactCustomerID == 0 && $customerID == 0) { } else { $res =& Customer::updateField('contact', 'customerid', $customerID, $f['contactid']); if ($res) { $objResponse->addAlert($locate->Translate("a_contact_binding")); } } } } $contactID = $respOk; } if ($f['surveyoption'] != '' || $f['surveynote'] != '') { $respOk = Customer::insertNewSurveyResult($f['surveyid'], $f['surveyoption'], $f['surveynote'], $customerID, $contactID); $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("survey_added")); } $saveNote = ''; if (!empty($f['note']) || !empty($f['note_code'])) { $saveNote = true; $respOk = Customer::insertNewNote($f, $customerID, $contactID); // add a new Note if ($respOk) { $html = createGrid(0, ROWSXPAGE); $objResponse->addAssign("grid", "innerHTML", $html); $objResponse->addAssign("msgZone", "innerHTML", $locate->Translate("a_new_note_added")); } else { $objResponse->addAlert($locate->Translate("note_add_error")); return $objResponse; } } else { $saveNote = false; } // 查看是否有scheduler call if ($f['addedSchedulerDialId'] != '') { $res = astercrm::updateAddedSchedulerDial($customerID, $f['addedSchedulerDialId']); $objResponse->addAssign("formdAddSechedualaraDiv", "style.visibility", "hidden"); $objResponse->addAssign("formdAddSechedualaraDiv", "innerHTML", ''); } /*if(empty($f['sDialNum'])) { } else{ $f['customerid'] = $customerID; $res = astercrm::insertNewSchedulerDial($f); if ($res){ $objResponse->addAlert($locate->Translate("Scheduler Call added")); } }*/ if ($f['customer_leads_check'] == 'on') { if ($customerID != '' && $customerID != 0) { astercrm::insertNewCustomerLead($customerID, $config['system']['customer_leads'], $saveNote); } } $objResponse->addAssign("formDiv", "style.visibility", "hidden"); $objResponse->addAssign("formCustomerInfo", "style.visibility", "hidden"); $objResponse->addAssign("formContactInfo", "style.visibility", "hidden"); $objResponse->addAssign("formNoteInfo", "style.visibility", "hidden"); $objResponse->addClear("formDiv", "innerHTML"); $objResponse->addClear("formCustomerInfo", "innerHTML"); $objResponse->addClear("formContactInfo", "innerHTML"); $objResponse->addClear("formNoteInfo", "innerHTML"); $objResponse->addScript("xajax_showGrid(0," . ROWSXPAGE . ",'','','')"); if ($chtml != '') { $objResponse->addAssign("formCustomerInfo", "style.visibility", "visible"); $objResponse->addAssign("formCustomerInfo", "innerHTML", $chtml); } return $objResponse->getXML(); }
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(); }