<?php

/**
 * @package     SP Medical
 * @subpackage  mod_spmedical_specialists
 *
 * @copyright   Copyright (c) 2010 - 2022 JoomShaper. All rights reserved.
 * @license     GNU General Public License version 2 or later.
 */

// no direct access
defined('_JEXEC') or die('Restricted access!');

use Joomla\CMS\Uri\Uri;

$doc = JFactory::getDocument();
$doc->addStyleSheet(Uri::base(true) . '/modules/mod_spmedical_specialists/assets/css/splide.min.css');
$doc->addScript(Uri::base(true) . '/modules/mod_spmedical_specialists/assets/js/splide.min.js');
$doc->addScriptDeclaration("
	document.addEventListener( 'DOMContentLoaded', function () {
		new Splide('.spmedical-specialist-carousel', {
			type       : 'loop',
			perPage    : " . $carousel_items . ",
			gap		   : '30px',
			breakpoints: {
				1199:{
                  perPage: 3,
				  gap: '30px',
				},
				991: {
					perPage    : 2,
					gap		   : '15px',
				},
				767: {
					perPage    : 1,
				},
			},
		}).mount();
	});
");

?>

<div class="mod-spmedical-specialists spmedical <?php echo $moduleclass_sfx; ?>">
	<div class="spmedical-specialist-list spmedical-specialist-carousel">
		<div class="splide__track">
			<div class="splide__list">
				<?php foreach (array_chunk($items, $columns) as $items) { ?>
					<?php foreach ($items as $item) { ?>
						<div class="splide__slide">
							<div class="spmedical-specialist">
								<a href="<?php echo $item->url; ?>">
									<img src="<?php echo Uri::root() . $item->image; ?>" alt="">
								</a>
								<div class="medical-specialist-info">
									<div class="medical-specialist-name">
										<a href="<?php echo $item->url; ?>"><?php echo $item->title; ?></a>
										<div class="medical-specialist-designation"><?php echo $item->designation; ?></div>
									</div>
									<div class="doctors-information-wrap">
										<div class="specialist-contact-info">
											<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="<?php if ($item->specialitist_on) {
																																						$specialitists = explode(', ', $item->specialitist_on);
																																					?>
                                        <?php $total_specialitists = count((array)$specialitists);
																																						foreach ($specialitists as $key => $specialitist) {
																																							$key++;
										?>
                                        <?php echo $specialitist; ?> <?php echo ($total_specialitists != $key) ? ', ' : ''; ?>
                                        <?php } ?>
                                        <?php } ?>">

												<i class="fas fa-crosshairs"></i>

											</button>

											<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="<?php echo $item->address; ?>"><i class="fa fa-map-marker" aria-hidden="true"></i></button>
											<?php $visiting_times = json_decode($item->visiting_times); ?>
											<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="<?php foreach ($visiting_times as $visiting_time) { ?>
                                        <?php echo $visiting_time->day; ?>
                                        <?php echo $visiting_time->visiting_time; ?>.
                                        <?php } ?>">
												<i class="fa fa-calendar-o" aria-hidden="true"></i>
											</button>
										</div>


									</div>
								</div> <!-- /.medical-specialist-info -->
							</div><!-- /.spmedical-specialist -->
						</div>
					<?php } ?>
				<?php } ?>
			</div>
		</div>
	</div>
</div>