2namespace Bitrix\Bizproc\BaseType;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Bizproc\FieldType;
9Loc::loadMessages(__FILE__);
48 public static function convertTo(
FieldType $fieldType,
$value, $toTypeClass)
51 $type = $toTypeClass::getType();
74 case FieldType::STRING:
79 if (
$type == FieldType::DATE)
131 $name = static::generateControlName($field);
132 $value = static::internalizeValue($fieldType,
'Renderer',
$value);
135 $className = static::generateControlClassName($fieldType, $field);
139 if ($isPublicControl && $allowSelection)
141 $selectorAttributes = sprintf(
142 'data-role="inline-selector-target" data-selector-type="%s" data-property="%s" ',
147 $renderResult = sprintf(
148 '<input name="%s" type="text" class="%s" value="%s" placeholder="%s" %s/>',
158 $renderResult =
'<div><input type="hidden" value="'
159 .htmlspecialcharsbx(
$value).
'" data-type="'
161 .
'<a href="#" onclick="return BX.BizProcMobile.showDatePicker(this, event);">'
167 $renderResult = sprintf(
168 '<input type="text" name="%s" value="%s" class="%s"/>'
169 .
'<img src="/bitrix/js/main/core/images/calendar-icon.gif" alt="calendar" class="calendar-icon" '
170 .
'onclick="BX.calendar({node:this, field: this.previousSibling, bTime: %s, bHideTime: %s});" '
171 .
'onmouseover="BX.addClass(this, \'calendar-icon-hover\');" '
172 .
'onmouseout="BX.removeClass(this, \'calendar-icon-hover\');" border="0"/>',
180 $tzName =
'tz_'.$name;
181 $zones = self::getZones();
188 $tzClassName =
'bizproc-type-control-date-lc';
191 $tzClassName .=
' bizproc-type-control-date-lc-multiple';
193 if (!$isPublicControl)
198 $renderResult .=
'<select name="'.htmlspecialcharsbx($tzName).
'" class="'.$tzClassName.
'">';
199 foreach ($zones as $zone)
201 $selected = ($offset && $offset === $zone[
'offset']) ?
'selected' :
'';
202 $renderResult .=
'<option value="'.htmlspecialcharsbx($zone[
'value']).
'" '.$selected.
'>'
203 .htmlspecialcharsbx($zone[
'text']).
'</option>';
205 $renderResult .=
'</select>';
215 return $renderResult;
228 $allowSelectionOrig = $allowSelection;
231 $allowSelection =
false;
235 $selectorValue =
null;
243 $renderResult = static::renderControl($fieldType, $field,
$value, $allowSelectionOrig, $renderMode);
247 $renderResult .= static::renderControlSelector($field, $selectorValue,
true,
'', $fieldType);
250 return $renderResult;
255 $allowSelectionOrig = $allowSelection;
258 $allowSelection =
false;
266 $selectorValue =
null;
289 $singleField = $field;
290 $singleField[
'Index'] =
$k;
291 $controls[] = static::renderControl(
302 $renderResult = static::renderPublicMultipleWrapper($fieldType, $field, $controls);
306 $renderResult = static::wrapCloneableControls($controls, static::generateControlName($field));
311 $renderResult .= static::renderControlSelector($field, $selectorValue,
true,
'', $fieldType);
314 return $renderResult;
346 static::addError(
array(
347 'code' =>
'ErrorValue',
348 'message' => Loc::getMessage(
'BPDT_DATE_INVALID'),
349 'parameter' => static::generateControlName($field),
354 $tzOffset = self::extractOffset($field,
$request);
372 $tzName =
'tz_'.$field[
'Field'];
376 $tz = isset($field[
'Index']) ? $tz[$field[
'Index']] : $tz[0];
379 if ($tz ===
'current')
381 return \CTimeZone::GetOffset();
385 $localTime = new \DateTime();
386 $localOffset = $localTime->getOffset();
388 $userTime = new \DateTime(
null,
new \DateTimeZone($tz));
389 $userOffset = $userTime->getOffset();
391 return $userOffset - $localOffset;
405 'callable' =>
'formatValueServer',
410 'callable' =>
'formatValueAuthor',
426 return date(
$value->getFormat(),
$value->getTimestamp());
445 $userId = \CBPHelper::ExtractUsers([
'author',
'responsible'], $documentId,
true);
461 $offset = \CTimeZone::GetOffset();
468 if ($obj->getTimestamp() !==
null)
481 : Value\DateTime::fromSystemObject(
$value);
491 return \CBPHelper::makeTimestamp(
$value) ?:
null;
495 if (is_string(
$value) && preg_match(
'#(.+)\s\[([0-9\-]+)\]#',
$value))
507 return date(
'c', strtotime(
$value));
513 private static function getZones()
515 $serverOffset = (new \DateTime())->getOffset();
518 $exclude = [
"Etc/",
"GMT",
"UTC",
"UCT",
"HST",
"PST",
"MST",
"CST",
"EST",
"CET",
"MET",
"WET",
"EET",
"PRC",
"ROC",
"ROK",
"W-SU"];
519 foreach (\DateTimeZone::listIdentifiers() as $tz)
521 foreach ($exclude as $ex)
522 if (mb_strpos($tz, $ex) === 0)
526 $dateTimeZone = new \DateTimeZone($tz);
527 $timezones[$tz] = [
'timezone_id' => $tz,
'offset' => $dateTimeZone->getOffset(
new \
DateTime(
"now", $dateTimeZone))];
533 uasort($timezones,
function (
$a, $b)
535 if (
$a[
'offset'] == $b[
'offset'])
536 return strcmp(
$a[
'timezone_id'], $b[
'timezone_id']);
538 return (
$a[
'offset'] < $b[
'offset'] ? -1 : 1);
542 [
'value' =>
'',
'text' => Loc::getMessage(
'BPDT_DATE_SERVER_TZ'),
'offset' => 0],
543 [
'value' =>
'current',
'text' => Loc::getMessage(
'BPDT_DATE_CURRENT_TZ'),
'offset' =>
'current']
545 foreach ($timezones as
$z)
548 'value' =>
$z[
'timezone_id'],
549 'text' =>
'(UTC'.($z[
'offset'] <> 0 ?
' '.($z[
'offset'] < 0 ?
'-' :
'+').sprintf(
"%02d", ($h = floor(abs(
$z[
'offset']) / 3600))).
':'.sprintf(
"%02d", abs(
$z[
'offset']) / 60 - $h * 60) :
'').
') '.
$z[
'timezone_id'],
550 'offset' =>
$z[
'offset'] - $serverOffset
559 $valueA = \CBPHelper::makeTimestamp($valueA,
true);
560 $valueB = \CBPHelper::makeTimestamp($valueB,
true);
566 return parent::compareValues($valueA, $valueB);
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static formatValueAuthor(FieldType $fieldType, $value)
static renderControl(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
static extractValue(FieldType $fieldType, array $field, array $request)
static externalizeValue(FieldType $fieldType, $context, $value)
static renderControlSingle(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
static internalizeValue(FieldType $fieldType, $context, $value)
static toSingleValue(FieldType $fieldType, $value)
static renderControlMultiple(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
static getConversionMap()
static compareValues($valueA, $valueB)
static canRenderControl($renderMode)
static formatValueServer(FieldType $fieldType, $value)
static fromSystemObject(Main\Type\Date $date)
setSettings(array $settings)
const VALUE_CONTEXT_JN_MOBILE
static createFromTimestamp($timestamp)
static convertFormatToPhp($format)
static isExpression($text)
static Init($arExt=array(), $bReturn=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
CheckDateTime($datetime, $format=false)
MakeTimeStamp($datetime, $format=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)