60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?
|
|
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
|
|
/** @var CBitrixComponent $this */
|
|
/** @var array $arParams */
|
|
/** @var array $arResult */
|
|
/** @var string $componentPath */
|
|
/** @var string $componentName */
|
|
/** @var string $componentTemplate */
|
|
/** @global CDatabase $DB */
|
|
/** @global CUser $USER */
|
|
/** @global CMain $APPLICATION */
|
|
|
|
use Bitrix\Main\Context,
|
|
Bitrix\Main\Type\DateTime,
|
|
Bitrix\Main\Loader,
|
|
Bitrix\Iblock;
|
|
|
|
if($this->StartResultCache(60*60*24, md5(var_export($_POST, true))))
|
|
{
|
|
if(CModule::IncludeModule('iblock'))
|
|
{
|
|
$arResult['ALLOW'] = false;
|
|
$arResult['SEARCH'] = $_REQUEST['search'];
|
|
|
|
print "<!-- SCHEDULE -->\n";
|
|
|
|
$sort = Array("ID" => "DESC");
|
|
$filter = Array("ACTIVE" => "Y", "IBLOCK_ID" => IBLOCK_ID_CALLBACK_SCHEDULE);
|
|
$options = Array("nPageSize" => 1);
|
|
|
|
$schedule_res = CIBlockElement::GetList($sort, $filter, false, $options);
|
|
while ($schedule_element = $schedule_res->GetNextElement())
|
|
{
|
|
$schedule = $schedule_element->GetFields();
|
|
$schedule['PROPERTIES'] = $schedule_element->GetProperties();
|
|
|
|
$day = date("w");
|
|
$time = date("H:i");
|
|
|
|
if($schedule['PROPERTIES']['WEEKDAY_'.$day.'_ENABLED']['VALUE_XML_ID'] === "YES")
|
|
{
|
|
if(!empty($schedule['PROPERTIES']['WEEKDAY_'.$day.'_FROM']['VALUE']) && $schedule['PROPERTIES']['WEEKDAY_'.$day.'_TO']['VALUE'])
|
|
{
|
|
$from = mktime($schedule['PROPERTIES']['WEEKDAY_'.$day.'_FROM']['VALUE'].":00");
|
|
$now = mktime( $time.":00" );
|
|
$to = mktime($schedule['PROPERTIES']['WEEKDAY_'.$day.'_TO']['VALUE'].":00");
|
|
|
|
if($now >= $from && $now < $to)
|
|
{
|
|
$arResult['ALLOW'] = true;
|
|
print "<!-- DAY ".$day." -->\n";
|
|
print "<!-- TIME ".$time." | ".$from." - ".$now."- ".$to." -->\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->IncludeComponentTemplate();
|
|
}
|
|
} |