| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template for Edit field CALENDAR DATES VIEW. |
| 4 |
* |
| 5 |
* This is the template that field layout for edit form, readonly |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly. |
| 11 |
} |
| 12 |
?> |
| 13 |
|
| 14 |
<?php |
| 15 |
|
| 16 |
if(isset($field->field)) |
| 17 |
{ |
| 18 |
$field_id = $field->field; |
| 19 |
} |
| 20 |
else |
| 21 |
{ |
| 22 |
$field_id = 'field_'.$field->idfield; |
| 23 |
} |
| 24 |
|
| 25 |
if(!isset($field->hint))$field->hint = ''; |
| 26 |
if(!isset($field->columns_number))$field->columns_number = ''; |
| 27 |
if(!isset($field->class))$field->class = ''; |
| 28 |
|
| 29 |
$field_label = $field->field_label; |
| 30 |
|
| 31 |
$required = ''; |
| 32 |
if(isset($field->is_required) && $field->is_required == 1) |
| 33 |
$required = '*'; |
| 34 |
|
| 35 |
?> |
| 36 |
|
| 37 |
<div class="wdk-field-edit <?php echo esc_attr($field->field_type); ?> wdk-col-<?php echo esc_attr($field->columns_number); ?> <?php echo esc_attr($field->class); ?>"> |
| 38 |
<label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html($field_label).esc_html($required); ?></label> |
| 39 |
<div class="wdk-field-container"> |
| 40 |
<div class="wdk-field-calendar"> |
| 41 |
<div class="hidden data-ajax" data-ajax="<?php echo esc_url(admin_url( 'admin-ajax.php' )); ?>"></div> |
| 42 |
<div class="hidden js_message_error_date"><?php echo esc_html__('Dates in not available, please set other dates', 'wdk-booking');?></div> |
| 43 |
<div class="wdk-row"> |
| 44 |
<?php |
| 45 |
$available_dates = []; |
| 46 |
$current_day = date("j"); |
| 47 |
$current_month = date("m"); |
| 48 |
$wdk_order = 0; |
| 49 |
?> |
| 50 |
<?php for($month_i=0;$month_i < wdk_show_data('month_count', $values, 48, TRUE, TRUE); $month_i++):?> |
| 51 |
<?php if($month_i%6==0 && $month_i !=0):?> |
| 52 |
</div> |
| 53 |
<div class="wdk-row wdk-field-calendar-addinition" style="display: none;"> |
| 54 |
<?php endif;?> |
| 55 |
<div class="wdk-col"> |
| 56 |
<table> |
| 57 |
<?php |
| 58 |
$next_month_time = strtotime("+$month_i month", strtotime(date("F") . "1")); |
| 59 |
|
| 60 |
// Get the value of day, month, year |
| 61 |
$days = array( |
| 62 |
0 => esc_html__('Sun','wpdirectorykit'), |
| 63 |
1 => esc_html__('Mon','wpdirectorykit'), |
| 64 |
2 => esc_html__('Tue','wpdirectorykit'), |
| 65 |
3 => esc_html__('Wed','wpdirectorykit'), |
| 66 |
4 => esc_html__('Thu','wpdirectorykit'), |
| 67 |
5 => esc_html__('Fri','wpdirectorykit'), |
| 68 |
6 => esc_html__('Sat','wpdirectorykit'), |
| 69 |
); |
| 70 |
|
| 71 |
list($mon, $month_m, $month, $year, $num_days) = explode('-', date("n-m-F-Y-t", $next_month_time)); |
| 72 |
|
| 73 |
$first_day_of_week = array_search(esc_html__(date('D', strtotime($year . '-' . $month . '-1')), 'wpdirectorykit'), $days); |
| 74 |
if(!$first_day_of_week) |
| 75 |
$first_day_of_week = 1; |
| 76 |
|
| 77 |
$num_days_last_month = date('j', strtotime('last day of previous month', strtotime($current_day. '-' . $month . '-' . $year))); |
| 78 |
$startDay = $first_day_of_week; |
| 79 |
?> |
| 80 |
<caption><?php echo esc_html__($month,'wpdirectorykit');?> <?php echo esc_html($year);?></caption> |
| 81 |
<thead> |
| 82 |
<tr> |
| 83 |
<?php foreach ($days as $key => $day) :?> |
| 84 |
<th><?php echo esc_html(substr($day,0,3));?></th> |
| 85 |
<?php endforeach;?> |
| 86 |
</tr> |
| 87 |
</thead> |
| 88 |
<tbody> |
| 89 |
<tr> |
| 90 |
<?php for ($i = $first_day_of_week; $i > 0; $i--):?> |
| 91 |
<td class='ignore' data-order="<?php echo esc_attr($wdk_order++);?>"><a><?php echo esc_html(($num_days_last_month-$i+1));?></a></td> |
| 92 |
<?php endfor;?> |
| 93 |
|
| 94 |
<?php for ($d=1;$d<=$num_days;$d++):?> |
| 95 |
<?php |
| 96 |
$date_day = ''; |
| 97 |
$class_td = ''; |
| 98 |
if($d<10) { |
| 99 |
$date_day = "{$year}-{$month_m}-0{$d}"; |
| 100 |
} else { |
| 101 |
$date_day = "{$year}-{$month_m}-{$d}"; |
| 102 |
} |
| 103 |
|
| 104 |
if ($d == $current_day && $month_m == $current_month) { |
| 105 |
$class_td = "bg-today"; |
| 106 |
} elseif (isset($available_dates[$date_day])) { |
| 107 |
if(strpos($available_dates[$date_day], 'book_book_current') !== FALSE ) { |
| 108 |
$class_td = "bg-booked"; |
| 109 |
} elseif(strpos($available_dates[$date_day], 'book_current_bookd') !== FALSE ) { |
| 110 |
$class_td = "bg-booked"; |
| 111 |
} elseif(strpos($available_dates[$date_day], 'reservation_start') !== FALSE && strpos($available_dates[$date_day], 'reservation_end') === FALSE) { |
| 112 |
$class_td = "bg-available bg-booked reservation-start"; |
| 113 |
} elseif(strpos($available_dates[$date_day], 'reservation_end') !== FALSE && strpos($available_dates[$date_day], 'reservation_start') === FALSE) { |
| 114 |
$class_td = "bg-available bg-booked reservation-end"; |
| 115 |
} elseif(strpos($available_dates[$date_day], 'booked') !== FALSE) { |
| 116 |
$class_td = "bg-booked"; |
| 117 |
} else { |
| 118 |
$class_td = "bg-available"; |
| 119 |
} |
| 120 |
} else { |
| 121 |
$class_td = "bg-not-selected"; |
| 122 |
} |
| 123 |
$startDay++; |
| 124 |
?> |
| 125 |
<td data-order="<?php echo esc_attr($wdk_order++);?>" class="<?php echo esc_html($class_td);?>"><a title="<?php echo esc_html($date_day);?>"><?php echo esc_html($d);?></a></td> |
| 126 |
|
| 127 |
<?php if($startDay > 6 && $d < $num_days):?> |
| 128 |
<?php $startDay = 0; ?> |
| 129 |
</tr><tr> |
| 130 |
<?php endif;?> |
| 131 |
<?php endfor;?> |
| 132 |
|
| 133 |
<?php for ($i = $startDay,$y=1; $i <= 6 ; $i++,$y++):?> |
| 134 |
<td class='ignore'><a><?php echo esc_html($y);?></a></td> |
| 135 |
<?php endfor;?> |
| 136 |
</tr> |
| 137 |
</tbody> |
| 138 |
</table> |
| 139 |
</div> |
| 140 |
<?php endfor;?> |
| 141 |
</div> |
| 142 |
<div class="wdk-row"> |
| 143 |
<div class="wdk-col wdk-col-full wdk-cal-pag"> |
| 144 |
<a href="#" class="wdk-btn-pag next"> |
| 145 |
<span class="dashicons dashicons-plus-alt2"></span> |
| 146 |
</a> |
| 147 |
<a href="#" class="wdk-btn-pag pre noactive"> |
| 148 |
<span class="dashicons dashicons-minus"></span> |
| 149 |
</a> |
| 150 |
</div> |
| 151 |
</div> |
| 152 |
</div> |
| 153 |
<?php if(!empty($field->hint)):?> |
| 154 |
<p class="wdk-hint"> |
| 155 |
<?php echo esc_html($field->hint); ?> |
| 156 |
</p> |
| 157 |
<?php endif;?> |
| 158 |
</div> |
| 159 |
</div> |