Payment complete flag for manual payments
This commit is contained in:
@@ -1426,7 +1426,8 @@ function _booking_room_email_summary($node) {
|
||||
//check that this attendee has had a room allocated
|
||||
if (! empty($node->rid))
|
||||
{
|
||||
$rows[] = t("Room Location: " . _booking_room_location_lookup($node->booking_room_location_id));
|
||||
//$rows[] = t("Room Location: " . _booking_room_location_lookup($node->booking_room_location_id));
|
||||
$rows[] = t("Room Location: " . $node->booking_roomlocation_descrip);
|
||||
$rows[] = t("Room Number: " . $node->booking_room_number);
|
||||
$rows[] = t("Bed Type: " . _booking_room_bedtype_lookup($node->booking_room_bedtype));
|
||||
}
|
||||
@@ -1460,7 +1461,7 @@ function _booking_room_email_summary($node) {
|
||||
} else {
|
||||
// If /dev/urandom isn't available (eg: in non-unix systems), use mt_rand().
|
||||
$pr_bits = "";
|
||||
for($cnt=0; $cnt < 16; $cnt++){
|
||||
for($cnt=0; $cnt < 16; $cnt++) {
|
||||
$pr_bits .= chr(mt_rand(0, 255));
|
||||
}
|
||||
}
|
||||
|
@@ -483,6 +483,14 @@ function booking_update_7226() {
|
||||
db_create_table('booking_room_locations', $booking_room_locations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add payment complete flag to simplify payment management
|
||||
*/
|
||||
function booking_update_7227() {
|
||||
$spec = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N');
|
||||
db_add_field('booking_person', 'booking_payment_complete', $spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
@@ -588,6 +596,7 @@ function booking_schema() {
|
||||
'booking_room_mate2' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
//payment info
|
||||
'booking_payment_id' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
|
||||
'booking_payment_complete' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||
//'booking_payment_method' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
|
||||
'booking_total_pay_reqd' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_amount_paid' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
|
@@ -104,6 +104,8 @@ function booking_manual_payment_admin($nid)
|
||||
function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$counter = 0;
|
||||
$price = 0;
|
||||
$fully_paid = 'N';
|
||||
$payment_date = REQUEST_TIME;
|
||||
$checkboxes = $form_state['values']['table']; //$values['booking_price_active'];
|
||||
//watchdog('booking', 'Formstate when setting buttons: @info', array ('@info' => var_export($form_state['values'], TRUE)));
|
||||
@@ -111,8 +113,7 @@ function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
//watchdog('booking', 'Manual payment form contents: @info', array('@info' => var_export($form_state['values'], TRUE)));
|
||||
|
||||
//check if there is a pre-defined payment type selected
|
||||
if ($form_state['values']['payment-type'] != '' && $form_state['values']['payment-custom-amount'] == '0.00')
|
||||
{
|
||||
if ($form_state['values']['payment-type'] != '' && $form_state['values']['payment-custom-amount'] == '0.00') {
|
||||
//look up the price relating to the price id selected
|
||||
$price_query = db_query("SELECT price.booking_price, price.booking_late_price, price.booking_price_descrip " .
|
||||
"FROM {booking_price} price " .
|
||||
@@ -122,42 +123,44 @@ function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
|
||||
$price = $form_state['values']['booking_earlybird'] == true ? $price_query->booking_price : $price_query->booking_late_price;
|
||||
$description = $price_query->booking_price_descrip;
|
||||
}
|
||||
elseif ($form_state['values']['payment-custom-amount'] != '0.00' && is_numeric($form_state['values']['payment-custom-amount']))
|
||||
{
|
||||
} elseif ($form_state['values']['payment-custom-amount'] != '0.00' && is_numeric($form_state['values']['payment-custom-amount'])) {
|
||||
$price = $form_state['values']['payment-custom-amount'];
|
||||
$description = "Custom Amount";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
drupal_set_message("Error: Could not determine payment amount to update user(s).", 'error', FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($checkboxes as $key => $value)
|
||||
{
|
||||
if (is_numeric($key) && $value != 0)
|
||||
{
|
||||
|
||||
//loop through the list of attendees
|
||||
foreach($checkboxes as $key => $value) {
|
||||
//if an attendee's checkbox was ticked, then process their payment
|
||||
if (is_numeric($key) && $value != 0) {
|
||||
|
||||
//check if they exist in the database first
|
||||
$person = db_query("SELECT person.nid, person.booking_firstname, person.booking_lastname, person.booking_status, person.booking_partner_id, person.booking_amount_paid " .
|
||||
"FROM {booking_person} person " .
|
||||
"WHERE nid = :nid",
|
||||
array(':nid' => $key))
|
||||
->fetchObject();
|
||||
/*
|
||||
$person = db_query("SELECT person.nid, person.booking_firstname, person.booking_lastname, person.booking_status, " .
|
||||
"person.booking_partner_id, person.booking_amount_paid " .
|
||||
"FROM {booking_person} person " .
|
||||
"WHERE nid = :nid",
|
||||
array(':nid' => $key))
|
||||
->fetchObject();
|
||||
*/
|
||||
$person = node_load($key);
|
||||
|
||||
if ($person)
|
||||
{
|
||||
if ($person) {
|
||||
//add this payment to their existing balance
|
||||
$total_paid = $person->booking_amount_paid + $price;
|
||||
|
||||
//check if they have now fully paid
|
||||
if ($total_paid >= _booking_total_due($person)) {
|
||||
$fully_paid = 'Y';
|
||||
}
|
||||
|
||||
//work out what their booking status is now
|
||||
if ($person->booking_status == 1 || _booking_check_bookings_full() == FALSE)
|
||||
{
|
||||
if ($person->booking_status == 1 || _booking_check_bookings_full() == FALSE) {
|
||||
//either they were already booked in, or there is room on the booked-in list
|
||||
$status = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//there must be a waiting list, so put them on that
|
||||
$status = 2;
|
||||
}
|
||||
@@ -170,12 +173,14 @@ function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
$status = 1;
|
||||
*/
|
||||
|
||||
watchdog('booking', 'Setting payment for regn id !nid to $!price and status to !status', array('!nid' => $key, '!price' => $price, '!status' => $status));
|
||||
watchdog('booking', 'Setting payment for regn id !nid to $!price and status to !status',
|
||||
array('!nid' => $key, '!price' => $price, '!status' => $status));
|
||||
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_amount_paid' => $total_paid,
|
||||
'booking_status' => $status,
|
||||
'booking_payment_complete' => $fully_paid,
|
||||
))
|
||||
->condition('nid', $key)
|
||||
->execute();
|
||||
|
Reference in New Issue
Block a user