/**
  * Do replacements.
  *
  * @param $text
  * @param string $type
  *
  * @return string
  */
 public function replace($text, $type = 'email')
 {
     // Company logo as <img> tag.
     $company_logo = '';
     if (get_option('ab_settings_company_logo_url') != '') {
         $company_logo = sprintf('<img src="%s" alt="%s" />', esc_attr(get_option('ab_settings_company_logo_url')), esc_attr(get_option('ab_settings_company_name')));
     }
     // Staff photo as <img> tag.
     $staff_photo = '';
     if ($this->data['staff_photo'] != '') {
         $staff_photo = sprintf('<img src="%s" alt="%s" />', esc_attr($this->get('staff_photo')), esc_attr($this->get('staff_name')));
     }
     // Cancel appointment URL and <a> tag.
     $cancel_appointment_url = admin_url('admin-ajax.php') . '?action=ab_cancel_appointment&token=' . $this->get('appointment_token');
     $cancel_appointment = sprintf('<a href="%1$s">%1$s</a>', $cancel_appointment_url);
     // Codes.
     $codes = array('[[APPOINTMENT_TIME]]' => AB_DateTimeUtils::formatTime($this->get('appointment_datetime')), '[[APPOINTMENT_DATE]]' => AB_DateTimeUtils::formatDate($this->get('appointment_datetime')), '[[CUSTOM_FIELDS]]' => $this->get('custom_fields'), '[[CUSTOM_FIELDS_2C]]' => $this->get('custom_fields_2c'), '[[CLIENT_NAME]]' => $this->get('client_name'), '[[CLIENT_PHONE]]' => $this->get('client_phone'), '[[CLIENT_EMAIL]]' => $this->get('client_email'), '[[SERVICE_NAME]]' => $this->get('service_name'), '[[SERVICE_PRICE]]' => AB_Utils::formatPrice($this->get('service_price')), '[[STAFF_EMAIL]]' => $this->get('staff_email'), '[[STAFF_NAME]]' => $this->get('staff_name'), '[[STAFF_PHONE]]' => $this->get('staff_phone'), '[[STAFF_PHOTO]]' => $staff_photo, '[[CANCEL_APPOINTMENT]]' => $cancel_appointment, '[[CANCEL_APPOINTMENT_URL]]' => $cancel_appointment_url, '[[CATEGORY_NAME]]' => $this->get('category_name'), '[[COMPANY_ADDRESS]]' => $type == 'email' ? nl2br(get_option('ab_settings_company_address')) : get_option('ab_settings_company_address'), '[[COMPANY_LOGO]]' => $company_logo, '[[COMPANY_NAME]]' => get_option('ab_settings_company_name'), '[[COMPANY_PHONE]]' => get_option('ab_settings_company_phone'), '[[COMPANY_WEBSITE]]' => get_option('ab_settings_company_website'), '[[NEXT_DAY_AGENDA]]' => $this->get('next_day_agenda'), '[[TOMORROW_DATE]]' => date_i18n(get_option('date_format'), strtotime($this->get('appointment_datetime'))), '[[TOTAL_PRICE]]' => AB_Utils::formatPrice($this->get('service_price') * $this->get('number_of_persons')), '[[NUMBER_OF_PERSONS]]' => $this->get('number_of_persons'), '[[SITE_ADDRESS]]' => $this->get('site_address'), '[[NEW_USERNAME]]' => $this->get('new_username'), '[[NEW_PASSWORD]]' => $this->get('new_password'));
     return strtr($text, $codes);
 }
 /**
  * Render info text into a variable.
  *
  * @param string $text
  * @param AB_UserBookingData $userData
  * @param int $preset_price
  *
  * @return string
  */
 private function _prepareInfoText($text, $userData, $preset_price = null)
 {
     if (empty($this->replacement)) {
         $service = $userData->getService();
         $category_name = $service->getCategoryName();
         $staff_name = $userData->getStaffName();
         $price = $preset_price === null ? $userData->getServicePrice() : $preset_price;
         $number_of_persons = $userData->get('number_of_persons');
         $service_date = AB_DateTimeUtils::formatDate($userData->get('appointment_datetime'));
         if (get_option('ab_settings_use_client_time_zone')) {
             $service_time = AB_DateTimeUtils::formatTime(AB_DateTimeUtils::applyTimeZoneOffset($userData->get('appointment_datetime'), $userData->get('time_zone_offset')));
         } else {
             $service_time = AB_DateTimeUtils::formatTime($userData->get('appointment_datetime'));
         }
         $this->replacement = array('[[STAFF_NAME]]' => '<b>' . $staff_name . '</b>', '[[SERVICE_NAME]]' => '<b>' . $service->get('title') . '</b>', '[[CATEGORY_NAME]]' => '<b>' . $category_name . '</b>', '[[NUMBER_OF_PERSONS]]' => '<b>' . $number_of_persons . '</b>', '[[SERVICE_TIME]]' => '<b>' . $service_time . '</b>', '[[SERVICE_DATE]]' => '<b>' . $service_date . '</b>', '[[SERVICE_PRICE]]' => '<b>' . AB_Utils::formatPrice($price) . '</b>', '[[TOTAL_PRICE]]' => '<b>' . AB_Utils::formatPrice($price * $number_of_persons) . '</b>', '[[LOGIN_FORM]]' => get_current_user_id() == 0 ? $this->render('_login_form', array(), false) : '');
     }
     return strtr(nl2br($text), $this->replacement);
 }
