mode change in options
This commit is contained in:
parent
0397aad602
commit
5ef7ec6538
@ -338,7 +338,7 @@ class ICrmOrderActions
|
||||
$resOrder = self::clearArr($resOrder);
|
||||
|
||||
if($send)
|
||||
return $api->createOrder($resOrder);
|
||||
return $api->orderEdit($resOrder);
|
||||
|
||||
return array(
|
||||
'order' => $resOrder,
|
||||
@ -392,7 +392,7 @@ class ICrmOrderActions
|
||||
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
|
||||
}
|
||||
|
||||
public static function expodeFIO($str) {
|
||||
public static function explodeFIO($str) {
|
||||
if(!$str)
|
||||
return array();
|
||||
|
||||
|
@ -21,8 +21,9 @@ class ICrmOrderEvent {
|
||||
* @param mixed $arFields - Order arFields
|
||||
*/
|
||||
function onUpdateOrder($ID, $arFields = array()) {
|
||||
//self::writeDataOnOrderCreate($ID);
|
||||
self::writeDataOnOrderCreate($ID);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* onSendOrderMail
|
||||
@ -61,7 +62,7 @@ class ICrmOrderEvent {
|
||||
}
|
||||
|
||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(Iself::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
|
||||
//saved cat params
|
||||
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
|
||||
|
@ -22,4 +22,9 @@ $MESS ['ERR_403'] = 'Неверный apiKey.';
|
||||
$MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.';
|
||||
$MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.';
|
||||
$MESS ['CANCELED'] = 'Флаг «Отменен»';
|
||||
$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.';
|
||||
$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.';
|
||||
|
||||
$MESS ['ICRM_OPTIONS_ORDER_DISCHARGE_TAB'] = 'Режим выгрузки заказов';
|
||||
$MESS ['ORDER_DISCH'] = 'Режим выгрузки заказов';
|
||||
$MESS ['DISCHARGE_AGENT'] = 'Выгрузка заказов с помощью агента';
|
||||
$MESS ['DISCHARGE_EVENTS'] = 'Выгрузка заказов по событию';
|
@ -11,6 +11,7 @@ $CRM_PAYMENT_TYPES = 'pay_types_arr';
|
||||
$CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
|
||||
$CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
||||
$CRM_ORDER_LAST_ID = 'order_last_id';
|
||||
$CRM_ORDER_DISCHARGE = 'order_discharge';
|
||||
|
||||
if(!CModule::IncludeModule('intaro.intarocrm')
|
||||
|| !CModule::IncludeModule('sale'))
|
||||
@ -132,11 +133,42 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
|
||||
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
|
||||
|
||||
$previousDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0);
|
||||
//order discharge mode
|
||||
// 0 - agent
|
||||
// 1 - event
|
||||
$orderDischarge = 0;
|
||||
$orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge']));
|
||||
|
||||
if (($orderDischarge != $previousDischarge) && ($orderDischarge == 0)) {
|
||||
// remove depenedencies
|
||||
UnRegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail");
|
||||
UnRegisterModuleDependences("sale", "OnOrderUpdate", $mid, "ICrmOrderEvent", "onUpdateOrder");
|
||||
// new agent
|
||||
$dateAgent = new DateTime();
|
||||
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
|
||||
$dateAgent->add($intAgent);
|
||||
CAgent::AddAgent(
|
||||
"ICrmOrderActions::uploadOrdersAgent();", $mid, "N", 600, // interval - 10 mins
|
||||
$dateAgent->format('d.m.Y H:i:s'), // date of first check
|
||||
"Y", // агент активен
|
||||
$dateAgent->format('d.m.Y H:i:s'), // date of first start
|
||||
30
|
||||
);
|
||||
} else if (($orderDischarge != $previousDischarge) && ($orderDischarge == 1)) {
|
||||
// remove agent
|
||||
CAgent::RemoveAgent("ICrmOrderActions::uploadOrdersAgent();", $mid);
|
||||
// event dependencies
|
||||
RegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail");
|
||||
RegisterModuleDependences("sale", "OnOrderUpdate", $mid, "ICrmOrderEvent", "onUpdateOrder");
|
||||
}
|
||||
|
||||
COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize($orderTypesArr));
|
||||
COption::SetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
|
||||
COption::SetOptionString($mid, $CRM_PAYMENT_TYPES, serialize($paymentTypesArr));
|
||||
COption::SetOptionString($mid, $CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
|
||||
COption::SetOptionString($mid, $CRM_PAYMENT, serialize($paymentArr));
|
||||
COption::SetOptionString($mid, $CRM_ORDER_DISCHARGE, $orderDischarge);
|
||||
|
||||
$uri .= '&ok=Y';
|
||||
LocalRedirect($uri);
|
||||
@ -249,6 +281,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
$optionsPayTypes = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_TYPES, 0));
|
||||
$optionsPayStatuses = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_STATUSES, 0)); // --statuses
|
||||
$optionsPayment = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT, 0));
|
||||
$optionsDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0);
|
||||
|
||||
$aTabs = array(
|
||||
array(
|
||||
@ -263,6 +296,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
"ICON" => '',
|
||||
"TITLE" => GetMessage('ICRM_OPTIONS_CATALOG_CAPTION')
|
||||
),
|
||||
array(
|
||||
"DIV" => "edit4",
|
||||
"TAB" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_TAB'),
|
||||
"ICON" => '',
|
||||
"TITLE" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_CAPTION')
|
||||
)
|
||||
);
|
||||
$tabControl = new CAdminTabControl("tabControl", $aTabs);
|
||||
$tabControl->Begin();
|
||||
@ -394,6 +433,18 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php $tabControl->BeginNextTab(); ?>
|
||||
<input type="hidden" name="tab" value="catalog">
|
||||
<tr class="heading">
|
||||
<td colspan="2"><b><?php echo GetMessage('ORDER_DISCH'); ?></b></td>
|
||||
</tr>
|
||||
<tr class="heading">
|
||||
<td colspan="2">
|
||||
<b>
|
||||
<label><input class="addr" type="radio" name="order-discharge" value="0" <?php if($optionsDischarge == 0) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_AGENT'); ?></label>
|
||||
<label><input class="addr" type="radio" name="order-discharge" value="1" <?php if($optionsDischarge == 1) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_EVENTS'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $tabControl->Buttons(); ?>
|
||||
<input type="hidden" name="Update" value="Y" />
|
||||
<input type="submit" title="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_TITLE'); ?>" value="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_VALUE'); ?>" name="btn-update" class="adm-btn-save" />
|
||||
|
Loading…
Reference in New Issue
Block a user