minor tweaks

This commit is contained in:
2014-06-03 22:21:52 +10:00
parent 6ca1c1ab80
commit 4f401aa245
2 changed files with 85 additions and 39 deletions

View File

@@ -38,7 +38,8 @@ function booking_report_summary() {
array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'), array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
array('data' => t('Name'), 'field' => 'booking_lastname'), array('data' => t('Name'), 'field' => 'booking_lastname'),
array('data' => t('Booking Status'), 'field' => 'booking_status'), array('data' => t('Booking Status'), 'field' => 'booking_status'),
array('data' => t('Edit Studygroups')), array('data' => t('Studygroups')),
array('data' => t('Room')),
array('data' => t('Email'), 'field' => 'booking_email'), array('data' => t('Email'), 'field' => 'booking_email'),
array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'), array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
array('data' => t('Total Payment Required')), array('data' => t('Total Payment Required')),
@@ -113,7 +114,8 @@ function booking_report_summary() {
t('node/!id/edit', array('!id' => $person->nid)) t('node/!id/edit', array('!id' => $person->nid))
), ),
_booking_status_generate($person->booking_status), _booking_status_generate($person->booking_status),
l(t('Edit Groups'), t('admin/booking/!id/edit-studygroup', array('!id' => $person->nid))), l(t('Groups'), t('admin/booking/!id/edit-studygroup', array('!id' => $person->nid))),
l(t('Room'), t('admin/booking/!id/edit-room', array('!id' => $person->nid))),
t('!email', array('!email' => $person->booking_email)), t('!email', array('!email' => $person->booking_email)),
t('!payment', array('!payment' => $person->booking_amount_paid)), t('!payment', array('!payment' => $person->booking_amount_paid)),
t('!payment', array('!payment' => $amount_owing == 0 ? $person->booking_total_pay_reqd : _booking_total_due($person))), t('!payment', array('!payment' => $amount_owing == 0 ? $person->booking_total_pay_reqd : _booking_total_due($person))),

View File

@@ -198,6 +198,10 @@ function booking_room_edit_form($node, &$form_state, $nid) {
$form['submit'] = array ( $form['submit'] = array (
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Submit'), '#value' => t('Submit'),
);
$form['remove'] = array (
'#type' => 'submit',
'#value' => t('Remove'),
); );
return array ( return array (
@@ -257,19 +261,23 @@ function _booking_get_roomedit_bedtype_options($location_id, $room_num) {
$details = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid AND booking_room_number = :num", $details = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid AND booking_room_number = :num",
array(':lid' => $location_id, ':num' => $room_num))->fetchObject(); array(':lid' => $location_id, ':num' => $room_num))->fetchObject();
//go through the bed options //check we got a response from the query
if ($details->booking_room_singlebeds > 0) if ($details)
{ {
$bed_options[1] = "Single"; //go through the bed options
if ($details->booking_room_singlebeds > 0)
{
$bed_options[1] = "Single";
}
if ($details->booking_room_doublebeds > 0)
{
$bed_options[2] = "Double";
}
if ($details->booking_room_queenbeds > 0)
{
$bed_options[3] = "Queen";
}
} }
if ($details->booking_room_doublebeds > 0)
{
$bed_options[2] = "Double";
}
if ($details->booking_room_queenbeds > 0)
{
$bed_options[3] = "Queen";
}
//watchdog('booking', "<pre>Room Number Options:\n@info</pre>", array('@info' => print_r( $bed_options, true))); //watchdog('booking', "<pre>Room Number Options:\n@info</pre>", array('@info' => print_r( $bed_options, true)));
@@ -323,39 +331,75 @@ function booking_room_edit_form_validate($form, &$form_state) {
function booking_room_edit_form_submit($form, &$form_state) { function booking_room_edit_form_submit($form, &$form_state) {
global $event; global $event;
$values = $form_state['input']; $values = $form_state['input'];
$details = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid AND booking_room_number = :num",
array(':lid' => $values['booking_room_location_id'], ':num' => $values['booking_room_number']))->fetchObject();
$check = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid AND booking_nodeid = :nid",
array(':eid' => $event->eid, ':nid' => $values['personid']))->fetchObject();
if ($check) //check if we should remove the room allocation
if ($form_state['values']['op'] == 'Remove')
{ {
//there is an existing mapping to update $message = t("Removing id !nid from room number !number in location !location",
$result = db_update('booking_room_mapping') array('!nid' => $values['personid'], '!location' => $values['booking_room_location_id'],
->fields(array( '!number' => $values['booking_room_number'])
'booking_roomid' => $details->rid, );
'booking_room_bedtype' => $values['booking_room_bedtype'], watchdog('booking', $message);
)) drupal_set_message($message, 'status', FALSE);
db_delete('booking_room_mapping')
->condition('booking_eventid', $event->eid) ->condition('booking_eventid', $event->eid)
->condition('booking_nodeid', $values['personid']) ->condition('booking_nodeid', $values['personid'])
->execute(); ->execute();
drupal_set_message("Successfully updated " . $result . " row(s) in the room allocation table.", $type = 'status');
return;
} }
//otherwise, continue with adding/updating the room allocation
else else
{ {
//create a new room mapping for this person $details = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid AND booking_room_number = :num",
$result = db_insert('booking_room_mapping') array(':lid' => $values['booking_room_location_id'], ':num' => $values['booking_room_number']))->fetchObject();
->fields(array(
'booking_roomid' => $details->rid, $check = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid AND booking_nodeid = :nid",
'booking_eventid' => $event->eid, array(':eid' => $event->eid, ':nid' => $values['personid']))->fetchObject();
'booking_nodeid' => $values['personid'],
'booking_room_bedtype' => $values['booking_room_bedtype'], //this person already exists in mapping table
)) if ($check)
->execute(); {
drupal_set_message("Successfully added " . $result . " row(s) to the room allocation table.", $type = 'status'); $message = t("Updating person id !nid to room id !id with bedtype !type",
} array('!nid' => $values['personid'], '!id' => $details->rid, '!type' => $values['booking_room_bedtype'],
'!number' => $values['booking_room_number'])
);
//there is an existing mapping to update
$result = db_update('booking_room_mapping')
->fields(array(
'booking_roomid' => $details->rid,
'booking_room_bedtype' => $values['booking_room_bedtype'],
))
->condition('booking_eventid', $event->eid)
->condition('booking_nodeid', $values['personid'])
->execute();
//drupal_set_message("Successfully updated " . $result . " row(s) in the room allocation table.", $type = 'status');
}
//create a new record in the mapping table
else
{
$message = t("Allocating person id !nid to room id !id with bedtype !type",
array('!nid' => $values['personid'], '!id' => $details->rid, '!type' => $values['booking_room_bedtype'],
'!number' => $values['booking_room_number'])
);
//create a new room mapping for this person
$result = db_insert('booking_room_mapping')
->fields(array(
'booking_roomid' => $details->rid,
'booking_eventid' => $event->eid,
'booking_nodeid' => $values['personid'],
'booking_room_bedtype' => $values['booking_room_bedtype'],
))
->execute();
//drupal_set_message("Successfully added id " . $values['personid'] . " to the room allocation table.", $type = 'status');
}
watchdog('booking', $message);
drupal_set_message($message, 'status', FALSE);
} //end operation check
} }