function merci_admin_settings in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6.2
Same name and namespace in other branches
- 6 merci.module \merci_admin_settings()
- 7.2 includes/merci.admin.inc \merci_admin_settings()
Builds the MERCI admininstration settings form.
1 string reference to 'merci_admin_settings'
- merci_menu in ./
merci.module - Implementation of hook_menu().
File
- includes/
merci.admin.inc, line 12 - MERCI - Managed Equipment Reservation Checkout and Inventory
Code
function merci_admin_settings() {
$form = array();
$statuses = array();
$statuses[MERCI_STATUS_UNCONFIRMED] = t('Unconfirmed');
$statuses[MERCI_STATUS_PENDING] = t('Confirmed');
$statuses[MERCI_STATUS_CHECKED_OUT] = t('Checked Out');
$hours_of_operation = merci_load_hours_of_operation();
$form['merci_default_reservation_status'] = array(
'#type' => 'select',
'#title' => t('Default Reservation Status'),
'#options' => $statuses,
'#default_value' => variable_get('merci_default_reservation_status', ''),
'#description' => t('New Reservations will be set to this by default. Use Checked Out if you are using MERCI to manage the checkout, but do not allow actual Reservations.'),
);
$form['merci_max_days_advance_reservation'] = array(
'#type' => 'textfield',
'#title' => t('Max Advance'),
'#size' => 11,
'#maxlength' => 11,
'#default_value' => variable_get('merci_max_days_advance_reservation', '0'),
'#description' => t('Maximum number of days a Reservation can be made in advance. Set to 0 if to allow Reservations to be made an unlimitted time into the future.'),
);
// Weekend
// Hours of operation
$hours_description = '<div>' . t('Enter military time for both opening and closing time, separated by a dash, in the format') . ' <em>hh:mm-hh:mm</em></div>' . t('ex.') . ' <em>09:00-17:00</em> ' . t('would be open at 9AM, close at 5PM. Leave blank to indicate not being open.');
$hours_description .= '<p><div>' . t('Check the box next to <em>considered a weekend</em> if MERCI should consider that day a weekend. Item\'s cannot be checked out or reserved on weekend days unless the "Allow Weekends" setting is checked for the content type.') . '</div>';
$hours_element = array(
'#type' => 'textfield',
'#title' => t('Monday hours'),
'#size' => 11,
'#maxlength' => 11,
'#element_validate' => array(
'merci_admin_validate_hours_of_operation',
),
);
$weekend_element = array(
'#type' => 'checkbox',
'#title' => t('is considered a weekend'),
);
$form['merci_hours'] = array(
'#title' => t('Hours of operation'),
'#type' => 'fieldset',
'#description' => $hours_description,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['merci_hours']['merci_hours_mon'] = array(
'#title' => t('Monday hours'),
'#default_value' => array_key_exists(1, $hours_of_operation) ? implode('-', $hours_of_operation[1]) : '',
) + $hours_element;
$form['merci_hours']['merci_monday_is_weekend'] = array(
'#default_value' => variable_get('merci_monday_is_weekend', 0),
) + $weekend_element;
$form['merci_hours']['merci_hours_tue'] = array(
'#title' => t('Tuesday hours'),
'#default_value' => array_key_exists(2, $hours_of_operation) ? implode('-', $hours_of_operation[2]) : '',
) + $hours_element;
$form['merci_hours']['merci_tuesday_is_weekend'] = array(
'#default_value' => variable_get('merci_tuesday_is_weekend', 0),
) + $weekend_element;
$form['merci_hours']['merci_hours_wed'] = array(
'#title' => t('Wednesday hours'),
'#default_value' => array_key_exists(3, $hours_of_operation) ? implode('-', $hours_of_operation[3]) : '',
) + $hours_element;
$form['merci_hours']['merci_wednesday_is_weekend'] = array(
'#default_value' => variable_get('merci_wednesday_is_weekend', 0),
) + $weekend_element;
$form['merci_hours']['merci_hours_thu'] = array(
'#title' => t('Thursday hours'),
'#default_value' => array_key_exists(4, $hours_of_operation) ? implode('-', $hours_of_operation[4]) : '',
) + $hours_element;
$form['merci_hours']['merci_thursday_is_weekend'] = array(
'#default_value' => variable_get('merci_thursday_is_weekend', 0),
) + $weekend_element;
$form['merci_hours']['merci_hours_fri'] = array(
'#title' => t('Friday hours'),
'#default_value' => array_key_exists(5, $hours_of_operation) ? implode('-', $hours_of_operation[5]) : '',
) + $hours_element;
$form['merci_hours']['merci_friday_is_weekend'] = array(
'#default_value' => variable_get('merci_friday_is_weekend', 0),
) + $weekend_element;
$form['merci_hours']['merci_hours_sat'] = array(
'#title' => t('Saturday hours'),
'#default_value' => array_key_exists(6, $hours_of_operation) ? implode('-', $hours_of_operation[6]) : '',
) + $hours_element;
$form['merci_hours']['merci_saturday_is_weekend'] = array(
'#default_value' => variable_get('merci_saturday_is_weekend', 1),
) + $weekend_element;
$form['merci_hours']['merci_hours_sun'] = array(
'#title' => t('Sunday hours'),
'#default_value' => array_key_exists(0, $hours_of_operation) ? implode('-', $hours_of_operation[0]) : '',
) + $hours_element;
$form['merci_hours']['merci_sunday_is_weekend'] = array(
'#default_value' => variable_get('merci_sunday_is_weekend', 1),
) + $weekend_element;
$form['merci_hours']['merci_hours_admin'] = array(
'#title' => t('Admin hours'),
'#default_value' => variable_get('merci_hours_admin', '07:00-22:00'),
'#description' => t('This setting controls the hours shown on the conflict grid for users with Adminster MERCI permessions. The conflict grid is normally limited to the days and hours the set above. Because users with Admister MERCI rights can create Resevervations outside the normal hours of operation, they need to see conflicts during those times as well.'),
) + $hours_element;
$form['merci_hours']['merci_closed_dates'] = array(
'#type' => 'textarea',
'#title' => t('Closed dates'),
'#rows' => 10,
// TODO: this doesn't seem to work...
'#cols' => 5,
'#default_value' => variable_get('merci_closed_dates', ''),
'#description' => '<div>' . t('Enter dates which are closed regardless of the day of the week, one date per line, in the format') . ' <em>mm-dd</em></div>' . t('ex.') . ' <em>07-04</em> ' . t('would mean July 4th is always closed, regardless of what day of the week it falls on.'),
'#element_validate' => array(
'merci_admin_validate_closed_days',
),
);
$form['merci_advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['merci_advanced']['merci_verbose_logging'] = array(
'#type' => 'checkbox',
'#title' => t('Verbose Logging Mode'),
'#default_value' => variable_get('merci_verbose_logging', 0),
'#description' => t('This option will add log messages at several points in the resevervation process making it easier to diagnose configuration issues.'),
);
$field = content_fields('field_merci_date');
$form['merci_advanced']['merci_lock'] = array(
'#type' => 'checkbox',
'#title' => t('Lock Fields'),
'#default_value' => $field['locked'],
'#description' => t('MERCI requires a Date field to function. This field is locked by default. Altering or deleting the Date field could cause serious problems. Always backup before altering this field!'),
);
$form = system_settings_form($form);
$form['#submit'][] = 'merci_admin_settings_submit';
return $form;
}