Payment complete flag for manual payments

This commit is contained in:
2014-11-29 11:23:42 +11:00
parent 0509376979
commit 780be0be7e
3 changed files with 43 additions and 28 deletions

View File

@@ -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();