add update price to current event query
This commit is contained in:
@@ -15,6 +15,7 @@ function booking_price_admin()
|
||||
|
||||
$header = array (
|
||||
'booking_price_active' => t('Active'),
|
||||
'booking_eventname' => t('Event Name'),
|
||||
'booking_eventid' => t('Event ID'),
|
||||
'booking_price_descrip' => t('Description'),
|
||||
'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, " .
|
||||
"booking_buttonid, booking_price_active, booking_depositonly, e.booking_eventname" .
|
||||
"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)
|
||||
{
|
||||
$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_price_descrip' => $data->booking_price_descrip,
|
||||
'booking_price' => $data->booking_price,
|
||||
@@ -93,23 +95,36 @@ function booking_price_admin_submit($form, &$form_state) {
|
||||
|
||||
foreach($checkboxes as $key => $value) {
|
||||
//only set the entries that are ticked
|
||||
if ($value != 0)
|
||||
{
|
||||
if ($form_state['values']['op'] == 'Set Active')
|
||||
$setting = 1;
|
||||
else
|
||||
$setting = 0;
|
||||
if ($value != 0) {
|
||||
//just update prices to match current event
|
||||
if ($form_state['values']['op'] == 'Change to current event') {
|
||||
db_update('booking_price')
|
||||
->fields(array (
|
||||
'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')
|
||||
->fields(array (
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_price_active' => $setting,
|
||||
))
|
||||
->condition('pid', $key)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
} //value not 0
|
||||
} //foreach checkbox
|
||||
} //end function
|
||||
|
||||
function booking_price_form($node, &$form_state, $create, $editid = 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user