From 490863ad6065182f6e4d51e2d708f7ee9158bf99 Mon Sep 17 00:00:00 2001 From: Martin Cording Date: Fri, 13 Mar 2015 15:46:53 +0100 Subject: [PATCH] DDBEASY-54 - Disable/enable quick-reservation. --- ding_reservation.module | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ding_reservation.module b/ding_reservation.module index 142920c..2794b3d 100644 --- a/ding_reservation.module +++ b/ding_reservation.module @@ -185,7 +185,16 @@ function ding_reservation_reserve_ajax($entity, $reservable = NULL) { // the options to select branch and period. $defaults = ding_provider_invoke('reservation', 'default_options', $user); $matches = preg_grep("/preferred_branch$/", array_keys($defaults)); - if (empty($defaults[array_shift($matches)])) { + $profile = ding_user_provider_profile($user); + $user_quick_reservation = $profile->field_quick_reservation[LANGUAGE_NONE][0]['value']; + $admin_quick_reservation = variable_get('ding_quick_reservation'); + if ($admin_quick_reservation == "0") { + $quick_reservation = ($user_quick_reservation == "0") ? TRUE : FALSE; + } + else { + $quick_reservation = ($user_quick_reservation == "0") ? FALSE : TRUE; + } + if (empty($defaults[array_shift($matches)]) || $quick_reservation) { $form = ding_provider_get_form('ding_reservation_reserve_form', $reservable, FALSE); $commands[] = ajax_command_ding_popup('ding_reservation', t('Reservation'), render($form)); } @@ -985,12 +994,12 @@ function ding_reservation_update_reservations_form_callback($form, &$form_state) */ function ding_reservation_default_options_branch($name, $default, $options) { $form = array(); + $allowed_branches = array('' => t('Select')) + $options; $form[$name] = array( '#type' => 'select', '#title' => t('Select branch'), - '#options' => $options, - '#required' => TRUE, + '#options' => $allowed_branches, '#default_value' => !empty($default) ? $default : '', ); @@ -1026,20 +1035,14 @@ function ding_reservation_interest_period_selector($name, $default, $options) { } } + $allowed_periods = array('' => t('Select')) + $options; $form[$name] = array( '#type' => 'select', '#title' => t('Select interest period'), - '#options' => $options, - '#required' => TRUE, + '#options' => $allowed_periods, '#default_value' => !empty($default) ? $default : '', ); - if (empty($default)) { - $form[$name . 'description'] = array( - '#markup' => '

' . t('Select an interest period.') . '

', - ); - } - return $form; }