function get_schedule_data($loc_id = '') { global $wpdb; $gc = new booking_general_class(); $ret = ''; if ($loc_id == '') { return; } $schds = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "booking_location_schedule WHERE loc_id='" . $loc_id . "' ORDER BY schd_id"); if (is_array($schds)) { foreach ($schds as $key => $value) { $ret .= ' <div class="sc_list"> <input type="hidden" name="schd_ids[]" value="' . $value->schd_id . '"> <label for="sc_user">' . __('User', 'wpb') . '</label> <select name="sc_users[]"> ' . $gc->sc_user_selected($value->user_id) . ' </select> <label for="open_days">' . __('Day', 'wpb') . '</label> <select name="open_days[]"> ' . $gc->booking_day_selected($value->schd_day) . ' </select> <label for="time_fr">' . __('From', 'wpb') . '</label> <select name="open_time_fr[]"> ' . $gc->booking_time_selected($value->schd_time_fr) . ' </select> <label for="time_to">' . __('To', 'wpb') . '</label> <select name="open_time_to[]"> ' . $gc->booking_time_selected($value->schd_time_to) . ' </select> <label for="status">' . __('Status', 'wpb') . '</label> <select name="sc_status[]"> ' . $gc->sc_status_selected($value->schd_status) . ' </select> <a href="javascript:void(0);" class="remove_sc_list" data="' . $value->schd_id . '">Delete</a> </div>'; } } return $ret; }
function edit() { $gc = new booking_general_class(); $mc = new booking_message_class(); $id = $_REQUEST['id']; $data = $this->get_single_row_data($id); $mc->show_message(); ?> <form name="f" action="" method="post"> <input type="hidden" name="book_id" value="<?php echo $id; ?> " /> <input type="hidden" name="action" value="booking_log_edit" /> <table width="95%" border="0" cellspacing="10" style="background-color:#FFFFFF; margin:2%; padding:5px; border:1px solid #CCCCCC;"> <tr> <td colspan="2"> <h2><?php _e('Order Details', 'wpb'); ?> <?php _e('#'); ?> <?php echo $id; ?> </h2> <p> <strong><?php _e('Date', 'wpb'); ?> </strong> <?php echo $data['order_date']; ?> </p> </td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr> <td valign="top"><strong><?php _e('Location', 'wpb'); ?> </strong></td> <td><?php echo $this->get_loc_data($data['loc_id']); ?> <p><?php echo nl2br(get_post_meta($data['loc_id'], 'booking_address', true)); ?> </p> </td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr> <td valign="top"><strong><?php _e('User Info', 'wpb'); ?> </strong></td> <td> <table width="100%" border="0"> <tbody> <tr> <td><?php _e('User'); ?> </td> <td><?php echo $data['user_id']; ?> </td> </tr> <tr> <td><?php _e('Name'); ?> </td> <td><?php echo $data['c_name']; ?> </td> </tr> <tr> <td><?php _e('Email'); ?> </td> <td><?php echo $data['c_email']; ?> </td> </tr> <tr> <td><?php _e('Phone'); ?> </td> <td><?php echo $data['c_phone']; ?> </td> </tr> </tbody> </table> </td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr> <td valign="top"><strong><?php _e('Schedule Details', 'wpb'); ?> </strong></td> <td><?php echo $this->get_schd_data($data['schd_id'], $data['schd_date']); ?> </td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr> <td><strong><?php _e('Order Total', 'wpb'); ?> </strong></td> <td><?php echo BOOKING_CURRENCY; ?> <?php echo $data['order_price']; ?> </td> </tr> <tr> <td><strong><?php _e('Status', 'wpb'); ?> </strong></td> <td><select name="order_status"> <?php echo $gc->order_status_selected($data['order_status']); ?> </select></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="<?php _e('Submit', 'wpb'); ?> " class="button" /></td> </tr> </table> </form> <?php }
function booking_front_user_data() { if (isset($_REQUEST['option']) and $_REQUEST['option'] == 'getSchdInfo') { global $wpdb; $gc = new booking_general_class(); $ret = '<table width="100%" border="0">'; $date = $_REQUEST['date']; $loc_id = $_REQUEST['loc_id']; $day = strtolower(date('l', strtotime($date))); $schds = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "booking_location_schedule WHERE loc_id='" . $loc_id . "' AND schd_day = '" . $day . "' AND schd_status = 'Active' ORDER BY schd_id"); if (is_array($schds)) { foreach ($schds as $key => $value) { $user_info = get_userdata($value->user_id); $ret .= '<tr> <td><strong>' . $user_info->display_name . '</strong>' . ($user_info->description != '' ? '<p>' . nl2br($user_info->description) . '</p>' : '') . '</td> <td>' . ucfirst($value->schd_day) . ' (' . $date . ') ' . __('From', 'wpb') . ' ' . $value->schd_time_fr . ' ' . __('To', 'wpb') . ' ' . $value->schd_time_to . ' ' . __('Hrs', 'wpb') . '</td> <td><a href="' . $gc->get_booking_url(array('schd_id' => $value->schd_id, 'loc_id' => $loc_id, 'date' => $date)) . '">' . __('Book Now', 'wpb') . '</a></td> </tr>'; } } $ret .= '</table>'; echo $ret; exit; } if (isset($_REQUEST['option']) and $_REQUEST['option'] == 'SchdBookingSubmit') { if (!session_id()) { @session_start(); } if ($_REQUEST['loc_id'] == '' or $_REQUEST['schd_id'] == '') { wp_die('Location not selected.'); } global $wpdb, $booking_payment_methods; $gc = new booking_general_class(); $mc = new booking_message_class(); $blc = new booking_log_class(); $log_data['loc_id'] = $_REQUEST['loc_id']; $log_data['schd_id'] = $_REQUEST['schd_id']; $log_data['schd_date'] = $_REQUEST['schd_date']; $log_data['user_id'] = get_current_user_id(); $log_data['c_name'] = $_REQUEST['c_name']; $log_data['c_email'] = $_REQUEST['c_email']; $log_data['c_phone'] = $_REQUEST['c_phone']; $log_data['order_date'] = date("Y-m-d H:i:s"); $log_data['order_price'] = get_option('schd_booking_price'); $log_data['order_status'] = 'Processing'; $wpdb->insert($wpdb->prefix . "booking_log", $log_data); $log_id = $wpdb->insert_id; // put data in session // $_SESSION['b_order']['name'] = $blc->get_loc_data($log_data['loc_id']); $_SESSION['b_order']['price'] = get_option('schd_booking_price'); $_SESSION['b_order']['log_id'] = $log_id; // put data in session // if (get_option('schd_booking_price') == '' || get_option('schd_booking_price') == '0' || get_option('schd_booking_price') == '0.00') { // booking is free // send email to user // $gc->sendOrderEmail($log_id); $mc->add_message(__('Booking successfully registered. Please check your email for details.', 'wpb')); $booking_form_page = get_option('booking_form_page'); wp_redirect(get_permalink($booking_form_page)); exit; } else { wp_die('Payment not allowed!'); } } }
function schd_booking_form_shortcode($atts) { global $post; extract(shortcode_atts(array('title' => ''), $atts)); ob_start(); if ($title) { echo '<h2>' . $title . '</h2>'; } $gc = new booking_general_class(); $gc->schd_booking_form(); $ret = ob_get_contents(); ob_end_clean(); return $ret; }