fixed fio parsing
This commit is contained in:
parent
8d7ee7b132
commit
0812440edc
@ -252,6 +252,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()) {
|
||||||
@ -267,7 +268,7 @@ class ICrmOrderActions
|
|||||||
$resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']);
|
$resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'FIO': $resOrder['contactName'] = explode(" ", self::toJSON($ar['VALUE']));
|
case 'FIO': $contactNameArr = self::explodeFIO($ar['VALUE']);
|
||||||
break;
|
break;
|
||||||
case 'PHONE': $resOrder['phone'] = $ar['VALUE'];
|
case 'PHONE': $resOrder['phone'] = $ar['VALUE'];
|
||||||
break;
|
break;
|
||||||
@ -306,10 +307,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'],
|
||||||
@ -326,7 +324,18 @@ 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],
|
||||||
|
}
|
||||||
|
|
||||||
|
$resOrder = self::clearArr($resOrder);
|
||||||
|
|
||||||
if($send)
|
if($send)
|
||||||
return $api->createOrder($resOrder);
|
return $api->createOrder($resOrder);
|
||||||
@ -382,4 +391,17 @@ class ICrmOrderActions
|
|||||||
|
|
||||||
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
|
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function expodeFIO($str) {
|
||||||
|
if(!$str)
|
||||||
|
return array();
|
||||||
|
|
||||||
|
$array = expolde(" ", ICrmOrderActions::toJSON($str), 3);
|
||||||
|
|
||||||
|
foreach($array as &$ar)
|
||||||
|
if(!$ar)
|
||||||
|
unset($ar);
|
||||||
|
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user