optimized json responses; +apiUpd initial price; discountPercent; progressBar fixes.
This commit is contained in:
parent
7adc05f146
commit
454e1a1553
@ -12,30 +12,6 @@ class ICrmOrderActions
|
|||||||
protected static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
protected static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
||||||
protected static $CRM_ORDER_LAST_ID = 'order_last_id';
|
protected static $CRM_ORDER_LAST_ID = 'order_last_id';
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @global type $APPLICATION
|
|
||||||
* @param type $str in SITE_CHARSET
|
|
||||||
* @return type $str in utf-8
|
|
||||||
*/
|
|
||||||
protected static function toJSON($str) {
|
|
||||||
global $APPLICATION;
|
|
||||||
|
|
||||||
return $APPLICATION->ConvertCharset($str, SITE_CHARSET, 'utf-8');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @global type $APPLICATION
|
|
||||||
* @param type $str in utf-8
|
|
||||||
* @return type $str in SITE_CHARSET
|
|
||||||
*/
|
|
||||||
public static function fromJSON($str) {
|
|
||||||
global $APPLICATION;
|
|
||||||
|
|
||||||
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mass order uploading, without repeating; always returns true, but writes error log
|
* Mass order uploading, without repeating; always returns true, but writes error log
|
||||||
* @return boolean
|
* @return boolean
|
||||||
@ -163,7 +139,7 @@ class ICrmOrderActions
|
|||||||
|
|
||||||
return true; //all ok!
|
return true; //all ok!
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* w+ event in bitrix log
|
* w+ event in bitrix log
|
||||||
@ -176,20 +152,6 @@ class ICrmOrderActions
|
|||||||
"ITEM_ID" => $itemId,
|
"ITEM_ID" => $itemId,
|
||||||
"DESCRIPTION" => $description,
|
"DESCRIPTION" => $description,
|
||||||
));
|
));
|
||||||
|
|
||||||
//self::sendEmail($itemId, $description);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* send email to admin
|
|
||||||
*/
|
|
||||||
private static function sendEmail($itemId, $description) {
|
|
||||||
$title = 'Error: Intaro CRM.';
|
|
||||||
$text = 'Error: ' . $itemId . ' - ' . $description;
|
|
||||||
$to = COption::GetOptionString("main", "email_from");
|
|
||||||
$from = COption::GetOptionString("main", "email_from");
|
|
||||||
mail($to, $title, $text, 'From:'.$from);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,13 +203,13 @@ class ICrmOrderActions
|
|||||||
);
|
);
|
||||||
$phones[] = $phoneWork;
|
$phones[] = $phoneWork;
|
||||||
|
|
||||||
$result = array(
|
$result = self::clearArr(array(
|
||||||
'externalId' => $arFields['USER_ID'],
|
'externalId' => $arFields['USER_ID'],
|
||||||
'lastName' => $lastName,
|
'lastName' => $lastName,
|
||||||
'firstName' => $firstName,
|
'firstName' => $firstName,
|
||||||
'patronymic' => $patronymic,
|
'patronymic' => $patronymic,
|
||||||
'phones' => $phones
|
'phones' => $phones
|
||||||
);
|
));
|
||||||
|
|
||||||
$customer = $api->customerEdit($result);
|
$customer = $api->customerEdit($result);
|
||||||
|
|
||||||
@ -301,17 +263,17 @@ class ICrmOrderActions
|
|||||||
$pr = '';
|
$pr = '';
|
||||||
|
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'price' => $p['PRICE'],
|
'initialPrice' => (double) $p['PRICE'] + (double) $p['DISCOUNT_PRICE'],
|
||||||
'purchasePrice' => $pr,
|
'purchasePrice' => $pr,
|
||||||
'discount' => $p['DISCOUNT_PRICE'],
|
'discount' => $p['DISCOUNT_PRICE'],
|
||||||
'discountPercent' => $p['DISCOUNT_VALUE'],
|
'discountPercent' => $p['DISCOUNT_VALUE'],
|
||||||
'quantity' => $p['QUANTITY'],
|
'quantity' => $p['QUANTITY'],
|
||||||
'productId' => $p['PRODUCT_ID'],
|
'productId' => $p['PRODUCT_ID'],
|
||||||
'productName' => self::toJSON($p['NAME'])
|
'productName' => self::toJSON($p['NAME'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$resOrder = array(
|
$resOrder = self::clearArr(array(
|
||||||
'contactName' => $resOrder['contactName'],
|
'contactName' => $resOrder['contactName'],
|
||||||
'phone' => $resOrder['phone'],
|
'phone' => $resOrder['phone'],
|
||||||
'email' => $resOrder['email'],
|
'email' => $resOrder['email'],
|
||||||
@ -327,7 +289,7 @@ class ICrmOrderActions
|
|||||||
'status' => $arParams['optionsPayStatuses'][$arFields['STATUS_ID']],
|
'status' => $arParams['optionsPayStatuses'][$arFields['STATUS_ID']],
|
||||||
'deliveryAddress' => $resOrderDeliveryAddress,
|
'deliveryAddress' => $resOrderDeliveryAddress,
|
||||||
'items' => $items
|
'items' => $items
|
||||||
);
|
));
|
||||||
|
|
||||||
if($send)
|
if($send)
|
||||||
return $api->createOrder($resOrder);
|
return $api->createOrder($resOrder);
|
||||||
@ -336,4 +298,49 @@ class ICrmOrderActions
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes all empty fields from arrays
|
||||||
|
* working with nested arrs
|
||||||
|
*
|
||||||
|
* @param type $arr
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function clearArr($arr) {
|
||||||
|
if(!$arr || !is_array($arr))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach($arr as $key => $value) {
|
||||||
|
if(!$value || (is_array($value) && empty($value)))
|
||||||
|
unset($arr[$key]);
|
||||||
|
|
||||||
|
if(is_array($value) && !empty($value))
|
||||||
|
$arr[$key] = self::clearArr($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global type $APPLICATION
|
||||||
|
* @param type $str in SITE_CHARSET
|
||||||
|
* @return type $str in utf-8
|
||||||
|
*/
|
||||||
|
protected static function toJSON($str) {
|
||||||
|
global $APPLICATION;
|
||||||
|
|
||||||
|
return $APPLICATION->ConvertCharset($str, SITE_CHARSET, 'utf-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global type $APPLICATION
|
||||||
|
* @param type $str in utf-8
|
||||||
|
* @return type $str in SITE_CHARSET
|
||||||
|
*/
|
||||||
|
public static function fromJSON($str) {
|
||||||
|
global $APPLICATION;
|
||||||
|
|
||||||
|
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ class intaro_intarocrm extends CModule
|
|||||||
&& isset($_POST['ajax']) && ($_POST['ajax'] == 1)) {
|
&& isset($_POST['ajax']) && ($_POST['ajax'] == 1)) {
|
||||||
include($this->INSTALL_PATH . '/../classes/general/ICrmOrderActions.php');
|
include($this->INSTALL_PATH . '/../classes/general/ICrmOrderActions.php');
|
||||||
|
|
||||||
ICrmOrderActions::uploadOrders(true); // each 500
|
ICrmOrderActions::uploadOrders(true); // each 50
|
||||||
|
|
||||||
$lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
|
$lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
|
||||||
$countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array());
|
$countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array());
|
||||||
|
@ -35,7 +35,7 @@ IncludeModuleLangFile(__FILE__);
|
|||||||
|
|
||||||
.instal-progress-bar-alignment {
|
.instal-progress-bar-alignment {
|
||||||
height: 28px;
|
height: 28px;
|
||||||
margin: 0 2px;
|
margin: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ IncludeModuleLangFile(__FILE__);
|
|||||||
background-image:linear-gradient(top, #27a8d7, #2396ce, #1c79c0);
|
background-image:linear-gradient(top, #27a8d7, #2396ce, #1c79c0);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
top: 2px;
|
top: 1px;
|
||||||
left:0;
|
left:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,9 +164,9 @@ IncludeModuleLangFile(__FILE__);
|
|||||||
<div class="instal-load-block" id="result">
|
<div class="instal-load-block" id="result">
|
||||||
<div class="instal-load-label" id="status"><?php echo GetMessage('MESS_1'); ?></div>
|
<div class="instal-load-label" id="status"><?php echo GetMessage('MESS_1'); ?></div>
|
||||||
<div class="instal-progress-bar-outer">
|
<div class="instal-progress-bar-outer">
|
||||||
<div class="instal-progress-bar-alignment" style="width: 980px;">
|
<div class="instal-progress-bar-alignment" style="width: 100%;">
|
||||||
<div class="instal-progress-bar-inner" id="indicator" style="width: 0%;">
|
<div class="instal-progress-bar-inner" id="indicator" style="width: 0%;">
|
||||||
<div class="instal-progress-bar-inner-text" style="width: 980px;" id="percent">0%</div>
|
<div class="instal-progress-bar-inner-text" style="width: 100%;" id="percent">0%</div>
|
||||||
</div>
|
</div>
|
||||||
<span id="percent2">0%</span>
|
<span id="percent2">0%</span>
|
||||||
</div>
|
</div>
|
||||||
|
5
intaro.intarocrm/install/version.php~
Executable file
5
intaro.intarocrm/install/version.php~
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
<?
|
||||||
|
$arModuleVersion = array(
|
||||||
|
'VERSION' => '0.4.5',
|
||||||
|
'VERSION_DATE' => '2013-07-24 13:41:00',
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user