예제 #1
0
 /**
  * Flesh out the details of a booking.
  *
  * @return tempcode	The result of execution.
  */
 function flesh_out()
 {
     $title = get_page_title('CREATE_BOOKING');
     // Check booking: redirect to last step as re-entrant if not valid
     $request = get_booking_request_from_form();
     $test = check_booking_dates_available($request, array());
     if (!is_null($test)) {
         attach_message($test, 'warn');
         return $this->choose_bookables_and_dates();
     }
     $bookables = array();
     $found = false;
     $bookable_rows = $GLOBALS['SITE_DB']->query_select('bookable', array('*'), NULL, 'ORDER BY sort_order');
     foreach ($bookable_rows as $bookable_row) {
         if (post_param_integer('bookable_' . strval($bookable_row['id']) . '_quantity', 0) > 0) {
             $found = true;
             $supplements = array();
             $supplement_rows = $GLOBALS['SITE_DB']->query_select('bookable_supplement a JOIN ' . get_table_prefix() . 'bookable_supplement_for b ON a.id=b.supplement_id', array('a.*'), array('bookable_id' => $bookable_row['id']), 'ORDER BY sort_order');
             foreach ($supplement_rows as $supplement_row) {
                 $supplements[] = array('SUPPLEMENT_ID' => strval($supplement_row['id']), 'SUPPLEMENT_TITLE' => get_translated_tempcode($supplement_row['title']), 'SUPPLEMENT_SUPPORTS_QUANTITY' => $supplement_row['supports_quantities'] == 1, 'SUPPLEMENT_QUANTITY' => strval(post_param_integer('bookable_' . strval($bookable_row['id']) . '_supplement_' . strval($supplement_row['id']) . '_quantity', 0)), 'SUPPLEMENT_SUPPORTS_NOTES' => $supplement_row['supports_notes'] == 1, 'SUPPLEMENT_NOTES' => post_param('bookable_' . strval($bookable_row['id']) . '_supplement_' . strval($supplement_row['id']) . '_notes', ''));
             }
             $bookables[] = array('BOOKABLE_ID' => strval($bookable_row['id']), 'BOOKABLE_TITLE' => get_translated_tempcode($bookable_row['title']), 'BOOKABLE_SUPPORTS_NOTES' => $bookable_row['supports_notes'] == 1, 'BOOKABLE_NOTES' => post_param('bookable_' . strval($bookable_row['id']) . '_notes', ''), 'BOOKABLE_SUPPLEMENTS' => $supplements, 'BOOKABLE_QUANTITY' => strval(post_param_integer('bookable_' . strval($bookable_row['id']) . '_quantity')));
         }
     }
     if (!$found) {
         warn_exit(do_lang_tempcode('BOOK_QUANTITY_NOTHING_CHOSEN'));
     }
     require_javascript('javascript_ajax');
     require_javascript('javascript_validation');
     return do_template('BOOKING_FLESH_OUT_SCREEN', array('TITLE' => $title, 'BOOKABLES' => $bookables, 'PRICE' => float_format(find_booking_price($request)), 'POST_URL' => build_url(array('page' => '_SELF', 'type' => 'account', 'usergroup' => get_param_integer('usergroup', NULL)), '_SELF'), 'BACK_URL' => build_url(array('page' => '_SELF', 'type' => 'misc', 'usergroup' => get_param_integer('usergroup', NULL)), '_SELF'), 'HIDDEN' => build_keep_post_fields()));
 }
예제 #2
0
/**
 * Take details posted about a booking, and save to the database.
 *
 * @param  array		Booking details structure.
 * @param  array		Existing bookings to ignore (presumably the booking we're trying to make - if this is an edit).
 * @param  ?MEMBER	The member ID we are saving as (NULL: current user).
 * @return ?array		Booking details structure (NULL: error -- reshow form).
 */
function save_booking_form_to_db($request, $ignore_bookings, $member_id = NULL)
{
    if (is_null($member_id)) {
        $member_id = get_member();
    }
    if (is_guest($member_id)) {
        fatal_exit(do_lang_tempcode('INTERNAL_ERROR'));
    }
    $test = check_booking_dates_available($request, $ignore_bookings);
    if (!is_null($test)) {
        attach_message($test, 'warn');
        return NULL;
    }
    $request = add_booking($request, $member_id);
    return $request;
}
예제 #3
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($_id)
 {
     list($member_id, $i) = array_map('intval', explode('_', $_id, 2));
     $old_request = get_member_booking_request($member_id);
     $ignore_bookings = array();
     foreach ($old_request[$i]['_rows'] as $row) {
         $ignore_bookings[] = $row['id'];
     }
     $request = get_booking_request_from_form();
     $test = check_booking_dates_available($request, $ignore_bookings);
     if (!is_null($test)) {
         warn_exit($test);
     }
     // Delete then re-add
     $this->delete_actualisation($_id);
     $this->new_id = $this->add_actualisation();
 }