<?php

/**
 * @package com_spmedical
 * @author JoomShaper http://www.joomshaper.com
 * @copyright Copyright (c) 2010 - 2022 JoomShaper
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
 */

// No Direct Access
defined('_JEXEC') or die('Restricted Access');

use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;

// get component params

$cParams = ComponentHelper::getParams('com_spmedical');
$specialists = $displayData['specialists'];
$total_items = count($specialists);
$columns = $displayData['columns'];

if (count((array)$specialists)) { ?>
    <div class="spmedical-col-md-8">
        <div class="spmedical-row">
            <?php foreach ($specialists as $specialist) { ?>
                <div class="spmedical-col-md-12 spmedical-col-lg-<?php echo round(12 / $columns); ?>">
                    <div class="spmedical-specialists">
                        <div class="specialist-wrapper spmedical-d-flex">
                            <a href="<?php echo $specialist->url; ?>">
                                <div class="specialists-img-wrapper">
                                    <img src="<?php echo $specialist->thumb; ?>" class="spmedical-person-img spmedical-img-responsive" alt="<?php echo $specialist->title; ?>">
                                </div> <!-- /.specialists-img-wrapper -->
                            </a>
                            <div class="specialists-info-wrapper">
                                <div class="specialists-name">
                                    <h3><a class="splms-person-title" href="<?php echo $specialist->url; ?>"><?php echo $specialist->title; ?></a></h3>
                                    <?php if (!empty($specialist->designation)) { ?>
                                        <span class="specialists-designation">
                                            <?php echo $specialist->designation; ?>
                                        </span>
                                    <?php } ?>
                                </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 ($specialist->specialitist_on) {
                                            $specialitists = explode(', ', $specialist->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 $specialist->address; ?>"><i class="fa fa-map-marker" aria-hidden="true"></i></button>

                                        <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="<?php foreach ($specialist->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> <!-- /.specialists-info-wrapper -->
                        </div>
                    </div> <!-- /.spmedical-specialists -->
                </div>
            <?php } ?>
        </div>
    </div><!-- //.spmedical-col-sm-9 -->
<?php } else { ?>
    <div class="row">
        <div class="spmedical-col-sm-12 sp-no-item-found">
            <p><?php echo Text::_('COM_SPMEDICAL_NO_ITEMS_FOUND'); ?></p>
        </div>
    </div>
<?php } ?>