1
0
mirror of synced 2024-11-29 08:46: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(); $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 ! // apiv3 !
if(!$dateFinish) $dateFinish = new \DateTime(); if(!$dateFinish) $dateFinish = new \DateTime();
$GLOBALS['INTARO_CRM_FROM_HISTORY'] = true; $GLOBALS['INTARO_CRM_FROM_HISTORY'] = true;
self::eventLog('ICrmOrderActions::orderHistory', '$orderHistory', json_encode($orderHistory));
// pushing existing orders // pushing existing orders
foreach ($orderHistory as $order) { foreach ($orderHistory as $order) {
@ -479,24 +501,8 @@ class ICrmOrderActions
$orderType = intarocrm_set_order_type($order); $orderType = intarocrm_set_order_type($order);
if($orderType) if($orderType)
$optionsOrderTypes[$order['orderType']] = $orderType; $optionsOrderTypes[$order['orderType']] = $orderType;
else { else
$dbOrderTypesList = CSalePersonType::GetList( $optionsOrderTypes[$order['orderType']] = $defaultOrderType;
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
if ($arOrderTypesList = $dbOrderTypesList->Fetch())
$optionsOrderTypes[$order['orderType']] = $arOrderTypesList['ID'];
}
} }
// we dont need new orders without any customers (can check only for externalId) // we dont need new orders without any customers (can check only for externalId)
@ -563,7 +569,7 @@ class ICrmOrderActions
// new order // new order
$newOrderFields = array( $newOrderFields = array(
'LID' => $defaultSiteId, 'LID' => $defaultSiteId,
'PERSON_TYPE_ID' => ($optionsOrderTypes[$order['orderType']]) ? $optionsOrderTypes[$order['orderType']] : 1, 'PERSON_TYPE_ID' => ($optionsOrderTypes[$order['orderType']]) ? $optionsOrderTypes[$order['orderType']] : $defaultOrderType,
'PAYED' => 'N', 'PAYED' => 'N',
'CANCELED' => 'N', 'CANCELED' => 'N',
'STATUS_ID' => 'N', 'STATUS_ID' => 'N',
@ -577,6 +583,8 @@ class ICrmOrderActions
'USER_DESCRIPTION' => '' 'USER_DESCRIPTION' => ''
); );
self::eventLog('ICrmOrderActions::orderHistory', '$newOrderFields', json_encode($newOrderFields));
if(isset($order['number']) && $order['number']) if(isset($order['number']) && $order['number'])
$GLOBALS['ICRM_ACCOUNT_NUMBER'] = $order['number']; $GLOBALS['ICRM_ACCOUNT_NUMBER'] = $order['number'];
@ -611,24 +619,8 @@ class ICrmOrderActions
$orderType = intarocrm_set_order_type($order); $orderType = intarocrm_set_order_type($order);
if($orderType) if($orderType)
$optionsOrderTypes[$order['orderType']] = $orderType; $optionsOrderTypes[$order['orderType']] = $orderType;
else { else
$dbOrderTypesList = CSalePersonType::GetList( $optionsOrderTypes[$order['orderType']] = $defaultOrderType;
array(
"SORT" => "ASC",
"NAME" => "ASC"
),
array(
"ACTIVE" => "Y",
),
false,
false,
array()
);
if ($arOrderTypesList = $dbOrderTypesList->Fetch())
$optionsOrderTypes[$order['orderType']] = $arOrderTypesList['ID'];
}
} }
$arFields = CSaleOrder::GetById($order['externalId']); $arFields = CSaleOrder::GetById($order['externalId']);