diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index 3da2f92b..a69af5d0 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -12,30 +12,6 @@ class ICrmOrderActions protected static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N 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 * @return boolean @@ -163,7 +139,7 @@ class ICrmOrderActions return true; //all ok! } - + /** * * w+ event in bitrix log @@ -176,20 +152,6 @@ class ICrmOrderActions "ITEM_ID" => $itemId, "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; - $result = array( + $result = self::clearArr(array( 'externalId' => $arFields['USER_ID'], 'lastName' => $lastName, 'firstName' => $firstName, 'patronymic' => $patronymic, 'phones' => $phones - ); + )); $customer = $api->customerEdit($result); @@ -301,17 +263,17 @@ class ICrmOrderActions $pr = ''; $items[] = array( - 'price' => $p['PRICE'], - 'purchasePrice' => $pr, - 'discount' => $p['DISCOUNT_PRICE'], + 'initialPrice' => (double) $p['PRICE'] + (double) $p['DISCOUNT_PRICE'], + 'purchasePrice' => $pr, + 'discount' => $p['DISCOUNT_PRICE'], 'discountPercent' => $p['DISCOUNT_VALUE'], - 'quantity' => $p['QUANTITY'], - 'productId' => $p['PRODUCT_ID'], - 'productName' => self::toJSON($p['NAME']) + 'quantity' => $p['QUANTITY'], + 'productId' => $p['PRODUCT_ID'], + 'productName' => self::toJSON($p['NAME']) ); } - $resOrder = array( + $resOrder = self::clearArr(array( 'contactName' => $resOrder['contactName'], 'phone' => $resOrder['phone'], 'email' => $resOrder['email'], @@ -327,7 +289,7 @@ class ICrmOrderActions 'status' => $arParams['optionsPayStatuses'][$arFields['STATUS_ID']], 'deliveryAddress' => $resOrderDeliveryAddress, 'items' => $items - ); + )); if($send) 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); + } } diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 4e5cc2a5..76b802ca 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -236,7 +236,7 @@ class intaro_intarocrm extends CModule && isset($_POST['ajax']) && ($_POST['ajax'] == 1)) { 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); $countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array()); diff --git a/intaro.intarocrm/install/step3.php b/intaro.intarocrm/install/step3.php index 78bcafe1..d4b7ac47 100755 --- a/intaro.intarocrm/install/step3.php +++ b/intaro.intarocrm/install/step3.php @@ -35,7 +35,7 @@ IncludeModuleLangFile(__FILE__); .instal-progress-bar-alignment { height: 28px; - margin: 0 2px; + margin: 0; position: relative; } @@ -51,7 +51,7 @@ IncludeModuleLangFile(__FILE__); background-image:linear-gradient(top, #27a8d7, #2396ce, #1c79c0); position: absolute; overflow: hidden; - top: 2px; + top: 1px; left:0; } @@ -164,9 +164,9 @@ IncludeModuleLangFile(__FILE__);
-
+
-
0%
+
0%
0%
diff --git a/intaro.intarocrm/install/version.php~ b/intaro.intarocrm/install/version.php~ new file mode 100755 index 00000000..39766b70 --- /dev/null +++ b/intaro.intarocrm/install/version.php~ @@ -0,0 +1,5 @@ + '0.4.5', + 'VERSION_DATE' => '2013-07-24 13:41:00', +); \ No newline at end of file