add room description field
This commit is contained in:
@@ -585,6 +585,16 @@ function booking_update_7237() {
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add description field to room definitions
|
||||
*/
|
||||
function booking_update_7237() {
|
||||
$spec = array('type' => 'varchar', 'length' => '200', 'not null' => FALSE);
|
||||
db_add_field('booking_room_definition', 'booking_room_description', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
@@ -921,6 +931,7 @@ function booking_schema() {
|
||||
'booking_room_doublebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_room_queenbeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_room_ensuite' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||
'booking_room_description' => array('type' => 'varchar', 'length' => '200', 'not null' => TRUE),
|
||||
),
|
||||
'primary key' => array('rid'),
|
||||
);
|
||||
|
@@ -762,7 +762,7 @@ function booking_view($node, $view_mode) {
|
||||
}
|
||||
$rows[] = array(t('Linked Partner:'), t($partner_name));
|
||||
$rows[] = array(t('Linked Boyfriend/Girlfriend:'), t($bf_gf));
|
||||
$rows[] = array(t('Node ID to keep separate:'), $node->booking_keepseparate_id);
|
||||
$rows[] = array(t('Node ID to keep separate:'), $node->booking_keepseparate_id == 0 ? 'N/A' : $node->booking_keepseparate_id);
|
||||
$rows[] = array(t('Home Phone Number:'), t('!home', array('!home' => $node->booking_phone)));
|
||||
$rows[] = array(t('Mobile Phone Number:'), t('!mob', array('!mob' => $node->booking_mobile)));
|
||||
$rows[] = array(t('Postal Address:'), t('!street<br />!suburb !state !code<br />!country',
|
||||
|
@@ -225,18 +225,20 @@ function booking_rooms_view_definitions() {
|
||||
$definition_query->join('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id');
|
||||
$definition_query->condition('l.booking_roomlocation_active', 'Y', '=')
|
||||
->fields('r')
|
||||
->fields('l');
|
||||
->fields('l')
|
||||
->orderBy('lid')->orderBy('booking_room_number');
|
||||
$definition_result = $definition_query->execute();
|
||||
|
||||
$location_header = array (
|
||||
'booking_roomlocation_descrip' => t('Location Description'),
|
||||
'booking_roomlocation_active' => t('Location Active?'),
|
||||
'booking_roomlocation_descrip' => t('Location Description'),
|
||||
'booking_roomlocation_active' => t('Location Active?'),
|
||||
'booking_location_edit' => t('Edit Location'),
|
||||
);
|
||||
|
||||
$definition_header = array (
|
||||
'booking_room_location_description' => t('Room Location'),
|
||||
'booking_room_number' => t('Room Number'),
|
||||
'booking_room_location_description' => t('Room Location'),
|
||||
'booking_room_number' => t('Room Number'),
|
||||
'booking_room_description' => t('Room Description'),
|
||||
'booking_room_singlebeds' => t('Number Single Beds'),
|
||||
'booking_room_doublebeds' => t('Number Double Beds'),
|
||||
'booking_room_queenbeds' => t('Number Queen Beds'),
|
||||
@@ -244,8 +246,7 @@ function booking_rooms_view_definitions() {
|
||||
'booking_room_edit' => t('Edit Room'),
|
||||
);
|
||||
|
||||
foreach($location_result as $data)
|
||||
{
|
||||
foreach($location_result as $data) {
|
||||
$location_rows[] = array (
|
||||
$data->booking_roomlocation_descrip,
|
||||
$data->booking_roomlocation_active == 'Y' ? 'Yes' : 'No',
|
||||
@@ -253,12 +254,12 @@ function booking_rooms_view_definitions() {
|
||||
);
|
||||
}
|
||||
|
||||
foreach($definition_result as $data)
|
||||
{
|
||||
foreach($definition_result as $data) {
|
||||
$definition_rows[] = array (
|
||||
//_booking_room_location_lookup($data->booking_room_location_id),
|
||||
//_booking_room_location_lookup($data->booking_room_location_id),
|
||||
$data->booking_roomlocation_descrip,
|
||||
$data->booking_room_number,
|
||||
$data->booking_room_number,
|
||||
$data->booking_room_description,
|
||||
$data->booking_room_singlebeds,
|
||||
$data->booking_room_doublebeds,
|
||||
$data->booking_room_queenbeds,
|
||||
@@ -309,33 +310,30 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
|
||||
$query = db_query("SELECT * FROM {booking_room_locations} where booking_roomlocation_active='Y'");
|
||||
|
||||
foreach($query as $row)
|
||||
{
|
||||
foreach($query as $row) {
|
||||
$location_options[$row->lid] = $row->booking_roomlocation_descrip;
|
||||
}
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
if ($create == true) {
|
||||
$data = $node;
|
||||
$prefix = t("<p>Create new room defintion.</p>");
|
||||
//watchdog('booking', 'Creating new room definition: @info', array ('@info' => var_export($node, TRUE)));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
//verify that $editid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $room_id)) {
|
||||
drupal_set_message("Error: Invalid room ID supplied. Unable to update room definition.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/rooms');
|
||||
return "";
|
||||
}
|
||||
$prefix = t("<p>Update the room defintions.</p>");
|
||||
|
||||
//$data = $form_state['input'];
|
||||
$data = db_query("SELECT * FROM {booking_room_definition} WHERE rid = :id",
|
||||
array(':id' => $room_id))
|
||||
$data = db_query("SELECT * FROM {booking_room_definition} WHERE rid = :id", array(':id' => $room_id))
|
||||
->fetchObject();
|
||||
$prefix = t("<p>Update the room defintions.</p>");
|
||||
|
||||
//add this to the form in a hidden field so we can update the right price
|
||||
$form['booking_rid'] = array (
|
||||
$form['booking_rid'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $room_id,
|
||||
);
|
||||
@@ -343,15 +341,14 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
}
|
||||
|
||||
//create the options array for bed counts
|
||||
for ($i = 0; $i <= 15; $i++)
|
||||
for ($i = 0; $i <= 15; $i++) {
|
||||
$bedcount_options[$i] = $i;
|
||||
}
|
||||
|
||||
//define the form for adding to the room definitions
|
||||
|
||||
if(!isset($form_state['storage']['confirm'])) {
|
||||
|
||||
$form[] = array (
|
||||
'first_heading' => array (
|
||||
'first_heading' => array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
@@ -363,26 +360,33 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
'#options' => $location_options,
|
||||
'#default_value' => !empty($data->booking_room_location_id) ? $data->booking_room_location_id : ''
|
||||
);
|
||||
$form['booking_room_number'] = array (
|
||||
$form['booking_room_number'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify room number'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 10,
|
||||
'#default_value' => !empty($data->booking_room_number) ? $data->booking_room_number : '',
|
||||
);
|
||||
$form['booking_room_singlebeds'] = array (
|
||||
$form['booking_room_description'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify room label (not mandatory)'),
|
||||
'#size' => 50,
|
||||
'#maxlength' => 100,
|
||||
'#default_value' => !empty($data->booking_room_description) ? $data->booking_room_description : '',
|
||||
);
|
||||
$form['booking_room_singlebeds'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Specify number of single beds'),
|
||||
'#options' => $bedcount_options,
|
||||
'#default_value' => !empty($data->booking_room_singlebeds) ? $data->booking_room_singlebeds : '',
|
||||
);
|
||||
$form['booking_room_doublebeds'] = array (
|
||||
$form['booking_room_doublebeds'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Specify number of double beds'),
|
||||
'#options' => $bedcount_options,
|
||||
'#default_value' => !empty($data->booking_room_doublebeds) ? $data->booking_room_doublebeds : '',
|
||||
);
|
||||
$form['booking_room_queenbeds'] = array (
|
||||
$form['booking_room_queenbeds'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Specify number of queen beds'),
|
||||
'#options' => $bedcount_options,
|
||||
@@ -394,21 +398,18 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
'#default_value' => (!empty($data->booking_room_ensuite) && $data->booking_room_ensuite == 'Y') ? 1 : 0,
|
||||
);
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
$form['submit'] = array
|
||||
(
|
||||
if ($create == true) {
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Add Room'),
|
||||
);
|
||||
} else {
|
||||
$form['Update'] = array
|
||||
(
|
||||
}
|
||||
else {
|
||||
$form['Update'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Update Room'),
|
||||
);
|
||||
$form['Delete'] = array
|
||||
(
|
||||
$form['Delete'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete Room'),
|
||||
);
|
||||
@@ -418,12 +419,10 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return confirm_form($form, "Are you sure you wish to delete room definition with id " . $room_id . "?",
|
||||
current_path(), NULL, "Delete Room");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,14 +436,12 @@ function booking_rooms_definition_form_submit($form, &$form_state) {
|
||||
//watchdog('booking', "<pre>Room definition submission:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
|
||||
//if we're deleting, add the confirmation to the form if it hasn't been defined yet
|
||||
if($form_state['values']['op'] == 'Delete Room' && (!isset($form_state['storage']['confirm'])))
|
||||
{
|
||||
if($form_state['values']['op'] == 'Delete Room' && (!isset($form_state['storage']['confirm']))) {
|
||||
//watchdog('booking', "<pre>Room deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
$form_state['storage']['confirm'] = TRUE;
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Room')
|
||||
{
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Room') {
|
||||
//delete the room
|
||||
watchdog('booking', "Deleting room ID !rid", array('!rid' => $values['booking_rid']));
|
||||
|
||||
@@ -455,12 +452,12 @@ function booking_rooms_definition_form_submit($form, &$form_state) {
|
||||
drupal_set_message('Deleted room id ' . $values['booking_rid'] );
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Update Room')
|
||||
{
|
||||
elseif ($form_state['values']['op'] == 'Update Room') {
|
||||
$result = db_update('booking_room_definition')
|
||||
->fields(array(
|
||||
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||
'booking_room_number' => $values['booking_room_number'],
|
||||
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||
'booking_room_number' => $values['booking_room_number'],
|
||||
'booking_room_description' => $values['booking_room_description'],
|
||||
'booking_room_singlebeds' => $values['booking_room_singlebeds'],
|
||||
'booking_room_doublebeds' => $values['booking_room_doublebeds'],
|
||||
'booking_room_queenbeds' => $values['booking_room_queenbeds'],
|
||||
@@ -475,8 +472,9 @@ function booking_rooms_definition_form_submit($form, &$form_state) {
|
||||
{
|
||||
db_insert('booking_room_definition')
|
||||
->fields(array(
|
||||
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||
'booking_room_number' => $values['booking_room_number'],
|
||||
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||
'booking_room_number' => $values['booking_room_number'],
|
||||
'booking_room_description' => $values['booking_room_description'],
|
||||
'booking_room_singlebeds' => $values['booking_room_singlebeds'],
|
||||
'booking_room_doublebeds' => $values['booking_room_doublebeds'],
|
||||
'booking_room_queenbeds' => $values['booking_room_queenbeds'],
|
||||
|
Reference in New Issue
Block a user