Example #3
0
 /**
  * Get SMS list.
  *
  * @param null $start_date
  * @param null $end_date
  * @return array|mixed
  */
 public function getSmsList($start_date = null, $end_date = null)
 {
     if ($this->token) {
         $response = $this->sendGetRequest(self::GET_SMS_LIST, array('start_date' => $start_date, 'end_date' => $end_date));
         if ($response) {
             array_walk($response->list, function (&$item) {
                 $date_time = AB_DateTimeUtils::UTCToWPTimeZone($item->datetime);
                 $item->date = AB_DateTimeUtils::formatDate($date_time);
                 $item->time = AB_DateTimeUtils::formatTime($date_time);
                 $item->message = nl2br($item->message);
                 $item->phone = '+' . $item->phone;
                 $item->charge = rtrim($item->charge, '0');
                 switch ($item->status) {
                     case 1:
                     case 10:
                         $item->status = __('Queued', 'bookly');
                         $item->charge = '$' . $item->charge;
                         break;
                     case 2:
                     case 16:
                         $item->status = __('Error', 'bookly');
                         $item->charge = '';
                         break;
                     case 3:
                         $item->status = __('Out of credit', 'bookly');
                         $item->charge = '';
                         break;
                     case 4:
                         $item->status = __('Country out of service', 'bookly');
                         $item->charge = '';
                         break;
                     case 11:
                         $item->status = __('Sending', 'bookly');
                         $item->charge = '$' . $item->charge;
                         break;
                     case 12:
                         $item->status = __('Sent', 'bookly');
                         $item->charge = '$' . $item->charge;
                         break;
                     case 13:
                         $item->status = __('Delivered', 'bookly');
                         $item->charge = '$' . $item->charge;
                         break;
                     case 14:
                         $item->status = __('Failed', 'bookly');
                         $item->charge = '$' . $item->charge;
                         break;
                     case 15:
                         $item->status = __('Undelivered', 'bookly');
                         $item->charge = '$' . $item->charge;
                         break;
                     default:
                         $item->status = __('Error', 'bookly');
                         $item->charge = '';
                 }
             });
             return $response;
         }
     }
     return array();
 }
 /**
  * Get item data for cart.
  *
  * @param $other_data
  * @param $cart_item
  *
  * @return array
  */
 function getItemData($other_data, $cart_item)
 {
     if (isset($cart_item['bookly'])) {
         $info_name = get_option('ab_woocommerce_cart_info_name');
         $info_value = get_option('ab_woocommerce_cart_info_value');
         $staff = new AB_Staff();
         $staff->load($cart_item['bookly']['staff_ids'][0]);
         $service = new AB_Service();
         $service->load($cart_item['bookly']['service_id']);
         $info_value = strtr($info_value, array('[[APPOINTMENT_TIME]]' => AB_DateTimeUtils::formatTime($cart_item['bookly']['appointment_datetime']), '[[APPOINTMENT_DATE]]' => AB_DateTimeUtils::formatDate($cart_item['bookly']['appointment_datetime']), '[[CATEGORY_NAME]]' => $service->getCategoryName(), '[[SERVICE_NAME]]' => $service->getTitle(), '[[SERVICE_PRICE]]' => $service->get('price'), '[[STAFF_NAME]]' => $staff->get('full_name')));
         $other_data[] = array('name' => $info_name, 'value' => $info_value);
     }
     return $other_data;
 }
Example #5
0
            }
            ?>

                    <?php 
            foreach ($appointments as $a) {
                ?>
                    <tr>
                        <?php 
                foreach ($columns as $column) {
                    ?>
                            <?php 
                    switch ($column) {
                        case 'date':
                            ?>
<td class="ab-column-date"><?php 
                            echo AB_DateTimeUtils::formatDate($a['start_date']);
                            ?>
</td><?php 
                            break;
                        case 'time':
                            ?>
<td class="ab-column-time"><?php 
                            echo AB_DateTimeUtils::formatTime($a['start_date']);
                            ?>
</td><?php 
                            break;
                        case 'price':
                            ?>
<td class="ab-column-price"><?php 
                            echo AB_Utils::formatPrice($a['price']);
                            ?>