default orderType fix
This commit is contained in:
parent
120aa7c713
commit
743b29c484
@ -464,22 +464,10 @@ class ICrmOrderActions
|
||||
|
||||
$dateFinish = $api->getGeneratedAt();
|
||||
|
||||
// apiv3 !
|
||||
if(!$dateFinish) $dateFinish = new \DateTime();
|
||||
// default orderType
|
||||
$defaultOrderType = 1;
|
||||
|
||||
$GLOBALS['INTARO_CRM_FROM_HISTORY'] = true;
|
||||
|
||||
// pushing existing orders
|
||||
foreach ($orderHistory as $order) {
|
||||
|
||||
if(!isset($order['externalId']) || !$order['externalId']) {
|
||||
|
||||
// custom orderType functunion
|
||||
if(function_exists('intarocrm_set_order_type')) {
|
||||
$orderType = intarocrm_set_order_type($order);
|
||||
if($orderType)
|
||||
$optionsOrderTypes[$order['orderType']] = $orderType;
|
||||
else {
|
||||
// if it not a ph. entity
|
||||
$dbOrderTypesList = CSalePersonType::GetList(
|
||||
array(
|
||||
"SORT" => "ASC",
|
||||
@ -494,9 +482,27 @@ class ICrmOrderActions
|
||||
);
|
||||
|
||||
if ($arOrderTypesList = $dbOrderTypesList->Fetch())
|
||||
$optionsOrderTypes[$order['orderType']] = $arOrderTypesList['ID'];
|
||||
$defaultOrderType = $arOrderTypesList['ID'];
|
||||
|
||||
}
|
||||
// apiv3 !
|
||||
if(!$dateFinish) $dateFinish = new \DateTime();
|
||||
|
||||
$GLOBALS['INTARO_CRM_FROM_HISTORY'] = true;
|
||||
|
||||
self::eventLog('ICrmOrderActions::orderHistory', '$orderHistory', json_encode($orderHistory));
|
||||
|
||||
// pushing existing orders
|
||||
foreach ($orderHistory as $order) {
|
||||
|
||||
if(!isset($order['externalId']) || !$order['externalId']) {
|
||||
|
||||
// custom orderType functunion
|
||||
if(function_exists('intarocrm_set_order_type')) {
|
||||
$orderType = intarocrm_set_order_type($order);
|
||||
if($orderType)
|
||||
$optionsOrderTypes[$order['orderType']] = $orderType;
|
||||
else
|
||||
$optionsOrderTypes[$order['orderType']] = $defaultOrderType;
|
||||
}
|
||||
|
||||
// we dont need new orders without any customers (can check only for externalId)
|
||||
@ -563,7 +569,7 @@ class ICrmOrderActions
|
||||
// new order
|
||||
$newOrderFields = array(
|
||||
'LID' => $defaultSiteId,
|
||||
'PERSON_TYPE_ID' => ($optionsOrderTypes[$order['orderType']]) ? $optionsOrderTypes[$order['orderType']] : 1,
|
||||
'PERSON_TYPE_ID' => ($optionsOrderTypes[$order['orderType']]) ? $optionsOrderTypes[$order['orderType']] : $defaultOrderType,
|
||||
'PAYED' => 'N',
|
||||
'CANCELED' => 'N',
|
||||
'STATUS_ID' => 'N',
|
||||
@ -577,6 +583,8 @@ class ICrmOrderActions
|
||||
'USER_DESCRIPTION' => ''
|
||||
);
|
||||
|
||||
self::eventLog('ICrmOrderActions::orderHistory', '$newOrderFields', json_encode($newOrderFields));
|
||||
|
||||
if(isset($order['number']) && $order['number'])
|
||||
$GLOBALS['ICRM_ACCOUNT_NUMBER'] = $order['number'];
|
||||
|
||||
@ -611,24 +619,8 @@ class ICrmOrderActions
|
||||
$orderType = intarocrm_set_order_type($order);
|
||||
if($orderType)
|
||||
$optionsOrderTypes[$order['orderType']] = $orderType;
|
||||
else {
|
||||
$dbOrderTypesList = CSalePersonType::GetList(
|
||||
array(
|
||||
"SORT" => "ASC",
|
||||
"NAME" => "ASC"
|
||||
),
|
||||
array(
|
||||
"ACTIVE" => "Y",
|
||||
),
|
||||
false,
|
||||
false,
|
||||
array()
|
||||
);
|
||||
|
||||
if ($arOrderTypesList = $dbOrderTypesList->Fetch())
|
||||
$optionsOrderTypes[$order['orderType']] = $arOrderTypesList['ID'];
|
||||
|
||||
}
|
||||
else
|
||||
$optionsOrderTypes[$order['orderType']] = $defaultOrderType;
|
||||
}
|
||||
|
||||
$arFields = CSaleOrder::GetById($order['externalId']);
|
||||
|
Loading…
Reference in New Issue
Block a user