<div class="modal fade" id="modalRegister" tabindex="-1" role="dialog" aria-labelledby="modalAnswer">
<div class="modal-dialog modal-dialog__bordered" role="document">
<div class="modal-content modal-content">
<div class="modal-body">
<button type="button" class="modal-close" data-dismiss="modal" aria-label="Закрыть"><span aria-hidden="true">×</span></button>
<form class="form jq-register-form" method="post" action="?send=Y">
<h3 class="form_heading heading">Регистрация</h3>
<div class="form_row">
<label class="form_label">Категория:</label>
<select class="field" name="category">
<option>Клиника</option>
<option value="2">Частный врач</option>
</select>
</div>
<div class="jq-content">
<div class="form_row">
<input class="field" type="text" placeholder="Название клиники" name="name" required>
</div>
<div class="form_row">
<textarea class="field field__textarea" placeholder="Описание" name="description"></textarea>
</div>
<div class="form_row">
<input class="field" type="email" placeholder="Электронная почта" name="email" required>
</div>
<div class="form_row">
<input class="field" placeholder="Регион:" type="text" name="region">
</div>
<div class="form_row">
<div id="reCaptcha1"></div>
</div>
</div>
<button class="main-btn" type="submit" name="register_submit" value="Y"><span class="icon icon-forum"></span> Отправить</button>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$('.jq-register-form').on('change', '[name="category"]', function(){
if ($(this).val() == 2) {
$('.jq-register-form .jq-content').html(
'<div class="form_row">'+
'<label class="form_label">Ф.И.О.: <span style="color: red;">*</span></label>' +
'<input class="field" type="text" name="name" required>' +
'</div>' +
'<div class="form_row">'+
'<label class="form_label">Профессия: <span style="color: red;">*</span></label>' +
'<input class="field" type="text" name="job" required>' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Опыт: <span style="color: red;">*</span></label>' +
'<textarea class="field field__textarea" name="exp" require></textarea>' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Специализация: <span style="color: red;">*</span></label>' +
'<textarea class="field field__textarea" name="spec" require></textarea>' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Адрес клиники: <span style="color: red;">*</span></label>' +
'<textarea class="field field__textarea" name="address" require></textarea>' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Ваш e-mail: <span style="color: red;">*</span></label>' +
'<input class="field" type="email" name="email" required>' +
'</div>' +
'<div class="form_row">'+
'<label class="form_label">Телефон (для связи администрации сайта с врачом, не публикуется на сайте): </label>' +
'<input class="field" type="text" name="phone">' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Регион:</label>' +
'<input class="field" type="text" name="region">' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Дополнительная информация: </label>' +
'<textarea class="field field__textarea" name="opt"></textarea>' +
'</div>'
);
}
else {
$('.jq-register-form .jq-content').html(
'<div class="form_row">'+
'<label class="form_label">Название: <span style="color: red;">*</span></label>' +
'<input class="field" type="text" name="name" required>' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Описание: <span style="color: red;">*</span></label>' +
'<textarea class="field field__textarea" name="description"></textarea>' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Ваш e-mail: <span style="color: red;">*</span></label>' +
'<input class="field" type="email" name="email" required>' +
'</div>' +
'<div class="form_row">' +
'<label class="form_label">Регион:</label>' +
'<input class="field" type="text" name="region">' +
'</div>'
);
}
});
</script>
<?php
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
// Если к нам идёт Ajax запрос, то ловим его
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['name'])) {$name = $_POST['name'];}
if (isset($_POST['phone'])) {$phone = $_POST['phone'];}
if (isset($_POST['messages'])) {$messages = $_POST['messages'];}
if (isset($_POST['formData'])) {$formData = $_POST['formData'];}
$json = array(); // пoдгoтoвим мaссив oтвeтa
if (!$name or !$email or !$subject or !$message) { // eсли хoть oднo пoлe oкaзaлoсь пустым
$json['error'] = 'Вы зaпoлнили нe всe пoля! oбмaнуть рeшили? =)'; // пишeм oшибку в мaссив
echo json_encode($json); // вывoдим мaссив oтвeтa
die(); // умирaeм
}
$to = "viktor242424@gmail.com"; /*Укажите адрес, га который должно приходить письмо*/
$sendfrom = "codabra@yandex.ru"; /*Укажите адрес, с которого будет приходить письмо, можно не настоящий, нужно для формирования заголовка письма*/
$headers = "From: " . strip_tags($sendfrom) . "\r\n";
$headers .= "Reply-To: ". strip_tags($sendfrom) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";
$subject = "$formData";
$message = "$formData<br> <b>Имя пославшего:</b> $name <br><b>Телефон:</b> $phone <br><b>Сообщение:</b> $messages";
$send = mail ($to, $subject, $message, $headers);
$json['error'] = 0; // oшибoк нe былo
echo json_encode($json); // вывoдим мaссив oтвeтa
} else {
http_response_code(403);
echo "Попробуйте еще раз";
}
}
//Если это не ajax запрос
echo 'Ошибка!';
?>
$(document).ready(function () {
$("form").submit(function () {
// Получение ID формы
var formID = $(this).attr('id');
// Добавление решётки к имени ID
var formNm = $('#' + formID);
$.ajax({
type: "POST",
url: 'mail.php',
dataType: 'json', // oтвeт ждeм в json фoрмaтe
data: data, // дaнныe для oтпрaвки
success: function(data){ // сoбытиe пoслe удaчнoгo oбрaщeния к сeрвeру и пoлучeния oтвeтa
if (data['error']) { // eсли oбрaбoтчик вeрнул oшибку
alert(data['error']); // пoкaжeм eё тeкст
} else { // eсли всe прoшлo oк
alert('Письмo oтврaвлeнo! Чeкaйтe пoчту! '); // пишeм чтo всe oк
}
},
});
return false;
});
});
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
/** @var array $arParams */
/** @var array $arResult */
/** @global CMain $APPLICATION */
/** @global CUser $USER */
/** @global CDatabase $DB */
/** @var CBitrixComponentTemplate $this */
/** @var string $templateName */
/** @var string $templateFile */
/** @var string $templateFolder */
/** @var string $componentPath */
/** @var CBitrixComponent $component */
$this->setFrameMode(true);
?>
<?if($arResult["ITEMS"]):?>
<div class="services post-left">
<?foreach($arResult["ITEMS"] as $cell=>$arItem):?>
<?
$this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_EDIT"));
$this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
?>
<div class="s_item">
<?if(is_array($arItem["PREVIEW_PICTURE"])):?>
<img src="<?=$arItem["PREVIEW_PICTURE"]["SRC"]?>"
alt="<?=$arItem["PREVIEW_PICTURE"]["ALT"]?>"
title="<?=$arItem["PREVIEW_PICTURE"]["TITLE"]?>"
/>
<?endif;?>
<?if($arParams["DISPLAY_PREVIEW_TEXT"]!="N" && $arItem["PREVIEW_TEXT"]):?>
<p><?echo $arItem["PREVIEW_TEXT"];?></p>
<?endif;?>
</div>
<?endforeach;?>
</div>
<?if($arParams["DISPLAY_BOTTOM_PAGER"]):?>
<?=$arResult["NAV_STRING"]?>
<?endif;?>
<?endif;?>
<select onchange="showPrice(this);" class="input-select" >
<?foreach($arResult['SIZES'] as $id => $size):?>
<option value="<?=$id?>" data-price><?=$size?></option>
<?endforeach;?>
</select>
function showPrice(e) {
$('.total_cost').html(e.options[e.selectedIndex].getAttribute('data-price'));
}
<script type="text/javascript">
$(document).ready(function(){
<?if (isset($_REQUEST["REPLIER_FORM_CLICK"])){?>
$('.AddReview').click();
<?}?>
<?if(!empty($arResult['SIZES_OPTIONS'])):?>
var size_option = JSON.parse('<?=$arResult['SIZES_OPTIONS']?>');
<?else:?>
var size_option = [];
<?endif;?>
<?if(!empty($arResult['MATERIAL_SIZE'])):?>
var size_material = JSON.parse('<?=$arResult['MATERIAL_SIZE']?>');
<?else:?>
var size_material = [];
<?endif;?>
<?if(!empty($arResult['DEFAULT_OFFER'])):?>
var default_offer = JSON.parse('<?=$arResult['DEFAULT_OFFER']?>');
<?else:?>
var default_offer = [];
<?endif;?>
function selectSize(size) {
$('.js-sizeRadio').removeAttr('checked');
$('.js-sizeRadio[value=' + size + ']').attr('checked', 'checked');
$('.js-sizeRadio').trigger('change');
}
function selectMaterial(material) {
$('.js-material').val(material);
$('.js-material').trigger('change');
}
function enableSizes(material) {
$('.js-sizeRadio').attr('disabled', 'disabled');
var selected = $('.js-sizeRadio:checked').val();
var last_key = 0;
a = size_material[material];
findSelected = false;
for (key in a) {
if (a.hasOwnProperty(key)) {
if(key === selected) {
findSelected = true;
}
$('.js-sizeRadio[value="' + key + '"]').removeAttr('disabled');
last_key = key;
}
}
if(!findSelected) {
selectSize(last_key);
}
}
function enableMaterials(size) {
$('.js-SelectMaterialsSection > option').attr('disabled','disabled');
var selected = $('.js-SelectMaterialsSection').val();
var last_key = 0;
findSelected = false;
for (key in size_material) {
if (size_material[key].hasOwnProperty(size)) {
if(key === selected) {
findSelected = true;
}
$('.js-SelectMaterialsSection > option[value="' + key + '"]').removeAttr('disabled');
last_key = key;
}
}
if(!findSelected) {
selectMaterial(last_key);
return last_key;
}
return selected;
}
function selectMaterialItem(item) {
$('.product-detail-choose-list > li').removeClass('selected');
if(item){
$('.product-detail-choose-list > li[rel="'+ item +'"]').addClass('selected');
}
}
function showMaterials(material) {
$('.product-detail-choose-list').hide();
$('.mats-' + material).show();
selectMaterialItem(false);
}
function getOptionCost(size) {
var opts = $('.js-option:checked');
if(opts.length == 0) {
return 0;
}
cost = 0;
for (var i = opts.length - 1; i >= 0; i--) {
cost += parseInt(size_option[size][$(opts[i]).val()]);
};
if(isNaN(cost)) {
cost = 0;
}
return cost;
}
function getMaterialItem(){
var mi = $('.product-detail-choose-list > li.selected');
if(mi.length <= 0) {
return 0;
}
return mi.attr('rel');
}
function showPrice(size, material) {
var optionCosts = getOptionCost(size);
var itemPrice = parseInt(size_material[material][size]);
var price = optionCosts + itemPrice;
$('.total_cost').html(price);
}
function enableOptions(size) {
$('.js-option').attr('disabled','disabled');
if(!size_option.hasOwnProperty(size)) {
return false;
}
for (key in size_option[size]) {
if (size_option[size].hasOwnProperty(key) && size_option[size][key] > 0) {
$('.js-option[value="' + key + '"]').removeAttr('disabled');
$('#price-' + key).html(" +" + size_option[size][key] + " руб.");
}
else
{
$('#price-' + key).html("");
}
}
removeDisabledOptions();
}
function removeDisabledOptions()
{
$('.js-option:checked').each(function(index, el){
var attr = $(this).attr('disabled');
if (attr == "disabled") {
$(el).attr("checked", false);
}
});
}
function getSize() {
return $('.js-sizeRadio:checked').val();
}
function getMaterial(){
return $('.js-SelectMaterialsSection').val();
}
function getOptions(){
var opt = [];
$.each($('.js-option:checked'), function(k, v){
opt.push($(v).val());
});
return opt;
}
function formPopulate(post){
$('.js-quantity').val(post.quantity);
$('.js-material-id').val(post.material);
$('.js-offer-code').val(post.offer_code);
$('.js-options-form-container').html('');
for (var i = post.options.length - 1; i >= 0; i--) {
var el = $('<input type="hidden" name="options[]" value="' + post.options[i] + '"/>');
el.appendTo('.js-options-form-container');
};
}
selectSize(default_offer['SIZE']);
selectMaterial(default_offer['MATERIAL']);
enableSizes(default_offer['MATERIAL']);
enableMaterials(default_offer['SIZE']);
enableOptions(default_offer['SIZE']);
showMaterials(default_offer['MATERIAL']);
showPrice(default_offer['SIZE'], default_offer['MATERIAL']);
$('.js-SelectMaterialsSection').change(function(){
enableSizes($(this).val());
showMaterials($(this).val());
showPrice(getSize(),getMaterial());
});
$('.js-sizeRadio').click(function(){
var id = enableMaterials($(this).val());
enableOptions($(this).val());
selectMaterial(id);
showMaterials(id);
showPrice(getSize(),getMaterial());
});
$('.product-detail-choose-list > li').mousedown(function(ev){
$(this).find('span').css('background-color', '#fff');
$(this).find('span').css('color', '#4d6192');
});
$('.product-detail-choose-list > li').mouseup(function(ev){
$(this).find('span').css('background-color', '#4d6192');
$(this).find('span').css('color', '#fff');
});
$('.product-detail-choose-list > li').click(function(){
selectMaterialItem($(this).attr('rel'));
});
$('.js-option').click(function(){
showPrice(getSize(),getMaterial());
});
$('.product-detail-submit').click(function(ev){
ev.preventDefault();
if(getMaterialItem() <= 0) {
alert('Пожалуйста, выберите обивочный материал');
return false;
}
post = {};
post.quantity = 1;
post.offer_code = '<?=$arResult['ID']?>_' + getMaterial() + '_' + getSize();
post.options = getOptions();
post.material = getMaterialItem();
formPopulate(post);
return $(this).parents('form').submit();
});
$('.input-select').chosen();
$('a.AddReview').fancybox({
'width': '620'
});
$('a.fancybox-img').fancybox(
{'width': 'auto'});
});
</script>