Форма бронирования

parent 15888960
<?
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("iblock");
if ($_POST['NAME']){
if (closed($_POST['DATE'],$_POST['TIME'],$_POST['QUEST'])>0){
echo "error";
} else {
$el = new CIBlockElement;
$PROP = [];
$PROP = $_POST;
$arLoad = array(
"MODIFIED_BY" => $USER->GetID(), // элемент изменен текущим пользователем
"IBLOCK_SECTION_ID" => false, // элемент лежит в корне раздела
"IBLOCK_ID" => 10,
"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['quest']);
if($ar_res = $res->GetNext())
$name=$ar_res['NAME'];
echo json_encode(['name' => $name, 'date' => rusdate($_POST['date'])]);
}
?>
......@@ -55,5 +55,123 @@ function color($genre)
}
return $color;
}
// русские даты
function rusdate($currentDate)
{
$_monthsList = array(
".01" => "января",
".02" => "февраля",
".03" => "марта",
".04" => "апреля",
".05" => "мая",
".06" => "июня",
".07" => "июля",
".08" => "августа",
".09" => "сентября",
".10" => "октября",
".11" => "ноября",
".12" => "декабря"
);
$_mD = date(".m", strtotime($currentDate)); //для замены
$currentDate = str_replace($_mD, " " . $_monthsList[$_mD] . " ", $currentDate);
$year=date("Y");
$currentDate=str_replace(".".$year, "", $currentDate);
return $currentDate;
}
//получение дней недели
function dayweek($currentDate)
{
$dayofweek = date('w', strtotime($currentDate));
$days = array( 'Пн' , 'Вт' , 'Cр' , 'Чт' , 'Пт' , 'Сб' , 'Вс' );
return $days[$dayofweek];
}
// функция получения что дата и время забронировано
function closed($date,$time,$questId)
{
$locations = array(4, 48, 65, 76);
$iblockId = 10;
$date = date('Y-m-d', strtotime($date));
$arSelect = array("ID", "NAME", "DATE_ACTIVE_FROM");
if (in_array($questId, $locations)){
$loc=0;
foreach($locations as $location) {
$arFilter = array(
"IBLOCK_ID" => $iblockId,
"ACTIVE" => "Y",
"PROPERTY_DATE" => $date,
"PROPERTY_TIME" => $time,
"PROPERTY_QUEST" => $location,
);
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
$count=$res->SelectedRowsCount();
if ($count>0) {
$loc=1;
break;
}
}
if (in_array($questId, $locations) && $loc==1){
return 1;
}
} else {
$arFilter = Array(
"IBLOCK_ID"=>$iblockId,
"ACTIVE"=>"Y",
"PROPERTY_DATE"=>$date,
"PROPERTY_TIME"=>$time,
"PROPERTY_QUEST"=>$questId,
);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
return $res-> SelectedRowsCount();
}
}
// получение цен в зависимости от времени
function price($time,$questId){
$arSelect = array("ID", "NAME", "IBLOCK_ID","PROPERTY_*");
$ar=explode(":",$time);
$hour=(int)$ar[0];
$iblockId=12;
$arFilter = Array(
"IBLOCK_ID"=>$iblockId,
"ACTIVE"=>"Y",
"PROPERTY_QUEST"=>$questId,
);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
if ( $res-> SelectedRowsCount()==0) return "5000";
$k=0;
$array =[];
while($ob = $res->GetNextElement())
{
$arItem = $ob->GetFields();
$arItem['PROPERTIES'] = $ob->GetProperties();
$arr= explode(":",$arItem['PROPERTIES']['TIME']['VALUE']);
$hourMin=(int)$arr[0];
$array[$k]['HOUR']=$hourMin;
$array[$k]['PRICE']=$arItem['PROPERTIES']['PRICE']['VALUE'];
$k++;
}
if ($hour>=$array[0]['HOUR'] && $hour<$array[1]['HOUR']){
return $array[0]['PRICE'];
} else return $array[1]['PRICE'];
}
?>
\ No newline at end of file
<?php
// текстовые блоки
if (!empty($arResult['PROPERTIES']['BLOCKS']['VALUE'])){
$arResult['BLOCKS']=[];
foreach($arResult['PROPERTIES']['BLOCKS']['VALUE'] as $elementId) {
$element = \Bitrix\Iblock\Elements\ElementBlocksTable::getByPrimary($elementId, [
'select' => ['ID', 'NAME', 'PREVIEW_TEXT', 'PREVIEW_PICTURE'],
])->fetch();
$arResult['BLOCKS'][]=$element;
if (!empty($arResult['PROPERTIES']['BLOCKS']['VALUE'])) {
$arResult['BLOCKS'] = [];
foreach ($arResult['PROPERTIES']['BLOCKS']['VALUE'] as $elementId) {
$element = \Bitrix\Iblock\Elements\ElementBlocksTable::getByPrimary($elementId, [
'select' => ['ID', 'NAME', 'PREVIEW_TEXT', 'PREVIEW_PICTURE'],
])->fetch();
$arResult['BLOCKS'][] = $element;
}
}
}
}
// отзывЫ
$iblockId=8;
$iblockId = 8;
$arResult['REVIEWS']=[];
$arSelect = Array("ID", "IBLOCK_ID", "NAME","PREVIEW_TEXT","PROPERTY_RAITING");//IBLOCK_ID и ID обязательно должны быть
$arFilter = Array("IBLOCK_ID"=>$iblockId, "ACTIVE"=>"Y","PROPERTY_QUEST"=>$arResult['ID']);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
while($ob = $res->GetNextElement()) {
$arResult['REVIEWS'] = [];
$arSelect = array("ID", "IBLOCK_ID", "NAME", "PREVIEW_TEXT", "PROPERTY_RAITING");//IBLOCK_ID и ID обязательно должны быть
$arFilter = array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "PROPERTY_QUEST" => $arResult['ID']);
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
while ($ob = $res->GetNextElement()) {
$arFields = $ob->GetFields();
$arResult['REVIEWS'][] = $arFields;
}
// чайные комнаты
if (!empty($arResult['PROPERTIES']['TEAS']['VALUE'])) {
$arResult['TEAS'] = [];
foreach ($arResult['PROPERTIES']['TEAS']['VALUE'] as $elementId) {
$element = \Bitrix\Iblock\Elements\ElementTeasTable::getByPrimary($elementId, [
'select' => ['ID', 'NAME'],
])->fetch();
$arResult['TEAS'][$element["ID"]] = $element;
}
}
// прайсы для списка
$arSelect = array("ID", "IBLOCK_ID", "PROPERTY_*");//IBLOCK_ID и ID обязательно должны быть
$arResult['TIMES'] = [];
$iblockId=12;
$arFilter = Array(
"IBLOCK_ID"=>$iblockId,
"ACTIVE"=>"Y",
"PROPERTY_QUEST"=>$arResult['ID'],
);
$res = CIBlockElement::GetList(array('PRPPERTY_PRICE' => 'ASC'), $arFilter, false, false, $arSelect);
while($ob = $res->GetNextElement()) {
$arItem = $ob->GetFields();
$arItem['PROPERTIES'] = $ob->GetProperties();
$times=[];
$times["TIME"]=$arItem['PROPERTIES']['TIME']['VALUE'];
$times["PRICE"]=$arItem['PROPERTIES']['PRICE']['VALUE'];
$times["COLOR"]=$arItem['PROPERTIES']['COLOR']['VALUE'];
$arResult['TIMES'][]=$times;
}
?>
\ No newline at end of file
.book{
color: #fff;
font-size: 20px;
background: #bd4648;
padding: 10px;
border-radius: 3px;
transition: transform 0.35s, -webkit-transform 0.35s;
-webkit-transform: translate3d(0, 200%, 0);
transform: translate3d(0, 200%, 0);
margin-left: 30px;
position: relative;
top:-5px;
}
.quest_contact{
display: inline-block;
margin-left: 30px;
position: relative;
top:12px;
}
.fix_fon .quest__content .quest__content__title .quest__content__title_link .quest_contact span{
font-size: 22px;
padding-left: 16px;
}
.quest_contact .fa{
font-size: 20px;
}
.fix_fon .quest__content .quest__content__attribute.attr{
text-align: left;
padding-left: 30px;
}
.review-title{
font-size: 25px;
font-weight: bold;
margin-bottom: 10px;
}
.review-phone{
background: #000;
width: 100%;
padding: 0 30px 30px 30px;
}
.reviews{
-webkit-column-count: 4;
column-count: 4;
-webkit-column-gap: 20px;
column-gap: 40px;
display: flex;
}
.review {
width: 100%;
padding: 16px 20px;
position: relative;
background: #222;
border-radius: 6px;
margin-bottom: 20px;
display: inline-block;
}
.review-name{
font-size: 13px;
fomt-weight:bold;
margin-bottom: 10px;
}
.send-review{
color: #fff;
font-size: 20px;
background: #222;
padding: 10px;
border-radius: 3px;
text-align: center;
display: block;
margin-bottom: 20px;
width: 180px;
}
.send-review:hover{
color: #fff;
}
.stars{
margin-bottom: 20px;
}
.stars .fa{
font-size: 20px;
}
.stars .fa-star:before{
color: #cbad34;
}
#review-form, .modal-title{
color:#000;
}
.mt-15{
margin-top: 15px;
}
.help-block-name, .help-block-comment{
display: none;
color:red;
}
.form-control.error{
border:1px solid red;
}
.thanks{
color: #000;
}
.review-more-btn {
color: #fff;
font-size: 20px;
background: #222;
padding: 10px;
border-radius: 3px;
text-align: center;
display: inline-block;
margin-bottom: 20px;
width: 180px;
-webkit-column-break-inside: avoid; /* Chrome, Safari, Opera */
page-break-inside: avoid; /* Firefox */
break-inside: avoid; /* IE 10+ */
}
.review-more-btn:hover{
color: #fff;
}
.review-more{
display: none;
-webkit-column-count: 4;
column-count: 4;
-webkit-column-gap: 40px;
column-gap: 40px;
}
.review-more .review:nth-child(2){
display: block;
}
/* бронирование */
.timetable p {
font-size: 16px;
}
.timetable p:last-child{
margin-bottom: 20px;
}
.timetable{
margin-bottom: 20px;
padding-left: 30px;
}
.timetable h2{
margin-bottom: 20px;
}
.tt_v1__row:not([hidden]) {
display: flex;
}
.tt_v1__date {
-webkit-font-smoothing: antialiased;
border-top: solid 1px #3b3b3b;
color: #ccc;
padding-right: .6em;
padding-bottom: 5px;
white-space: nowrap;
align-self: flex-start;
margin-right: 1em;
min-width: 125px;
padding-top: 1px;
padding-left: .6em;
}
.tt_v1__cal-date {
display: inline-block;
min-width: 7ch;
}
.tt_v1__DOW {
color: #666;
}
.tt_v1__DOW--week-end {
color: #e25a5a;
}
[data-price="1"] {
--color: #FFCCCC;
}
[data-price="2"] {
--color: #FF9999;
}
[data-price="3"] {
--color: #FF6666;
}
[data-price="4"] {
--color: #FF3333;
}
[data-price="5"] {
--color: #FF0033;
}
[data-price="6"] {
--color: #CC0033;
}
.price-legend-1 .label {
display: inline-block;
background-color: var(--color);
font-weight: 700;
padding-top: .5em;
margin-right: 3px;
}
.time_table_label {
border: 0;
background-color: var(--color);
border-radius: 2px;
display: inline-block;
font-size: 14px;
font-weight: 400;
line-height: 1;
margin-bottom: 3px;
margin-left: 0;
margin-right: 3px;
margin-top: 0;
min-width: 50px;
padding: 5px;
text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
vertical-align: top;
white-space: nowrap;
color:#000;
}
.time_table_label.closed {
background-color: #393939;
color: #fff;
}
.bronblock{
display: flex;
justify-content: space-between;
}
.mt-20{
margin-top: 20px;
}
.mbt-5{
margin-top: 5px;
margin-bottom: 20px;
}
.info-block {
-webkit-font-smoothing: antialiased;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-around;
margin-left: 0;
margin-right: 0;
}
.info-block .column{
flex-basis: 33%;
text-align: center;
line-height: 1.4em;
font-size: 14px;
}
.info-block .fa {
display: block;
margin-left: auto;
margin-right: auto;
font-size: 25px;
line-height: 1.2;
color: #3aa5df;
}
.help-block-bron{
color: red;
display: none;
}
.help-block-bron.error{
display: block;
}
.bron_error{
color: red;
font-weight: bold;
padding-left: 30px;
display: none;
}
.bron_error.active{
display: block;
}
\ No newline at end of file
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