Exemplo n.º 1
0
 /**
  * Prepare data for email.
  *
  * @param AB_CustomerAppointment $ca
  * @return array
  */
 private static function _prepareData(AB_CustomerAppointment $ca)
 {
     $appointment = new AB_Appointment();
     $appointment->load($ca->get('appointment_id'));
     $customer = new AB_Customer();
     $customer->load($ca->get('customer_id'));
     $staff = new AB_Staff();
     $staff->load($appointment->get('staff_id'));
     $service = new AB_Service();
     $service->load($appointment->get('service_id'));
     $staff_service = new AB_StaffService();
     $staff_service->loadBy(array('staff_id' => $staff->get('id'), 'service_id' => $service->get('id')));
     $price = $staff_service->get('price');
     if ($ca->get('coupon_discount') or $ca->get('coupon_deduction')) {
         $coupon = new AB_Coupon();
         $coupon->set('discount', $ca->get('coupon_discount'));
         $coupon->set('deduction', $ca->get('coupon_deduction'));
         $price = $coupon->apply($price);
     }
     $codes = new AB_NotificationCodes();
     $codes->set('appointment_datetime', $appointment->get('start_date'));
     $codes->set('appointment_token', $ca->get('token'));
     $codes->set('category_name', $service->getCategoryName());
     $codes->set('client_name', $customer->get('name'));
     $codes->set('client_phone', $customer->get('phone'));
     $codes->set('client_email', $customer->get('email'));
     $codes->set('custom_fields', $ca->getFormattedCustomFields('text'));
     $codes->set('custom_fields_2c', $ca->getFormattedCustomFields('html'));
     $codes->set('number_of_persons', $ca->get('number_of_persons'));
     $codes->set('service_name', $service->getTitle());
     $codes->set('service_price', $price);
     $codes->set('staff_name', $staff->get('full_name'));
     $codes->set('staff_email', $staff->get('email'));
     $codes->set('staff_phone', $staff->get('phone'));
     $codes->set('staff_photo', $staff->get('avatar_url'));
     return array($codes, $staff, $appointment, $customer);
 }
Exemplo n.º 2
0
 /**
  * Delete a customer.
  */
 public function executeDeleteCustomer()
 {
     $customer = new AB_Customer();
     $customer->load($this->getParameter('id'));
     $customer->deleteWithWPUser((bool) $this->getParameter('with_wp_user'));
 }
 /**
  * Get appointment data
  *
  * @param stdClass     $appointment
  * @param null         $user_id
  * @param bool         $day_view
  *
  * @return array
  */
 private function getAppointment(stdClass $appointment, $user_id = null, $day_view = false)
 {
     $startDate = new DateTime($appointment->start_date);
     $endDate = new DateTime($appointment->end_date);
     $desc = array();
     if ($appointment->max_capacity == 1) {
         $customer = new AB_Customer();
         $customer->load($appointment->customer_id);
         foreach (array('name', 'phone', 'email') as $data_entry) {
             $entry_value = $customer->get($data_entry);
             if ($entry_value) {
                 $desc[] = '<div class="wc-employee">' . esc_html($entry_value) . '</div>';
             }
         }
         if ($appointment->notes) {
             $desc[] = '<div class="wc-notes">' . nl2br(esc_html($appointment->notes)) . '</div>';
         }
     } else {
         $desc[] = '<div class="wc-notes">Signed up ' . $appointment->current_capacity . '</div>';
         $desc[] = '<div class="wc-notes">Capacity ' . $appointment->max_capacity . '</div>';
     }
     $appointment_data = array('id' => $appointment->id, 'start' => $startDate->format('m/d/Y H:i'), 'end' => $endDate->format('m/d/Y H:i'), 'title' => $appointment->title ? esc_html($appointment->title) : __('Untitled', 'ab'), 'desc' => implode('', $desc), 'color' => $appointment->color, 'notes' => $appointment->max_capacity == 1 && $appointment->notes ? $appointment->notes : null);
     // if needed to be rendered for a specific user
     // pass the the user id
     if (null !== $user_id) {
         $appointment_data['userId'] = $user_id;
     }
     return $appointment_data;
 }