PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / application / views / fields_edit / CALENDAR_DATES_VIEW.php

CALENDAR_DATES_VIEW.php in WP Directory Kit 1.5.9, at application/views/fields_edit/CALENDAR_DATES_VIEW.php

164 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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-<?php echo esc_attr($field_id);?> 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', 'wpdirectorykit');?></div>
43 <div class="wdk-row">
44 <?php
45 $available_dates = [];
46 $current_day = gmdate("j");
47 $current_month = gmdate("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(gmdate("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('-', gmdate("n-m-F-Y-t", $next_month_time));
72
73 // Dynamic field values are registered in the translation catalog separately.
74 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
75 $first_day_of_week = array_search(esc_html__(gmdate('D', strtotime($year . '-' . $month . '-1')), 'wpdirectorykit'), $days);
76 if(!$first_day_of_week && $first_day_of_week != 0)
77 $first_day_of_week = 1;
78
79 $num_days_last_month = gmdate('j', strtotime('last day of previous month', strtotime($current_day. '-' . $month . '-' . $year)));
80 $startDay = $first_day_of_week;
81 ?>
82 <caption><?php
83 // Dynamic field values are registered in the translation catalog separately.
84 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
85 echo esc_html__($month,'wpdirectorykit');?> <?php echo esc_html($year);?></caption>
86 <thead>
87 <tr>
88 <?php foreach ($days as $key => $day) :?>
89 <th><?php echo esc_html(substr($day,0,3));?></th>
90 <?php endforeach;?>
91 </tr>
92 </thead>
93 <tbody>
94 <tr>
95 <?php for ($i = $first_day_of_week; $i > 0; $i--):?>
96 <td class='ignore' data-order="<?php echo esc_attr($wdk_order++);?>"><a><?php echo esc_html(($num_days_last_month-$i+1));?></a></td>
97 <?php endfor;?>
98
99 <?php for ($d=1;$d<=$num_days;$d++):?>
100 <?php
101 $date_day = '';
102 $class_td = '';
103 if($d<10) {
104 $date_day = "{$year}-{$month_m}-0{$d}";
105 } else {
106 $date_day = "{$year}-{$month_m}-{$d}";
107 }
108
109 if ($d == $current_day && $month_m == $current_month) {
110 $class_td = "bg-today";
111 } elseif (isset($available_dates[$date_day])) {
112 if(strpos($available_dates[$date_day], 'book_book_current') !== FALSE ) {
113 $class_td = "bg-booked";
114 } elseif(strpos($available_dates[$date_day], 'book_current_bookd') !== FALSE ) {
115 $class_td = "bg-booked";
116 } elseif(strpos($available_dates[$date_day], 'reservation_start') !== FALSE && strpos($available_dates[$date_day], 'reservation_end') === FALSE) {
117 $class_td = "bg-available bg-booked reservation-start";
118 } elseif(strpos($available_dates[$date_day], 'reservation_end') !== FALSE && strpos($available_dates[$date_day], 'reservation_start') === FALSE) {
119 $class_td = "bg-available bg-booked reservation-end";
120 } elseif(strpos($available_dates[$date_day], 'booked') !== FALSE) {
121 $class_td = "bg-booked";
122 } else {
123 $class_td = "bg-available";
124 }
125 } else {
126 $class_td = "bg-not-selected";
127 }
128 $startDay++;
129 ?>
130 <td data-order="<?php echo esc_attr($wdk_order++);?>" class="<?php echo esc_attr($class_td);?>"><a title="<?php echo esc_attr($date_day);?>"><?php echo esc_html($d);?></a></td>
131
132 <?php if($startDay > 6 && $d < $num_days):?>
133 <?php $startDay = 0; ?>
134 </tr><tr>
135 <?php endif;?>
136 <?php endfor;?>
137
138 <?php for ($i = $startDay,$y=1; $i <= 6 ; $i++,$y++):?>
139 <td class='ignore'><a><?php echo esc_html($y);?></a></td>
140 <?php endfor;?>
141 </tr>
142 </tbody>
143 </table>
144 </div>
145 <?php endfor;?>
146 </div>
147 <div class="wdk-row">
148 <div class="wdk-col wdk-col-full wdk-cal-pag">
149 <a href="#" class="wdk-btn-pag next">
150 <span class="dashicons dashicons-plus-alt2"></span>
151 </a>
152 <a href="#" class="wdk-btn-pag pre noactive">
153 <span class="dashicons dashicons-minus"></span>
154 </a>
155 </div>
156 </div>
157 </div>
158 <?php if(!empty($field->hint)):?>
159 <p class="wdk-hint">
160 <?php echo esc_html($field->hint); ?>
161 </p>
162 <?php endif;?>
163 </div>
164 </div>