wrap_db_query($query); //save the new preferences to the db for use next time $numBookingOptions = count($_POST['bookingOptions']); for ($o = 0; $o < $numBookingOptions; $o++) { $query = "INSERT INTO " . BOOKING_USER_OPTIONS_TABLE . " SET user_id = " . $bookingByUserID . ", option_id = '" . $_POST['bookingOptions'][$o] . "'"; wrap_db_query($query); } } } // Attempt to Add the Event to the Database $add_event_id = add_event($bookingForUsername, $scheduled_date_time_data, $_REQUEST['subject'], $_REQUEST['location'], $starting_date . ' ' . $_REQUEST['start_time'], $ending_date . ' ' . $_REQUEST['end_time'], $_REQUEST['recur_interval'], $_REQUEST['recur_freq'], $recur_date, $_REQUEST['desc'], $_POST['bookingOptions']); if (!empty($add_event_id)) { $page_info_message = "Event added successfully!"; //if the user uses booking credits update their remaining credits if ($deductCredits && $bookeeUsesCredits) { update_booking_credits($bookingForUsername, $scheduled_slots, 'dec'); //Set the right message depending on if we are making the booking for ourselves or not if ($bookingForUsername == $_SESSION['valid_user']) { //booking for self $page_info_message .= '<br><br>' . $scheduled_slots . ' credits have been deducted for this booking. You have ' . remaining_booking_credits($bookingForUsername) . ' credits remaining.'; } else { //booking for someone else $page_info_message .= '<br><br>NOTE: User ' . $bookingForUsername . ' has had ' . $scheduled_slots . ' credits deducted. ' . remaining_booking_credits($bookingForUsername) . ' credits remaining.'; } } //see if booking cinfirmation e-mails are to get sent out if ($_SESSION['BOOKING_CONF_EMAILS_SEND']) { //create an array of the things we are looking to replace in the body and subject of the e-mail $mailTags = array('%firstname%', '%lastname%', '%sitename%', '%bookingtimes%', '%bookingtimesvertical%', '%period%', '%location%', '%slots%', '%briefdesc%', '%fulldesc%', '%options%'); //figure out the variables that might be reuired in the message $mailVars['firstname'] = $user_info['firstname'];
function delete_event($username, $event_id, $refundCredits = true) { // delete one event (and event schedule) from the database // Use global $location_db_name global $location_db_name; // get user_id based on current $username $user_id = get_user_id($username); if (empty($user_id)) { return false; } // get event data: location id $event = get_event_details($event_id); //echo "location: $event['location'], event_id: $event['event_id'] <br />"; // delete any options set for this event_id $query = 'DELETE FROM ' . BOOKING_EVENT_OPTIONS_TABLE . ' WHERE event_id="' . $event_id . '"'; wrap_db_query($query); // delete the event_id $result = wrap_db_query("DELETE FROM " . BOOKING_EVENT_TABLE . "\n\t\tWHERE location = '" . $event['location'] . "' AND event_id = " . $event_id . " LIMIT 1"); // delete the event schedule, set back to zero $result = wrap_db_query("UPDATE " . DATE_TIME_SCHEDULE_TABLE . "\n\t\tSET " . $location_db_name[$event['location']] . " = 0\n\t\tWHERE " . $location_db_name[$event['location']] . " = " . $event_id); //store the number of slots deleted in case we need to refund credits $creditsToRefund = wrap_affected_rows(); if ($refundCredits) { //if the user uses credits, refund used credits $userDetails = get_user($user_id); if ($userDetails['booking_credits'] == 'Not used') { //nothing to do, the user does not use credits return true; } else { //refund a credit for each booking slot deleted update_booking_credits($username, $creditsToRefund, 'inc'); } } return true; }
//make sure the user is an administrator require_once 'admin_security.php'; $page_title = "Set Booking Credits"; $page_title_bar = "Set Booking Credits"; //echo '<pre>' ; //print_r( $_POST ) ; //echo '</pre>' ; $saved_changes = false; //holder for potential save state //check for form submission if ($_POST['send_form'] != '') { //ensure that both a user and a value were submitted if ($_POST['user_select'] != '' && $_POST['booking_credits'] != '') { $userDetails = get_user($_POST['user_select']); $username = $userDetails['username']; update_booking_credits($username, $_POST['booking_credits'], 'set'); } else { $page_error_message = 'Unable to save changes. Please make your selection again before resubmitting this form.'; } } include_once "header.php"; $admin_account_id = ''; $users_full_name = ''; $users_current_booking_limit = ''; ?> <br> Select the user account you wish to modify, then select a new value and press the 'Save Changes' button. <br> <form name="form1" method="post" action="<?php echo FILENAME_ADMIN_BOOKING_CREDITS;