Implementing balance/total choice for manual payments

This commit is contained in:
2016-02-17 09:41:26 +11:00
parent 74eccf57d3
commit 274c4b9156
3 changed files with 19 additions and 37 deletions

View File

@@ -10,11 +10,16 @@ function booking_manual_payment_admin($nid)
{ {
global $event; global $event;
$payment_type_options = array(); $payment_type_options = array();
$payment_balance_options = array();
$form = array(); $form = array();
$options = array(); $options = array();
$early_price_applies = _booking_is_earlybird(); $early_price_applies = _booking_is_earlybird();
$payment_balance_options[0] = t('Balance Payment');
$payment_balance_options[1] = t('Total Payment');
//collect the various payment options //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 " . $result = db_query("SELECT pid, booking_price_descrip, booking_price, booking_late_price FROM {booking_price} where booking_eventid = :eid " .
"and booking_price_active=1", "and booking_price_active=1",
@@ -30,7 +35,7 @@ function booking_manual_payment_admin($nid)
} }
//any html to put at the start of the form //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.</strong></p>"); $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>");
$form['booking_earlybird'] = array ( $form['booking_earlybird'] = array (
'#type' => 'hidden', '#type' => 'hidden',
@@ -53,6 +58,16 @@ function booking_manual_payment_admin($nid)
'#default_value' => '0.00' '#default_value' => '0.00'
); );
$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.')
'#options' => $payment_balance_options,
'#default_value' => 0,
'#required' => TRUE
);
$header = array ( $header = array (
'booking_nid' => array('data' => t('Booking ID')), 'booking_nid' => array('data' => t('Booking ID')),
'booking_name' => array('data' => t('Name')), 'booking_name' => array('data' => t('Name')),

View File

@@ -1362,6 +1362,7 @@ function booking_form_submit($form, &$form_state) {
$node->booking_lifesaver = empty($values['booking_lifesaver']) ? 'N' : ($values['booking_lifesaver'] == 1 ? 'Y' : 'N'); $node->booking_lifesaver = empty($values['booking_lifesaver']) ? 'N' : ($values['booking_lifesaver'] == 1 ? 'Y' : 'N');
$node->booking_doctor = empty($values['booking_doctor']) ? 'N' : ($values['booking_doctor'] == 1 ? 'Y' : 'N'); $node->booking_doctor = empty($values['booking_doctor']) ? 'N' : ($values['booking_doctor'] == 1 ? 'Y' : 'N');
$node->booking_dietary = empty($values['booking_dietary']) ? 'N/A' : $values['booking_dietary']; $node->booking_dietary = empty($values['booking_dietary']) ? 'N/A' : $values['booking_dietary'];
$node->booking_medical_conditions = empty($values['booking_medical_conditions']) ? 'N/A' : $values['booking_medical_conditions'];
$node->booking_mission_experience_details = empty($values['booking_mission_experience_details']) ? 'N/A' : $values['booking_mission_experience_details']; $node->booking_mission_experience_details = empty($values['booking_mission_experience_details']) ? 'N/A' : $values['booking_mission_experience_details'];
$node->booking_has_mission_experience = empty($values['booking_has_mission_experience']) ? 'N' : ($values['booking_has_mission_experience'] == 1 ? 'Y' : 'N'); $node->booking_has_mission_experience = empty($values['booking_has_mission_experience']) ? 'N' : ($values['booking_has_mission_experience'] == 1 ? 'Y' : 'N');
$node->booking_skills_builder = empty($values['booking_skills_builder']) ? 'N' : ($values['booking_skills_builder'] == 1 ? 'Y' : 'N'); $node->booking_skills_builder = empty($values['booking_skills_builder']) ? 'N' : ($values['booking_skills_builder'] == 1 ? 'Y' : 'N');
@@ -1371,12 +1372,7 @@ function booking_form_submit($form, &$form_state) {
$node->booking_skills_language_details = empty($values['booking_skills_language_details']) ? 'N/A' : $values['booking_skills_language_details']; $node->booking_skills_language_details = empty($values['booking_skills_language_details']) ? 'N/A' : $values['booking_skills_language_details'];
$node->booking_skills_other = empty($values['booking_skills_other']) ? 'N' : ($values['booking_skills_other'] == 1 ? 'Y' : 'N'); $node->booking_skills_other = empty($values['booking_skills_other']) ? 'N' : ($values['booking_skills_other'] == 1 ? 'Y' : 'N');
$node->booking_skills_other_details = empty($values['booking_skills_other_details']) ? 'N/A' : $values['booking_skills_other_details']; $node->booking_skills_other_details = empty($values['booking_skills_other_details']) ? 'N/A' : $values['booking_skills_other_details'];
$node->booking_comment_field = empty($values['booking_comment_field']) ? '' : $values['booking_comment_field'];
//remove newlines from these fields so the CSV output doesn't get messed up
$medical = empty($values['booking_medical_conditions']) ? 'N/A' : $values['booking_medical_conditions'];
$comment = empty($values['booking_comment_field']) ? '' : $values['booking_comment_field'];
$node->booking_medical_conditions = str_replace(PHP_EOL, '', $medical);
$node->booking_comment_field = str_replace(PHP_EOL, '', $comment);
//potential fields for future //potential fields for future
//$node->booking_payment_method = $payment_method; //$node->booking_payment_method = $payment_method;

View File

@@ -659,40 +659,11 @@ function booking_csv_report() {
} }
} }
//query the db
/*
$query = db_select('booking_person', 'p');
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
$query->condition('p.booking_event_id', $event->eid)
->fields('p')
->fields('pr', array('booking_price', 'booking_price_descrip'));
$result = $query->execute()->fetchAll();
*/
/*
//pivot table based on http://anothermysqldba.blogspot.de/2013/06/pivot-tables-example-in-mysql.html //pivot table based on http://anothermysqldba.blogspot.de/2013/06/pivot-tables-example-in-mysql.html
$query = db_query("select distinct p.*, s1.booking_session_id as session1, s1.booking_is_leader as session1_leader, s1.booking_is_reserveleader as session1_reserveleader, s1.booking_is_helper as session1_helper, s2.booking_session_id as session2, s2.booking_is_leader as session2_leader, s2.booking_is_reserveleader as session2_reserveleader, s2.booking_is_helper as session2_helper, s3.booking_session_id as session3, s3.booking_is_leader as session3_leader, s3.booking_is_reserveleader as session3_reserveleader, s3.booking_is_helper as session3_helper, s4.booking_session_id as session4, s4.booking_is_leader as session4_leader, s4.booking_is_reserveleader as session4_reserveleader, s4.booking_is_helper as session4_helper, s5.booking_session_id as session5, s5.booking_is_leader as session5_leader, s5.booking_is_reserveleader as session5_reserveleader, s5.booking_is_helper as session5_helper, s6.booking_session_id as session6, s6.booking_is_leader as session6_leader, s6.booking_is_reserveleader as session6_reserveleader, s6.booking_is_helper as session6_helper, s7.booking_session_id as readinggroup, s7.booking_is_leader as readinggroup_leader, s7.booking_is_reserveleader as readinggroup_reserveleader, s7.booking_is_helper as readinggroup_helper, pr.booking_price, pr.booking_price_descrip, t.* from {booking_person} p
inner join {booking_price} pr on p.booking_payment_id = pr.pid
left outer join {booking_travel} t on p.nid = t.booking_person_nid
left outer join {booking_studygroup_mapping} s1 on p.nid = s1.booking_node_id and s1.booking_studygroup_id = 1
left outer join {booking_studygroup_mapping} s2 on p.nid = s2.booking_node_id and s2.booking_studygroup_id = 2
left outer join {booking_studygroup_mapping} s3 on p.nid = s3.booking_node_id and s3.booking_studygroup_id = 3
left outer join {booking_studygroup_mapping} s4 on p.nid = s4.booking_node_id and s4.booking_studygroup_id = 4
left outer join {booking_studygroup_mapping} s5 on p.nid = s5.booking_node_id and s5.booking_studygroup_id = 5
left outer join {booking_studygroup_mapping} s6 on p.nid = s6.booking_node_id and s6.booking_studygroup_id = 6
left outer join {booking_studygroup_mapping} s7 on p.nid = s7.booking_node_id and s7.booking_studygroup_id = 7
where p.booking_event_id = :eid ORDER BY p.nid", array('eid' => $event->eid));
$result = $query->fetchAllAssoc('nid');
*/
$result = booking_load_query(NULL, TRUE); $result = booking_load_query(NULL, TRUE);
//watchdog('booking', "CSV raw data: @info", array('@info' => var_export($result, TRUE))); //watchdog('booking', "CSV raw data: @info", array('@info' => var_export($result, TRUE)));
//open the filehandle
//$handle = @fopen($filename, 'w');
//write the header based on the first result //write the header based on the first result
$header_array = array(); $header_array = array();
foreach (reset($result) as $key => $value) foreach (reset($result) as $key => $value)