1
0
mirror of synced 2024-11-25 14:56:09 +03:00

default orderType fix

This commit is contained in:
Grisha Pomadchin 2014-07-09 14:42:45 +04:00
parent 120aa7c713
commit 743b29c484

View File

@ -464,11 +464,33 @@ class ICrmOrderActions
$dateFinish = $api->getGeneratedAt();
// default orderType
$defaultOrderType = 1;
// if it not a ph. entity
$dbOrderTypesList = CSalePersonType::GetList(
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
if ($arOrderTypesList = $dbOrderTypesList->Fetch())
$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) {
@ -479,24 +501,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;
}
// 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']);