default.php
1 day ago
dropdown.php
1 day ago
index.html
1 day ago
ratesgrid.php
1 day ago
seats.php
1 day ago
table.php
1 day ago
table.php
200 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | extract($displayData); |
| 15 | |
| 16 | /** |
| 17 | * Layout variables |
| 18 | * ----------------- |
| 19 | * @var integer $id_emp The employee ID. |
| 20 | * @var integer $id_ser The service ID. |
| 21 | * @var array $table The associative array containing all the available times. |
| 22 | * @var integer $max_rows The maximum number of available times per day. |
| 23 | * @var mixed $prev_day The day to use after clicking "prev" arrow. Null if the button is disabled. |
| 24 | * @var string $next_day The day to use after clicking "next" arrow. |
| 25 | * @var integer $itemid The current Item ID. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * The maximum number of times that should |
| 30 | * be (initially) visible for each day. |
| 31 | * |
| 32 | * @var integer |
| 33 | */ |
| 34 | $times_per_rows = 4; |
| 35 | |
| 36 | /** |
| 37 | * Since the table of an employee may be empty, |
| 38 | * we need to display at least the minimum number |
| 39 | * of times for each column. |
| 40 | * |
| 41 | * @see $times_per_rows |
| 42 | */ |
| 43 | $max_rows = max(array($max_rows, $times_per_rows)); |
| 44 | |
| 45 | // build base URI |
| 46 | $base = "index.php?option=com_vikappointments&view=employeesearch&id_employee={$id_emp}&id_service={$id_ser}"; |
| 47 | |
| 48 | if ($itemid) |
| 49 | { |
| 50 | $base .= "&Itemid={$itemid}"; |
| 51 | } |
| 52 | |
| 53 | $config = VAPFactory::getConfig(); |
| 54 | |
| 55 | $tz = VikAppointments::getUserTimezone(); |
| 56 | |
| 57 | ?> |
| 58 | |
| 59 | <div class="emp-avail-table"> |
| 60 | |
| 61 | <!-- TABLE HEADING (days and arrows) --> |
| 62 | |
| 63 | <div class="avail-table-head"> |
| 64 | |
| 65 | <!-- LEFT ARROW TO SEE PREVIOUS 4 DAYS --> |
| 66 | |
| 67 | <div class="table-head-left-arrow"> |
| 68 | <?php |
| 69 | if ($prev_day) |
| 70 | { |
| 71 | ?> |
| 72 | <a href="javascript: void(0);" onclick="loadOtherTableTimes(<?php echo $id_emp; ?>, '<?php echo $prev_day; ?>');"><i class="fas fa-chevron-left"></i></a> |
| 73 | <?php |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | ?> |
| 78 | <i class="fas fa-chevron-left"></i> |
| 79 | <?php |
| 80 | } |
| 81 | ?> |
| 82 | </div> |
| 83 | |
| 84 | <!-- CURRENT DAYS --> |
| 85 | |
| 86 | <div class="table-head-center"> |
| 87 | <?php |
| 88 | foreach (array_keys($table) as $day) |
| 89 | { |
| 90 | $date = JFactory::getDate($day); |
| 91 | |
| 92 | /** |
| 93 | * The dates are always displayed using the UTC timezone, since there are no times set. |
| 94 | * |
| 95 | * @since 1.7 |
| 96 | */ |
| 97 | ?> |
| 98 | <div class="table-head-day"> |
| 99 | <div class="day-name"><?php echo JHtml::fetch('date', $date, 'D', 'UTC'); ?></div> |
| 100 | <div class="day-desc"><?php echo JHtml::fetch('date', $date, 'j M', 'UTC'); ?></div> |
| 101 | </div> |
| 102 | <?php |
| 103 | } |
| 104 | ?> |
| 105 | </div> |
| 106 | |
| 107 | <!-- RIGHT ARROW TO SEE NEXT 4 DAYS --> |
| 108 | |
| 109 | <div class="table-right-arrow"> |
| 110 | <a href="javascript: void(0);" onclick="loadOtherTableTimes(<?php echo $id_emp; ?>, '<?php echo $next_day; ?>');"><i class="fas fa-chevron-right"></i></a> |
| 111 | </div> |
| 112 | |
| 113 | </div> |
| 114 | |
| 115 | <!-- TABLE BODY (times) --> |
| 116 | |
| 117 | <div class="avail-table-body" id="avail-tbody<?php echo $id_emp; ?>"> |
| 118 | |
| 119 | <div class="table-body-arrow-col"> </div> |
| 120 | |
| 121 | <div class="avail-table-body-cols"> |
| 122 | <?php |
| 123 | foreach ($table as $date => $timeline) |
| 124 | { |
| 125 | $count = 0; |
| 126 | ?> |
| 127 | <div class="avail-table-day-col"> |
| 128 | <?php |
| 129 | // make sure we have a timeline to parse |
| 130 | if ($timeline) |
| 131 | { |
| 132 | // iterate all timeline levels |
| 133 | foreach ($timeline as $times) |
| 134 | { |
| 135 | foreach ($times as $slot) |
| 136 | { |
| 137 | if (!$slot->isAvailable()) |
| 138 | { |
| 139 | // skip time in case it is not available |
| 140 | continue; |
| 141 | } |
| 142 | |
| 143 | // fetch time slot visibility |
| 144 | $hidden = $count < $times_per_rows ? '' : ' hidden'; |
| 145 | $count++; |
| 146 | |
| 147 | // get hour and minutes |
| 148 | $hour = (int) $slot->checkin('G'); |
| 149 | $min = (int) $slot->checkin('i'); |
| 150 | |
| 151 | // build details URL |
| 152 | $url = JRoute::rewrite($base . "&date={$date}&hour={$hour}&min={$min}"); |
| 153 | ?> |
| 154 | <div class="table-body-free-slot timetable-slot<?php echo $hidden; ?>"> |
| 155 | <a href="<?php echo $url; ?>"> |
| 156 | <?php echo $slot->checkin($config->get('timeformat'), $tz); ?> |
| 157 | </a> |
| 158 | </div> |
| 159 | <?php |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // display empty remaining slot |
| 165 | for ($count; $count < $max_rows; $count++) |
| 166 | { |
| 167 | // fetch time slot visibility |
| 168 | $hidden = $count < $times_per_rows ? '' : ' hidden'; |
| 169 | ?> |
| 170 | <div class="table-body-empty-slot timetable-slot<?php echo $hidden; ?>">--</div> |
| 171 | <?php |
| 172 | } |
| 173 | ?> |
| 174 | </div> |
| 175 | <?php |
| 176 | } |
| 177 | ?> |
| 178 | </div> |
| 179 | |
| 180 | <div class="table-body-arrow-col"> </div> |
| 181 | |
| 182 | </div> |
| 183 | |
| 184 | <?php |
| 185 | if ($max_rows > $times_per_rows) |
| 186 | { |
| 187 | ?> |
| 188 | <!-- TABLE FOOTER (show more link) --> |
| 189 | |
| 190 | <div class="avail-table-footer"> |
| 191 | <a href="javascript: void(0);" onclick="showMoreTimesFromTable(<?php echo $id_emp; ?>, this);"> |
| 192 | <?php echo JText::translate('VAPSHOWMORETIMES'); ?> |
| 193 | </a> |
| 194 | </div> |
| 195 | <?php |
| 196 | } |
| 197 | ?> |
| 198 | |
| 199 | </div> |
| 200 |