/** * Adds required JS */ public function add_appointments_js() { $this->compatibility_mode = EALogic::get_option_value('compatibility.mode', 0); if (!empty($this->compatibility_mode)) { wp_enqueue_script('ea-compatibility-mode'); } wp_enqueue_script('ea-appointments'); wp_enqueue_style('ea-admin-css'); wp_enqueue_style('jquery-style'); wp_enqueue_style('time-picker'); wp_enqueue_style('ea-admin-awesome-css'); }
echo EALogic::get_option_value("trans.service"); ?> </label> <div class="col-sm-8"> <select name="service" data-c="service" class="filter form-control" data-currency> <?php $this->get_options("services"); ?> </select> </div> </div> <div class="step form-group"> <div class="block"></div> <label class="ea-label col-sm-4 control-label"> <?php echo EALogic::get_option_value("trans.worker"); ?> </label> <div class="col-sm-8"> <select name="worker" data-c="worker" class="filter form-control"> <?php $this->get_options("staff"); ?> </select> </div> </div> <div class="step calendar" class="filter"> <div class="block"></div> <div class="date"></div> </div> <div class="step" class="filter">
public function ajax_open_times() { $data = $this->parse_input_data(); $logic = new EALogic(); if (!array_key_exists('app_id', $data)) { $data['app_id'] = null; } $block_time = (int) EALogic::get_option_value('block.time', 0); $slots = $logic->get_open_slots($data['location'], $data['service'], $data['worker'], $data['date'], $data['app_id'], true, $block_time); die(json_encode($slots)); }
/** * Sending mail with every status change */ public static function send_status_change_mail($app_id) { global $wpdb; $dbmodels = new EADBModels(); $table_name = 'ea_appointments'; $app = $dbmodels->get_row($table_name, $app_id); $app_array = $dbmodels->get_appintment_by_id($app_id); $params = array(); foreach ($app_array as $key => $value) { $params["#{$key}#"] = $value; } $body_template = EALogic::get_option_value('mail.' . $app->status, 'mail'); $body = str_replace(array_keys($params), array_values($params), $body_template); if (array_key_exists('email', $app_array)) { $headers = array('Content-Type: text/html; charset=UTF-8'); wp_mail($app_array['email'], 'Reservation #' . $app_id, $body, $headers); } }
public function ajax_final_appointment() { $logic = new EALogic(); $table = 'ea_appointments'; $data = $_GET; unset($data['action']); $data['status'] = 'pending'; $appointment = $this->models->get_row('ea_appointments', $data['id'], ARRAY_A); // check IP if ($appointment['ip'] != $_SERVER['REMOTE_ADDR']) { $this->send_err_json_result('{"err":true}'); } $appointment['status'] = 'pending'; $response = $this->models->replace($table, $appointment, true); $meta = $this->models->get_all_rows('ea_meta_fields'); foreach ($meta as $f) { $fields = array(); $fields['app_id'] = $appointment['id']; $fields['field_id'] = $f->id; if (array_key_exists($f->slug, $data)) { $fields['value'] = $data[$f->slug]; } else { $fields['value'] = ''; } $response = $response && $this->models->replace('ea_fields', $fields, true); } if ($response == false) { $this->send_err_json_result('{"err":true}'); } else { EALogic::send_notification($data); $send_user_mail = $logic->get_option_value('send.user.email', false); if (!empty($send_user_mail)) { EALogic::send_status_change_mail($data['id']); } } $response = new stdClass(); $response->message = 'Ok'; $this->send_ok_json_result($response); }
/** * Standard widget */ public function standard_app($attrs) { $settings = EALogic::get_options(); $settings['scroll_off'] = $this->defaultSettings($attrs, 'scroll_off', false); $settings['trans.please-select-new-date'] = __('Please select another day', 'easy-appointments'); $settings['trans.date-time'] = __('Date & time', 'easy-appointments'); $settings['trans.price'] = __('Price', 'easy-appointments'); $customCss = $settings['custom.css']; $customCss = strip_tags($customCss); $customCss = str_replace(array('<?php', '?>'), array('', ''), $customCss); wp_localize_script('ea-front-end', 'ea_settings', $settings); wp_enqueue_script('underscore'); wp_enqueue_script('ea-validator'); wp_enqueue_script('ea-front-end'); //wp_enqueue_script( 'ea-datepicker-localization' ); if (empty($settings['css.off'])) { wp_enqueue_style('jquery-style'); wp_enqueue_style('ea-frontend-style'); wp_enqueue_style('ea-admin-awesome-css'); } $dbmod = new EADBModels(); $meta = $dbmod->get_all_rows("ea_meta_fields", array(), array('position' => 'ASC')); $custom_form = $this->generate_custom_fields($meta); ob_start(); echo "<style type='text/css'>{$customCss}</style>"; // require tempalte require EA_SRC_DIR . 'templates/booking.overview.tpl.php'; ?> <script type="text/javascript"> var ea_ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?> "; </script> <div class="ea-standard"> <form> <div class="step"> <div class="block"></div> <label class="ea-label"><?php echo EALogic::get_option_value("trans.location"); ?> </label><select name="location" data-c="location" class="filter"><?php $this->get_options("locations"); ?> </select> </div> <div class="step"> <div class="block"></div> <label class="ea-label"><?php echo EALogic::get_option_value("trans.service"); ?> </label><select name="service" data-c="service" class="filter" data-currency="<?php echo EALogic::get_option_value("trans.currency"); ?> "><?php $this->get_options("services"); ?> </select> </div> <div class="step"> <div class="block"></div> <label class="ea-label"><?php echo EALogic::get_option_value("trans.worker"); ?> </label><select name="worker" data-c="worker" class="filter"><?php $this->get_options("staff"); ?> </select> </div> <div class="step calendar" class="filter"> <div class="block"></div> <div class="date"></div> </div> <div class="step" class="filter"> <div class="block"></div> <div class="time"></div> </div> <div class="step final"> <div class="block"></div> <p class="section"><?php _e('Personal information', 'easy-appointments'); ?> </p> <small><?php _e('Fields with * are required', 'easy-appointments'); ?> </small><br> <?php echo $custom_form; ?> <br> <p class="section"><?php _e('Booking overview', 'easy-appointments'); ?> </p> <div id="booking-overview"></div> <?php if (!empty($settings['show.iagree'])) { ?> <p> <label style="font-size: 65%; width: 80%;"><?php _e('I agree with terms and conditions', 'easy-appointments'); ?> * : </label><input style="width: 15%;" type="checkbox" name="iagree" data-rule-required="true" data-msg-required="<?php _e('You must agree with terms and conditions', 'easy-appointments'); ?> "> </p> <br> <?php } ?> <button class="ea-btn ea-submit"><?php _e('Submit', 'easy-appointments'); ?> </button> <button class="ea-btn ea-cancel"><?php _e('Cancel', 'easy-appointments'); ?> </button> </div> </form> <div id="ea-loader"></div> </div> <?php return ob_get_clean(); }
/** * Send email notification for admin */ public static function send_notification($data) { $emails = self::get_option_value('pending.email', ''); if ($emails == '') { return; } $dbmodels = new EADBModels(); $app_id = $data['id']; $data = $dbmodels->get_appintment_by_id($app_id); $meta = $dbmodels->get_all_rows('ea_meta_fields', array(), array('position' => 'ASC')); $params = array(); $time_format = get_option('time_format'); $date_format = get_option('date_format'); foreach ($data as $key => $value) { if ($key == 'start' || $key == 'end') { $value = date($time_format, strtotime("{$data['date']} {$value}")); } if ($key == 'date') { $value = date($date_format, strtotime("{$value} {$data['start']}")); } $params["#{$key}#"] = $value; $data[$key] = $value; } $subject_template = EALogic::get_option_value('pending.subject.email', 'Notification : #id#'); $send_from = EALogic::get_option_value('send.from.email', ''); $subject = str_replace(array_keys($params), array_values($params), $subject_template); ob_start(); require EA_SRC_DIR . 'templates/mail.notification.tpl.php'; $mail_content = ob_get_clean(); $headers = array('Content-Type: text/html; charset=UTF-8'); if (!empty($send_from)) { $headers[] = 'From: ' . $send_from; } wp_mail($emails, $subject, $mail_content, $headers); }