Update balance/total payment for manual payment processing
This commit is contained in:
@@ -16,9 +16,8 @@ function booking_manual_payment_admin($nid)
|
||||
|
||||
$early_price_applies = _booking_is_earlybird();
|
||||
|
||||
$payment_balance_options[0] = t('Balance Payment');
|
||||
$payment_balance_options[1] = t('Total Payment');
|
||||
|
||||
$payment_balance_options[0] = t('Total Payment (sets total amount paid to this value)');
|
||||
$payment_balance_options[1] = t('Balance Payment (adds this value to the total amount paid)');
|
||||
|
||||
//collect the various payment options
|
||||
$result = db_query("SELECT pid, booking_price_descrip, booking_price, booking_late_price FROM {booking_price} where booking_eventid = :eid " .
|
||||
@@ -35,7 +34,7 @@ function booking_manual_payment_admin($nid)
|
||||
}
|
||||
|
||||
//any html to put at the start of the form
|
||||
$prefix = t("<p>Manually enter payment details.<br /><strong>Note that this adds to the total amount paid already by each person - the choice below is not yet implemented.</strong></p>");
|
||||
$prefix = t("<p>Manually enter payment details.</p>");
|
||||
|
||||
$form['booking_earlybird'] = array (
|
||||
'#type' => 'hidden',
|
||||
@@ -61,10 +60,10 @@ function booking_manual_payment_admin($nid)
|
||||
$form['payment-balance-type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Balance or total payment?'),
|
||||
'#description' => t('If this is a total payment, the amount selected above will be added to any existing payment. ' .
|
||||
'For balance payments, the amount paid is the total above minus any previous payments.<br />Select balance if the person had already paid their deposit and now has manually paid any outstanding balance.')
|
||||
'#description' => t('For balance payments, the amount entered above will be added to any payments the person has already made.<br />' .
|
||||
'A total payment will replace the person\'s total payment with the value entered above.'),
|
||||
'#options' => $payment_balance_options,
|
||||
'#default_value' => 0,
|
||||
'#default_value' => 1,
|
||||
'#required' => TRUE
|
||||
);
|
||||
|
||||
@@ -123,7 +122,7 @@ function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
$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)));
|
||||
watchdog('booking', 'Formstate when setting buttons: @info', array ('@info' => var_export($form_state['values'], TRUE)));
|
||||
//watchdog('booking', 'Checkboxes when setting buttons: @info', array ('@info' => var_export($checkboxes, TRUE)));
|
||||
//watchdog('booking', 'Manual payment form contents: @info', array('@info' => var_export($form_state['values'], TRUE)));
|
||||
|
||||
@@ -163,8 +162,23 @@ function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
$person = node_load($key);
|
||||
|
||||
if ($person) {
|
||||
//add this payment to their existing balance
|
||||
$total_paid = $person->booking_amount_paid + $price;
|
||||
|
||||
//check whether this is a balance or total payment
|
||||
$is_balance = $form_state['values']['payment-balance-type'];
|
||||
|
||||
//balance payment
|
||||
if ($is_balance == 1) {
|
||||
//add this payment to their existing balance
|
||||
$total_paid = $person->booking_amount_paid + $price;
|
||||
//total payment
|
||||
} elseif ($is_balance == 0) {
|
||||
//set this as the persons new balance
|
||||
$total_paid = $price;
|
||||
//change $price so that we add the correct dollar amount in the payment record
|
||||
//the actual amount newly paid is the price entered in the form, subtracting what they had previously paid
|
||||
watchdog('booking', 'Changing price for payment record from $!price to !newprice.', array('!price' => $price, '!newprice' => ($price - $person->booking_amount_paid)));
|
||||
$price = $price - $person->booking_amount_paid;
|
||||
}
|
||||
|
||||
//check if they have now fully paid
|
||||
if ($total_paid >= _booking_total_due($person)) {
|
||||
@@ -188,7 +202,7 @@ 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',
|
||||
watchdog('booking', 'New payment for regn id !nid of $!price and status is now !status',
|
||||
array('!nid' => $key, '!price' => $price, '!status' => $status));
|
||||
|
||||
db_update('booking_person')
|
||||
|
Reference in New Issue
Block a user