コード例 #1
0
    function booking_admin_ajax()
    {
        if (isset($_REQUEST['option']) and $_REQUEST['option'] == 'RemoveSchdData') {
            global $wpdb;
            $schd_id = $_REQUEST['schd_id'];
            $where = array('schd_id' => $schd_id);
            $wpdb->delete($wpdb->prefix . 'booking_location_schedule', $where);
            exit;
        }
        if (isset($_REQUEST['option']) and $_REQUEST['option'] == 'AddNewSchedule') {
            $gc = new booking_general_class();
            echo '
			<div class="sc_list">
			<input type="hidden" name="schd_ids[]" value="">
			<label for="sc_user">' . __('User', 'wpb') . '</label>
			<select name="sc_users[]">
			' . $gc->sc_user_selected() . '
			</select>	
			  
			<label for="open_days">' . __('Day', 'wpb') . '</label>
			<select name="open_days[]">
			' . $gc->booking_day_selected() . '
			</select>		  
			
			<label for="time_fr">' . __('From', 'wpb') . '</label>
			<select name="open_time_fr[]">
			' . $gc->booking_time_selected() . '
			</select>
			
			<label for="time_to">' . __('To', 'wpb') . '</label>
			<select name="open_time_to[]">
			' . $gc->booking_time_selected() . '
			</select>
			
			<label for="status">' . __('Status', 'wpb') . '</label>
			<select name="sc_status[]">
			' . $gc->sc_status_selected() . '
			</select>
			
			<a href="javascript:void(0);" class="remove_sc_list">Delete</a>
			</div>';
            exit;
        }
        if (isset($_REQUEST['option']) and $_REQUEST['option'] == 'LoadSchedules') {
            global $wpdb;
            $gc = new booking_general_class();
            $ret = '';
            $loc_id = $_REQUEST['loc_id'];
            $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 .= '<input type="radio" name="schd_id" value="' . $value->schd_id . '"><label for="' . $value->schd_id . '">' . $value->user_id . ' ' . $value->schd_day . ' From ' . $value->schd_time_fr . ' To ' . $value->schd_time_to . '</label>';
                    $ret .= '<br>';
                }
            }
            echo $ret;
            exit;
        }
        if (isset($_REQUEST['action']) and $_REQUEST['action'] == 'booking_log_edit') {
            global $wpdb;
            $blc = new booking_log_class();
            $mc = new booking_message_class();
            $gc = new booking_general_class();
            $update = array('order_status' => $_REQUEST['order_status']);
            $where = array('book_id' => $_REQUEST['book_id']);
            $wpdb->update($wpdb->prefix . $blc->table, $update, $where);
            // send order update mail to user
            $gc->sendOrderEmail($_REQUEST['book_id']);
            // send order update mail to user
            $mc->add_message(__('Booking order successfully updated.', 'wpb'), 'success');
            wp_redirect($blc->plugin_page . "&action=edit&id=" . $_REQUEST['book_id']);
            exit;
        }
        if (isset($_POST['option']) and $_POST['option'] == "wp_booking_save_settings") {
            global $booking_payment_methods;
            update_option('booking_admin_email', sanitize_text_field($_POST['booking_admin_email']));
            update_option('booking_admin_email_from_name', sanitize_text_field($_POST['booking_admin_email_from_name']));
            update_option('booking_form_page', sanitize_text_field($_POST['booking_form_page']));
            update_option('bool_open_till', sanitize_text_field($_POST['bool_open_till']));
        }
    }
コード例 #2
0
    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;
    }