add ensuite info to booking_rooms_view_form() as well as change to an associative array

This commit is contained in:
2016-06-28 13:30:16 +10:00
parent 69442d30b5
commit 06df0a1856

View File

@@ -446,14 +446,36 @@ function booking_rooms_view_form($node, &$form_state, $location_id) {
$header = array(
'booking_room_number' => array('data' => t('Room Number')),
'booking_room_description' => array('data' => t('Room Label')),
'booking_room_ensuite' => array('data' => t('Ensuite?')),
'booking_room_singlebed' => array('data' => t('Single Bed')),
'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')),
'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')),
'booking_room_queenbed_p1' => array('data' => t('Queen Bed Person 1')),
'booking_room_queenbed_p2' => array('data' => t('Queen Bed Person 2')),
);
//define the default fields in a table row
$default_row = array();
$default_row['booking_room_number'] = "";
$default_row['booking_room_description'] = "";
$default_row['booking_room_ensuite'] = "";
$default_row['booking_room_singlebed'] = "";
$default_row['booking_room_doublebed_p1'] = "";
$default_row['booking_room_doublebed_p2'] = "";
$default_row['booking_room_queenbed_p1'] = "";
$default_row['booking_room_queenbed_p2'] = "";
foreach ($room_query as $data) {
//create a row that contains just the room location and number and the custom css id for a separating line between the rooms
$new_row = _booking_clone_array($default_row);
$new_row['booking_room_number'] = $data->booking_room_number;
$new_row['booking_room_description'] = $data->booking_room_description;
$new_row['booking_room_ensuite'] = $data->booking_room_ensuite == 'Y' ? "Yes" : "No";
$rows[] = array(
'data' => $new_row,
'id' => array("new-group-row"),
);
//load the existing bed mappings for this room
$existing_beds = array();
for ($i = 1; $i <= 3; $i++) {
@@ -464,13 +486,15 @@ function booking_rooms_view_form($node, &$form_state, $location_id) {
$existing_beds[$i][] = $mapping->booking_nodeid;
}
}
}
} //end creating existing room mappings for this room
/*
//create a row that contains just the room location and number
$rows[] = array(
'data' => array(
$data->booking_room_number,
$data->booking_room_description,
$data->booking_room_ensuite == 'Y' ? "Yes" : "No",
"",
"",
"",
@@ -478,15 +502,22 @@ function booking_rooms_view_form($node, &$form_state, $location_id) {
"",
),
'id' => array("new-group-row"),
);
);
*/
//create an additional row for each single bed
for ($i = 0; $i < $data->booking_room_singlebeds; $i++) {
//retrieve the default value if one exists
$nid = (!empty($existing_beds[1][$i])) ? $existing_beds[1][$i] : 0;
$new_row = _booking_clone_array($default_row);
$new_row['booking_room_singlebed'] = _booking_rooms_view_formatperson($attendees, $nid);
$rows[] = array(
'data' => $new_row,
);
/*
$rows[] = array(
'data' => array(
"",
"",
"",
_booking_rooms_view_formatperson($attendees, $nid),
@@ -495,41 +526,60 @@ function booking_rooms_view_form($node, &$form_state, $location_id) {
"",
"",
),
);
);
*/
}
//create an additional row for each double bed
//$j is our counter that increments twice as fast as $i to cater for both beds
$j = 0;
for ($i = 0; $i < $data->booking_room_doublebeds; $i++) {
$new_row = _booking_clone_array($default_row);
$new_row['booking_room_doublebed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0);
$new_row['booking_room_doublebed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0);
$rows[] = array(
'data' => $new_row,
);
/*
$rows[] = array(
'data' => array(
"",
"",
"",
"",
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0),
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0),
"",
"",
),
);
);
*/
}
//create an additional row for each queen bed
//$j is our counter that increments twice as fast as $i to cater for both beds
$j = 0;
for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) {
$new_row = _booking_clone_array($default_row);
$new_row['booking_room_queenbed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0);
$new_row['booking_room_queenbed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0);
$rows[] = array(
'data' => $new_row,
);
/*
$rows[] = array(
'data' => array(
"",
"",
"",
"",
"",
"",
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0),
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0),
),
);
);
*/
}
}