date-picker.blade.php
82 lines
| 1 | <div id="iawp-date-picker" class="iawp-date-picker" data-relative-range="<?php echo esc_attr($relative_range); ?>"> |
| 2 | <div class="iawp-date-inputs"> |
| 3 | <div class="iawp-input-container prev-month"> |
| 4 | <button class="iawp-fast-travel prev-month" |
| 5 | data-month="<?php echo esc_attr($start_date->format('Y-m')); ?>" |
| 6 | tabindex="-1"> |
| 7 | <span class="dashicons dashicons-calendar-alt" aria-hidden="true"></span> |
| 8 | </button> |
| 9 | <input id="iawp-start-date-keyboard" class="iawp-start-date-keyboard keyboard-input" type="date" |
| 10 | value="<?php echo esc_attr(iawp()->date_i18n('Y-m-d', $start_date)); ?>" |
| 11 | aria-label="<?php esc_html_e('Start date', 'independent-analytics'); ?>" /> |
| 12 | <input id="iawp-start-date" class="iawp-start-date iawp-active" type="text" |
| 13 | readonly value="<?php echo esc_attr(iawp()->date_i18n($user_format, $start_date)); ?>" |
| 14 | data-date="<?php echo esc_attr($start_date->format('Y-m-d')); ?>" |
| 15 | data-month="<?php echo esc_attr($start_date->format('Y-m')); ?>" |
| 16 | tabindex="-1" /> |
| 17 | </div> |
| 18 | <span class="iawp-date-input-separator">-</span> |
| 19 | <div class="iawp-input-container current-month"> |
| 20 | <input id="iawp-end-date-keyboard" class="iawp-end-date-keyboard keyboard-input" type="date" |
| 21 | value="<?php echo esc_attr(iawp()->date_i18n('Y-m-d', $end_date)); ?>" |
| 22 | aria-label="<?php esc_html_e('End date', 'independent-analytics'); ?>" /> |
| 23 | <input id="iawp-end-date" class="iawp-end-date" type="text" |
| 24 | readonly value="<?php echo esc_attr(iawp()->date_i18n($user_format, $end_date)); ?>" |
| 25 | data-date="<?php echo esc_attr($end_date->format('Y-m-d')); ?>" |
| 26 | data-month="<?php echo esc_attr($end_date->format('Y-m')); ?>" |
| 27 | tabindex="-1" /> |
| 28 | <button class="iawp-fast-travel current-month" |
| 29 | data-month="<?php echo esc_attr($end_date->format('Y-m')); ?>" |
| 30 | tabindex="-1"> |
| 31 | <span class="dashicons dashicons-calendar-alt" aria-hidden="true"></span> |
| 32 | </button> |
| 33 | </div> |
| 34 | <div class="apply-buttons"> |
| 35 | <button id="apply-date" |
| 36 | class="iawp-button purple" |
| 37 | data-testid="apply-dates" |
| 38 | > |
| 39 | <?php esc_html_e('Apply', 'independent-analytics'); ?> |
| 40 | </button> |
| 41 | <button id="cancel-date" |
| 42 | class="iawp-button ghost-purple" |
| 43 | data-testid="close-calendar" |
| 44 | > |
| 45 | <?php esc_html_e('Cancel', 'independent-analytics'); ?> |
| 46 | </button> |
| 47 | </div> |
| 48 | </div> |
| 49 | <div id="iawp-calendars" class="iawp-calendars"><?php |
| 50 | foreach($months as $month) { |
| 51 | echo iawp_render('date-picker.calendar-month', [ |
| 52 | 'month' => $month, |
| 53 | 'start_date' => $start_date->format('Y-m-d'), |
| 54 | 'end_date' => $end_date->format('Y-m-d'), |
| 55 | 'user_format' => $user_format, |
| 56 | 'first_data' => $first_data, |
| 57 | ]); |
| 58 | } ?> |
| 59 | </div> |
| 60 | <div class="relative-dates iawp-date-range-buttons"><?php |
| 61 | foreach ($date_ranges as $date_range): |
| 62 | $exact_start = $date_range->start()->setTimezone($timezone)->format('Y-m-d'); |
| 63 | $exact_end = $date_range->end()->setTimezone($timezone)->format('Y-m-d'); |
| 64 | $classes = $relative_range == $date_range->relative_range_id() ? 'iawp-button active' : 'iawp-button'; ?> |
| 65 | <button class="<?php echo esc_attr($classes); ?>" |
| 66 | data-dates-target="relativeRange" |
| 67 | data-action="dates#relativeRangeSelected" |
| 68 | data-relative-range-id="<?php echo esc_attr($date_range->relative_range_id()) ?>" |
| 69 | data-relative-range-label="<?php echo esc_attr($date_range->label()) ?>" |
| 70 | data-relative-range-start="<?php echo esc_attr($exact_start) ?>" |
| 71 | data-relative-range-end="<?php echo esc_attr($exact_end) ?>" |
| 72 | data-display-date-start="<?php echo (new \DateTime($exact_start, new \DateTimeZone('utc')))->format($user_format); ?>" |
| 73 | data-display-date-end="<?php echo (new \DateTime($exact_end, new \DateTimeZone('utc')))->format($user_format); ?>" |
| 74 | data-timestamp-start="<?php echo strtotime($exact_start); ?>" |
| 75 | data-timestamp-end="<?php echo strtotime($exact_end); ?>" |
| 76 | > |
| 77 | <?php echo esc_html($date_range->label()) ?> |
| 78 | </button> |
| 79 | <?php endforeach; ?> |
| 80 | </div> |
| 81 | </div> |
| 82 |