1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
admin_calendar.php
См. документацию.
1<?php
8
10{
11 const PERIOD_EMPTY = "NOT_REF";
12 const PERIOD_DAY = "day";
13 const PERIOD_WEEK = "week";
14 const PERIOD_MONTH = "month";
15 const PERIOD_QUARTER = "quarter";
16 const PERIOD_YEAR = "year";
17 const PERIOD_EXACT = "exact";
18 const PERIOD_BEFORE = "before";
19 const PERIOD_AFTER = "after";
20 const PERIOD_INTERVAL = "interval";
21
22 private static function InitPeriodList($arPeriodParams = array())
23 {
24 $arPeriod = array(
25 self::PERIOD_EMPTY => GetMessage("admin_lib_calend_no_period"),
26 self::PERIOD_DAY => GetMessage("admin_lib_calend_day"),
27 self::PERIOD_WEEK => GetMessage("admin_lib_calend_week"),
28 self::PERIOD_MONTH => GetMessage("admin_lib_calend_month"),
29 self::PERIOD_QUARTER => GetMessage("admin_lib_calend_quarter"),
30 self::PERIOD_YEAR => GetMessage("admin_lib_calend_year"),
31 self::PERIOD_EXACT => GetMessage("admin_lib_calend_exact"),
32 self::PERIOD_BEFORE => GetMessage("admin_lib_calend_before"),
33 self::PERIOD_AFTER => GetMessage("admin_lib_calend_after"),
34 self::PERIOD_INTERVAL => GetMessage("admin_lib_calend_interval")
35 );
36
37 if (empty($arPeriodParams) || !is_array($arPeriodParams))
38 return $arPeriod;
39
40 $arReturnPeriod = array();
41
42 foreach ($arPeriodParams as $periodName => $lPhrase)
43 {
44 if (isset($arPeriod[$periodName]))
45 $arReturnPeriod[$periodName] = $lPhrase;
46 elseif (isset($arPeriod[$lPhrase]))
47 $arReturnPeriod[$lPhrase] = $arPeriod[$lPhrase];
48 }
49
50 if (empty($arReturnPeriod))
51 $arReturnPeriod = $arPeriod;
52 return $arReturnPeriod;
53 }
54
55 public static function ShowScript()
56 {
57 \Bitrix\Main\UI\Extension::load('ui.date-picker');
58 }
59
60 public static function Calendar($sFieldName, $sFromName="", $sToName="", $bTime=false)
61 {
63 global $APPLICATION;
64
65 ob_start();
66 $APPLICATION->IncludeComponent('bitrix:main.calendar', '', array(
67 'RETURN' => 'Y',
68 'SHOW_INPUT' => 'N',
69 'INPUT_NAME' => $sFieldName,
70 'SHOW_TIME' => $bTime ? 'Y' : 'N'
71 ), null, array('HIDE_ICONS' => 'Y'));
72 $res = ob_get_contents();
73 ob_end_clean();
74
75 return $res;
76 }
77
78 public static function CalendarDate($sFieldName, $sValue="", $size="10", $bTime=false)
79 {
80 \Bitrix\Main\UI\Extension::load('ui.date-picker');
81
82 // component can't set 'size' param
83 return '
84 <div class="adm-input-wrap adm-input-wrap-calendar">
85 <input class="adm-input adm-input-calendar" type="text" name="'.$sFieldName.'" size="'.(intval($size)+3).'" value="'.htmlspecialcharsbx($sValue).'">
86 <button type="button" class="adm-calendar-icon" title="'.GetMessage("admin_lib_calend_title").'"></button>
87 <script>
88 (function() {
89 const input = document.querySelector(`input[name="' . $sFieldName . '"]`);
90 const button = input.nextElementSibling;
91 let picker = null;
92 const getPicker = () => {
93 if (picker === null)
94 {
95 picker = new BX.UI.DatePicker.DatePicker({
96 targetNode: input,
97 inputField: input,
98 enableTime: '.($bTime ? "true" : "false").',
99 useInputEvents: false,
100 });
101 }
102
103 return picker;
104 };
105
106 BX.Event.bind(button, "click", () => getPicker().show());
107 })();
108 </script>
109 </div>';
110
111 }
112
125 public static function CalendarPeriodCustom($sFromName, $sToName, $sFromVal="", $sToVal="", $bSelectShow=false, $size=10, $bTime=false, $arPeriod = false, $periodValue = '')
126 {
127 $arPeriodList = self::InitPeriodList($arPeriod);
128
129 return self::GetPeriodHtml($sFromName, $sToName, $sFromVal, $sToVal, $bSelectShow, $size, $bTime, $arPeriodList, $periodValue);
130 }
131
142 public static function CalendarPeriod($sFromName, $sToName, $sFromVal="", $sToVal="", $bSelectShow=false, $size=10, $bTime=false)
143 {
144 $arPeriodList = self::InitPeriodList();
145
146 return self::GetPeriodHtml($sFromName, $sToName, $sFromVal, $sToVal, $bSelectShow, $size, $bTime, $arPeriodList);
147 }
148
161 private static function GetPeriodHtml($sFromName, $sToName, $sFromVal, $sToVal, $bSelectShow, $size, $bTime, $arPeriod, $periodValue = '')
162 {
163 \Bitrix\Main\UI\Extension::load('ui.date-picker');
164
165 $size = (int)$size;
166
167 $s = '
168 <div class="adm-calendar-block adm-filter-alignment">
169 <div class="adm-filter-box-sizing">';
170
171 if($bSelectShow)
172 {
173 $sPeriodName = $sFromName."_FILTER_PERIOD";
174 $sDirectionName = $sFromName."_FILTER_DIRECTION";
175
176 $arDirection = array(
177 "previous"=>GetMessage("admin_lib_calend_previous"),
178 "current"=>GetMessage("admin_lib_calend_current"),
179 "next"=>GetMessage("admin_lib_calend_next")
180 );
181
182 $s .= '<span class="adm-select-wrap adm-calendar-period" ><select class="adm-select adm-calendar-period" id="'.$sFromName.'_calendar_period" name="'.$sPeriodName.'" onchange="BX.CalendarPeriod.OnChangeP(this);" title="'.GetMessage("admin_lib_calend_period_title").'">';
183
184 $currentPeriod = '';
185 if (isset($GLOBALS[$sPeriodName]))
186 $currentPeriod = (string)$GLOBALS[$sPeriodName];
187 $periodValue = (string)$periodValue;
188 if ($periodValue != '')
189 $currentPeriod = $periodValue;
190 foreach($arPeriod as $k => $v)
191 {
192 $k = ($k != "NOT_REF" ? $k : "");
193 $s .= '<option value="'.$k.'"'.(($currentPeriod != '' && $currentPeriod == $k) ? " selected":"").'>'.$v.'</option>';
194 }
195 unset($currentPeriod);
196
197 $s .='</select></span>';
198
199 $currentDirection = '';
200 if (isset($GLOBALS[$sDirectionName]))
201 $currentDirection = (string)$GLOBALS[$sDirectionName];
202 $s .= '<span class="adm-select-wrap adm-calendar-direction" style="display: none;"><select class="adm-select adm-calendar-direction" id="'.$sFromName.'_calendar_direct" name="'.$sDirectionName.'" onchange="BX.CalendarPeriod.OnChangeD(this);" title="'.GetMessage("admin_lib_calend_direct_title").'">';
203 foreach($arDirection as $k => $v)
204 $s .= '<option value="'.$k.'"'.($currentDirection == $k ? " selected":"").'>'.$v.'</option>';
205 unset($currentDirection);
206
207 $s .='</select></span>';
208 }
209
210 $s .=
211 '<div class="adm-input-wrap adm-calendar-inp adm-calendar-first" style="display: ' .($bSelectShow ? 'none' : 'inline-block').';">'.
212 '<input type="text" class="adm-input adm-calendar-from" id="'.$sFromName.'_calendar_from" name="'.$sFromName.'" size="'.($size+5).'" value="'.htmlspecialcharsbx($sFromVal).'">'.
213 '<button type="button" class="adm-calendar-icon" title="'.GetMessage("admin_lib_calend_title").'"></button>'.
214 '</div>
215 <span class="adm-calendar-separate" style="display: '.($bSelectShow ? 'none' : 'inline-block').'"></span>'.
216 '<div class="adm-input-wrap adm-calendar-second" style="display: '.($bSelectShow ? 'none' : 'inline-block').';">'.
217 '<input type="text" class="adm-input adm-calendar-to" id="'.$sToName.'_calendar_to" name="'.$sToName.'" size="'.($size+5).'" value="'.htmlspecialcharsbx($sToVal).'">'.
218 '<button type="button" class="adm-calendar-icon" title="'.GetMessage("admin_lib_calend_title").'"></button>'.
219 '</div>'.
220 '<script>
221 (function() {
222 const inputFrom = document.getElementById("' . $sFromName . '_calendar_from");
223 const buttonFrom = inputFrom.nextElementSibling;
224 const inputTo = document.getElementById("' . $sToName . '_calendar_to");
225 const buttonTo = inputTo.nextElementSibling;
226
227 let pickerFrom = null;
228 let pickerTo = null;
229 const getPickerFrom = () => {
230 if (pickerFrom === null)
231 {
232 pickerFrom = new BX.UI.DatePicker.DatePicker({
233 targetNode: inputFrom,
234 inputField: inputFrom,
235 useInputEvents: false,
236 enableTime: '.($bTime ? "true" : "false").',
237 });
238 }
239
240 return pickerFrom;
241 };
242
243 const getPickerTo = () => {
244 if (pickerTo === null)
245 {
246 pickerTo = new BX.UI.DatePicker.DatePicker({
247 targetNode: inputTo,
248 inputField: inputTo,
249 useInputEvents: false,
250 enableTime: '.($bTime ? "true" : "false").',
251 });
252 }
253
254 return pickerTo;
255 };
256
257 BX.Event.bind(buttonFrom, "click", () => getPickerFrom().show());
258 BX.Event.bind(buttonTo, "click", () => getPickerTo().show());
259 })();
260
261 window["'.$sFromName.'_bTime"] = '.($bTime ? "true" : "false").';';
262
263 if($bSelectShow)
264 $s .='BX.CalendarPeriod.Init(BX("'.$sFromName.'_calendar_from"), BX("'.$sToName.'_calendar_to"), BX("'.$sFromName.'_calendar_period"));';
265
266 $s .='
267 </script>
268 </div>
269 </div>';
270
271 return $s;
272 }
273}
global $APPLICATION
Определения include.php:80
static load($extNames)
Определения extension.php:16
const PERIOD_MONTH
Определения admin_calendar.php:14
const PERIOD_EXACT
Определения admin_calendar.php:17
const PERIOD_BEFORE
Определения admin_calendar.php:18
static CalendarDate($sFieldName, $sValue="", $size="10", $bTime=false)
Определения admin_calendar.php:78
static CalendarPeriod($sFromName, $sToName, $sFromVal="", $sToVal="", $bSelectShow=false, $size=10, $bTime=false)
Определения admin_calendar.php:142
static CalendarPeriodCustom($sFromName, $sToName, $sFromVal="", $sToVal="", $bSelectShow=false, $size=10, $bTime=false, $arPeriod=false, $periodValue='')
Определения admin_calendar.php:125
const PERIOD_INTERVAL
Определения admin_calendar.php:20
const PERIOD_YEAR
Определения admin_calendar.php:16
static Calendar($sFieldName, $sFromName="", $sToName="", $bTime=false)
Определения admin_calendar.php:60
const PERIOD_AFTER
Определения admin_calendar.php:19
const PERIOD_QUARTER
Определения admin_calendar.php:15
const PERIOD_WEEK
Определения admin_calendar.php:13
static ShowScript()
Определения admin_calendar.php:55
const PERIOD_EMPTY
Определения admin_calendar.php:11
const PERIOD_DAY
Определения admin_calendar.php:12
</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
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$k
Определения template_pdf.php:567
$GLOBALS['_____370096793']
Определения update_client.php:1