add update price to current event query

This commit is contained in:
2017-08-22 21:18:55 +10:00
parent d9107c0d48
commit 512f863058

View File

@@ -15,6 +15,7 @@ function booking_price_admin()
$header = array ( $header = array (
'booking_price_active' => t('Active'), 'booking_price_active' => t('Active'),
'booking_eventname' => t('Event Name'),
'booking_eventid' => t('Event ID'), 'booking_eventid' => t('Event ID'),
'booking_price_descrip' => t('Description'), 'booking_price_descrip' => t('Description'),
'booking_price' => t('Early-Bird Price'), 'booking_price' => t('Early-Bird Price'),
@@ -28,13 +29,14 @@ function booking_price_admin()
$result = db_query("SELECT pid, p.booking_eventid, booking_price, booking_late_price, booking_late_buttonid, booking_price_descrip, " . $result = db_query("SELECT pid, p.booking_eventid, booking_price, booking_late_price, booking_late_buttonid, booking_price_descrip, " .
"booking_buttonid, booking_price_active, booking_depositonly, e.booking_eventname" . "booking_buttonid, booking_price_active, booking_depositonly, e.booking_eventname" .
"from {booking_price} p " . "from {booking_price} p " .
"inner join {booking_event} e on e.booking_eventid = p.booking_eventid"); "inner join {booking_event} e on e.eid = p.booking_eventid");
foreach($result as $data) foreach($result as $data)
{ {
$options[$data->pid] = array $options[$data->pid] = array
( (
'booking_price_active' => $data->booking_price_active == 1 ? 'Yes' : 'No', 'booking_price_active' => $data->booking_price_active == 1 ? 'Yes' : 'No',
'booking_eventname' => $data->booking_eventname,
'booking_eventid' => $data->booking_eventid, 'booking_eventid' => $data->booking_eventid,
'booking_price_descrip' => $data->booking_price_descrip, 'booking_price_descrip' => $data->booking_price_descrip,
'booking_price' => $data->booking_price, 'booking_price' => $data->booking_price,
@@ -93,23 +95,36 @@ function booking_price_admin_submit($form, &$form_state) {
foreach($checkboxes as $key => $value) { foreach($checkboxes as $key => $value) {
//only set the entries that are ticked //only set the entries that are ticked
if ($value != 0) if ($value != 0) {
{ //just update prices to match current event
if ($form_state['values']['op'] == 'Set Active') if ($form_state['values']['op'] == 'Change to current event') {
$setting = 1; db_update('booking_price')
else ->fields(array (
$setting = 0; 'booking_eventid' => $event->eid,
))
->condition('pid', $key)
->execute();
}
//either make a price active or inactive
else {
if ($form_state['values']['op'] == 'Set Active') {
$setting = 1;
}
else {
$setting = 0;
}
db_update('booking_price')
->fields(array (
'booking_eventid' => $event->eid,
'booking_price_active' => $setting,
))
->condition('pid', $key)
->execute();
}
db_update('booking_price') } //value not 0
->fields(array ( } //foreach checkbox
'booking_eventid' => $event->eid, } //end function
'booking_price_active' => $setting,
))
->condition('pid', $key)
->execute();
}
}
}
function booking_price_form($node, &$form_state, $create, $editid = 0) function booking_price_form($node, &$form_state, $create, $editid = 0)
{ {