コード例 #1
0
 public function executeRenderService()
 {
     $form_id = $this->getParameter('form_id');
     if ($form_id) {
         $configuration = new AB_BookingConfiguration();
         if (get_option('ab_settings_use_client_time_zone') && $this->getParameter('client_time_zone_offset')) {
             $configuration->setClientTimeZoneOffset($this->getParameter('client_time_zone_offset') / 60);
         }
         $this->work_day_time_data = $configuration->fetchAvailableWorkDaysAndTime();
         $this->userData = new AB_UserBookingData($form_id);
         $this->userData->load();
         $this->_prepareProgressTracker(1, $this->userData->getServicePrice());
         $this->info_text = nl2br(esc_html(get_option('ab_appearance_text_info_first_step')));
         echo json_encode(array('html' => $this->render('service', array(), false), 'categories' => $configuration->getCategories(), 'staff' => $configuration->getStaff(), 'services' => $configuration->getServices(), 'attributes' => $this->userData->hasData() ? array('sid' => $this->userData->getServiceId(), 'eid' => $this->userData->getStaffId()) : null));
     }
     exit;
 }
コード例 #2
0
 /**
  * 1. Render first step.
  *
  * @return string JSON
  */
 public function executeRenderService()
 {
     $response = null;
     $form_id = $this->getParameter('form_id');
     if ($form_id) {
         $configuration = new AB_BookingConfiguration();
         $userData = new AB_UserBookingData($form_id);
         $userData->load();
         if (get_option('ab_settings_use_client_time_zone')) {
             $time_zone_offset = $this->getParameter('time_zone_offset');
             $configuration->setClientTimeZoneOffset($time_zone_offset / 60);
             $userData->saveData(array('time_zone_offset' => $time_zone_offset, 'date_from' => date('Y-m-d', current_time('timestamp') + AB_BookingConfiguration::getMinimumTimePriorBooking() - (get_option('gmt_offset') * HOUR_IN_SECONDS + $time_zone_offset * 60))));
         }
         $this->work_day_time_data = $configuration->fetchAvailableWorkDaysAndTime();
         $this->_prepareProgressTracker(1, $userData->getServicePrice());
         $this->info_text = $this->_prepareInfoText(get_option('ab_appearance_text_info_first_step'), $userData);
         // Prepare week days that need to be checked.
         $days_checked = $userData->get('days');
         if (empty($days_checked)) {
             // Check all available days.
             $days_checked = array_keys($this->work_day_time_data['available_days']);
         }
         $response = array('status' => 'success', 'html' => $this->render('1_service', array('userData' => $userData, 'days_checked' => $days_checked), false), 'categories' => $configuration->getCategories(), 'staff' => $configuration->getStaff(), 'services' => $configuration->getServices(), 'attributes' => $userData->get('service_id') ? array('service_id' => $userData->get('service_id'), 'staff_member_id' => $userData->getStaffId(), 'number_of_persons' => $userData->get('number_of_persons')) : null);
     } else {
         $response = array('status' => 'error', 'error' => __('Form ID error.', 'bookly'));
     }
     // Output JSON response.
     wp_send_json($response);
 }