File: /var/www/vhosts/greenclinic.kz/newsite/wp-content/themes/green-clinic/single-prices.php
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package asds
*/
//$categories = get_the_category( $the_post );
//$categories_name = $categories[0]->name;
//$categories_id = $categories[0]->term_id;
//$categories_slug = $categories[0]->slug;
$the_post = get_the_ID();
$theme_uri = get_template_directory_uri();
get_header();
?>
<?php get_template_part('template-parts/content_header', 'none'); ?>
<?php
$name = get_field('name', FALSE, FALSE);
$speciality = get_field('speciality');
$specialization = get_field('specialization');
$experience = get_field('experience');
$inte = get_field('International');
$photo = get_field('photo');
$btn_show = get_field('btn_show');
if (empty($photo)) {
$photo = '/wp-content/uploads/2024/02/doctor.webp';
}
$about_doc = get_field('about_doc');
/*echo '<pre>';
var_dump($photo);
echo '</pre>';*/
?>
<?php while (have_posts()) : the_post(); ?>
<section class="section doctor <?php if ($inte == 1) : ?>supervisory<?php endif; ?>">
<div class="container">
<div class="services-container">
<?php
$page_field = get_field_objects(get_the_ID());
?>
<?php if (isset($page_field['prices']['value'])) { ?>
<div class="service-item service-item__btn service-item__grid service-item__grid-head">
<div class="service-item-left"></div>
<div class="service-item-right">
Для резидентов
</div>
<div class="service-item-right">
Для нерезидентов
</div>
</div>
<?php foreach ($page_field['prices']['value'] as $item) { ?>
<div class="service-item service-item__btn service-item__grid js-service-list-item">
<div id="pageidid" style="display:none;"><?php the_ID(); ?></div>
<div class="service-item-left">
<p><?= $item['nomer']; ?></p>
<p class="js-name"><?= $item['name']; ?></p>
</div>
<div class="service-item-right">
<p class="service-item-head">Для резидентов</p>
<h3 class="js-price"><?= $item['price']; ?> тг.</h3>
</div>
<div class="service-item-right">
<p class="service-item-head">Для нерезидентов</p>
<h3><?= $item['outprice']; ?> тг.</h3>
</div>
</div>
<?php /*/ ?>
<div class="search__results-service">
<div class="search__service">
<div id="pageidid" style="display:none;"> <?php the_ID(); ?></div>
<!-- <p class="search__service-id"><?= $item['nomer']; ?></p> -->
<p class="search__service-name">
<em><?= $item['nomer']; ?></em>
<?= $item['name']; ?>
</p>
<!-- <p class="search__service-type" style="margin-left: auto;"><?= $item['price']; ?>Поликлиника платная</p> -->
</div>
<h3 class="search__results-price"><?= $item['price']; ?> тг.</h3>
<h3 class="search__results-price"><?= $item['outprice']; ?> тг.</h3>
</div>
<?php /**/ ?>
<?php } ?>
<?php } ?>
</div>
</div>
</section>
<?php endwhile; ?>
<script>
const id = 1;
const doctors = [{
id: 1,
imgSrc: "<?php echo $photo ?>",
name: "<?php echo $name ?>",
position: "<?php echo $speciality ?>",
experience: "<?php echo $experience ?>",
specializations: [
<?php foreach ($specialization as $spt_item) : ?>
"<?php echo $spt_item->name; ?>",
<?php endforeach; ?>
],
description: '',
}, ];
const doctorImg = document.getElementById("img");
const doctorName = document.getElementById("name");
const doctorPosition = document.getElementById("position");
const doctorExperience = document.getElementById("experience");
const doctorSpecializations = document.getElementById("specializations");
const doctorDescription = document.getElementById("description");
doctorSpecializations.innerHTML = "";
doctors.map((doctor) => {
if (doctor.id === id) {
doctorImg.src = doctor.imgSrc;
doctorName.textContent = doctor.name;
doctorPosition.textContent = doctor.position;
doctorExperience.textContent = doctor.experience;
doctor.specializations.map((spec) => {
let docSpec = `
<div class="doctor__info-spec">
<span>${spec}</span>
</div>
`;
doctorSpecializations.innerHTML += docSpec;
});
}
});
</script>
<script>
// Debounce function to limit the rate of invoking the performSearch function
function debounce(func, wait, immediate) {
let timeout;
return function() {
const context = this,
args = arguments;
const later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
// Function to perform the search via AJAX
function performSearch() {
let searchTerm = jQuery('#searchInput').val().trim();
// Only perform the search if the search term is not too short
if (searchTerm.length < 3) {
// Optionally, clear the search results if the term is too short
jQuery('#search__results').html('');
return;
}
// Show the preloader animation
jQuery('.preloader').show();
// Send the AJAX request to perform the search
jQuery.ajax({
url: '/wp-admin/admin-ajax.php',
type: 'POST',
data: {
action: 'search_prices',
term: searchTerm
},
success: function(response) {
// Display the search results
jQuery('#search__results').html(response);
// Hide the preloader animation
jQuery('.preloader').hide();
},
error: function() {
// Hide the preloader animation
jQuery('.preloader').hide();
// Display an error message to the user
alert('Search failed. Please try again.');
}
});
}
(function($) {
$(document).ready(function() {
// Debounce the keyup event to limit the rate of AJAX requests
const debouncedSearch = debounce(performSearch, 300);
// Attach the debounced search function to the keyup event on the search input
$('#searchBtn').on('click', debouncedSearch);
var value_two = localStorage.getItem("value_ls");
var click_two = localStorage.getItem("value_click");
if (click_two == 1) {
let serIn = $('#searchInput');
serIn.val(value_two);
serIn.trigger('keydown');
serIn.trigger('keyup');
localStorage.removeItem("value_ls");
localStorage.removeItem("value_click");
localStorage.clear();
} else {}
$('#paidFilter').on('click', function() {
$('#search__results').removeClass('open');
$('#search__results_osms').removeClass('open');
$('#search__results_paid').addClass('open');
});
$('#osmsFilter').on('click', function() {
$('#search__results').removeClass('open');
$('#search__results_paid').removeClass('open');
$('#search__results_osms').addClass('open');
});
});
$('body').on('click', '.js-service-list-item', function() {
var value_name = $(this).find('.js-name').html();
var value_price = $(this).find('.js-price').html();
// var value_type = $(this).find('.search__service-type').html();
var value_price_id = $(this).find('#pageidid').html();
// var click_one = 1;
localStorage.setItem("value_name", value_name);
localStorage.setItem("value_price", value_price);
// localStorage.setItem("value_type", value_type);
localStorage.setItem("value_click", 1);
localStorage.setItem("value_price_id", value_price_id);
console.log(value_price_id);
document.location.href = '/zapis-na-priem';
});
// $('body').on('click', '.search__results-service', function() {
// var value_name = $(this).find('.search__service-name').html();
// var value_price = $(this).find('.search__results-price').html();
// var value_type = $(this).find('.search__service-type').html();
// var value_price_id = $(this).find('#pageidid').html();
// var click_one = 1;
// localStorage.setItem("value_name", value_name);
// localStorage.setItem("value_price", value_price);
// localStorage.setItem("value_type", value_type);
// localStorage.setItem("value_click", click_one);
// localStorage.setItem("value_price_id", value_price_id);
// console.log(value_price_id);
// document.location.href = '/zapis-na-priem';
// });
})(jQuery);
</script>
<?php get_template_part('blocks/blocks'); ?>
<?php get_footer(); ?>