Бронирование чайных

parent 95afbbcc
<?
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("iblock");
if ($_POST['NAME']){
if (closedTea($_POST['DATE'],$_POST['TIME'],$_POST['TEA'])>0){
echo "error";
} else {
$el = new CIBlockElement;
$PROP = [];
$PROP = $_POST;
$arLoad = array(
"MODIFIED_BY" => $USER->GetID(), // элемент изменен текущим пользователем
"IBLOCK_SECTION_ID" => false, // элемент лежит в корне раздела
"IBLOCK_ID" => 13,
"PROPERTY_VALUES" => $PROP,
"NAME" => $_POST['NAME'],
"ACTIVE" => "Y",
"PREVIEW_TEXT" => $_POST["COMMENT"]
);
$el->Add($arLoad);
echo "ok";
}
}
?>
<?
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("iblock");
?>
<?
if (!empty($_POST)){
$res = CIBlockElement::GetByID($_POST['tea']);
if($ar_res = $res->GetNext())
$name=$ar_res['NAME'];
$times=timeend($_POST['time'],$_POST['tea'],$_POST['date']);
echo json_encode(['name' => $name, 'date' => rusdate($_POST['date']), 'times'=>$times]);
}
?>
......@@ -7,37 +7,74 @@ if (!isset($_GET['date'])){
$date =date('d.m.Y');
} else $date=$_GET['date'];
$property_enums = CIBlockPropertyEnum::GetList(Array("ID"=>"ASC", "SORT"=>"ASC"), Array("IBLOCK_ID"=>1, "CODE"=>"ADDRESS"));
while ($enum_fields = $property_enums->GetNext()) {
$arResult['ADDRESS'][$enum_fields["ID"]]['NAME']=$enum_fields["VALUE"];
}
$arSelect = Array("ID", "IBLOCK_ID","NAME");
// получение квестов
$date = date('Y-m-d', strtotime($date));
$arFilter = Array(
"IBLOCK_ID"=>1,
"ACTIVE"=>"Y",
);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
while($ob = $res->GetNextElement()) {
$arSelect = Array("ID", "IBLOCK_ID","PROPERTY_*");
$arItem = $ob->GetFields();
$arFilter1 = Array(
"IBLOCK_ID"=>12,
"ACTIVE"=>"Y",
"PROPERTY_QUEST"=>$arItem['ID'],
"PROPERTY_DATE"=>$date,
$arSelect = array("ID", "IBLOCK_ID", "NAME", "PROPERTY_*");
foreach($arResult["ADDRESS"] as $k=>$adress) {
// добавляем квесты
$arItem=[];
$arFilter = array(
"IBLOCK_ID" => 1,
"ACTIVE" => "Y",
"PROPERTY_ADDRESS" => $k,
);
$res1 = CIBlockElement::GetList(array('SORT' => 'ASC','ID'=>"ASC"), $arFilter1, false, false, $arSelect);
while($ob1 = $res1->GetNextElement()) {
$arItem1 = $ob1->GetFields();
$arItem1['PROPERTIES']=$ob1->GetProperties();
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
while ($ob = $res->GetNextElement()) {
$arItem = $ob->GetFields();
$arFilter1 = array(
"IBLOCK_ID" => 12,
"ACTIVE" => "Y",
"PROPERTY_QUEST" => $arItem['ID'],
"PROPERTY_DATE" => $date,
);
$res1 = CIBlockElement::GetList(array('SORT' => 'ASC', 'ID' => "ASC"), $arFilter1, false, false, $arSelect);
while ($ob1 = $res1->GetNextElement()) {
$arItem1 = $ob1->GetFields();
$arItem1['PROPERTIES'] = $ob1->GetProperties();
$arItem['TIMES'][] = $arItem1;
}
$arResult["ADDRESS"][$k]['ITEMS'][] = $arItem;
$arItem['TIMES'][]=$arItem1;
}
$arResult['ITEMS'][]=$arItem;
// добавляем чайные
$arItem=[];
if ($k==9){
$add=24;
} else $add=$k+18;
$arFilter = array(
"IBLOCK_ID" => 7,
"ACTIVE" => "Y",
"PROPERTY_ADDRESS" => $add,
);
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
while ($ob = $res->GetNextElement()) {
$arSelect = array("ID", "IBLOCK_ID", "NAME", "PROPERTY_*");
$arItem = $ob->GetFields();
$arResult["ADDRESS"][$k]['ITEMS'][] = $arItem;
}
}
}
$this->IncludeComponentTemplate();
......
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); ?>
<?
//echo "<pre>";
//print_r($arResult);
//echo "</pre>";
?>
<div class="page_content">
<div class="content_box">
<h1 class="h1_head">Общее расписание</h1>
<div class="schedules">
<div class="date-list">
<? for ($i = 0; $i <= 30; $i++) {
$date = date('d.m.Y', strtotime('+' . $i . ' days'));
$dayweek=trim(dayweek($date));
if (!isset($_GET['date'])) $_GET['date']=date('d.m.Y');
?>
<div class="item-slider" >
<a class="date-list__elem <?=($_GET['date']==$date)?'active':'not-active'?>"
href="/schedule/?date=<?=$date?>"
tabindex="0"><?=mb_substr($date,0,5)?> <br> <?=mb_strtolower($dayweek)?>
</a>
</div>
<?}?>
<?foreach($arResult["ADDRESS"] as $adress){?>
<h1 class="h1_head"><?=$adress['NAME']?></h1>
<div class="schedules">
<div class="date-list">
<? for ($i = 0; $i <= 30; $i++) {
$date = date('d.m.Y', strtotime('+' . $i . ' days'));
$dayweek=trim(dayweek($date));
if (!isset($_GET['date'])) $_GET['date']=date('d.m.Y');
?>
<div class="item-slider" >
<a class="date-list__elem <?=($_GET['date']==$date)?'active':'not-active'?>"
href="/schedule/?date=<?=$date?>"
tabindex="0"><?=mb_substr($date,0,5)?> <br> <?=mb_strtolower($dayweek)?>
</a>
</div>
<?}?>
</div>
<div class="schedules-inner">
<div class="schedules-wrapp">
<?foreach($arResult["ITEMS"] as $arItem){?>
<div class="quest">
<div class="quest__title addr-quests berezka">
<div class="quest__title-text"><?=$arItem['NAME']?></div>
</div>
<?if (!empty($arItem['TIMES'])){?>
<div class="slots tt_v1__slots">
<?
foreach ($arItem['TIMES'] as $item) {
$time=$item['PROPERTIES']['TIME']['VALUE'];
$color=$item['PROPERTIES']['COLOR']['VALUE'];
$price=$item['PROPERTIES']['PRICE']['VALUE'];
</div>
<div class="schedules-inner">
<div class="schedules-wrapp">
<?foreach($adress["ITEMS"] as $arItem){?>
<div class="quest">
<div class="quest__title addr-quests berezka">
<div class="quest__title-text"><?=$arItem['NAME']?></div>
</div>
<?if ($arItem['IBLOCK_ID']==7){?>
<div class="slots tt_v1__slots">
<? $time="11:00";
for ($i = 0; $i <= 24; $i++) {
$ti=explode(":",$time);
$hour=(int)$ti[0];
$min=(int)$ti[1];
if ($i>0){
$min=$min+30;
if ($min==60){
$hour+=1;
$min=0;
}
}
if ($min==0){
$time=$hour.":".$min."0";
} else $time=$hour.":".$min;
//если бронь недоступна
if (closedTea($_GET['date'],$time, $arItem['ID'])>0){?>
<button type="button" data-toggle="tooltip"
class="item time_table_label closed"><?=$time?>
</button>
<?}else{?>
<button type="button" data-action="show-order-tea"
data-tea="<?= $arItem['ID'] ?>" data-date="<?= $_GET['date'] ?>"
data-time="<?= $time ?>"
data-type="tea"
data-cost="<?=$price?>"
data-price="<?=$color?>" class="item time_table_label free">
<?= $time ?>
</button>
<?
}
}
?>
<?//если бронь недоступна
if (closed($_GET['date'],$time, $arItem['ID'])>0){?>
<button type="button" data-toggle="tooltip"
class="item time_table_label closed"><?=$time?>
</button>
<?}else{?>
<button type="button" data-action="show-order-form"
data-quest="<?= $arItem['ID'] ?>" data-date="<?= $_GET['date'] ?>"
data-time="<?= $time ?>"
data-type="quest"
data-cost="<?=$price?>"
data-price="<?=$color?>" class="item time_table_label free">
<?= $time ?>
</button>
<?
</div>
<?}?>
<?if (!empty($arItem['TIMES'])){?>
<div class="slots tt_v1__slots">
<?
foreach ($arItem['TIMES'] as $item) {
$time=$item['PROPERTIES']['TIME']['VALUE'];
$color=$item['PROPERTIES']['COLOR']['VALUE'];
$price=$item['PROPERTIES']['PRICE']['VALUE'];
?>
<?//если бронь недоступна
if (closed($_GET['date'],$time, $arItem['ID'])>0){?>
<button type="button" data-toggle="tooltip"
class="item time_table_label closed"><?=$time?>
</button>
<?}else{?>
<button type="button" data-action="show-order-form"
data-quest="<?= $arItem['ID'] ?>" data-date="<?= $_GET['date'] ?>"
data-time="<?= $time ?>"
data-type="quest"
data-cost="<?=$price?>"
data-price="<?=$color?>" class="item time_table_label free">
<?= $time ?>
</button>
<?
}
}
?>
</div>
<?}?>
}
?>
</div>
<?}?>
</div>
<?}?>
</div>
<?}?>
</div>
</div>
</div>
<?}?>
</div>
</div>
\ No newline at end of file
......@@ -259,3 +259,94 @@ function teaBron($time,$date,$questId){
}
return $teas;
}
function closedTea($date,$time,$teaId){
// получаем бронирование чайных
$iblockId=13;
$arSelect = Array("ID", "IBLOCK_ID","PROPERTY_*");
$date = date('Y-m-d', strtotime($date));
$arFilter = Array(
"IBLOCK_ID"=>$iblockId,
"ACTIVE"=>"Y",
"PROPERTY_TEA"=>$teaId,
"PROPERTY_DATE"=>$date
);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
while($ob = $res->GetNextElement()) {
$arItem = $ob->GetFields();
$arItem['PROPERTIES'] = $ob->GetProperties();
$hourBeg = explode(':', $arItem['PROPERTIES']['TIME_BEGIN']['VALUE']);
$hourBegin = $hourBeg[0];
$minBegin = $hourBeg[1];
$hourEn = explode(':', $arItem['PROPERTIES']['TIME_END']['VALUE']);
$hourEnd = $hourEn[0];
$minEnd = $hourEn[1];
$hou = explode(':', $time);
$hour = $hou[0];
$min=$hou[0];
// если время брони совпадает
if ($hour >= $hourBegin && $hour < $hourEnd) {
return true;
} elseif ($time==$arItem['PROPERTIES']['TIME_END']['VALUE']) {
return true;
} else return false;
}
}
//формирование списка времени для чайных
function timeend($tim,$teaId,$date)
{
$times=[];
$iblockId = 13;
$arSelect = array("ID", "IBLOCK_ID", "PROPERTY_*");
$date = date('Y-m-d', strtotime($date));
$arFilter = array(
"IBLOCK_ID" => $iblockId,
"ACTIVE" => "Y",
"PROPERTY_TEA" => $teaId,
"PROPERTY_DATE" => $date
);
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
while ($ob = $res->GetNextElement()) {
$arItem = $ob->GetFields();
$arItem['PROPERTIES'] = $ob->GetProperties();
$hourBeg = explode(':', $arItem['PROPERTIES']['TIME_BEGIN']['VALUE']);
$hourBegin = $hourBeg[0];
$minBegin = $hourBeg[1];
$hourEn = explode(':', $arItem['PROPERTIES']['TIME_END']['VALUE']);
$hourEnd = $hourEn[0];
$minEnd = $hourEn[1];
}
$time=$tim;
for ($i = 0; $i <= 25; $i++) {
$ti = explode(":", $time);
$hour = (int)$ti[0];
$min = (int)$ti[1];
if ($i > 0) {
$min = $min + 30;
if ($min == 60) {
$hour += 1;
$min = 0;
}
}
if ($min == 0) {
$time = $hour . ":" . $min . "0";
} else $time = $hour . ":" . $min;
if ($hour<=23 && $time!=$tim) {
if ($hour < $hourBegin || $hour > $hourEnd) {
$times[] = $time;
} elseif ($hour == $hourEnd && $min != $minEnd) {
$times[] = $time;
}
}
}
return $times;
}
\ No newline at end of file
......@@ -16,10 +16,10 @@
}
.quest_contact{
display: inline-block;
margin-left: 30px;
position: relative;
top:12px;
top:20px;
}
.fix_fon .quest__content .quest__content__title .quest__content__title_link .quest_contact span{
......@@ -139,7 +139,7 @@
}
.q-phone{
top: 0px;
top: 20px;
}
.help-block1{
display: none;
......@@ -154,4 +154,14 @@
.order-children .thanks{
margin: 20px 0;
font-size: 14px;
}
.order-holiday{
display: inline-block;
border: none;
background: none;
margin-left: 78px;
top: 15px;
position: relative;
}
\ No newline at end of file
......@@ -36,6 +36,13 @@ $kol = 3;
<div class="quest__content__title">
<div class="quest__content__title_link">
<span><?= $arResult['NAME'] ?></span>
<button class="order-holiday" data-toggle="modal" data-target=".childCall">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="230px" height="50px">
<path fill-rule="evenodd" fill="rgb(189, 70, 72)" d="M230.011,25.510 L215.889,49.995 L9.443,49.995 L-0.010,25.510 L9.443,0.003 L215.889,0.003 L230.011,25.510 Z"></path>
<text font-family="Exo 2" fill="rgb(255, 255, 255)" font-weight="bold" font-size="18px" x="18px" y="32px">ЗАКАЗАТЬ ПРАЗДНИК
</text>
</svg>
</button>
<div class="quest_contact q-phone">
<div class="quest__content__attribute__contact-phone">
<i class="fa fa-phone" aria-hidden="true"></i>
......@@ -157,6 +164,12 @@ if (!empty($arResult['PROPERTIES']['SLIDER']['VALUE']) && is_array($arResult['PR
</div>
<!--<div class="reservation"></div>-->
<? $APPLICATION->IncludeComponent("bitrix:main.include", "", array(
"AREA_FILE_SHOW" => "file", // Показывать включаемую область
"PATH" => SITE_DIR . "include/child/form.php", // Путь к файлу области
),
false
); ?>
<? //модальное окно отзывов?>
<script src="https://www.google.com/recaptcha/api.js"></script>
......@@ -207,68 +220,3 @@ if (!empty($arResult['PROPERTIES']['SLIDER']['VALUE']) && is_array($arResult['PR
</div>
</div>
<div class="order-children">
<form class="form form-inline" id="zakaz-form" method="post">
<input type="hidden" name="QUEST" value="<?=$arResult['ID']?>">
<h1>Форма заказа</h1>
<div class="form-group">
<select class="form-control" id="zakaz1" name="POVOD">
<option value="">Повод для праздника</option>
<?foreach($arResult["POVODS"] as $povod){?>
<option value="<?=$povod['ID']?>"><?=$povod['VALUE']?></option>
<?}?>
</select>
</div>
<div class="help-block1">Необходимо заполнить поле «Повод для праздника».</div>
<div class="form-group">
<select class="form-control" id="zakaz2" name="KOLVO">
<option value="">Кол-во участников</option>
<? for ($i = 0; $i <= 5; $i++) {?>
<option value="<?=$i?>"><?=$i?></option>
<?} ?>
<option value="10">10 и более</option>
</select>
</div>
<div class="help-block1">Необходимо заполнить поле «Кол-во участников».</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-calendar"></i></span>
<input class="form-control ct-form-control" id="date" type="text"
placeholder="Дата мероприятия" name="DATE" id="date">
</div>
</div>
<div class="help-block1">Необходимо заполнить поле «Дата мероприятия».</div>
<div class="form-group">
<input class="form-control" placeholder="Имя" name="NAME" id="zakaz3" type="text">
</div>
<div class="help-block1">Необходимо заполнить поле «Имя».</div>
<div class="form-group">
<input class="form-control" placeholder="Телефон" name="PHONE" id="phone" type="text">
</div>
<div class="help-block1">Необходимо заполнить поле «Телефон».</div>
<div class="form-group">
<input class="form-control" placeholder="E-mail" name="EMAIL" id="zakaz4" type="text">
</div>
<div class="help-block1">Необходимо заполнить поле «E-mail».</div>
<div class="form-group check">
<div class="checkbox">
<label class="inline">
<input name="i_agree" id="i_agree" value="1" type="checkbox">
Я ознакомился и согласен с правилами
</label>
</div>
</div>
<div class="help-block1">Вы должны ознакомиться с правилами</div>
<div class="form-group submit">
<input id="callback-button" class="btn btn-default callback-form-button" data-send="ajax" type="submit"
name="send" value="Заказать праздник">
</div>
</form>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment