1
0
mirror of synced 2024-11-22 05:16:09 +03:00

fio parsing fix

This commit is contained in:
Grisha Pomadchin 2013-09-09 16:43:44 +04:00
parent 5dd88b798d
commit 1524a94db0

View File

@ -260,6 +260,7 @@ class ICrmOrderActions
$resOrder = array(); $resOrder = array();
$resOrderDeliveryAddress = array(); $resOrderDeliveryAddress = array();
$contactNameArr = array();
$rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID'])); $rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID']));
while ($ar = $rsOrderProps->Fetch()) { while ($ar = $rsOrderProps->Fetch()) {
@ -275,7 +276,7 @@ class ICrmOrderActions
$resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']); $resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']);
} }
break; break;
case $arParams['optionsOrderProps']['fio']: $resOrder['contactName'] = explode(" ", self::toJSON($ar['VALUE'])); case $arParams['optionsOrderProps']['fio']:$contactNameArr = self::explodeFIO($ar['VALUE']);
break; break;
case $arParams['optionsOrderProps']['phone']: $resOrder['phone'] = $ar['VALUE']; case $arParams['optionsOrderProps']['phone']: $resOrder['phone'] = $ar['VALUE'];
break; break;
@ -339,10 +340,7 @@ class ICrmOrderActions
$createdAt = new \DateTime($arFields['DATE_INSERT']); $createdAt = new \DateTime($arFields['DATE_INSERT']);
$createdAt = $createdAt->format('Y-m-d H:i:s'); $createdAt = $createdAt->format('Y-m-d H:i:s');
$resOrder = self::clearArr(array( $resOrder = array(
'lastName' => $resOrder['contactName'][0],
'firstName' => $resOrder['contactName'][1],
'patronymic' => $resOrder['contactName'][2],
'phone' => $resOrder['phone'], 'phone' => $resOrder['phone'],
'email' => $resOrder['email'], 'email' => $resOrder['email'],
'deliveryCost' => $arFields['PRICE_DELIVERY'], 'deliveryCost' => $arFields['PRICE_DELIVERY'],
@ -359,11 +357,21 @@ class ICrmOrderActions
'createdAt' => $createdAt, 'createdAt' => $createdAt,
'deliveryAddress' => $resOrderDeliveryAddress, 'deliveryAddress' => $resOrderDeliveryAddress,
'items' => $items 'items' => $items
)); );
// parse fio
if(count($contactNameArr) == 1) {
$resOrder['firstName'] = $contactNameArr[0];
} else {
$resOrder['lastName'] = $contactNameArr['contactName'][0];
$resOrder['firstName'] = $contactNameArr['contactName'][1];
$resOrder['patronymic'] = $contactNameArr['contactName'][2];
}
if(isset($arParams['optionsSites']) && is_array($arParams['optionsSites']) if(isset($arParams['optionsSites']) && is_array($arParams['optionsSites'])
&& in_array($arFields['LID'], $arParams['optionsSites'])) && in_array($arFields['LID'], $arParams['optionsSites']))
$resOrder['site'] = $arFields['LID']; $resOrder['site'] = $arFields['LID'];
$resOrder = self::clearArr($resOrder);
if($send) if($send)
$api->createOrder($resOrder); $api->createOrder($resOrder);