1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
admin_tool.php
См. документацию.
1<?
7// some of this functions should probably migrate to CSaleHelper
8
9/*
10 * get clean content for CRM
11 */
13{
14 while(@ob_end_clean());
15 echo $text;
16 die();
17}
18
19/*
20 * get user name
21 */
22function fGetUserName($USER_ID)
23{
24 $user = GetMessage('NEWO_BUYER_NAME_NULL');
25
26 if (intval($USER_ID) > 0)
27 {
28 $rsUser = CUser::GetByID($USER_ID);
29 $arUser = $rsUser->Fetch();
30
31 if (count($arUser) > 1)
32 {
33 $user = "<a href='javascript:void(0);' onClick=\"window.open('/bitrix/admin/user_search.php?lang=".LANGUAGE_ID."&FN=order_edit_info_form&FC=user_id', '', 'scrollbars=yes,resizable=yes,width=840,height=500,top='+Math.floor((screen.height - 840)/2-14)+',left='+Math.floor((screen.width - 760)/2-5));\">";
34 $user .= "(".htmlspecialcharsbx($arUser["LOGIN"]).")";
35
36 if ($arUser["NAME"] != "")
37 $user .= " ".htmlspecialcharsbx($arUser["NAME"]);
38 if ($arUser["LAST_NAME"] != "")
39 $user .= " ".htmlspecialcharsbx($arUser["LAST_NAME"]);
40
41 $user .= "<span class='pencil'>&nbsp;</span></a>";
42 }
43 }
44
45 return $user;
46}
47
48/*
49 * get template recomendet & basket product
50 */
51function fGetFormatedProductData($USER_ID, $LID, $arData, $CNT, $currency, $type, $crmMode = false)
52{
53 $result = "";
54 $arSet = array();
55
56 if (!is_array($arData) || count($arData) <= 0)
57 return $result;
58
59 $result = '<table width="100%">';
60 if (CModule::IncludeModule('catalog'))
61 {
62 $arProductId = array();
63 $arDataTab = array();
64
65 $arSkuParentChildren = array();
66 $arSkuParentId = array();
67 $arSkuParent = array();
68
69 foreach ($arData as $item)
70 {
71 if (!empty($item["CURRENCY"]) && $item["CURRENCY"] != $currency)
72 {
73 if (doubleval($item["PRICE"]) > 0)
74 $item["PRICE"] = CCurrencyRates::ConvertCurrency($item["PRICE"], $item["CURRENCY"], $currency);
75
76 if (doubleval($item["DISCOUNT_PRICE"]) > 0)
77 $item["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($item["DISCOUNT_PRICE"], $item["CURRENCY"], $currency);
78
79 $item["CURRENCY"] = $currency;
80 }
81
82 // get set items
84 if ($productProvider = CSaleBasket::GetProductProvider($item))
85 {
86 if (method_exists($productProvider, "GetSetItems"))
87 {
88 $itemInfo = (isset($item['ID']) ? array('BASKET_ID' => $item['ID']) : array());
89 $arSets = $productProvider::GetSetItems($item["PRODUCT_ID"], CSaleBasket::TYPE_SET, $itemInfo);
90 unset($itemInfo);
91
92 if (is_array($arSets))
93 {
94 foreach ($arSets as $arSetData)
95 {
96 foreach ($arSetData["ITEMS"] as $setItem)
97 {
98 $setItem["FUSER_ID"] = $item["FUSER_ID"];
99 $setItem["LID"] = $item["LID"];
100 $setItem["MODULE"] = $item["MODULE"];
101 $setItem["PRODUCT_PROVIDER_CLASS"] = $productProvider;
102 $setItem["SET_PARENT_ID"] = $item["ID"];
103
104 $arSet[$item["PRODUCT_ID"]][] = $setItem;
105 }
106 }
107 }
108 }
109 }
110
111 if ($item["MODULE"] == "catalog")
112 {
113 $arProductId[] = $item["PRODUCT_ID"];
114 $arDataTab[$item["PRODUCT_ID"]] = $item;
115
116 $arParent = CCatalogSku::GetProductInfo($item["PRODUCT_ID"]);
117 if ($arParent)
118 {
119 $arSkuParentChildren[$item["PRODUCT_ID"]] = $arParent["ID"];
120 $arSkuParentId[$arParent["ID"]] = $arParent["ID"];
121 }
122 }
123 }
124
125 if(!empty($arSkuParentId))
126 {
127 $res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
128 while ($arItems = $res->GetNext())
129 $arSkuParent[$arItems["ID"]] = $arItems;
130 }
131
132 if(!empty($arProductId))
133 {
134 $arProducts = array();
135 $dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
136 while($arProduct = $dbProduct->GetNext())
137 $arProducts[] = $arProduct;
138
139 foreach ($arProducts as $arProduct)
140 {
141 $imgCode = "";
142 $arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
143 $arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
144 $arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
145 $arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
146 $arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
147 $arProduct = $arDataTab[$arProduct['ID']];
148
149 if ($arProduct["PREVIEW_PICTURE"] == "" && $arProduct["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$arProduct["PRODUCT_ID"]]))
150 {
151 $idTmp = $arSkuParentChildren[$arProduct["PRODUCT_ID"]];
152 $arProduct["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
153 $arProduct["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
154 }
155
156 if ($arProduct["IBLOCK_ID"] > 0)
157 {
158 $arProduct["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arProduct["IBLOCK_ID"], $arProduct["PRODUCT_ID"], array(
159 "find_section_section" => $arProduct["IBLOCK_SECTION_ID"],
160 'WF' => 'Y',
161 ));
162 }
163
164 $arProduct["NAME"] = htmlspecialcharsEx($arProduct["NAME"]);
165 $arProduct["DETAIL_PAGE_URL"] = htmlspecialcharsEx($arProduct["DETAIL_PAGE_URL"]);
166 $arProduct["CURRENCY"] = htmlspecialcharsEx($arProduct["CURRENCY"]);
167
168 if ($arProduct["PREVIEW_PICTURE"] > 0)
169 $imgCode = $arProduct["PREVIEW_PICTURE"];
170 elseif ($arProduct["DETAIL_PICTURE"] > 0)
171 $imgCode = $arProduct["DETAIL_PICTURE"];
172
173 $imgProduct = '';
174 if ($imgCode > 0)
175 {
176 $arFile = CFile::GetFileArray($imgCode);
177 $arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
178 if (is_array($arImgProduct))
179 {
180 $imgProduct = '<a href="'.$arProduct["EDIT_PAGE_URL"].'" target="_blank"><img src="'.$arImgProduct["src"].'" alt="" title="'.$arProduct["NAME"].'" ></a>';
181 }
182 }
183 else
184 $imgProduct = '<div class="no_foto">'.GetMessage('SOD_NO_FOTO')."</div>";
185
186 $result .= '<tr><td class="tab_img">'.$imgProduct.'</td><td class="tab_text">
187 <div class="order_name"><a href="'.$arProduct["EDIT_PAGE_URL"].'" target="_blank" title="'.$arProduct["NAME"].'">'.$arProduct["NAME"].'</a></div>
188 <div class="order_price">'.GetMessage('SOD_ORDER_RECOM_PRICE').': <b>'.SaleFormatCurrency($arProduct["PRICE"], $currency).'</b>';
189
190 if (!empty($arSet) && array_key_exists($arProduct["PRODUCT_ID"], $arSet)) // show/hide set item link
191 {
192 $result .= '<br/>
193 <div>
194 <a id="set_toggle_link_b'.$arProduct["ID"].'"
195 href="javascript:void(0);"
196 class="dashed-link show-set-link"
197 title="'.GetMessage("SOD_SHOW_SET").'"
198 onclick="fToggleSetItems(\'b'.$arProduct["ID"].'\');">'.GetMessage("SOD_SHOW_SET").'</a>
199 </div>';
200 }
201
202 $result .= '</div>';
203
204 $arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $arProduct["PRODUCT_ID"], $arProduct["NAME"], '', $arProduct);
205
206 $arResult["POPUP_MESSAGE"] = array(
207 "PRODUCT_ADD" => GetMessage('SOD_POPUP_TO_BASKET'),
208 "PRODUCT_NOT_ADD" => GetMessage('SOD_POPUP_TO_BASKET_NOT'),
209 "PRODUCT_PRICE_FROM" => GetMessage('SOD_POPUP_FROM')
210 );
211
212 if (!$crmMode)
213 {
214 if (!empty($arResult["SKU_ELEMENTS"]))
215 {
216 $result .= '<a href="javascript:void(0);" class="get_new_order" onclick="fAddToBasketMoreProductSku('.CUtil::PhpToJSObject($arResult['SKU_ELEMENTS']).', '.CUtil::PhpToJSObject($arResult['SKU_PROPERTIES']).', \'\', '.CUtil::PhpToJSObject($arResult["POPUP_MESSAGE"]).');"><span></span>'.GetMessage('SOD_SUBTAB_ADD_ORDER').'</a>';
217 }
218 else
219 {
220 $cntProd = (floatval($arProduct["QUANTITY"]) > 0) ? floatval($arProduct["QUANTITY"]) : 1;
221 $url = "/bitrix/admin/sale_order_new.php?lang=".LANGUAGE_ID."&user_id=".$USER_ID."&LID=".$LID."&product[".$arProduct["PRODUCT_ID"]."]=".$cntProd;
222 $result .= "<a href=\"".$url."\" target=\"_blank\" class=\"get_new_order\"><span></span>".GetMessage('SOD_SUBTAB_ADD_ORDER')."</a>";
223 }
224 }
225
226 $result .= "</td></tr>";
227
228 // show set items
229 if (!empty($arSet) && array_key_exists($arProduct["PRODUCT_ID"], $arSet))
230 {
231 foreach ($arSet[$arProduct["PRODUCT_ID"]] as $set)
232 {
233 $editUrl = CIBlock::GetAdminElementEditLink($set["IBLOCK_ID"], $set["ITEM_ID"], array(
234 "find_section_section" => $set["IBLOCK_SECTION_ID"],
235 'WF' => 'Y',
236 ));
237
238 if ($set["PREVIEW_PICTURE"] > 0)
239 $imgCode = $set["PREVIEW_PICTURE"];
240 elseif ($set["DETAIL_PICTURE"] > 0)
241 $imgCode = $set["DETAIL_PICTURE"];
242
243 $img = '';
244 if ($imgCode > 0)
245 {
246 $arFile = CFile::GetFileArray($imgCode);
247 $arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
248 if (is_array($arImgProduct))
249 {
250 $img = '<a href="'.$editUrl.'" target="_blank"><img src="'.$arImgProduct["src"].'" alt="" title="'.$set["NAME"].'" ></a>';
251 }
252 }
253 else
254 $img = '<div class="no_foto">'.GetMessage('SOD_NO_FOTO')."</div>";
255
256 $result .= '
257 <tr style="display:none" class="set_item_b'.$arProduct["ID"].'">
258 <td class="tab_img">'.$img.'</td>
259 <td class="tab_text">
260 <div class="order_name">
261 <a href="'.$editUrl.'" style="font-style:italic" target="_blank" title="'.$set["NAME"].'">'.$set["NAME"].'</a>
262 </div>
263 <div class="order_price">'.GetMessage('SOD_ORDER_RECOM_PRICE').': <b>'.SaleFormatCurrency($set["PRICE"], $currency).'</b></div>
264 </td>
265 </tr>';
266 }
267 }
268 }
269 }
270 }//end if
271
272 $result .= '<tr><td colspan="2" align="right" class="more_product">';
273 if ($CNT > 2)
274 $result .= "<a href='javascript:void(0);' onClick=\"fGetMoreProduct('".$type."');\" class=\"get_more\">".GetMessage('SOD_SUBTAB_MORE')."<span></span></a>";
275 $result .= "</td></tr>";
276 $result .= "</table>";
277
278 return $result;
279}
280
281function fChangeOrderStatus($ID, $STATUS_ID)
282{
283 global $APPLICATION;
284 global $crmMode;
285
286 $errorMessageTmp = "";
287
288 $STATUS_ID = trim($STATUS_ID);
289 if ($STATUS_ID == '')
290 $errorMessageTmp .= GetMessage("ERROR_NO_STATUS").". ";
291
292 if ('' == $errorMessageTmp)
293 {
294 if (!CSaleOrder::CanUserChangeOrderStatus($ID, $STATUS_ID, $GLOBALS["USER"]->GetUserGroupArray()))
295 $errorMessageTmp .= GetMessage("SOD_NO_PERMS2STATUS").". ";
296 }
297
298 if ('' == $errorMessageTmp)
299 {
300 if (!CSaleOrder::StatusOrder($ID, $STATUS_ID))
301 {
302 if ($ex = $APPLICATION->GetException())
303 {
304 if ($ex->GetID() != "ALREADY_FLAG")
305 $errorMessageTmp .= $ex->GetString();
306 }
307 else
308 $errorMessageTmp .= GetMessage("ERROR_CHANGE_STATUS").". ";
309 }
310 }
311
313 'STATUS_ERR' => false,
314 'STATUS_ERR_MESS' => '',
315 );
316
317 $dbOrder = CSaleOrder::GetList(
318 array("ID" => "DESC"),
319 array("ID" => $ID),
320 false,
321 false,
322 array("DATE_STATUS", "EMP_STATUS_ID", "STATUS_ID")
323 );
324 if ($arOrder = $dbOrder->Fetch())
325 {
326 $arResult["DATE_STATUS"] = $arOrder["DATE_STATUS"];
327 if (!$crmMode && (int)$arOrder["EMP_STATUS_ID"] > 0)
328 $arResult["EMP_STATUS_ID"] = GetFormatedUserName($arOrder["EMP_STATUS_ID"], false);
329
330 $arResult["STATUS_ID"] = $arOrder["STATUS_ID"];
331 }
332 if ('' != $errorMessageTmp)
333 {
334 $arResult['STATUS_ERR'] = true;
335 $arResult['STATUS_ERR_MESS'] = $errorMessageTmp;
336 }
337
338 return $arResult;
339}
340
341/*
342 * shows file property input control
343 */
344function fShowFilePropertyField($name, $property_fields, $values, $max_file_size_show=50000)
345{
346 global $crmMode;
347 $disableFiles = (isset($crmMode) && $crmMode);
348 $res = "";
349 if (CModule::IncludeModule('fileman'))
350 {
351 if (!is_array($values) || empty($values))
352 $values = array("n0" => 0);
353
354 if ($property_fields["MULTIPLE"] == "N")
355 {
356 foreach($values as $key => $val)
357 {
358 if(is_array($val))
359 $file_id = $val["VALUE"];
360 else
361 $file_id = $val;
362
363 $res = CFileInput::Show(
364 $name."[".$key."]",
365 $file_id,
366 array(
367 "IMAGE" => "Y",
368 "PATH" => "Y",
369 "FILE_SIZE" => "Y",
370 "DIMENSIONS" => "Y",
371 "IMAGE_POPUP" => "Y",
372 "MAX_SIZE" => array("W" => 200, "H" => 170),
373 ),
374 array(
375 'upload' => !$disableFiles,
376 'del' => !$disableFiles,
377 'medialib' => false,
378 'file_dialog' => false,
379 'cloud' => false,
380 'description' => false
381 )
382 );
383 }
384 }
385 else
386 {
387 $inputName = array();
388 foreach($values as $key=>$val)
389 {
390 if(is_array($val))
391 $inputName[$name."[".$key."]"] = $val["VALUE"];
392 else
393 $inputName[$name."[".$key."]"] = $val;
394 }
395
396 $res = CFileInput::ShowMultiple($inputName, $name."[n#IND#]", array(
397 "IMAGE" => "Y",
398 "PATH" => "Y",
399 "FILE_SIZE" => "Y",
400 "DIMENSIONS" => "Y",
401 "IMAGE_POPUP" => "Y",
402 "MAX_SIZE" => array("W" => 200, "H" => 170),
403 ), false, array(
404 'upload' => !$disableFiles,
405 'del' => !$disableFiles,
406 'medialib' => false,
407 'file_dialog' => false,
408 'cloud' => false,
409 'description' => false
410 ));
411 }
412 }
413
414 return $res;
415}
416
417/*
418 * get count name, mail, phones in profiles
419 */
420function fGetCountProfileProps($PERSON_TYPE_ID)
421{
422 $arResult = array();
423 $dbProperties = CSaleOrderProps::GetList(
424 array(),
425 array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y"),
426 array("IS_PHONE", "COUNT" => "ID"),
427 false,
428 array("IS_PHONE")
429 );
430 while ($arProperties = $dbProperties->Fetch())
431 {
432 if ($arProperties["IS_PHONE"] == "Y")
433 $arResult["IS_PHONE"] = $arProperties["CNT"];
434 }
435
436 $dbProperties = CSaleOrderProps::GetList(
437 array(),
438 array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y"),
439 array("IS_PAYER", "COUNT" => "ID"),
440 false,
441 array("IS_PAYER")
442 );
443 while ($arProperties = $dbProperties->Fetch())
444 {
445 if ($arProperties["IS_PAYER"] == "Y")
446 $arResult["IS_PAYER"] = $arProperties["CNT"];
447 }
448
449 $dbProperties = CSaleOrderProps::GetList(
450 array(),
451 array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y"),
452 array("IS_EMAIL", "COUNT" => "ID"),
453 false,
454 array("IS_EMAIL")
455 );
456 while ($arProperties = $dbProperties->Fetch())
457 {
458 if ($arProperties["IS_EMAIL"] == "Y")
459 $arResult["IS_EMAIL"] = $arProperties["CNT"];
460 }
461
462 return $arResult;
463}
464
465/*
466 * user property (parameters order)
467 */
468function fGetBuyerType($PERSON_TYPE_ID, $LID, $USER_ID = '', $ORDER_ID = 0, $formVarsSubmit = false)
469{
470 global $locationZipID, $locationID, $DELIVERY_LOCATION, $DELIVERY_LOCATION_ZIP;
471 $resultHtml = "<script>locationZipID = 0;locationID = 0;</script><table width=\"100%\" id=\"order_type_props\" class=\"edit-table\">";
472
473 //select person type
474 $personTypeSelect = "<select name='buyer_type_id' id='buyer_type_id' OnChange='fBuyerChangeType(this);' >";
475 $dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"));
476 while ($arPersonType = $dbPersonType->GetNext())
477 {
478 if (!in_array($LID, $arPersonType["LIDS"]))
479 continue;
480
481 if (!isset($PERSON_TYPE_ID) OR $PERSON_TYPE_ID == "")
482 $PERSON_TYPE_ID = $arPersonType["ID"];
483
484 $class = "";
485 if (intval($arPersonType["ID"]) == intval($PERSON_TYPE_ID))
486 $class = " selected";
487
488 $personTypeSelect .= "<option value=\"".$arPersonType["ID"]."\" ".$class.">".$arPersonType["NAME"]." [".$arPersonType["ID"]."]</option>";
489 }
490 $personTypeSelect .= "</select>";
491
492 $userComment = "";
493 $userDisplay = "none";
494 if (intval($ORDER_ID) > 0)
495 {
496 $dbOrder = CSaleOrder::GetList(
497 array(),
498 array("ID" => $ORDER_ID, "ACTIVE" => "Y"),
499 false,
500 false,
501 array()
502 );
503 $arOrder = $dbOrder->Fetch();
504 $userComment = $arOrder["USER_DESCRIPTION"];
505 $userDisplay = "table-row";
506 }
507
508 if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerNew")
509 $userDisplay = "none";
510 elseif ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist")
511 $userDisplay = "table-row";
512
513 $resultHtml .= "<tr id=\"btnBuyerExistField\" style=\"display:".$userDisplay."\">
514 <td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("NEWO_BUYER").":</td>
515 <td class=\"adm-detail-content-cell-r\" width=\"60%\"><div id=\"user_name\">".fGetUserName($USER_ID)."</div></td></tr>";
516
517 $resultHtml .= "<tr class=\"adm-detail-required-field\">
518 <td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("SOE_PERSON_TYPE").":</td>
519 <td class=\"adm-detail-content-cell-r\" width=\"60%\">".$personTypeSelect."</td>
520 </tr>";
521
522 $bShowTrProfile = "none";
523 if ($formVarsSubmit && $_POST["btnTypeBuyer"] == "btnBuyerExist")
524 $bShowTrProfile = "table-row";
525
526 $resultHtml .= "<tr id=\"buyer_profile_display\" style=\"display:".$bShowTrProfile."\" class=\"adm-detail-required-field\">
527 <td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_PROFILE").":</td>
528 <td class=\"adm-detail-content-cell-r\">
529 <div id=\"buyer_profile_select\">";
530
531 if ($formVarsSubmit && $_POST["btnTypeBuyer"] == "btnBuyerExist")
532 {
533 $resultHtml .= fUserProfile(intval($_POST["user_id"]), intval($_POST["buyer_type_id"]), $default = '');
534 }
535
536 $resultHtml .= "</div></td>
537 </tr>";
538
539 if ($ORDER_ID <= 0)
540 {
541 $arCountProps = fGetCountProfileProps($PERSON_TYPE_ID);
542 $resultHtml .= "<tr id=\"btnBuyerNewField\">";
543 if (count($arCountProps) < 3)
544 {
545 $resultHtml .= "<td colspan=2>
546 <table width=\"100%\" class=\"edit-table\" >";
547 if (intval($arCountProps["IS_EMAIL"]) <= 0)
548 $resultHtml .= "<tr class=\"adm-detail-required-field\">
549 <td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("NEWO_BUYER_REG_MAIL")."</td>
550 <td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_EMAIL\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_EMAIL"]))."\" tabindex=\"1\" /></td>
551 </tr>";
552 if (intval($arCountProps["IS_PAYER"]) <= 0)
553 $resultHtml .= "<tr class=\"adm-detail-required-field\">
554 <td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_REG_LASTNAME")."</td>
555 <td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_LAST_NAME\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_LAST_NAME"]))."\" tabindex=\"3\" /></td>
556 </tr>
557 <tr class=\"adm-detail-required-field\">
558 <td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_REG_NAME")."</td>
559 <td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_NAME\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_NAME"]))."\" tabindex=\"2\" /></td>
560 </tr>";
561 $resultHtml .= "</table>
562 </td>";
563 }
564 $resultHtml .= "</tr>";
565 }
566
567 $arPropertiesList = array();
568 $dbProperties = CSaleOrderProps::GetList(
569 array("GROUP_SORT" => "ASC", "PROPS_GROUP_ID" => "ASC", "SORT" => "ASC", "NAME" => "ASC"),
570 array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y", "RELATED" => false),
571 false,
572 false,
573 array("*")
574 );
575 while($property = $dbProperties->GetNext())
576 {
577 $arPropertiesList[$property['ID']] = $property;
578 }
579
580 // getting values
581 $arPropValues = array();
582 if ($formVarsSubmit) // from request
583 {
584 $locationIndexForm = "";
585 foreach ($_POST as $key => $value)
586 {
587 if (mb_substr($key, 0, mb_strlen("CITY_ORDER_PROP_")) == "CITY_ORDER_PROP_")
588 {
589 $arPropValues[intval(mb_substr($key, mb_strlen("CITY_ORDER_PROP_")))] = htmlspecialcharsbx($value);
590 $locationIndexForm = intval(mb_substr($key, mb_strlen("CITY_ORDER_PROP_")));
591 }
592 if (mb_substr($key, 0, mb_strlen("ORDER_PROP_")) == "ORDER_PROP_")
593 {
594 if ($locationIndexForm != intval(mb_substr($key, mb_strlen("ORDER_PROP_"))) && !is_array($value))
595 $arPropValues[intval(mb_substr($key, mb_strlen("ORDER_PROP_")))] = htmlspecialcharsbx($value);
596 }
597 }
598 $userComment = $_POST["USER_DESCRIPTION"];
599 }
600 elseif ($ORDER_ID == "" AND $USER_ID != "") // from profile
601 {
602 //profile
603 $userProfile = CSaleOrderUserProps::DoLoadProfiles($USER_ID, $PERSON_TYPE_ID);
604 $arPropValues = $userProfile[$PERSON_TYPE_ID]["VALUES"];
605 }
606 elseif ($ORDER_ID != "") // from order properties
607 {
608 $dbPropValuesList = CSaleOrderPropsValue::GetList(
609 array(),
610 array("ORDER_ID" => $ORDER_ID, "ACTIVE" => "Y"),
611 false,
612 false,
613 array("ID", "ORDER_PROPS_ID", "NAME", "VALUE", "CODE")
614 );
615 while ($arPropValuesList = $dbPropValuesList->Fetch())
616 {
617 $arPropValues[intval($arPropValuesList["ORDER_PROPS_ID"])] = htmlspecialcharsbx($arPropValuesList["VALUE"]);
618 }
619 }
620
621 $location2townFldMap = array();
622 $arDisableFieldForLocation = array();
623 //select field (town) for disable
624 $dbProperties = CSaleOrderProps::GetList(
625 array(),
626 array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y", ">INPUT_FIELD_LOCATION" => 0),
627 false,
628 false,
629 array("INPUT_FIELD_LOCATION")
630 );
631 while ($arProperties = $dbProperties->Fetch())
632 {
633 $arDisableFieldForLocation[$arProperties["INPUT_FIELD_LOCATION"]] = $arProperties["INPUT_FIELD_LOCATION"];
634 }
635
636 //show town if location is another
637 if ($ORDER_ID > 0)
638 {
640 while ($arOrderProps = $dbOrderProps->Fetch())
641 {
642 if ($arOrderProps["TYPE"] == "LOCATION" && $arOrderProps["ACTIVE"] == "Y" && $arOrderProps["IS_LOCATION"] == "Y")
643 {
644 if (in_array($arOrderProps["INPUT_FIELD_LOCATION"], $arDisableFieldForLocation))
645 {
647 {
648 //if(CSaleLocation::checkLocationIsAboveCity($arPropValues[$arOrderProps["ORDER_PROPS_ID"]]))
649 unset($arDisableFieldForLocation[$arOrderProps["INPUT_FIELD_LOCATION"]]);
650 }
651 else
652 {
653 $arLocation = CSaleLocation::GetByID($arPropValues[$arOrderProps["ORDER_PROPS_ID"]]);
654 if (intval($arLocation["CITY_ID"]) <= 0)
655 unset($arDisableFieldForLocation[$arOrderProps["INPUT_FIELD_LOCATION"]]);
656 }
657 }
658
659 $location2townFldMap[$arOrderProps['ORDER_PROPS_ID']] = $arOrderProps['INPUT_FIELD_LOCATION'];
660 }
661 }
662 }
663
664 $propertyGroupID = -1;
665
666 foreach($arPropertiesList as $arProperties)
667 {
668 if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
669 {
670 $resultHtml .= "<tr><td colspan=\"2\" style=\"text-align:center;font-weight:bold;font-size:14px;color:rgb(75, 98, 103);\" >".htmlspecialcharsEx($arProperties["GROUP_NAME"])."\n</td>\n</tr>";
671 $propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
672 }
673
674 if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
675 $propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
676
677 $adit = "";
678 $requiredField = "";
679 if ($arProperties["REQUIED"] == "Y" || $arProperties["IS_PROFILE_NAME"] == "Y" || $arProperties["IS_LOCATION"] == "Y" || $arProperties["IS_LOCATION4TAX"] == "Y" || $arProperties["IS_PAYER"] == "Y" || $arProperties["IS_ZIP"] == "Y")
680 {
681 $adit = " class=\"adm-detail-required-field\"";
682 $requiredField = " class=\"adm-detail-content-cell-l\"";
683 }
684
685 $isTownProperty = in_array($arProperties["ID"], $location2townFldMap) || $arProperties['CODE'] == 'CITY';
686
687 //delete town from location
688 if (in_array($arProperties["ID"], $arDisableFieldForLocation))
689 $resultHtml .= "<tr style=\"display:none;\" id=\"town_location_".$arProperties["ID"]."\"".$adit.">\n";
690 else
691 $resultHtml .= "<tr id=\"town_location_".$arProperties["ID"]."\"".$adit.($isTownProperty ? " class=\"-bx-order-property-city\"" : '').">\n";
692
693 if(($arProperties["TYPE"] == "MULTISELECT" || $arProperties["TYPE"] == "TEXTAREA" || $arProperties["TYPE"] == "FILE") || ($ORDER_ID <= 0 && $arProperties["IS_PROFILE_NAME"] == "Y") )
694 $resultHtml .= "<td valign=\"top\" class=\"adm-detail-content-cell-l\" width=\"40%\">\n";
695 else
696 $resultHtml .= "<td align=\"right\" width=\"40%\" ".$requiredField.">\n";
697
698 $resultHtml .= $arProperties["NAME"].":</td>";
699
700 $curVal = $arPropValues[intval($arProperties["ID"])];
701
702 if($arProperties["IS_EMAIL"] == "Y" || $arProperties["IS_PAYER"] == "Y")
703 {
704 if($arProperties["DEFAULT_VALUE"] == '' && intval($USER_ID) > 0)
705 {
706 $rsUser = CUser::GetByID($USER_ID);
707 if ($arUser = $rsUser->Fetch())
708 {
709 if($arProperties["IS_EMAIL"] == "Y")
710 $arProperties["DEFAULT_VALUE"] = $arUser["EMAIL"];
711 else
712 {
713 if ($arUser["LAST_NAME"] <> '')
714 $arProperties["DEFAULT_VALUE"] .= $arUser["LAST_NAME"];
715 if ($arUser["NAME"] <> '')
716 $arProperties["DEFAULT_VALUE"] .= " ".$arUser["NAME"];
717 if ($arUser["SECOND_NAME"] <> '' AND $arUser["NAME"] <> '')
718 $arProperties["DEFAULT_VALUE"] .= " ".$arUser["SECOND_NAME"];
719 }
720 }
721 }
722 }
723
724 $resultHtml .= "<td class=\"adm-detail-content-cell-r\" width=\"60%\">";
725
726 if ($arProperties["TYPE"] == "CHECKBOX")
727 {
728 $resultHtml .= '<input type="checkbox" class="inputcheckbox" ';
729 $resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" value="Y"';
730 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
731 if ($curVal=="Y" || !isset($curVal) && $arProperties["DEFAULT_VALUE"]=="Y")
732 $resultHtml .= " checked";
733 $resultHtml .= '>';
734 }
735 elseif ($arProperties["TYPE"] == "TEXT")
736 {
737 $change = "";
738 if ($arProperties["IS_ZIP"] == "Y")
739 {
740 $DELIVERY_LOCATION_ZIP = $curVal;
741 $resultHtml .= '<script> locationZipID = \''.$arProperties["ID"].'\';</script>';
742 $locationZipID = ((isset($curVal)) ? htmlspecialcharsEx($curVal) : htmlspecialcharsEx($arProperties["DEFAULT_VALUE"]));
743 }
744
745 if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
746 {
747 $resultHtml .= '<div id="BREAK_NAME"';
748 if ($ORDER_ID > 0 || ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist"))
749 $resultHtml .= ' style="display:none"';
750 $resultHtml .= '>';
751
752 $BREAK_LAST_NAME_TMP = GetMessage('NEWO_BREAK_LAST_NAME');
753 if (isset($_REQUEST["BREAK_LAST_NAME"]) && $_REQUEST["BREAK_LAST_NAME"] <> '')
754 $BREAK_LAST_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_LAST_NAME"]));
755
756 $NEWO_BREAK_NAME_TMP = GetMessage('NEWO_BREAK_NAME');
757 if (isset($_REQUEST["BREAK_NAME"]) && $_REQUEST["BREAK_NAME"] <> '')
758 $NEWO_BREAK_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_NAME"]));
759
760 $BREAK_SECOND_NAME_TMP = GetMessage('NEWO_BREAK_SECOND_NAME');
761 if (isset($_REQUEST["BREAK_SECOND_NAME"]) && $_REQUEST["BREAK_SECOND_NAME"] <> '')
762 $BREAK_SECOND_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_SECOND_NAME"]));
763
764 $resultHtml .= '<div class="fio newo_break_active">'.
765 '<input type="text" name="BREAK_LAST_NAME" id="BREAK_LAST_NAME" size="30" '.
766 'value="'.$BREAK_LAST_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_LAST_NAME')).'" '.
767 'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
768 'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
769 '</div>';
770
771 $resultHtml .= '<div class="fio newo_break_active">'.
772 '<input type="text" name="BREAK_NAME" id="BREAK_NAME_BUYER" size="30" '.
773 'value="'.$NEWO_BREAK_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_NAME')).'" '.
774 'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
775 'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
776 '</div>';
777 $resultHtml .= '<div class="fio newo_break_active">'.
778 '<input type="text" name="BREAK_SECOND_NAME" id="BREAK_SECOND_NAME" size="30" '.
779 'value="'.$BREAK_SECOND_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_SECOND_NAME')).'" '.
780 'onblur="if (this.value==\'\'){BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
781 'onfocus="if (this.value==\'\') {BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
782 '</div>';
783 $resultHtml .= '</div>';
784
785 $tmpNone = '';
786 $resultHtml .= '<div id="NO_BREAK_NAME"';
787 if ($ORDER_ID <= 0)
788 $tmpNone = ' style="display:none"';
789 if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist")
790 $tmpNone = ' style="display:block"';
791 $resultHtml .= $tmpNone.'>';
792 }
793
794 $resultHtml .= '<input type="text" maxlength="250" ';
795 $resultHtml .= 'size="30" ';
796 $resultHtml .= 'value="'.((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]).'" ';
797 $resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
798 $resultHtml .= ($arProperties["IS_ZIP"] == "Y" ? 'class="-bx-property-is-zip" ' : '');
799 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" '.$change.'>';
800
801 if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
802 $resultHtml .= '</div>';
803 }
804 elseif ($arProperties["TYPE"] == "SELECT")
805 {
806 $size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;
807
808 $resultHtml .= '<select name="ORDER_PROP_'.$arProperties["ID"].'" ';
809 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
810 $resultHtml .= 'size='.$size.' ';
811 $resultHtml .= 'class="typeselect">';
812 $dbVariants = CSaleOrderPropsVariant::GetList(
813 array("SORT" => "ASC"),
814 array("ORDER_PROPS_ID" => $arProperties["ID"]),
815 false,
816 false,
817 array("*")
818 );
819 while ($arVariants = $dbVariants->Fetch())
820 {
821 $resultHtml .= '<option value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
822 if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
823 $resultHtml .= " selected";
824 $resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
825 }
826 $resultHtml .= '</select>';
827 }
828 elseif ($arProperties["TYPE"] == "MULTISELECT")
829 {
830 $size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;
831
832 $resultHtml .= '<select multiple name="ORDER_PROP_'.$arProperties["ID"].'[]" ';
833 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
834 $resultHtml .= 'size='.$size.' ';
835 $resultHtml .= 'class="typeselect" type="multyselect">';
836
837 if (!is_array($curVal))
838 {
839 if ($curVal <> '' OR $ORDER_ID != "")
840 $curVal = explode(",", $curVal);
841 else
842 $curVal = explode(",", $arProperties["DEFAULT_VALUE"]);
843
844 $arCurVal = array();
845 $countCurVal = count($curVal);
846 for ($i = 0; $i < $countCurVal; $i++)
847 $arCurVal[$i] = trim($curVal[$i]);
848 }
849 else
850 $arCurVal = $curVal;
851
852 $dbVariants = CSaleOrderPropsVariant::GetList(
853 array("SORT" => "ASC"),
854 array("ORDER_PROPS_ID" => $arProperties["ID"]),
855 false,
856 false,
857 array("*")
858 );
859 while ($arVariants = $dbVariants->Fetch())
860 {
861 $resultHtml .= '<option value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
862 if (in_array($arVariants["VALUE"], $arCurVal))
863 $resultHtml .= " selected";
864 $resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
865 }
866 $resultHtml .= '</select>';
867 }
868 elseif ($arProperties["TYPE"] == "TEXTAREA")
869 {
870 $resultHtml .= '<textarea ';
871 $resultHtml .= 'rows="4" ';
872 $resultHtml .= 'cols="40" ';
873 $resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
874 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" type="textarea">';
875 $resultHtml .= ((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]);
876 $resultHtml .= '</textarea>';
877 }
878 elseif ($arProperties["TYPE"] == "LOCATION")
879 {
880 $DELIVERY_LOCATION = $arPropValues[intval($arProperties["ID"])];
881
882 $locationID = $curVal;
883
884 ob_start();
885 ?>
886
887 <?if($arProperties['IS_LOCATION'] == 'Y'):?>
888
889 <?
890 $funcId = 'changeLocationCity_'.$arProperties['ID'];
891 ?>
892
893 <script>
894 window['<?=$funcId?>'] = function(node, info){
895 fChangeLocationCity(node, info, <?=intval($location2townFldMap[$arProperties['ID']])?>)
896 }
897 window.orderNewLocationPropId = <?=intval($arProperties['ID'])?>;
898 </script>
899
900 <?endif?>
901
902 <?
903 CSaleLocation::proxySaleAjaxLocationsComponent(
904 array(
905 "SITE_ID" => $LID,
906 "AJAX_CALL" => "N",
907 "COUNTRY_INPUT_NAME" => "ORDER_PROP_".$arProperties["ID"],
908 "REGION_INPUT_NAME" => "REGION_ORDER_PROP_".$arProperties["ID"],
909 "CITY_INPUT_NAME" => "CITY_ORDER_PROP_".$arProperties["ID"],
910 "CITY_OUT_LOCATION" => "Y",
911 "ALLOW_EMPTY_CITY" => "Y",
912 "LOCATION_VALUE" => $curVal,
913 "COUNTRY" => "",
914 "ONCITYCHANGE" => "fChangeLocationCity",
915 "PUBLIC" => "N",
916 ),
917 array(
918 "JS_CALLBACK" => $arProperties['IS_LOCATION'] == 'Y' ? $funcId : false,
919 "ID" => $curVal,
920 "CODE" => '',
921 "SHOW_DEFAULT_LOCATIONS" => 'Y',
922 "JS_CONTROL_GLOBAL_ID" => intval($arProperties["ID"]),
923
924 "PRECACHE_LAST_LEVEL" => "Y",
925 "PRESELECT_TREE_TRUNK" => "Y"
926 ),
927 '',
928 false,
929 'location-selector-wrapper prop-'.intval($arProperties["ID"])
930 );
931
932 $tmpLocation = ob_get_contents();
933 ob_end_clean();
934
935 $resultHtml .= '<script>var locationID = \''.$arProperties["ID"].'\';</script>';
936 $resultHtml .= $tmpLocation;
937 }
938 elseif ($arProperties["TYPE"] == "RADIO")
939 {
940 $dbVariants = CSaleOrderPropsVariant::GetList(
941 array("SORT" => "ASC"),
942 array("ORDER_PROPS_ID" => $arProperties["ID"]),
943 false,
944 false,
945 array("*")
946 );
947 $resultHtml .= '<div id="ORDER_PROP_'.$arProperties["ID"].'" type="radio">';// type="radio"
948 while ($arVariants = $dbVariants->Fetch())
949 {
950 $resultHtml .= '<input type="radio" class="inputradio" ';
951 $resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
952 $resultHtml .= 'value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
953 if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
954 $resultHtml .= " checked";
955 $resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'<br>';
956 }
957 $resultHtml .= '</div>';
958 }
959 elseif ($arProperties["TYPE"] == "FILE")
960 {
961 $arValues = array();
962 $arTmpValues = array();
963 if (isset($arPropValues[$arProperties["ID"]]))
964 {
965 $arTmpValues = explode(", ", $arPropValues[$arProperties["ID"]]);
966 foreach ($arTmpValues as $key => $value)
967 $arValues[$value] = $value;
968 }
969
970 $resultHtml .= fShowFilePropertyField("ORDER_PROP_".$arProperties["ID"], $arProperties, $arValues, $arProperties["SIZE1"], $formVarsSubmit);
971 }
972
973 if ($arProperties["DESCRIPTION"] <> '')
974 {
975 $resultHtml .= "<br><small>".htmlspecialcharsEx($arProperties["DESCRIPTION"])."</small>";
976 }
977 $resultHtml .= "\n</td>\n</tr>";
978
979 }//end while
980
981 $resultHtml .= "<tr>\n<td valign=\"top\" class=\"adm-detail-content-cell-l\">".GetMessage("SOE_BUYER_COMMENT").":
982 </td>
983 <td class=\"adm-detail-content-cell-r\">
984 <textarea name=\"USER_DESCRIPTION\" rows=\"4\" cols=\"40\">".htmlspecialcharsbx($userComment)."</textarea>
985 </td>
986 </tr>";
987
988 $resultHtml .= "</table>";
989 return $resultHtml;
990}
991
992/*
993 * Returns HTML controls of the order properties
994 *
995 * Currently is used to show order properties related to payment/delivery systems in the order_new form
996 */
997function getOrderPropertiesHTML($arOrderProps, $arPropValues = array(), $LID = '', $USER_ID = '', $ORDER_ID = 0, $formVarsSubmit = false)
998{
999 $propertyGroupID = -1;
1000 $arDisableFieldForLocation = array();
1001 $resultHtml = "<table id=\"order_related_props\">";
1002
1003 // get order properties values
1004 if ($formVarsSubmit)
1005 {
1006 $locationIndexForm = "";
1007 foreach ($_POST as $key => $value)
1008 {
1009 if (mb_substr($key, 0, mb_strlen("CITY_ORDER_PROP_")) == "CITY_ORDER_PROP_")
1010 {
1011 $arPropValues[intval(mb_substr($key, mb_strlen("CITY_ORDER_PROP_")))] = htmlspecialcharsbx($value);
1012 $locationIndexForm = intval(mb_substr($key, mb_strlen("CITY_ORDER_PROP_")));
1013 }
1014 if (mb_substr($key, 0, mb_strlen("ORDER_PROP_")) == "ORDER_PROP_")
1015 {
1016 if ($locationIndexForm != intval(mb_substr($key, mb_strlen("ORDER_PROP_"))))
1017 {
1018 if (!is_array($value))
1019 $arPropValues[intval(mb_substr($key, mb_strlen("ORDER_PROP_")))] = htmlspecialcharsbx($value);
1020 else
1021 {
1022 $arValues = array();
1023 foreach ($value as $k => $v)
1024 $arValues[$key] = htmlspecialcharsbx($v);
1025
1026 $arPropValues[intval(mb_substr($key, mb_strlen("ORDER_PROP_")))] = $arValues;
1027 }
1028 }
1029 }
1030 }
1031 }
1032
1033 // iterate over list of properties
1034 if (is_array($arOrderProps))
1035 {
1036 foreach ($arOrderProps as $arProperties)
1037 {
1038 if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
1039 {
1040 $resultHtml .= "<tr><td colspan=\"2\" style=\"text-align:center;font-weight:bold;font-size:14px;color:rgb(75, 98, 103);\" >".htmlspecialcharsEx($arProperties["GROUP_NAME"])."\n</td>\n</tr>";
1041 $propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
1042 }
1043
1044 if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
1045 $propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
1046
1047 $adit = "";
1048 $requiredField = "";
1049 if ($arProperties["REQUIED"] == "Y" || $arProperties["IS_PROFILE_NAME"] == "Y" || $arProperties["IS_LOCATION"] == "Y" || $arProperties["IS_LOCATION4TAX"] == "Y" || $arProperties["IS_PAYER"] == "Y" || $arProperties["IS_ZIP"] == "Y")
1050 {
1051 $adit = " class=\"adm-detail-required-field\"";
1052 $requiredField = " class=\"adm-detail-content-cell-l\"";
1053 }
1054
1055 //delete town from location
1056 if (in_array($arProperties["ID"], $arDisableFieldForLocation))
1057 $resultHtml .= "<tr style=\"display:none;\" id=\"town_location_".$arProperties["ID"]."\"".$adit.">\n";
1058 else
1059 $resultHtml .= "<tr id=\"town_location_".$arProperties["ID"]."\"".$adit.">\n";
1060
1061 if(($arProperties["TYPE"] == "MULTISELECT" || $arProperties["TYPE"] == "TEXTAREA") || ($ORDER_ID <= 0 && $arProperties["IS_PROFILE_NAME"] == "Y") )
1062 $resultHtml .= "<td valign=\"top\" class=\"adm-detail-content-cell-l\" width=\"40%\">\n";
1063 else
1064 $resultHtml .= "<td align=\"right\" width=\"40%\" ".$requiredField.">\n";
1065
1066 $resultHtml .= $arProperties["NAME"].":</td>";
1067
1068 $curVal = $arPropValues[intval($arProperties["ID"])];
1069
1070 if($arProperties["IS_EMAIL"] == "Y" || $arProperties["IS_PAYER"] == "Y")
1071 {
1072 if($arProperties["DEFAULT_VALUE"] == '' && intval($USER_ID) > 0)
1073 {
1074 $rsUser = CUser::GetByID($USER_ID);
1075 if ($arUser = $rsUser->Fetch())
1076 {
1077 if($arProperties["IS_EMAIL"] == "Y")
1078 $arProperties["DEFAULT_VALUE"] = $arUser["EMAIL"];
1079 else
1080 {
1081 if ($arUser["LAST_NAME"] <> '')
1082 $arProperties["DEFAULT_VALUE"] .= $arUser["LAST_NAME"];
1083 if ($arUser["NAME"] <> '')
1084 $arProperties["DEFAULT_VALUE"] .= " ".$arUser["NAME"];
1085 if ($arUser["SECOND_NAME"] <> '' AND $arUser["NAME"] <> '')
1086 $arProperties["DEFAULT_VALUE"] .= " ".$arUser["SECOND_NAME"];
1087 }
1088 }
1089 }
1090 }
1091
1092 $resultHtml .= "<td class=\"adm-detail-content-cell-r\" width=\"60%\">";
1093
1094 if ($arProperties["TYPE"] == "CHECKBOX")
1095 {
1096 $resultHtml .= '<input type="checkbox" class="inputcheckbox" ';
1097 $resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" value="Y"';
1098 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
1099 if ($curVal=="Y" || !isset($curVal) && $arProperties["DEFAULT_VALUE"]=="Y")
1100 $resultHtml .= " checked";
1101 $resultHtml .= '>';
1102 }
1103 elseif ($arProperties["TYPE"] == "TEXT")
1104 {
1105 $change = "";
1106 if ($arProperties["IS_ZIP"] == "Y")
1107 {
1108 $DELIVERY_LOCATION_ZIP = $curVal;
1109 $resultHtml .= '<script> locationZipID = \''.$arProperties["ID"].'\';</script>';
1110 $locationZipID = ((isset($curVal)) ? htmlspecialcharsEx($curVal) : htmlspecialcharsEx($arProperties["DEFAULT_VALUE"]));
1111 }
1112
1113 if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
1114 {
1115 $resultHtml .= '<div id="BREAK_NAME"';
1116 if ($ORDER_ID > 0 || ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist"))
1117 $resultHtml .= ' style="display:none"';
1118 $resultHtml .= '>';
1119
1120 $BREAK_LAST_NAME_TMP = GetMessage('NEWO_BREAK_LAST_NAME');
1121 if (isset($_REQUEST["BREAK_LAST_NAME"]) && $_REQUEST["BREAK_LAST_NAME"] <> '')
1122 $BREAK_LAST_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_LAST_NAME"]));
1123
1124 $NEWO_BREAK_NAME_TMP = GetMessage('NEWO_BREAK_NAME');
1125 if (isset($_REQUEST["BREAK_NAME"]) && $_REQUEST["BREAK_NAME"] <> '')
1126 $NEWO_BREAK_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_NAME"]));
1127
1128 $BREAK_SECOND_NAME_TMP = GetMessage('NEWO_BREAK_SECOND_NAME');
1129 if (isset($_REQUEST["BREAK_SECOND_NAME"]) && $_REQUEST["BREAK_SECOND_NAME"] <> '')
1130 $BREAK_SECOND_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_SECOND_NAME"]));
1131
1132 $resultHtml .= '<div class="fio newo_break_active">'.
1133 '<input type="text" name="BREAK_LAST_NAME" id="BREAK_LAST_NAME" size="30" '.
1134 'value="'.$BREAK_LAST_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_LAST_NAME')).'" '.
1135 'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
1136 'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
1137 '</div>';
1138 $resultHtml .= '<div class="fio newo_break_active">'.
1139 '<input type="text" name="BREAK_NAME" id="BREAK_NAME_BUYER" size="30" '.
1140 'value="'.$NEWO_BREAK_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_NAME')).'" '.
1141 'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
1142 'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
1143 '</div>';
1144 $resultHtml .= '<div class="fio newo_break_active">'.
1145 '<input type="text" name="BREAK_SECOND_NAME" id="BREAK_SECOND_NAME" size="30" '.
1146 'value="'.$BREAK_SECOND_NAME_TMP.'" placeholder="'.htmlspecialcharsbx(GetMessage('NEWO_BREAK_SECOND_NAME')).'" '.
1147 'onblur="if (this.value==\'\'){ BX.addClass(this.parentNode, \'newo_break_active\'); }" '.
1148 'onfocus="if (this.value==\'\') { BX.removeClass(this.parentNode, \'newo_break_active\'); }">'.
1149 '</div>';
1150 $resultHtml .= '</div>';
1151
1152 $tmpNone = '';
1153 $resultHtml .= '<div id="NO_BREAK_NAME"';
1154 if ($ORDER_ID <= 0)
1155 $tmpNone = ' style="display:none"';
1156 if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist")
1157 $tmpNone = ' style="display:block"';
1158 $resultHtml .= $tmpNone.'>';
1159 }
1160
1161 $resultHtml .= '<input type="text" maxlength="250" ';
1162 $resultHtml .= 'size="30" ';
1163 $resultHtml .= 'value="'.((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]).'" ';
1164 $resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
1165 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" '.$change.'>';
1166
1167 if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
1168 $resultHtml .= '</div>';
1169 }
1170 elseif ($arProperties["TYPE"] == "SELECT")
1171 {
1172 $size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;
1173
1174 $resultHtml .= '<select name="ORDER_PROP_'.$arProperties["ID"].'" ';
1175 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
1176 $resultHtml .= 'size='.$size.' ';
1177 $resultHtml .= 'class="typeselect">';
1178 $dbVariants = CSaleOrderPropsVariant::GetList(
1179 array("SORT" => "ASC"),
1180 array("ORDER_PROPS_ID" => $arProperties["ID"]),
1181 false,
1182 false,
1183 array("*")
1184 );
1185 while ($arVariants = $dbVariants->Fetch())
1186 {
1187 $resultHtml .= '<option value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
1188 if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
1189 $resultHtml .= " selected";
1190 $resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
1191 }
1192 $resultHtml .= '</select>';
1193 }
1194 elseif ($arProperties["TYPE"] == "MULTISELECT")
1195 {
1196 $size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;
1197
1198 $resultHtml .= '<select multiple name="ORDER_PROP_'.$arProperties["ID"].'[]" ';
1199 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
1200 $resultHtml .= 'size='.$size.' ';
1201 $resultHtml .= 'class="typeselect" type="multyselect">';
1202
1203 if (!is_array($curVal))
1204 {
1205 if ($curVal <> '' OR $ORDER_ID != "")
1206 $curVal = explode(",", $curVal);
1207 else
1208 $curVal = explode(",", $arProperties["DEFAULT_VALUE"]);
1209
1210 $arCurVal = array();
1211 $countCurVal = count($curVal);
1212 for ($i = 0; $i < $countCurVal; $i++)
1213 $arCurVal[$i] = trim($curVal[$i]);
1214 }
1215 else
1216 $arCurVal = $curVal;
1217
1218 $dbVariants = CSaleOrderPropsVariant::GetList(
1219 array("SORT" => "ASC"),
1220 array("ORDER_PROPS_ID" => $arProperties["ID"]),
1221 false,
1222 false,
1223 array("*")
1224 );
1225 while ($arVariants = $dbVariants->Fetch())
1226 {
1227 $resultHtml .= '<option value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
1228 if (in_array($arVariants["VALUE"], $arCurVal))
1229 $resultHtml .= " selected";
1230 $resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
1231 }
1232 $resultHtml .= '</select>';
1233 }
1234 elseif ($arProperties["TYPE"] == "TEXTAREA")
1235 {
1236 $resultHtml .= '<textarea ';
1237 $resultHtml .= 'rows="4" ';
1238 $resultHtml .= 'cols="40" ';
1239 $resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
1240 $resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" type="textarea">';
1241 $resultHtml .= ((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]);
1242 $resultHtml .= '</textarea>';
1243 }
1244 elseif ($arProperties["TYPE"] == "LOCATION")
1245 {
1246 $countryID = "";
1247 $cityID = "";
1248 $cityList = "";
1249 $DELIVERY_LOCATION = $arPropValues[intval($arProperties["ID"])];
1250 $locationID = $curVal;
1251 $tmpLocation = '';
1252
1253 ob_start();
1254
1255 CSaleLocation::proxySaleAjaxLocationsComponent(
1256 array(
1257 "SITE_ID" => $LID,
1258 "AJAX_CALL" => "N",
1259 "COUNTRY_INPUT_NAME" => "ORDER_PROP_".$arProperties["ID"],
1260 "REGION_INPUT_NAME" => "REGION_ORDER_PROP_".$arProperties["ID"],
1261 "CITY_INPUT_NAME" => "CITY_ORDER_PROP_".$arProperties["ID"],
1262 "CITY_OUT_LOCATION" => "Y",
1263 "ALLOW_EMPTY_CITY" => "Y",
1264 "LOCATION_VALUE" => $curVal,
1265 "COUNTRY" => "",
1266 "ONCITYCHANGE" => "",
1267 "PUBLIC" => "N",
1268 ),
1269 array(
1270 "ID" => "",
1271 "CODE" => $curVal,
1272 "PROVIDE_LINK_BY" => "code",
1273 )
1274 );
1275
1276 $tmpLocation = ob_get_contents();
1277 ob_end_clean();
1278
1279 $resultHtml .= '<script>var locationID = \''.$arProperties["ID"].'\';</script>';
1280 $resultHtml .= $tmpLocation;
1281 }
1282 elseif ($arProperties["TYPE"] == "RADIO")
1283 {
1284 $dbVariants = CSaleOrderPropsVariant::GetList(
1285 array("SORT" => "ASC"),
1286 array("ORDER_PROPS_ID" => $arProperties["ID"]),
1287 false,
1288 false,
1289 array("*")
1290 );
1291 $resultHtml .= '<div id="ORDER_PROP_'.$arProperties["ID"].'">';// type="radio"
1292 while ($arVariants = $dbVariants->Fetch())
1293 {
1294 $resultHtml .= '<input type="radio" class="inputradio" ';
1295 $resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
1296 $resultHtml .= 'value="'.htmlspecialcharsEx($arVariants["VALUE"]).'"';
1297 if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
1298 $resultHtml .= " checked";
1299 $resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'<br>';
1300 }
1301 $resultHtml .= '</div>';
1302 }
1303 elseif ($arProperties["TYPE"] == "FILE")
1304 {
1305 $arValues = array();
1306 $arTmpValues = array();
1307 if (isset($arPropValues[$arProperties["ID"]]) && !is_array($arPropValues[$arProperties["ID"]]))
1308 {
1309 $arTmpValues = explode(", ", $arPropValues[$arProperties["ID"]]);
1310 foreach ($arTmpValues as $key => $value)
1311 $arValues[$value] = $value;
1312 }
1313
1314 $resultHtml .= fShowFilePropertyField("ORDER_PROP_".$arProperties["ID"], $arProperties, $arValues, $arProperties["SIZE1"], $formVarsSubmit);
1315 }
1316
1317 if ($arProperties["DESCRIPTION"] <> '')
1318 {
1319 $resultHtml .= "<br><small>".htmlspecialcharsEx($arProperties["DESCRIPTION"])."</small>";
1320 }
1321 $resultHtml .= "\n</td>\n</tr>";
1322
1323 }//end while
1324 }
1325
1326 $resultHtml .= "</table>";
1327
1328 return $resultHtml;
1329}
1330
1331/*
1332 * Returns HTML control with payment systems data
1333 */
1334function fGetPaySystemsHTML($PERSON_TYPE_ID, $PAY_SYSTEM_ID)
1335{
1336 $resultHtml = "<table width=\"100%\">";
1337 $resultHtml .= "<tr class=\"adm-detail-required-field\">\n<td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("SOE_PAY_SYSTEM").":</td><td class=\"adm-detail-content-cell-r\" width=\"60%\">";
1338
1339 $arPaySystem = CSalePaySystem::DoLoadPaySystems($PERSON_TYPE_ID);
1340
1341 $resultHtml .= "<select name=\"PAY_SYSTEM_ID\" id=\"PAY_SYSTEM_ID\" onChange=\"fChangePaymentSystem();\">\n";
1342 $resultHtml .= "<option value=\"\">(".GetMessage("SOE_SELECT").")</option>";
1343 foreach ($arPaySystem as $key => $val)
1344 {
1345 $resultHtml .= "<option value=\"".$key."\"";
1346 if ($key == intval($PAY_SYSTEM_ID))
1347 $resultHtml .= " selected";
1348 $resultHtml .= ">".$val["NAME"]." [".$key."]</option>";
1349 }
1350 $resultHtml .= "</select>";
1351 $resultHtml .= "</td>\n</tr>";
1352 $resultHtml .= "</table>";
1353
1354 return $resultHtml;
1355}
1356
1357/*
1358 * user profile
1359 */
1360function fUserProfile($USER_ID, $BUYER_TYPE = '', $default = '')
1361{
1362 $userProfileSelect = "<select name=\"user_profile\" id=\"user_profile\" onChange=\"fChangeProfile(this);\">";
1363 $userProfileSelect .= "<option value=\"0\">".GetMessage("NEWO_BUYER_PROFILE_NEW")."</option>";
1364 $userProfile = CSaleOrderUserProps::DoLoadProfiles($USER_ID, $BUYER_TYPE);
1365 $i = "";
1366 if (!empty($userProfile) && is_array($userProfile))
1367 {
1368 foreach($userProfile as $key => $val)
1369 {
1370 if ($default == "" AND $i == "")
1371 {
1372 $userProfileSelect .= "<option selected value=\"".$key."\">".$val["NAME"]."</option>";
1373 $i = $key;
1374 }
1375 elseif ($default == $key)
1376 $userProfileSelect .= "<option selected value=\"".$key."\">".$val["NAME"]."</option>";
1377 else
1378 $userProfileSelect .= "<option value=\"".$key."\">".$val["NAME"]."</option>";
1379 }
1380 }
1381 $userProfileSelect .= "</select>";
1382
1383 return $userProfileSelect;
1384}
1385
1386/*
1387 * user balance
1388 */
1389function fGetPayFromAccount($USER_ID, $CURRENCY)
1390{
1391 $arResult = array("PAY_MESSAGE" => GetMessage("NEWO_PAY_FROM_ACCOUNT_NO"));
1392 $dbUserAccount = CSaleUserAccount::GetList(
1393 array(),
1394 array(
1395 "USER_ID" => $USER_ID,
1396 "CURRENCY" => $CURRENCY,
1397 )
1398 );
1399 if ($arUserAccount = $dbUserAccount->GetNext())
1400 {
1401 if ((float)$arUserAccount["CURRENT_BUDGET"] > 0)
1402 {
1403 $arResult["PAY_BUDGET"] = SaleFormatCurrency($arUserAccount["CURRENT_BUDGET"], $CURRENCY);
1404 $arResult["PAY_MESSAGE"] = str_replace("#MONEY#", $arResult["PAY_BUDGET"], GetMessage("NEWO_PAY_FROM_ACCOUNT_YES"));
1405 $arResult["CURRENT_BUDGET"] = $arUserAccount["CURRENT_BUDGET"];
1406 }
1407 }
1408
1409 return $arResult;
1410}
1411
1416function fGetDeliverySystemsHTML($location, $locationZip, $weight, $price, $currency, $siteId, $defaultDelivery, $arShoppingCart)
1417{
1418 $arResult = array();
1419 $description = "";
1420 $error = "";
1421 $setDeliveryPrice = false;
1422
1423 $arDelivery = CSaleDelivery::DoLoadDelivery($location, $locationZip, $weight, $price, $currency, $siteId, $arShoppingCart);
1424 if (empty($arDelivery) || !is_array($arDelivery))
1425 {
1426 $arDelivery = [];
1427 }
1428
1429 $deliveryHTML = "<select name=\"DELIVERY_ID\" id=\"DELIVERY_ID\" onchange=\"fChangeDelivery();\">";
1430 $deliveryHTML .= "<option value=\"\">".GetMessage('NEWO_DELIVERY_NO')."</option>";
1431
1432 if (count($arDelivery) > 0)
1433 {
1434 foreach($arDelivery as $val)
1435 {
1436 if (isset($val["PROFILES"]))
1437 {
1438 foreach($val["PROFILES"] as $k => $v)
1439 {
1440 $currency = $v["CURRENCY"];
1441 $selected = "";
1442 if ($v["ID"] == $defaultDelivery)
1443 {
1444 $selected = " selected=\"selected\"";
1445
1446 if (floatval($v["DELIVERY_PRICE"]) <= 0)
1447 {
1448 $error = "<div class='error'>".GetMessage('NEWO_DELIVERY_ERR')."</div>";
1449 $v["DELIVERY_PRICE"] = 0;
1450 $val["DESCRIPTION"] = "";
1451 }
1452 $price = $v["DELIVERY_PRICE"];
1453 $description = $val["DESCRIPTION"];
1454 $setDeliveryPrice = true;
1455 }
1456
1457 $deliveryHTML .= "<option".$selected." value=\"".$v["ID"]."\">".$val["TITLE"]." (".$v["TITLE"].") [".$v["ID"]."]</option>";
1458 }
1459 }
1460 else
1461 {
1462 $currency = $val["CURRENCY"];
1463 $selected = "";
1464 if ($val["ID"] == $defaultDelivery)
1465 {
1466 $selected = " selected=\"selected\"";
1467 $price = $val["PRICE"];
1468 $setDeliveryPrice = true;
1469 $description = $val["DESCRIPTION"];
1470 }
1471
1472 $deliveryHTML .= "<option".$selected." value=\"".$val["ID"]."\">".$val["NAME"]." [".$val["ID"]."]</option>";
1473 }
1474 }
1475 }
1476
1477 $deliveryHTML .= "</select>";
1478
1479 $arResult["DELIVERY"] = $deliveryHTML;
1480 $arResult["DELIVERY_DEFAULT"] = $defaultDelivery;
1481 $arResult["DELIVERY_DEFAULT_PRICE"] = (count($arDelivery) > 0 && $setDeliveryPrice === true) ? $price : 0;
1482 $arResult["DELIVERY_DEFAULT_DESCRIPTION"] = $description;
1483 $arResult["DELIVERY_DEFAULT_ERR"] = $error;
1484 $arResult["CURRENCY"] = $currency;
1485
1486 return $arResult;
1487}
1488
1489/*
1490 * coupons
1491 */
1492function fGetCoupon($COUPON)
1493{
1494 $arCoupon = array();
1495 if (!empty($COUPON))
1496 {
1497 if (is_array($COUPON))
1498 {
1499 foreach ($COUPON as &$oneCoupon)
1500 {
1501 $oneCoupon = trim((string)$oneCoupon);
1502 if ($oneCoupon != '')
1503 $arCoupon[] = $oneCoupon;
1504 }
1505 unset($oneCoupon);
1506 }
1507 else
1508 {
1509 $coupons = explode(",", $COUPON);
1510 if (!empty($coupons))
1511 {
1512 foreach($coupons as &$val)
1513 {
1514 $val = trim($val);
1515 if ($val != '')
1516 $arCoupon[] = $val;
1517 }
1518 unset($val);
1519 }
1520 }
1521 }
1522 return $arCoupon;
1523}
1524
1525/*
1526 * get location ID and ZIP
1527 */
1528function fGetLocationID($PERSON_TYPE_ID)
1529{
1530 $arResult = array();
1531 $dbProperties = CSaleOrderProps::GetList(
1532 array("SORT" => "ASC"),
1533 array("PERSON_TYPE_ID" => $PERSON_TYPE_ID),
1534 false,
1535 false,
1536 array("TYPE", "IS_ZIP", "ID", "SORT")
1537 );
1538 while ($arProperties = $dbProperties->Fetch())
1539 {
1540 if ($arProperties["TYPE"] == "TEXT")
1541 {
1542 if ($arProperties["IS_ZIP"] == "Y")
1543 {
1544 $arResult["LOCATION_ZIP_ID"] = $arProperties["ID"];
1545 }
1546 }
1547 elseif ($arProperties["TYPE"] == "LOCATION")
1548 {
1549 $arResult["LOCATION_ID"] = $arProperties["ID"];
1550 }
1551 }
1552
1553 return $arResult;
1554}
1555
1556/*
1557 * product basket array
1558 */
1559function fGetUserShoppingCart($arProduct, $LID, $recalcOrder)
1560{
1561 $arOrderProductPrice = array();
1562 $i = 0;
1563
1564 $arSortNum = array();
1565 foreach($arProduct as $key => $val)
1566 {
1567 $arSortNum[] = $val['PRICE_DEFAULT'];
1568 $arProduct[$key]["PRODUCT_ID"] = (int)$val["PRODUCT_ID"];
1569 $arProduct[$key]["TABLE_ROW_ID"] = $key;
1570 }
1571 if (!empty($arProduct) && !empty($arSortNum))
1572 array_multisort($arSortNum, SORT_DESC, $arProduct);
1573
1574 $arBasketIds = array();
1575 $basketMap = array();
1576 foreach($arProduct as $key => $val)
1577 {
1578 $val["QUANTITY"] = abs(str_replace(",", ".", $val["QUANTITY"]));
1579 $val["QUANTITY_DEFAULT"] = $val["QUANTITY"];
1580 $val["PRICE"] = str_replace(",", ".", $val["PRICE"]);
1581
1582 // Y is used when custom price was set in the admin form
1583 if ($val["CALLBACK_FUNC"] == "Y")
1584 {
1585 $val["CALLBACK_FUNC"] = false;
1586 $val["CUSTOM_PRICE"] = "Y";
1587
1588 if (isset($val["BASKET_ID"]) && (int)$val["BASKET_ID"] > 0)
1589 {
1590 CSaleBasket::Update($val["BASKET_ID"], array("CUSTOM_PRICE" => "Y"));
1591 }
1592
1593 //$val["DISCOUNT_PRICE"] = $val["PRICE_DEFAULT"] - $val["PRICE"];
1594 }
1595
1596 $arOrderProductPrice[$i] = $val;
1597 $arOrderProductPrice[$i]["TABLE_ROW_ID"] = $val["TABLE_ROW_ID"];
1598 $arOrderProductPrice[$i]["NAME"] = htmlspecialcharsback($val["NAME"]);
1599 $arOrderProductPrice[$i]["LID"] = $LID;
1600 $arOrderProductPrice[$i]["CAN_BUY"] = "Y";
1601 $arOrderProductPrice[$i]['RESERVED'] = 'N';
1602
1603 if (isset($val["BASKET_ID"]) && (int)$val["BASKET_ID"] > 0)
1604 {
1605 $basketId = (int)$val["BASKET_ID"];
1606 $arOrderProductPrice[$i]["ID"] = $basketId;
1607
1608 $arBasketIds[] = $basketId;
1609 $basketMap[$basketId] = &$arOrderProductPrice[$i];
1610
1611 if ($recalcOrder != "Y" && $arOrderProductPrice[$i]["CALLBACK_FUNC"] != false)
1612 unset($arOrderProductPrice[$i]["CALLBACK_FUNC"]);
1613
1614 $arNewProps = array();
1615 if (is_array($val["PROPS"]))
1616 {
1617 foreach($val["PROPS"] as $k => $v)
1618 {
1619 if ($v["NAME"] != "" AND $v["VALUE"] != "")
1620 $arNewProps[$k] = $v;
1621 }
1622 }
1623 else
1624 $arNewProps = array("NAME" => "", "VALUE" => "", "CODE" => "", "SORT" => "");
1625
1626 $arOrderProductPrice[$i]["PROPS"] = $arNewProps;
1627 }
1628 $i++;
1629 }//endforeach $arProduct
1630
1631 // collect status of reservation elements basket
1632 if (!empty($arBasketIds))
1633 {
1634 $rsBasketItems = CSaleBasket::GetList(
1635 array(),
1636 array("ID" => $arBasketIds),
1637 false,
1638 false,
1639 array(
1640 "ID",
1641 "RESERVED",
1642 )
1643 );
1644 while ($arBasketItems = $rsBasketItems->Fetch())
1645 {
1646 $arBasketItems['ID'] = (int)$arBasketItems['ID'];
1647 if (!isset($basketMap[$arBasketItems['ID']]))
1648 continue;
1649 $basketMap[$arBasketItems['ID']]['RESERVED'] = $arBasketItems['RESERVED'];
1650 }
1651 unset($arBasketItems, $rsBasketItems);
1652 }
1653 unset($basketMap, $arBasketIds);
1654
1655 return $arOrderProductPrice;
1656}
1657
1658/*
1659 * Returns HTML for recommended product, basket product or product from the viewed list
1660 */
1661function fGetFormatedProduct($USER_ID, $LID, $arData, $currency, $type = '')
1662{
1663 global $crmMode;
1664 $result = "";
1665 $arSet = array();
1666
1667 if (!is_array($arData["ITEMS"]) || count($arData["ITEMS"]) <= 0)
1668 return $result;
1669
1670 $result = "<table width=\"100%\">";
1671 if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock'))
1672 {
1673 $arProductId = array();
1674 $arDataTab = array();
1675
1676 $arSkuParentChildren = array();
1677 $arSkuParentId = array();
1678 $arSkuParent = array();
1679
1680 foreach ($arData["ITEMS"] as $item)
1681 {
1682 if (!empty($item["CURRENCY"]) && $item["CURRENCY"] != $currency)
1683 {
1684 if (floatval($item["PRICE"]) > 0)
1685 $item["PRICE"] = CCurrencyRates::ConvertCurrency($item["PRICE"], $item["CURRENCY"], $currency);
1686
1687 if (floatval($item["DISCOUNT_PRICE"]) > 0)
1688 $item["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($item["DISCOUNT_PRICE"], $item["CURRENCY"], $currency);
1689
1690 $item["CURRENCY"] = $currency;
1691 }
1692
1694 if ($productProvider = CSaleBasket::GetProductProvider($item))
1695 {
1696 if (method_exists($productProvider, "GetSetItems"))
1697 {
1698 $itemInfo = (isset($item['ID']) ? array('BASKET_ID' => $item['ID']) : array());
1699 $arSets = $productProvider::GetSetItems($item["PRODUCT_ID"], CSaleBasket::TYPE_SET, $itemInfo);
1700 unset($itemInfo);
1701
1702 if (is_array($arSets))
1703 {
1704 foreach ($arSets as $arSetData)
1705 {
1706 foreach ($arSetData["ITEMS"] as $setItem)
1707 {
1708 $setItem["FUSER_ID"] = $item["FUSER_ID"];
1709 $setItem["LID"] = $item["LID"];
1710 $setItem["MODULE"] = $item["MODULE"];
1711 $setItem["PRODUCT_PROVIDER_CLASS"] = $productProvider;
1712 $setItem["SET_PARENT_ID"] = $item["ID"];
1713
1714 $arSet[$item["PRODUCT_ID"]][] = $setItem;
1715 }
1716 }
1717 }
1718 }
1719 }
1720
1721 if ($item["MODULE"] == "catalog")
1722 {
1723 $arProductId[$item["PRODUCT_ID"]] = $item["PRODUCT_ID"];
1724 $arDataTab[$item["PRODUCT_ID"]] = $item;
1725
1726 $arParent = CCatalogSku::GetProductInfo($item["PRODUCT_ID"]);
1727 if ($arParent)
1728 {
1729 $arSkuParentChildren[$item["PRODUCT_ID"]] = $arParent["ID"];
1730 $arSkuParentId[$arParent["ID"]] = $arParent["ID"];
1731 }
1732 }
1733 }
1734
1735 if(!empty($arSkuParentId))
1736 {
1737 $res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
1738 while ($arItems = $res->GetNext())
1739 $arSkuParent[$arItems["ID"]] = $arItems;
1740 }
1741
1742 if(!empty($arProductId))
1743 {
1744 $dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
1745 while($arProduct = $dbProduct->Fetch())
1746 {
1747 $imgCode = 0;
1748 $arImgProduct = false;
1749 $arFile = false;
1750 $imgUrl = '';
1751 $imgProduct = '';
1752 $arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
1753 $arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
1754 $arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
1755 $arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
1756 $arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
1757 $item = $arDataTab[$arProduct['ID']];
1758
1759 if ($item["PREVIEW_PICTURE"] == "" && $item["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$item["PRODUCT_ID"]]))
1760 {
1761 $idTmp = $arSkuParentChildren[$item["PRODUCT_ID"]];
1762 $item["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
1763 $item["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
1764 }
1765
1766 if ($item["DETAIL_PICTURE"] > 0)
1767 $imgCode = $item["DETAIL_PICTURE"];
1768 elseif ($item["PREVIEW_PICTURE"] > 0)
1769 $imgCode = $item["PREVIEW_PICTURE"];
1770
1771 $arSkuProperty = CSaleProduct::GetProductSkuProps($item["PRODUCT_ID"], $item["IBLOCK_ID"]);
1772
1773 $item["NAME"] = htmlspecialcharsex($item["NAME"]);
1774 $item["EDIT_PAGE_URL"] = htmlspecialcharsex($item["EDIT_PAGE_URL"]);
1775 $item["CURRENCY"] = htmlspecialcharsex($item["CURRENCY"]);
1776
1777 if ($imgCode > 0)
1778 {
1779 $arFile = CFile::GetFileArray($imgCode);
1780 $arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
1781 }
1782
1783 if (is_array($arImgProduct))
1784 {
1785 $imgUrl = $arImgProduct["src"];
1786 $imgProduct = "<a href=\"".$item["EDIT_PAGE_URL"]."\" target=\"_blank\"><img src=\"".$imgUrl."\" alt=\"\" title=\"".$item["NAME"]."\" ></a>";
1787 }
1788 else
1789 $imgProduct = "<div class='no_foto'>".GetMessage('NO_FOTO')."</div>";
1790
1791 $arCurFormat = CCurrencyLang::GetCurrencyFormat($item["CURRENCY"]);
1792 $priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
1793
1794 $currentTotalPrice = ($item["PRICE"] + $item["DISCOUNT_PRICE"]);
1795
1796 $discountPercent = 0;
1797 if ($item["DISCOUNT_PRICE"] > 0)
1798 $discountPercent = intval(($item["DISCOUNT_PRICE"] * 100) / $currentTotalPrice);
1799
1800 $arProduct = CCatalogProduct::GetByID($item["PRODUCT_ID"]);
1801 $balance = floatval($arProduct["QUANTITY"]);
1802
1803 $result .= "<tr id='more_".$type."_".$item["ID"]."'>
1804 <td class=\"tab_img\" >".$imgProduct."</td>
1805 <td class=\"tab_text\">
1806 <div class=\"order_name\"><a href=\"".$item["EDIT_PAGE_URL"]."\" target=\"_blank\" title=\"".$item["NAME"]."\">".$item["NAME"]."</a></div>
1807 <div class=\"order_price\">
1808 ".GetMessage('NEWO_SUBTAB_PRICE').": <b>".SaleFormatCurrency($item["PRICE"], $currency)."</b>";
1809
1810 if (!empty($arSet) && array_key_exists($arProduct["ID"], $arSet)) // show/hide set item link
1811 {
1812 $result .= '<br/>
1813 <div>
1814 <a id="set_toggle_link_b'.$arProduct["ID"].'"
1815 href="javascript:void(0);"
1816 class="dashed-link show-set-link"
1817 title="'.GetMessage("SOE_SHOW_SET").'"
1818 onclick="fToggleSetItems(\'b'.$arProduct["ID"].'\');">'.GetMessage("SOE_SHOW_SET").'</a>
1819 </div>';
1820 }
1821
1822 $result .= "</div>";
1823
1824 $arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $item["PRODUCT_ID"], $item["NAME"], $currency, $arProduct);
1825
1826 if (count($arResult["SKU_ELEMENTS"]) > 0)
1827 {
1828 foreach ($arResult["SKU_ELEMENTS"] as $key => $val)
1829 {
1830 $arTmp = array();
1831 foreach ($val as $k => $v)
1832 {
1833 if (is_numeric($k))
1834 {
1835 $arTmp[$arResult["SKU_PROPERTIES"][$k]["NAME"]] = $v;
1836 }
1837 }
1838 $arResult["SKU_ELEMENTS"][$key]["SKU_PROPS"] = CUtil::PhpToJSObject($arTmp);
1839 }
1840 }
1841
1842 $arResult["POPUP_MESSAGE"] = array(
1843 "PRODUCT_ADD" => GetMessage('NEWO_POPUP_TO_BASKET'),
1844 "PRODUCT_ORDER" => GetMessage('NEWO_POPUP_TO_ORDER'),
1845 "PRODUCT_NOT_ADD" => GetMessage('NEWO_POPUP_DONT_CAN_BUY'),
1846 "PRODUCT_PRICE_FROM" => GetMessage('NEWO_POPUP_FROM')
1847 );
1848
1849 if (count($arResult["SKU_ELEMENTS"]) <= 0)
1850 $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProduct('".$type."', ".$item["PRODUCT_ID"].");return false;\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_BASKET')."</a><br>";
1851 else
1852 $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProductSku(".CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']).", ".CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']).", 'basket', ".CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]).");\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_BASKET')."</a><br>";
1853
1854 if (!$crmMode)
1855 {
1856 if (count($arResult["SKU_ELEMENTS"]) > 0)
1857 {
1858 $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProductSku(".CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']).", ".CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']).", 'neworder', ".CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]).");\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_ORDER')."</a>";
1859 }
1860 else
1861 {
1862 $cntProd = (floatval($item["QUANTITY"]) > 0) ? floatval($item["QUANTITY"]) : 1;
1863 $url = "/bitrix/admin/sale_order_new.php?lang=".LANGUAGE_ID."&user_id=".$USER_ID."&LID=".$LID."&product[".$item["PRODUCT_ID"]."]=".$cntProd;
1864 $result .= "<a href=\"".$url."\" target=\"_blank\" class=\"get_new_order\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_ORDER')."</a>";
1865 }
1866 }
1867
1868 $result .= "</td></tr>";
1869
1870 // show set items
1871 if (!empty($arSet) && array_key_exists($arProduct["ID"], $arSet))
1872 {
1873 foreach ($arSet[$arProduct["ID"]] as $set)
1874 {
1875 $editUrl = CIBlock::GetAdminElementEditLink($set["IBLOCK_ID"], $set["ITEM_ID"], array(
1876 "find_section_section" => $set["IBLOCK_SECTION_ID"],
1877 'WF' => 'Y',
1878 ));
1879
1880 if ($set["PREVIEW_PICTURE"] > 0)
1881 $imgCode = $set["PREVIEW_PICTURE"];
1882 elseif ($set["DETAIL_PICTURE"] > 0)
1883 $imgCode = $set["DETAIL_PICTURE"];
1884
1885 if ($imgCode > 0)
1886 {
1887 $arFile = CFile::GetFileArray($imgCode);
1888 $arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
1889 if (is_array($arImgProduct))
1890 {
1891 $imgUrl = $arImgProduct["src"];
1892 $img = '<a href="'.$editUrl.'" target="_blank"><img src="'.$arImgProduct["src"].'" alt="" title="'.$set["NAME"].'" ></a>';
1893 }
1894 }
1895 else
1896 $img = '<div class="no_foto">'.GetMessage('SOD_NO_FOTO')."</div>";
1897
1898 $result .= '
1899 <tr style="display:none" class="set_item_b'.$arProduct["ID"].'">
1900 <td class="tab_img">'.$img.'</td>
1901 <td class="tab_text">
1902 <div class="order_name">
1903 <a href="'.$editUrl.'" style="font-style:italic" target="_blank" title="'.$set["NAME"].'">'.$set["NAME"].'</a>
1904 </div>
1905 <div class="order_price">'.GetMessage('NEWO_SUBTAB_PRICE').': <b>'.SaleFormatCurrency($set["PRICE"], $currency).'</b></div>
1906 </td>
1907 </tr>';
1908 }
1909 }
1910
1911 }//end foreach
1912 }
1913 }//end if
1914
1915 if ($arData["CNT"] > 2 && $arData["CNT"] != count($arData["ITEMS"]))
1916 {
1917 $result .= "<tr><td colspan='2' align='right' class=\"more_product\">";
1918 if ($type == "basket")
1919 $result .= "<a href='javascript:void(0);' onClick='fGetMoreBasket(\"Y\");' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
1920 elseif ($type == "viewed")
1921 $result .= "<a href='javascript:void(0);' onClick='fGetMoreViewed(\"Y\");' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
1922 else
1923 $result .= "<a href='javascript:void(0);' onClick='fGetMoreRecom();' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
1924 $result .= "</td></tr>";
1925 }
1926
1927 $result .= "</table>";
1928
1929 return $result;
1930}
1931
1932function fDeleteDoubleProduct($arShoppingCart = array(), $arDelete = array(), $showAll = 'N')
1933{
1934 global $COUNT_RECOM_BASKET_PROD;
1935 $arResult = array(
1936 "CNT" => 0,
1937 "ITEMS" => array(),
1938 );
1939
1940 $arShoppingCartTmp = array();
1941 $arProductId = array();
1942 if (empty($arDelete) ||!is_array($arDelete))
1943 $arDelete = array();
1944
1945 if (!empty($arShoppingCart) && is_array($arShoppingCart))
1946 {
1947 foreach($arShoppingCart as $key => $val)
1948 {
1949 if (!in_array($val["PRODUCT_ID"], $arDelete))
1950 {
1951 $arShoppingCartTmp[] = $val;
1952 $arProductId[] = $val["PRODUCT_ID"];
1953 }
1954 }
1955 }
1956
1957 if (!empty($arShoppingCartTmp))
1958 {
1959 if (CModule::IncludeModule('catalog'))
1960 {
1961 $i = 0;
1962
1963 $arSection = array();
1964 $res = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'IBLOCK_TYPE_ID'));
1965 while ($arSectionTmp = $res->Fetch())
1966 $arSection[$arSectionTmp["ID"]] = $arSectionTmp;
1967
1968 foreach($arShoppingCartTmp as $key => $val)
1969 {
1970 if (!isset($val["PRODUCT_ID"]))
1971 $val["PRODUCT_ID"] = $val["ID"];
1972
1973 if ((!isset($val["EDIT_PAGE_URL"]) || $val["EDIT_PAGE_URL"] == "") && $arSection[$val["PRODUCT_ID"]]["IBLOCK_ID"] > 0)
1974 {
1975 $val["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arSection[$val["PRODUCT_ID"]]["IBLOCK_ID"], $val["PRODUCT_ID"], array(
1976 "find_section_section" => $arSection[$val["PRODUCT_ID"]]["IBLOCK_SECTION_ID"],
1977 'WF' => 'Y',
1978 ));
1979 }
1980
1981 $arResult["ITEMS"][] = $val;
1982 $i++;
1983 if ($i >= $COUNT_RECOM_BASKET_PROD && $showAll == "N")
1984 break;
1985 }
1986 }
1987 }
1988
1989 if ($showAll == "Y")
1990 $arResult["CNT"] = count($arResult["ITEMS"]);
1991 else
1992 $arResult["CNT"] = count($arShoppingCartTmp);
1993
1994 return $arResult;
1995}
1996
1997function getNameCount($propName, $propCode, $arProps)
1998{
1999 $count = 1;
2000 foreach ($arProps as &$arData)
2001 {
2002 if (isset($arData["NAME"]) && $arData["NAME"] == $propName && $propCode != $arData["CODE"])
2003 $count++;
2004 }
2005 unset($arData);
2006 return $count;
2007}
2008
2009function getIblockNames($arIblockIDs, $arIblockNames)
2010{
2011 $str = '';
2012 foreach ($arIblockIDs as &$iblockID)
2013 {
2014 $str .= '"'.$arIblockNames[$iblockID].'", ';
2015 }
2016 unset($iblockID);
2017 $str .= '#';
2018
2019 return str_replace(', #', '', $str);
2020}
2021
2023{
2024 static $propList = null;
2025
2026 if ($propList === null && Loader::includeModule('catalog'))
2027 {
2028 $arIblockIDs = array();
2029 $arIblockNames = array();
2030 $catalogIterator = Catalog\CatalogIblockTable::getList(array(
2031 'select' => array('IBLOCK_ID', 'NAME' => 'IBLOCK.NAME'),
2032 'order' => array('IBLOCK_ID' => 'ASC')
2033 ));
2034 while ($catalog = $catalogIterator->fetch())
2035 {
2036 $catalog['IBLOCK_ID'] = (int)$catalog['IBLOCK_ID'];
2037 $arIblockIDs[] = $catalog['IBLOCK_ID'];
2038 $arIblockNames[$catalog['IBLOCK_ID']] = $catalog['NAME'];
2039 }
2040 unset($catalog, $catalogIterator);
2041
2042 if (!empty($arIblockIDs))
2043 {
2044 $arProps = array();
2045 $propertyIterator = Iblock\PropertyTable::getList(array(
2046 'select' => array('ID', 'CODE', 'NAME', 'IBLOCK_ID'),
2047 'filter' => array('@IBLOCK_ID' => $arIblockIDs, '=ACTIVE' => 'Y'),
2048 'order' => array('IBLOCK_ID' => 'ASC', 'SORT' => 'ASC', 'ID' => 'ASC')
2049 ));
2050 while ($property = $propertyIterator->fetch())
2051 {
2052 $property['ID'] = (int)$property['ID'];
2053 $property['IBLOCK_ID'] = (int)$property['IBLOCK_ID'];
2054 $property['CODE'] = (string)$property['CODE'];
2055 if ($property['CODE'] == '')
2056 $property['CODE'] = $property['ID'];
2057 if (!isset($arProps[$property['CODE']]))
2058 {
2059 $arProps[$property['CODE']] = array(
2060 'CODE' => $property['CODE'],
2061 'TITLE' => $property['NAME'].' ['.$property['CODE'].']',
2062 'ID' => array($property['ID']),
2063 'IBLOCK_ID' => array($property['IBLOCK_ID'] => $property['IBLOCK_ID']),
2064 'IBLOCK_TITLE' => array($property['IBLOCK_ID'] => $arIblockNames[$property['IBLOCK_ID']]),
2065 'COUNT' => 1
2066 );
2067 }
2068 else
2069 {
2070 $arProps[$property['CODE']]['ID'][] = $property['ID'];
2071 $arProps[$property['CODE']]['IBLOCK_ID'][$property['IBLOCK_ID']] = $property['IBLOCK_ID'];
2072 if ($arProps[$property['CODE']]['COUNT'] < 2)
2073 $arProps[$property['CODE']]['IBLOCK_TITLE'][$property['IBLOCK_ID']] = $arIblockNames[$property['IBLOCK_ID']];
2074 $arProps[$property['CODE']]['COUNT']++;
2075 }
2076 }
2077 unset($property, $propertyIterator, $arIblockNames, $arIblockIDs);
2078
2079 $propList = array();
2080 foreach ($arProps as &$property)
2081 {
2082 $iblockList = '';
2083 if ($property['COUNT'] > 1)
2084 {
2085 $iblockList = ($property['COUNT'] > 2 ? ' ( ... )' : ' ('.implode(', ', $property['IBLOCK_TITLE']).')');
2086 }
2087 $propList['PROPERTY_'.$property['CODE']] = $property['TITLE'].$iblockList;
2088 }
2089 unset($property, $arProps);
2090 }
2091 }
2092
2093 return (empty($propList) ? array() : $propList);
2094}
2095
2096/*
2097 * Returns old history data records (used before august 2013) in the new format
2098 */
2100{
2101 foreach ($arFields as $fieldname => $fieldvalue)
2102 {
2103 if ($fieldvalue <> '')
2104 {
2105 foreach (CSaleOrderChangeFormat::$operationTypes as $code => $arInfo)
2106 {
2107 if (in_array($fieldname, $arInfo["TRIGGER_FIELDS"]))
2108 {
2109 $arData = array();
2110 foreach ($arInfo["DATA_FIELDS"] as $field)
2111 $arData[$field] = $arFields["$field"];
2112
2113 return array(
2114 "ID" => $arFields["ID"],
2115 "ORDER_ID" => $arFields["H_ORDER_ID"],
2116 "TYPE" => $code,
2117 "DATA" => serialize($arData),
2118 "DATE_CREATE" => $arFields["H_DATE_INSERT"],
2119 "DATE_MODIFY" => $arFields["H_DATE_INSERT"],
2120 "USER_ID" => $arFields["H_USER_ID"]
2121 );
2122 }
2123 }
2124 }
2125 }
2126
2127 return false;
2128}
2129
2130/*
2131 * Returns HTML to download or view file (if image) in the order_detail
2132 */
2133function showImageOrDownloadLink($fileId, $orderId = 0, $arSize = array("WIDTH" => 90, "HEIGHT" => 90))
2134{
2135 $resultHTML = "";
2136 $arFile = CFile::GetFileArray($fileId);
2137
2138 if ($arFile)
2139 {
2140 $is_image = CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"]);
2141 if ($is_image)
2142 $resultHTML = CFile::ShowImage($arFile["ID"], $arSize["WIDTH"], $arSize["HEIGHT"], "border=0", "", true);
2143 else
2144 $resultHTML = "<a href=\"sale_order_detail.php?ID=".$orderId."&download=Y&file_id=".$arFile["ID"]."&".bitrix_sessid_get()."\">".$arFile["ORIGINAL_NAME"]."</a>";
2145 }
2146
2147 return $resultHTML;
2148}
2149
2150function getIblockPropInfo($value, $propData, $arSize = array("WIDTH" => 90, "HEIGHT" => 90), $orderId = 0)
2151{
2152 $res = "";
2153
2154 if ($propData["MULTIPLE"] == "Y")
2155 {
2156 $arVal = array();
2157 if (!is_array($value))
2158 {
2159 if (mb_strpos($value, ",") !== false)
2160 $arVal = explode(",", $value);
2161 else
2162 $arVal[] = $value;
2163 }
2164 else
2165 $arVal = $value;
2166
2167 if (count($arVal) > 0)
2168 {
2169 foreach ($arVal as $key => $val)
2170 {
2171 if ($propData["PROPERTY_TYPE"] == "F")
2172 {
2173 if ($res <> '')
2174 $res .= "<br/> ".showImageOrDownloadLink(trim($val), $orderId, $arSize);
2175 else
2176 $res = showImageOrDownloadLink(trim($val), $orderId, $arSize);
2177 }
2178 else
2179 {
2180 if ($res <> '')
2181 $res .= ", ".$val;
2182 else
2183 $res = $val;
2184 }
2185 }
2186 }
2187 }
2188 else
2189 {
2190 if ($propData["PROPERTY_TYPE"] == "F")
2191 $res = showImageOrDownloadLink($value, $orderId, $arSize);
2192 else
2193 $res = $value;
2194 }
2195
2196 if ($res == '')
2197 $res = "&nbsp";
2198
2199 return $res;
2200}
2201
2202/*
2203 * Returns HTML of columns names (<td></td>) for the basket items table
2204 * Used in the order_new and order_detail
2205 */
2206function getColumnsHeaders($arUserColumns, $page = "edit", $bWithStores = false)
2207{
2208 $prefix = ($page == "edit") ? "NEW_" : "SOD_";
2209
2210 if ($page != "edit")
2211 $bWithStores = false;
2212
2213 foreach ($arUserColumns as $columnCode => $columnName)
2214 {
2215 switch ($columnCode)
2216 {
2217 case "COLUMN_NUMBER":
2218 ?>
2219 <td><?=GetMessage($prefix."COLUMN_NUMBER")?></td>
2220 <?
2221 break;
2222
2223 case "COLUMN_NAME":
2224 ?>
2225 <td><?=GetMessage($prefix."COLUMN_NAME")?></td>
2226 <?
2227 break;
2228
2229 case "COLUMN_IMAGE":
2230 ?>
2231 <td><?=GetMessage($prefix."COLUMN_IMAGE")?></td>
2232 <?
2233 break;
2234
2235 case "COLUMN_QUANTITY":
2236 ?>
2237 <td><?=GetMessage($prefix."COLUMN_QUANTITY")?></td>
2238 <?
2239 if ($bWithStores):
2240 ?>
2241 <td><?=GetMessage("SALE_F_STORE")?></td>
2242 <td><?=GetMessage("SALE_F_STORE_CUR_AMOUNT")?></td>
2243 <td><?=GetMessage("SALE_F_STORE_AMOUNT")?></td>
2244 <td><?=GetMessage("SALE_F_STORE_BARCODE")?></td>
2245 <?
2246 endif;
2247 break;
2248
2249 case "COLUMN_REMAINING_QUANTITY":
2250 ?>
2251 <td><?=GetMessage($prefix."COLUMN_REMAINING_QUANTITY")?></td>
2252 <?
2253 break;
2254
2255 case "COLUMN_PROPS":
2256 ?>
2257 <td><?=GetMessage($prefix."COLUMN_PROPS")?></td>
2258 <?
2259 break;
2260
2261 case "COLUMN_PRICE":
2262 ?>
2263 <td><?=GetMessage($prefix."COLUMN_PRICE")?></td>
2264 <?
2265 break;
2266
2267 case "COLUMN_SUM":
2268 ?>
2269 <td><?=GetMessage($prefix."COLUMN_SUM")?></td>
2270 <?
2271 break;
2272
2273 default:
2274 ?>
2275 <td><?=$columnName?></td>
2276 <?
2277 break;
2278 }
2279 }
2280}
2281
2282/*
2283 * Returns appropriate css class for the input control if barcode is valid or not
2284 */
2285function setBarcodeClass($barcodeValue)
2286{
2287 $result = "";
2288
2289 if ($barcodeValue == "Y")
2290 $result = "store_barcode_found_input";
2291 elseif ($barcodeValue == "N")
2292 $result = "store_barcode_not_found";
2293
2294 return $result;
2295}
2296
2297/*
2298 * Returns array of product parameters to fill basket table row in the order_new form
2299 * Can be called recursively to get data about Set items
2300 */
2301function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
2302{
2303 if (!\Bitrix\Main\Loader::includeModule("catalog"))
2304 return array();
2305
2306 $arParams = array();
2307
2308 static $proxyIblockElement = array();
2309 static $proxyCatalogMeasure = array();
2310 static $proxyParent = array();
2311 static $proxyIblockProperty = array();
2312 static $proxyProductData = array();
2313 static $proxyCatalogProduct = array();
2314 static $proxyCatalogMeasureRatio = array();
2315
2316 $productId = (int)$productId;
2317 if ($productId <= 0)
2318 {
2319 return $arParams;
2320 }
2321
2322 if (!empty($proxyIblockElement[$productId]))
2323 {
2324 $iblockId = $proxyIblockElement[$productId];
2325 }
2326 else
2327 {
2328 $iblockId = (int)CIBlockElement::GetIBlockByID($productId);
2329
2330 if (intval($iblockId) > 0)
2331 $proxyIblockElement[$productId] = $iblockId;
2332 }
2333
2334 if ($iblockId <= 0)
2335 {
2336 return $arParams;
2337 }
2338
2339 $arSku2Parent = array();
2340 $arElementId = array();
2341
2342 $arElementId[] = $productId;
2343
2344 $proxyParentKey = $productId."|".$iblockId;
2345
2346 if (!empty($proxyParent[$proxyParentKey]) && is_array($proxyParent[$proxyParentKey]))
2347 {
2348 $arParent = $proxyParent[$proxyParentKey];
2349 }
2350 else
2351 {
2352 $arParent = CCatalogSku::GetProductInfo($productId, $iblockId);
2353 $proxyParent[$proxyParentKey] = $arParent;
2354 }
2355
2356
2357 if ($arParent)
2358 {
2359 $arElementId[] = $arParent["ID"];
2360 $arSku2Parent[$productId] = $arParent["ID"];
2361 }
2362
2363 $arPropertyInfo = array();
2364 $userColumns = (string)$userColumns;
2365 $arUserColumns = ($userColumns != '') ? explode(",", $userColumns) : array();
2366 foreach ($arUserColumns as $key => $column)
2367 {
2368 if (strncmp($column, 'PROPERTY_', 9) != 0)
2369 {
2370 unset($arUserColumns[$key]);
2371 }
2372 else
2373 {
2374 $column = mb_strtoupper($column);
2375 $propertyCode = mb_substr($column, 9);
2376 if ($propertyCode == '')
2377 {
2378 unset($arUserColumns[$key]);
2379 continue;
2380 }
2381
2382 if (!empty($proxyIblockProperty[$propertyCode]) && is_array($proxyIblockProperty[$propertyCode]))
2383 {
2384 $arPropertyInfo[$column] = $proxyIblockProperty[$propertyCode];
2385 }
2386 else
2387 {
2388 $dbres = CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
2389 if ($arPropData = $dbres->GetNext())
2390 {
2391 $arPropertyInfo[$column] = $arPropData;
2392 $proxyIblockProperty[$propertyCode] = $arPropData;
2393 }
2394 }
2395
2396 }
2397 }
2398
2399 $arSelect = array_merge(
2400 array("ID", "NAME", "LID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "XML_ID", "IBLOCK_XML_ID"),
2401 $arUserColumns
2402 );
2403
2404
2405 $proxyProductDataKey = md5(join('|', $arElementId)."_".join('|', $arSelect));
2406 if (!empty($proxyProductData[$proxyProductDataKey]) && is_array($proxyProductData[$proxyProductDataKey]))
2407 {
2408 $arProductData = $proxyProductData[$proxyProductDataKey];
2409 }
2410 else
2411 {
2412 $arProductData = getProductProps($arElementId, $arSelect);
2413 $proxyProductData[$proxyProductDataKey] = $arProductData;
2414 }
2415
2416 $defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
2417
2418 if (!empty($arProductData))
2419 {
2420 $arElementInfo = array();
2421 foreach ($arProductData as $elemId => &$arElement)
2422 {
2423 foreach ($arElement as $key => $value)
2424 {
2425 if (strncmp($key, 'PROPERTY_', 9) == 0 && mb_substr($key, -6) == "_VALUE")
2426 {
2427 $columnCode = str_replace("_VALUE", "", $key);
2428 if (!isset($arPropertyInfo[$columnCode]))
2429 continue;
2430 $keyResult = 'PROPERTY_'.$arPropertyInfo[$columnCode]['CODE'].'_VALUE';
2431 $arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
2432 if ($keyResult != $key)
2433 $arElement[$keyResult] = $arElement[$key];
2434 unset($keyResult);
2435 }
2436 }
2437 }
2438 unset($arElement);
2439
2440 if (isset($arProductData[$productId]))
2441 $arElementInfo = $arProductData[$productId];
2442
2443 if (isset( $arSku2Parent[$productId]))
2444 $arParent = $arProductData[$arSku2Parent[$productId]];
2445
2446 if (!empty($arSku2Parent)) // if sku element doesn't have value of some property - we'll show parent element value instead
2447 {
2448 foreach ($arUserColumns as $field)
2449 {
2450 $fieldVal = $field."_VALUE";
2451 $parentId = $arSku2Parent[$productId];
2452
2453 if ((!isset($arElementInfo[$fieldVal]) || (isset($arElementInfo[$fieldVal]) && $arElementInfo[$fieldVal] == ''))
2454 && (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) // can be array or string
2455 {
2456 $arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
2457 }
2458 }
2459 if (mb_strpos($arElementInfo["~XML_ID"], '#') === false)
2460 {
2461 $arElementInfo["~XML_ID"] = $arParent['~XML_ID'].'#'.$arElementInfo["~XML_ID"];
2462 }
2463 }
2464
2465 $arElementInfo["MODULE"] = "catalog";
2466 $arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
2467
2468 $arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];
2469
2470 if ($arElementInfo["IBLOCK_ID"] > 0)
2471 {
2472 $arElementInfo["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array(
2473 "find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"],
2474 'WF' => 'Y',
2475 ));
2476 }
2477
2478 $arBuyerGroups = CUser::GetUserGroup($userId);
2479
2480 // price
2483 'CURRENCY' => Sale\Internals\SiteCurrencyTable::getSiteCurrency($LID),
2484 'PRECISION' => (int)Main\Config\Option::get('sale', 'value_precision'),
2485 'USE_DISCOUNTS' => true,
2486 'RESULT_WITH_VAT' => true
2487 ));
2488 $arPrice = CCatalogProduct::GetOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
2490
2491 $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
2492 $arElementInfo['PRICE'] = $currentPrice;
2493 $arElementInfo['CURRENCY'] = $arPrice['RESULT_PRICE']['CURRENCY'];
2494 $arElementInfo['DISCOUNT_PRICE'] = $arPrice['RESULT_PRICE']['DISCOUNT'];
2495 $currentTotalPrice = $arPrice['RESULT_PRICE']['BASE_PRICE'];
2496 $discountPercent = (int)$arPrice['RESULT_PRICE']['PERCENT'];
2497
2498 $arProduct = array();
2499
2500 if (!empty($proxyCatalogProduct[$productId]) && is_array($proxyCatalogProduct[$productId]))
2501 {
2502 $arProduct = $proxyCatalogProduct[$productId];
2503 }
2504 else
2505 {
2506 $rsProducts = CCatalogProduct::GetList(
2507 array(),
2508 array('ID' => $productId),
2509 false,
2510 false,
2511 array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI')
2512 );
2513 if ($arProduct = $rsProducts->Fetch())
2514 {
2515 $proxyCatalogProduct[$productId] = $arProduct;
2516 }
2517 }
2518
2519 if (empty($arProduct) || !is_array($arProduct))
2520 {
2521 return array();
2522 }
2523
2524 $balance = floatval($arProduct["QUANTITY"]);
2525
2526 // sku props
2527 $arSkuData = array();
2528 $arProps[] = array(
2529 "NAME" => "Catalog XML_ID",
2530 "CODE" => "CATALOG.XML_ID",
2531 "VALUE" => $arElementInfo['~IBLOCK_XML_ID']
2532 );
2533
2534 static $proxySkuProperty = array();
2535
2536 if (!empty($proxySkuProperty[$productId]) && is_array($proxySkuProperty[$productId]))
2537 {
2538 $arSkuProperty = $proxySkuProperty[$productId];
2539 }
2540 else
2541 {
2542 $arSkuProperty = CSaleProduct::GetProductSkuProps($productId, '', true);
2543 $proxySkuProperty[$productId] = $arSkuProperty;
2544 }
2545
2546 if (!empty($arSkuProperty))
2547 {
2548 foreach ($arSkuProperty as &$val)
2549 {
2550 $arSkuData[] = array(
2551 'NAME' => $val['NAME'],
2552 'VALUE' => $val['VALUE'],
2553 'CODE' => $val['CODE']
2554 );
2555 }
2556 unset($val);
2557 }
2558
2559
2560 $arSkuData[] = array(
2561 "NAME" => "Product XML_ID",
2562 "CODE" => "PRODUCT.XML_ID",
2563 "VALUE" => $arElementInfo["~XML_ID"]
2564 );
2565
2566 // currency
2567 $arCurFormat = CCurrencyLang::GetCurrencyFormat($arElementInfo["CURRENCY"]);
2568 $priceValutaFormat = str_replace("#", "", $arCurFormat["FORMAT_STRING"]);
2569
2570 $arElementInfo["WEIGHT"] = $arProduct["WEIGHT"];
2571
2572 // measure
2573 $arElementInfo["MEASURE_TEXT"] = "";
2574 $arElementInfo["MEASURE_CODE"] = 0;
2575 if ((int)$arProduct["MEASURE"] > 0)
2576 {
2577
2578 if (!empty($proxyCatalogMeasure[$arProduct["MEASURE"]]) && is_array($proxyCatalogMeasure[$arProduct["MEASURE"]]))
2579 {
2580 $arMeasure = $proxyCatalogMeasure[$arProduct["MEASURE"]];
2581 }
2582 else
2583 {
2584 $dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL"));
2585 if ($arMeasure = $dbMeasure->Fetch())
2586 {
2587 $proxyCatalogMeasure[$arProduct["MEASURE"]] = $arMeasure;
2588 }
2589 }
2590
2591 if (!empty($arMeasure) && is_array($arMeasure))
2592 {
2593 $arElementInfo["MEASURE_TEXT"] = ($arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"]);
2594 $arElementInfo["MEASURE_CODE"] = $arMeasure["CODE"];
2595 }
2596 }
2597 if ($arElementInfo["MEASURE_TEXT"] == '')
2598 {
2599 $arElementInfo["MEASURE_TEXT"] = ($defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"]);
2600 }
2601
2602 // ratio
2603 $arElementInfo["RATIO"] = 1;
2604
2605 if (!empty($proxyCatalogMeasureRatio[$productId]) && is_array($proxyCatalogMeasureRatio[$productId]))
2606 {
2607 $arRatio = $proxyCatalogMeasureRatio[$productId];
2608 }
2609 else
2610 {
2611 $dbratio = Catalog\MeasureRatioTable::getList(array(
2612 'select' => array('*'),
2613 'filter' => array('=PRODUCT_ID' => $productId, '=IS_DEFAULT' => 'Y')
2614 ));
2615 if ($arRatio = $dbratio->fetch())
2616 {
2617 $proxyCatalogMeasureRatio[$productId] = $arRatio;
2618 }
2619
2620 }
2621
2622 if (!empty($arRatio) && is_array($arRatio))
2623 $arElementInfo["RATIO"] = $arRatio["RATIO"];
2624
2625 // image
2626 $imgCode = '';
2627 $imgUrl = '';
2628 if ($arElementInfo["PREVIEW_PICTURE"] > 0)
2629 $imgCode = $arElementInfo["PREVIEW_PICTURE"];
2630 elseif ($arElementInfo["DETAIL_PICTURE"] > 0)
2631 $imgCode = $arElementInfo["DETAIL_PICTURE"];
2632
2633 if ($imgCode == "" && count($arParent) > 0)
2634 {
2635 if ($arParent["PREVIEW_PICTURE"] > 0)
2636 $imgCode = $arParent["PREVIEW_PICTURE"];
2637 elseif ($arParent["DETAIL_PICTURE"] > 0)
2638 $imgCode = $arParent["DETAIL_PICTURE"];
2639 }
2640
2641 if ($imgCode > 0)
2642 {
2643 $arFile = CFile::GetFileArray($imgCode);
2644 $arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
2645 if (is_array($arImgProduct))
2646 $imgUrl = $arImgProduct["src"];
2647 }
2648
2649 $arSetInfo = array();
2650 $arStores = array();
2651
2653 if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"])))
2654 {
2655 // get set items if it is set
2656 if ($arProduct["TYPE"] == CCatalogProduct::TYPE_SET)
2657 {
2658 if (method_exists($productProvider, "GetSetItems"))
2659 {
2660 $arSets = $productProvider::GetSetItems($productId, CSaleBasket::TYPE_SET);
2661
2662 if ($tmpId == "")
2663 $tmpId = randString(7);
2664
2665 if (!empty($arSets))
2666 {
2667 foreach ($arSets as $arSetData)
2668 {
2669 foreach ($arSetData["ITEMS"] as $setItem)
2670 {
2671 $arSetItemParams = getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId); // recursive call
2672
2673 // re-define some fields with set data values
2674 $arSetItemParams["id"] = $setItem["PRODUCT_ID"];
2675 $arSetItemParams["name"] = $setItem["NAME"];
2676 $arSetItemParams["module"] = $setItem["MODULE"];
2677 $arSetItemParams["productProviderClass"] = $setItem["PRODUCT_PROVIDER_CLASS"];
2678 $arSetItemParams["url"] = $setItem["DETAIL_PAGE_URL"];
2679 $arSetItemParams["quantity"] = $setItem["QUANTITY"] * $quantity;
2680 $arSetItemParams["barcodeMulti"] = $setItem["BARCODE_MULTI"];
2681 $arSetItemParams["productType"] = $setItem["TYPE"];
2682 $arSetItemParams["weight"] = $setItem["WEIGHT"];
2683 $arSetItemParams["vatRate"] = $setItem["VAT_RATE"];
2684 $arSetItemParams["setItems"] = "";
2685
2686 $arSetItemParams["setParentId"] = $productId."_tmp".$tmpId;
2687 $arSetItemParams["isSetItem"] = "Y";
2688 $arSetItemParams["isSetParent"] = "N";
2689
2690 $arSetInfo[] = $arSetItemParams;
2691 }
2692 }
2693 }
2694 }
2695 }
2696
2697 // get stores
2698 $storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID)); // with exact SITE_ID or SITE_ID = NULL
2699
2700 if ($storeCount > 0)
2701 {
2702 if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $productId, "SITE_ID" => $LID)))
2703 $arStores = $arProductStore;
2704 }
2705 }
2706
2707 $currentTotalPrice = (float)$currentTotalPrice;
2708 // params array
2709 $arParams["id"] = $productId;
2710 $arParams["name"] = $arElementInfo["~NAME"];
2711 $arParams["url"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]);
2712 $arParams["urlEdit"] = $arElementInfo["EDIT_PAGE_URL"];
2713 $arParams["urlImg"] = $imgUrl;
2714 $arParams["price"] = floatval($arElementInfo["PRICE"]);
2715 $arParams["priceBase"] = $currentTotalPrice;
2716 $arParams["priceBaseFormat"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], false);
2717 $arParams["priceFormated"] = CCurrencyLang::CurrencyFormat(floatval($arElementInfo["PRICE"]), $arElementInfo["CURRENCY"], false);
2718 $arParams["valutaFormat"] = $priceValutaFormat;
2719 $arParams["dimensions"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"]));
2720 $arParams["priceDiscount"] = floatval($arElementInfo["DISCOUNT_PRICE"]);
2721 $arParams["priceTotalFormated"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], true);
2722 $arParams["discountPercent"] = $discountPercent;
2723 $arParams["summaFormated"] = CCurrencyLang::CurrencyFormat($arElementInfo["PRICE"], $arElementInfo["CURRENCY"], false);
2724 $arParams["quantity"] = $quantity;
2725 $arParams["module"] = $arElementInfo["MODULE"];
2726 $arParams["currency"] = $arElementInfo["CURRENCY"];
2727 $arParams["weight"] = $arElementInfo["WEIGHT"];
2728 $arParams["vatRate"] = $arPrice["PRICE"]["VAT_RATE"];
2729 $arParams["priceType"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"];
2730 $arParams["balance"] = $balance;
2731 $arParams["notes"] = (!empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"]) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : "");
2732 $arParams["catalogXmlID"] = $arElementInfo["~IBLOCK_XML_ID"];
2733 $arParams["productXmlID"] = $arElementInfo["~XML_ID"];
2734 $arParams["callback"] = "";
2735 $arParams["orderCallback"] = "";
2736 $arParams["cancelCallback"] = "";
2737 $arParams["payCallback"] = "";
2738 $arParams["productProviderClass"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"];
2739 $arParams["skuProps"] = $arSkuData;
2740 $arParams["measureText"] = $arElementInfo["MEASURE_TEXT"];
2741 $arParams["measureCode"] = $arElementInfo["MEASURE_CODE"];
2742 $arParams["ratio"] = $arElementInfo["RATIO"];
2743 $arParams["barcodeMulti"] = $arProduct["BARCODE_MULTI"];
2744
2745 $arParams["productType"] = empty($arSetInfo) ? "" : CSaleBasket::TYPE_SET;
2746 $arParams["setParentId"] = empty($arSetInfo) ? "" : $productId."_tmp".$tmpId;
2747
2748 $arParams["setItems"] = $arSetInfo;
2749 $arParams["isSetItem"] = "N";
2750 $arParams["isSetParent"] = empty($arSetInfo) ? "N" : "Y";
2751
2752 $arParams["stores"] = empty($arSetInfo) ? $arStores : array();
2753 $arParams["productPropsValues"] = $arElementInfo; // along with other information also contains values of properties with correct keys (after getProductProps)
2754 }
2755
2756 return $arParams;
2757}
2758
2759?>
$arParams
Определения access_dialog.php:21
return select
Определения access_edit.php:440
$count
Определения admin_tab.php:4
fUserProfile($USER_ID, $BUYER_TYPE='', $default='')
Определения admin_tool.php:1360
fGetBuyerType($PERSON_TYPE_ID, $LID, $USER_ID='', $ORDER_ID=0, $formVarsSubmit=false)
Определения admin_tool.php:468
CRMModeOutput($text)
Определения admin_tool.php:12
getColumnsHeaders($arUserColumns, $page="edit", $bWithStores=false)
Определения admin_tool.php:2206
getIblockPropInfo($value, $propData, $arSize=array("WIDTH"=> 90, "HEIGHT"=> 90), $orderId=0)
Определения admin_tool.php:2150
convertHistoryToNewFormat($arFields)
Определения admin_tool.php:2099
fGetUserName($USER_ID)
Определения admin_tool.php:22
getAdditionalColumns()
Определения admin_tool.php:2022
fGetCountProfileProps($PERSON_TYPE_ID)
Определения admin_tool.php:420
showImageOrDownloadLink($fileId, $orderId=0, $arSize=array("WIDTH"=> 90, "HEIGHT"=> 90))
Определения admin_tool.php:2133
getIblockNames($arIblockIDs, $arIblockNames)
Определения admin_tool.php:2009
setBarcodeClass($barcodeValue)
Определения admin_tool.php:2285
getNameCount($propName, $propCode, $arProps)
Определения admin_tool.php:1997
fChangeOrderStatus($ID, $STATUS_ID)
Определения admin_tool.php:281
fDeleteDoubleProduct($arShoppingCart=array(), $arDelete=array(), $showAll='N')
Определения admin_tool.php:1932
fShowFilePropertyField($name, $property_fields, $values, $max_file_size_show=50000)
Определения admin_tool.php:344
$type
Определения options.php:106
global $APPLICATION
Определения include.php:80
while($arIBlock=$rsIBlocks->Fetch()) $catalogIterator
Определения options.php:1934
$arVal
Определения options.php:1785
$arResult
Определения generate_coupon.php:16
change_password_forgot_link login popup forget pas AUTH_GOTO_FORGOT_FORM login btn wrap change_password_button login popup link login popup return auth javascript
Определения change_password.php:57
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static setConfig(array $config)
Определения calculation.php:46
Определения loader.php:13
static GetProductSkuProps($ID, $IBLOCK_ID='', $getExt=false)
Определения product.php:14
const TYPE_SET
Определения product.php:18
static GetOptimalPrice($intProductID, $quantity=1, $arUserGroups=array(), $renewal="N", $priceList=array(), $siteID=false, $arDiscountCoupons=false)
Определения product.php:973
static ConvertCurrency($valSum, $curFrom, $curTo, $valDate="")
Определения currency_rate.php:393
static GetAdminElementEditLink($IBLOCK_ID, $ELEMENT_ID, $arParams=array(), $strAdd="")
Определения iblock.php:3981
static GetList($arOrder=Array(), $arFilter=Array())
Определения iblockproperty.php:14
const TYPE_SET
Определения basket.php:13
static GetProductProvider($arBasketItem)
Определения basket.php:24
static isLocationProMigrated()
Определения location.php:58
static StatusOrder($ID, $val)
Определения order.php:2449
static CanUserChangeOrderStatus($ID, $statusID, $arUserGroups=false)
Определения order.php:624
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения order_props_values.php:12
static GetOrderProps($ORDER_ID)
Определения order_props_values.php:149
static DoLoadProfiles($userId, $personTypeId=null)
Определения order_user_props.php:198
static GetUserGroup($ID)
Определения user.php:3409
static getDefaultMeasure($getStub=false, $getExt=false)
Определения measure.php:185
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения product.php:23
static GetProductInfo($intOfferID, $intIBlockID=0)
Определения catalog_sku.php:51
static CurrencyFormat($price, $currency, $useTemplate=true)
Определения currency_lang.php:655
static GetCurrencyFormat($currency, $lang=LANGUAGE_ID)
Определения currency_lang.php:393
static ResizeImageGet($file, $arSize, $resizeType=BX_RESIZE_IMAGE_PROPORTIONAL, $bInitSizes=false, $arFilters=false, $bImmediate=false, $jpgQuality=false)
Определения file.php:2242
static GetFileArray($fileId, $uploadDir=false)
Определения file.php:1207
static GetList($arOrder=array("SORT"=>"ASC"), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения iblockelement.php:658
static GetByID($primary, $strLang=LANGUAGE_ID)
Определения location.php:118
static $operationTypes
Определения order_change.php:357
static GetList($arOrder=array("ID"=>"DESC"), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array(), $arOptions=array())
Определения order.php:339
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения order_props.php:410
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения person_type.php:7
$str
Определения commerceml2.php:63
$arFields
Определения dblapprove.php:5
$orderId
Определения payment.php:5
hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> height
Определения file_new.php:759
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения file_new.php:677
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$result
Определения get_property_values.php:14
if($ajaxMode) $ID
Определения get_user.php:27
$iblockId
Определения iblock_catalog_edit.php:30
$catalog
Определения iblock_catalog_edit.php:135
$iblockList
Определения iblock_catalog_list.php:271
if(preg_match('/^ else[a-z0-9_]{2}$/i', $siteID)===1)
Определения cron_frame.php:23
endif
Определения csv_new_setup.php:990
$inputName
Определения options.php:197
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
const BX_RESIZE_IMAGE_PROPORTIONAL
Определения constants.php:11
htmlspecialcharsEx($str)
Определения tools.php:2685
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
randString($pass_len=10, $pass_chars=false)
Определения tools.php:2154
bitrix_sessid_get($varname='sessid')
Определения tools.php:4695
$name
Определения menu_edit.php:35
$user
Определения mysql_to_pgsql.php:33
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
$text
Определения template_pdf.php:79
lang
Определения options.php:182
$i
Определения factura.php:643
font style
Определения invoice.php:442
font size
Определения invoice.php:442
$page
Определения order_form.php:33
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$ORDER_ID
Определения html.php:2
$currency
Определения template.php:266
$arCurFormat
Определения template.php:265
SaleFormatCurrency($fSum, $strCurrency, $OnlyValue=false, $withoutFormat=false)
Определения include.php:142
GetFormatedUserName($userId, $bEnableId=true, $createEditLink=true)
Определения include.php:248
getProductProps($arElementId, $arSelect)
Определения include.php:549
$arLocation['REGION_NAME']
Определения options.php:2800
$val
Определения options.php:1793
margin right
Определения options_user_settings.php:273
$GLOBALS['_____370096793']
Определения update_client.php:1
if( $site[ 'SERVER_NAME']==='') if($site['SERVER_NAME']==='') $arProperties
Определения yandex_run.php:644