public function executeRenderNextTime() { $response = null; $userData = new AB_UserBookingData($this->getParameter('form_id')); if ($userData->load()) { $availableTime = new AB_AvailableTime($userData); $availableTime->setLastFetchedDay($this->getParameter('start_date')); $availableTime->load(); if (count($availableTime->getTime())) { // check, if there are available time $html = ''; foreach ($availableTime->getTime() as $client_timestamp => $slot) { if ($slot['is_day']) { $button = sprintf('<button class="ab-available-day" value="%s">%s</button>', esc_attr(date($availableTime->isWholeDayService() ? 'Y-m' : 'Y-m-d', -$client_timestamp)), date_i18n($availableTime->isWholeDayService() ? 'M' : 'D, M d', -$client_timestamp)); } else { $button = sprintf('<button %s data-date="%s" data-staff_id="%s" class="ab-available-hour ladda-button %s" value="%s" data-style="zoom-in" data-spinner-color="#333"><span class="ladda-label"><i class="ab-hour-icon"><span></span></i>%s</span></button>', disabled($slot['booked'], true, false), esc_attr(date($availableTime->isWholeDayService() ? 'Y-m' : 'Y-m-d', $client_timestamp)), $slot['staff_id'], $slot['booked'] ? 'booked' : '', esc_attr(date($availableTime->isWholeDayService() ? 'Y-m' : 'Y-m-d H:i:s', $slot['timestamp'])), date_i18n(!$availableTime->isWholeDayService() ? get_option('time_format') : 'D, M d', $client_timestamp)); } $html .= $button; } // Set response. $response = array('success' => true, 'html' => $html, 'has_slots' => true, 'has_more_slots' => $availableTime->hasMoreSlots()); } else { $response = array('success' => true, 'has_slots' => false); } } else { $response = array('success' => false, 'error' => __('Session error.', 'bookly')); } // Output JSON response. wp_send_json($response); }