You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.6 KiB
84 lines
2.6 KiB
2 years ago
|
<?php
|
||
|
|
||
|
/**
|
||
|
* Provide a public-facing view for the plugin
|
||
|
*
|
||
|
* This file is used to markup the public-facing aspects of the plugin.
|
||
|
*
|
||
|
* @link https://kolarix.com/biztime
|
||
|
* @since 1.0.0
|
||
|
*
|
||
|
* @package BizTime
|
||
|
* @subpackage BizTime/public/partials
|
||
|
*/
|
||
|
?>
|
||
|
|
||
|
<?php
|
||
|
|
||
|
$current_day = strtolower(date("l"));
|
||
|
$current_time = date('H:i');
|
||
|
$is_available = false;
|
||
|
$true_msg = $options['true-msg'];
|
||
|
$false_msg = $options['false-msg'];
|
||
|
$show_next = $options['show-next'];
|
||
|
$next_msg = $options['next-msg'];
|
||
|
|
||
|
foreach ($days as $day) {
|
||
|
// Convert the availability range to 24 hour format
|
||
|
$from = date("H:i", strtotime($options[$day]['from']));
|
||
|
$to = date("H:i", strtotime($options[$day]['to']));
|
||
|
if (!empty($options[$day]['check']) && strtotime($from) <= strtotime($current_time) && strtotime($current_time) <= strtotime($to)) {
|
||
|
$is_available = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
|
||
|
<div class="checker-demo">
|
||
|
<button id="open-modal" type="button" class="button primary"><?php esc_html_e( 'CHECK AVAILABILITY', 'biztime' ); ?></button>
|
||
|
<span class="sm-grey"><?php esc_html_e( 'TO SEE A PREVIEW', 'biztime' ); ?></span>
|
||
|
</div>
|
||
|
|
||
|
<div id="availability-modal" class="modal">
|
||
|
<div class="modal-content">
|
||
|
<span id="close-modal">×</span>
|
||
|
<div class="modal-content__wrapper">
|
||
|
<?php
|
||
|
if ($is_available) {
|
||
|
$phone_number = $options['phone-number'];
|
||
|
echo "<div class='available'><p>" . $true_msg . "</p><div class='only-when-available'>" . $phone_number . "</div></div>";
|
||
|
} else {
|
||
|
echo "<div class='not-available'><p>" . $false_msg . "</p></div>";
|
||
|
$next_day = null;
|
||
|
$start_searching = false;
|
||
|
|
||
|
foreach ($days as $day) {
|
||
|
if ($day === $current_day) {
|
||
|
$start_searching = true;
|
||
|
}
|
||
|
|
||
|
if ($start_searching && !empty($options[$day]['check'])) {
|
||
|
$next_day = $day;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
// if still not found, start from Monday again
|
||
|
if (!$next_day) {
|
||
|
foreach ($days as $day) {
|
||
|
if (!empty($options[$day]['check'])) {
|
||
|
$next_day = $day;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if ($next_day && $show_next) {
|
||
|
echo "<p class='next-available'>" . $next_msg . ucfirst($next_day) . " from " . $options[$next_day]['from'] . " to " . $options[$next_day]['to'] . ".</p>";
|
||
|
}
|
||
|
}
|
||
|
?>
|
||
|
</div>
|
||
|
<pre><br><span>Current:<?php print_r(date("l"));?>, <?php print_r(date('H:i'));?></span></pre>
|
||
|
</div>
|
||
|
</div>
|