5require_once __DIR__.
'/../internals/input.php';
18 if(!is_array($values))
23 return $input[
"ITEMS"][
"FROM"][
"NAME"].
": ".Input\Manager::getViewHtml($input[
"ITEMS"][
"FROM"], $values[
"FROM"]).
24 $input[
"ITEMS"][
"TO"][
"NAME"].
": ".Input\Manager::getViewHtml($input[
"ITEMS"][
"TO"], $values[
"TO"]).
25 " ".Input\Manager::getViewHtml($input[
"ITEMS"][
"TYPE"], $values[
"TYPE"]);
30 if (!isset($input[
"ITEMS"]))
39 "NAME" =>
" - "
53 $input[
"ITEMS"][
"FROM"][
"NAME"]
54 . Input\Manager::getEditHtml($name .
"[FROM]", $input[
"ITEMS"][
"FROM"], $values[
"FROM"] ??
null)
55 . $input[
"ITEMS"][
"TO"][
"NAME"]
56 . Input\Manager::getEditHtml($name .
"[TO]", $input[
"ITEMS"][
"TO"], $values[
"TO"] ??
null)
58 . Input\Manager::getEditHtml($name .
"[TYPE]", $input[
"ITEMS"][
"TYPE"], $values[
"TYPE"] ??
null)
62 public static function getError(array $input, $values)
64 if(!is_array($values))
72 if(!is_array($values))
83 $errors = array_merge($errors, $error);
86 $errors = array_merge($errors, $error);
101 protected static function checkArgs(array $input, array $values)
103 if(!isset($input[
"ITEMS"][
"FROM"]) || !isset($input[
"ITEMS"][
"TO"]) || !isset($input[
"ITEMS"][
"TYPE"]))
106 if(!isset($values[
"FROM"]) || !isset($values[
"TO"]) || !isset($values[
"TYPE"]))
107 throw new \Bitrix\Main\ArgumentException(
"Wrong argument structure!",
"values");
113Input\Manager::register(
'DELIVERY_PERIOD', array(
114 'CLASS' => __NAMESPACE__.
'\\Period',
124 if(!empty($input[
'ID']))
125 $result .=
' id="'.$input[
'ID'].
'_view"';
128 $result .= isset($input[
"VALUE_VIEW"]) ? $input[
"VALUE_VIEW"] : $value;
129 $result .=
'</span>';
135 $value = str_replace(
'"',
"'", $value);
136 $res = self::getViewHtml($input, $value).
'<input type="hidden" value="'.htmlspecialcharsbx($value).
'" name="'.htmlspecialcharsbx($name).
'"';
138 if(!empty($input[
'ID']))
139 $res .=
' id="'.$input[
'ID'].
'"';
146 public static function getError(array $input, $values)
167Input\Manager::register(
'DELIVERY_READ_ONLY', array(
168 'CLASS' => __NAMESPACE__.
'\\ReadOnlyField',
180 $this->items[$key] = $control;
185 $this->myParams = $params;
208 return empty($this->myParams);
213 $this->myParams = $this->items = $this->myKey = array();
220 foreach($input[
"ITEMS"] as $key => $item)
222 isset($item[
"NAME"]) ? $item[
"NAME"] :
"".
223 Input\Manager::getViewHtml($item, isset($values[$key]) ? $values[$key] :
null).
233 foreach($input[
"ITEMS"] as $key => $item)
235 isset($item[
"NAME"]) ? $item[
"NAME"] :
"".
236 Input\Manager::getEditHtml($name.
"[".$key.
"]", $item, isset($values[$key]) ? $values[$key] :
null).
244 if(!is_array($values))
249 foreach($input[
"ITEMS"] as $key => $item)
250 if ($error = Input\
Manager::getError($item, isset($values[$key]) ? $values[$key] :
null))
251 $errors[$key] = $error;
279 public static function getError(array $input, $value)
283 foreach($input[
"ITEMS"] as $key => $item)
299 foreach($input[
"ITEMS"] as $key => $item)
308Input\Manager::register(
'DELIVERY_MULTI_CONTROL_STRING', array(
309 'CLASS' => __NAMESPACE__.
'\\MultiControlString',
315 protected static $d2LClass =
'\Bitrix\Sale\Delivery\DeliveryLocationTable';
320 $class = static::$d2LClass;
322 $res = $class::getConnectedLocations(
323 $input[
"DELIVERY_ID"],
325 'select' => array(
'LNAME' =>
'NAME.NAME'),
326 'filter' => array(
'NAME.LANGUAGE_ID' => LANGUAGE_ID)
330 while($loc = $res->fetch())
331 $result .= htmlspecialcharsbx($loc[
"LNAME"]).
"<br>\n";
333 $res = $class::getConnectedGroups(
334 $input[
"DELIVERY_ID"],
336 'select' => array(
'LNAME' =>
'NAME.NAME'),
337 'filter' => array(
'NAME.LANGUAGE_ID' => LANGUAGE_ID)
341 while($loc = $res->fetch())
342 $result .= htmlspecialcharsbx($loc[
"LNAME"]).
"<br>\n";
347 public static function getEditHtml($name, array $input, $values =
null)
353 $APPLICATION->IncludeComponent(
354 "bitrix:sale.location.selector.system",
357 "ENTITY_PRIMARY" => $input[
"DELIVERY_ID"],
358 "LINK_ENTITY_NAME" => mb_substr(static::$d2LClass, 0, -5),
359 "INPUT_NAME" => $name,
360 'FILTER_BY_SITE' =>
'N',
365 $result = ob_get_contents();
367 <script type="text/javascript">
368 var bxInputdeliveryLocMultiStep3 = function()
370 BX.loadScript("/bitrix/components/bitrix/sale.location.selector.system/templates/.default/script.js", function(){
371 BX.onCustomEvent("deliveryGetRestrictionHtmlScriptsReady");
375 var bxInputdeliveryLocMultiStep2 = function()
378 "/bitrix/js/sale/core_ui_etc.js",
379 "/bitrix/js/sale/core_ui_autocomplete.js",
380 "/bitrix/js/sale/core_ui_itemtree.js"
382 bxInputdeliveryLocMultiStep3
386 BX.loadScript("/bitrix/js/sale/core_ui_widget.js", bxInputdeliveryLocMultiStep2);
388 //at first we must load some scripts in the right order
389 window["deliveryGetRestrictionHtmlScriptsLoadingStarted"] = true;
393 <link rel="stylesheet" type="text/css" href="/bitrix/panel/main/adminstyles_fixed.css">
394 <link rel="stylesheet" type="text/css" href="/bitrix/panel/main/admin.css">
395 <link rel="stylesheet" type="text/css" href="/bitrix/panel/main/admin-public.css">
396 <link rel="stylesheet" type="text/css" href="/bitrix/components/bitrix/sale.location.selector.system/templates/.default/style.css">
403 public static function getError(array $input, $values)
420Input\Manager::register(
'LOCATION_MULTI', array(
421 'CLASS' => __NAMESPACE__.
'\\LocationMulti',
427 protected static $d2LClass =
'\Bitrix\Sale\Delivery\DeliveryLocationExcludeTable';
430Input\Manager::register(
'LOCATION_MULTI_EXCLUDE', array(
431 'CLASS' => __NAMESPACE__.
'\\LocationMultiExclude',
438Input\Manager::register(
'DELIVERY_PRODUCT_CATEGORIES', array(
439 'CLASS' => __NAMESPACE__.
'\\ProductCategories',
447 if(!is_array($values))
450 $itemName = ($values[
'NAME'] <>
'' ? htmlspecialcharsbx($values[
'NAME']) :
'');
452 if($itemName ==
'' && $input[
'NAME_DEFAULT'] <>
'')
454 $itemName = htmlspecialcharsbx($input[
'NAME_DEFAULT']);
462 $input[
'NAME_DEFAULT'] = trim((
string)($input[
'NAME_DEFAULT'] ??
''));
463 $input[
'VALUE_DEFAULT'] = trim((
string)($input[
'VALUE_DEFAULT'] ??
''));
465 if (!is_array($values))
469 $values[
'NAME'] = trim((
string)($values[
'NAME'] ??
''));
470 $values[
'VALUE'] = trim((
string)($values[
'VALUE'] ??
''));
472 $itemName = htmlspecialcharsbx($values[
'NAME'] ?: $input[
'NAME_DEFAULT']);
473 $itemValue = htmlspecialcharsbx($values[
'VALUE'] ?: $input[
'VALUE_DEFAULT']);
476 '<div id="'.$input[
'READONLY_NAME_ID'].
'">'.htmlspecialcharsbx($itemName).
'</div>'.
477 ' <input type="button" value="'.$input[
'BUTTON'][
'NAME'].
'" onclick="'.$input[
'BUTTON'][
'ONCLICK'].
' return false;" style="margin-top: 20px;">'.
478 '<input type="hidden" name="'.$name.
'[NAME]" value="'.$itemName.
'">'.
479 '<input type="hidden" name="'.$name.
'[VALUE]" value="'.$itemValue.
'">'.
493 public static function getError(array $input, $values)
508Input\Manager::register(
'DELIVERY_BUTTON_SELECTOR', array(
509 'CLASS' => __NAMESPACE__.
'\\ButtonSelector',
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)