public function index_json() { $this->db = $GLOBALS['phpgw']->db; $applications = $this->bo->read_dashboard_data($this->show_all_dashboard_applications() ? array(null, $this->current_account_id()) : array(1, $this->current_account_id())); foreach ($applications['results'] as &$application) { $application['status'] = lang($application['status']); $application['type'] = lang($application['type']); $application['created'] = pretty_timestamp($application['created']); $application['modified'] = pretty_timestamp($application['modified']); $application['frontend_modified'] = pretty_timestamp($application['frontend_modified']); $application['resources'] = $this->resource_bo->so->read(array('filters' => array('id' => $application['resources']))); $application['resources'] = $application['resources']['results']; if ($application['resources']) { $names = array(); foreach ($application['resources'] as $res) { $names[] = $res['name']; } $application['what'] = $application['resources'][0]['building_name'] . ' (' . join(', ', $names) . ')'; } $sql = "SELECT account_lastname, account_firstname FROM phpgw_accounts WHERE account_lid = '" . $application['case_officer_name'] . "'"; $this->db->query($sql); while ($record = array_shift($this->db->resultSet)) { $application['case_officer_name'] = $record['account_firstname'] . " " . $record['account_lastname']; } } array_walk($applications["results"], array($this, "_add_links"), "booking.uiapplication.show"); return $this->yui_results($applications); }
public function index_json() { $this->db = $GLOBALS['phpgw']->db; $config = CreateObject('phpgwapi.config', 'booking'); $config->read(); # if ($config->config_data['output_files'] == 'single') $export_files = $this->bo->read(); array_walk($export_files["results"], array($this, "_add_links"), $this->module . ".uicompleted_reservation_export_file.show"); foreach ($export_files["results"] as &$export_file) { $export_file['created_on'] = pretty_timestamp(substr($export_file['created_on'], 0, 19)); $export_file['type'] = lang($export_file['type']); $export_file['download'] = array('label' => lang('Download'), 'href' => $this->link_to('download', array('id' => $export_file['id']))); if ($export_file['total_items'] > 0 and !empty($export_file['log_filename'])) { $export_file['log'] = array('label' => lang('log'), 'href' => $this->link_to('log', array('id' => $export_file['id']))); } else { $export_file['log'] = array('label' => ' ', 'href' => '#'); } if ($export_file['total_items'] > 0 and $export_file['id'] > $config->config_data['invoice_last_id']) { $export_file['upload'] = array('label' => lang('Upload'), 'href' => $this->link_to('upload', array('id' => $export_file['id']))); } else { $export_file['upload'] = array('label' => ' ', 'href' => '#'); } $sql = "SELECT account_lastname, account_firstname FROM phpgw_accounts WHERE account_lid = '" . $export_file['created_by_name'] . "'"; $this->db->query($sql); while ($record = array_shift($this->db->resultSet)) { $export_file['created_by_name'] = $record['account_firstname'] . " " . $record['account_lastname']; } } $results = $this->yui_results($export_files); return $results; }
public function add_default_display_data(&$export) { $this->create_link_data_by_ref($export, 'season_id', 'season_name', lang('All'), 'season'); $this->create_link_data_by_ref($export, 'building_id', 'building_name', lang('All'), 'building'); $export['created_on'] = pretty_timestamp($export['created_on']); $export['from_'] = pretty_timestamp($export['from_']); $export['to_'] = pretty_timestamp($export['to_']); $export['index_link'] = $this->link_to('index'); $this->add_export_configurations_display_data($export); }
public function generate() { $season_id = intval(phpgw::get_var('id', 'GET')); $season = $this->bo->read_single($season_id); $this->bo->authorize_write($season); $season['buildings_link'] = self::link(array('menuaction' => 'booking.uibuilding.index')); $season['building_link'] = self::link(array('menuaction' => 'booking.uibuilding.show', 'id' => $season['building_id'])); $season['wtemplate_link'] = self::link(array('menuaction' => 'booking.uiseason.wtemplate', 'id' => $season['id'])); $result = array(); $step = 1; $errors = array(); $from_ = $season['from_']; $to_ = $season['to_']; $interval = 1; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $step = phpgw::get_var('create', 'POST') ? 3 : 2; $from = strtotime(phpgw::get_var('from_', 'POST')); $to = strtotime(phpgw::get_var('to_', 'POST')); $from_ = date("Y-m-d", $from); $to_ = date("Y-m-d", $to); $interval = phpgw::get_var('field_interval', 'POST'); if ($from_ < $season['from_']) { $errors['from_'] = lang('Start date must be after %1', pretty_timestamp($season['from_'])); } if ($to_ > $season['to_']) { $errors['to_'] = lang('To date must be before %1', pretty_timestamp($season['to_'])); } if ($errors) { $step = 1; } else { $result = $this->bo->generate_allocation($season_id, new DateTime($from_), new DateTime($to_), $interval, $step == 3); } $this->bo->so->update_id_string(); } $this->flash_form_errors($errors); self::render_template('season_generate', array('season' => $season, 'result' => $result, 'step' => $step, 'interval' => $interval, 'from_' => $from_, 'to_' => $to_)); }
public function info() { $event = $this->bo->read_single(intval(phpgw::get_var('id', 'GET'))); $resources = $this->resource_bo->so->read(array('filters' => array('id' => $event['resources']), 'sort' => 'name')); $event['resources'] = $resources['results']; $res_names = array(); foreach ($event['resources'] as $res) { $res_names[] = $res['name']; } $event['resource'] = phpgw::get_var('resource', 'GET'); $event['resource_info'] = join(', ', $res_names); $event['building_link'] = self::link(array('menuaction' => 'booking.uibuilding.show', 'id' => $event['resources'][0]['building_id'])); $event['org_link'] = self::link(array('menuaction' => 'booking.uiorganization.show', 'id' => $event['organization_id'])); $event['add_link'] = self::link(array('menuaction' => 'booking.uibooking.add', 'allocation_id' => $event['id'], 'from_' => $event['from_'], 'to_' => $event['to_'], 'resource' => $event['resource'])); $event['when'] = pretty_timestamp($event['from_']) . ' - ' . pretty_timestamp($event['to_']); $event['edit_link'] = self::link(array('menuaction' => 'booking.uievent.edit', 'id' => $event['id'])); self::render_template('event_info', array('event' => $event)); $GLOBALS['phpgw']->xslttpl->set_output('wml'); // Evil hack to disable page chrome }
public function info() { $config = CreateObject('phpgwapi.config', 'booking'); $config->read(); if ($config->config_data['user_can_delete_allocations'] != 'never') { if ($config->config_data['user_can_delete_allocations'] != 'yes') { $user_can_delete_allocations = 0; } else { $user_can_delete_allocations = 1; } } else { $user_can_delete_allocations = 2; } $allocation = $this->bo->read_single(intval(phpgw::get_var('id', 'GET'))); $resources = $this->resource_bo->so->read(array('filters' => array('id' => $allocation['resources']), 'sort' => 'name')); $allocation['resources'] = $resources['results']; $res_names = array(); foreach ($allocation['resources'] as $res) { $res_names[] = $res['name']; } $allocation['resource'] = phpgw::get_var('resource', 'GET'); $allocation['resource_info'] = join(', ', $res_names); $allocation['building_link'] = self::link(array('menuaction' => 'bookingfrontend.uibuilding.show', 'id' => $allocation['resources'][0]['building_id'])); $allocation['org_link'] = self::link(array('menuaction' => 'bookingfrontend.uiorganization.show', 'id' => $allocation['organization_id'])); $bouser = CreateObject('bookingfrontend.bouser'); if ($bouser->is_organization_admin($allocation['organization_id'])) { $allocation['add_link'] = self::link(array('menuaction' => 'bookingfrontend.uibooking.add', 'allocation_id' => $allocation['id'], 'from_' => $allocation['from_'], 'to_' => $allocation['to_'], 'resource' => $allocation['resource'])); $allocation['cancel_link'] = self::link(array('menuaction' => 'bookingfrontend.uiallocation.cancel', 'allocation_id' => $allocation['id'], 'from_' => $allocation['from_'], 'to_' => $allocation['to_'], 'resource' => $allocation['resource'])); } $allocation['when'] = pretty_timestamp($allocation['from_']) . ' - ' . pretty_timestamp($allocation['to_']); self::render_template('allocation_info', array('allocation' => $allocation, 'user_can_delete_allocations' => $user_can_delete_allocations)); $GLOBALS['phpgw']->xslttpl->set_output('wml'); // Evil hack to disable page chrome }
function send_admin_notification($booking, $maildata, $system_message, $allocation, $valid_dates = null) { if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && $GLOBALS['phpgw_info']['server']['smtp_server'])) { return; } $send = CreateObject('phpgwapi.send'); $config = CreateObject('phpgwapi.config', 'booking'); $config->read(); $from = isset($config->config_data['email_sender']) && $config->config_data['email_sender'] ? $config->config_data['email_sender'] : "noreply<noreply@{$GLOBALS['phpgw_info']['server']['hostname']}>"; $external_site_address = isset($config->config_data['external_site_address']) && $config->config_data['external_site_address'] ? $config->config_data['external_site_address'] : $GLOBALS['phpgw_info']['server']['webserver_url']; $subject = $system_message['title']; $body = '<b>Beskjed fra ' . $system_message['name'] . '</b><br />' . $system_message['message'] . '<br /><br /><b>Epost som er sendt til brukere av Hallen:</b><br />'; $mailadresses = $config->config_data['emails']; $mailadresses = explode("\n", $mailadresses); if ($maildata['outseason'] != 'on' && $maildata['recurring'] != 'on' && $maildata['delete_allocation'] != 'on' || $maildata['outseason'] != 'on' && $maildata['recurring'] != 'on' && $maildata['delete_allocation'] == 'on' && $maildata['allocation'] == 0) { $link = $external_site_address . '/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id='; $link .= $booking['building_id'] . '&building_name=' . urlencode($booking['building_name']) . '&from_[]='; $link .= urlencode($booking['from_']) . '&to_[]=' . urlencode($booking['to_']) . '&resource=' . $booking['resources'][0]; $body .= "<p>" . $config->config_data['booking_canceled_mail']; $body .= '</p><p>' . $booking['group_name'] . ' har avbestilt tid i ' . $booking['building_name'] . ':<br />'; $body .= $this->so->get_resource($booking['resources'][0]) . ' den ' . pretty_timestamp($booking['from_']); $body .= ' til ' . pretty_timestamp($booking['to_']); $body .= ' - <a href="' . $link . '">' . lang('Apply for time') . '</a></p>'; } elseif (($maildata['outseason'] == 'on' || $maildata['recurring'] == 'on') && $maildata['delete_allocation'] != 'on') { $res_names = ''; foreach ($booking['resources'] as $res) { $res_names = $res_names . $this->so->get_resource($res) . " "; } $info_deleted = ':<p>'; foreach ($valid_dates as $valid_date) { $info_deleted = $info_deleted . "" . $res_names . " - "; $info_deleted .= pretty_timestamp($valid_date['from_']) . " - "; $info_deleted .= pretty_timestamp($valid_date['to_']); $link = $external_site_address . '/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id='; $link .= $booking['building_id'] . '&building_name=' . urlencode($booking['building_name']); $link .= '&from_[]=' . urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) . '&resource=' . $booking['resources'][0]; $info_deleted .= ' - <a href="' . $link . '">' . lang('Apply for time') . '</a><br />'; } $body .= "<p>" . $config->config_data['booking_canceled_mail']; $body .= '<br />' . $booking['group_name'] . ' har avbestilt tid i ' . $booking['building_name']; $body .= $info_deleted . '</p>'; } elseif (($maildata['outseason'] == 'on' || $maildata['recurring'] == 'on') && $maildata['delete_allocation'] == 'on') { $res_names = ''; foreach ($booking['resources'] as $res) { $res_names = $res_names . $this->so->get_resource($res) . " "; } $info_deleted = ':<p>'; foreach ($valid_dates as $valid_date) { if (!in_array($valid_date, $maildata['delete'])) { $info_deleted = $info_deleted . "" . $res_names . " - "; $info_deleted .= pretty_timestamp($valid_date['from_']) . " - "; $info_deleted .= pretty_timestamp($valid_date['to_']); $link = $external_site_address . '/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id='; $link .= $booking['building_id'] . '&building_name=' . urlencode($booking['building_name']) . '&from_[]='; $link .= urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) . '&resource=' . $booking['resources'][0]; $info_deleted .= ' - <a href="' . $link . '">' . lang('Apply for time') . '</a><br />'; } } foreach ($maildata['delete'] as $valid_date) { $info_deleted = $info_deleted . "" . $res_names . " - "; $info_deleted .= pretty_timestamp($valid_date['from_']) . " - "; $info_deleted .= pretty_timestamp($valid_date['to_']); $link = $external_site_address . '/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id='; $link .= $booking['building_id'] . '&building_name=' . urlencode($booking['building_name']) . '&from_[]='; $link .= urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) . '&resource=' . $booking['resources'][0]; $info_deleted .= ' - <a href="' . $link . '">' . lang('Apply for time') . '</a><br />'; } $body .= "<p>" . $config->config_data['allocation_canceled_mail']; $body .= '<br />' . $booking['group_name'] . ' har avbestilt tid i ' . $booking['building_name']; $body .= $info_deleted . '</p>'; } else { $res_names = ''; foreach ($booking['resources'] as $res) { $res_names = $res_names . $this->so->get_resource($res) . " "; } $info_deleted = ':<p>'; foreach ($maildata['delete'] as $valid_date) { $info_deleted = $info_deleted . "" . $res_names . " - "; $info_deleted .= pretty_timestamp($allocation['from_']) . " - "; $info_deleted .= pretty_timestamp($allocation['to_']); $link = $external_site_address . '/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id='; $link .= $booking['building_id'] . '&building_name=' . urlencode($booking['building_name']); $link .= '&from_[]=' . urlencode($valid_date['from_']) . '&to_[]=' . urlencode($valid_date['to_']) . '&resource=' . $booking['resources'][0]; $info_deleted .= ' - <a href="' . $link . '">' . lang('Apply for time') . '</a><br />'; } $body .= "<p>" . $config->config_data['allocation_canceled_mail']; $body .= '<br />' . $booking['group_name'] . ' har avbestilt tid i ' . $booking['building_name']; $body .= $info_deleted . '</p>'; } $body .= "<p>" . $config->config_data['application_mail_signature'] . "</p>"; foreach ($mailadresses as $adr) { try { $send->msg('email', $adr, $subject, $body, '', '', '', $from, '', 'html'); } catch (phpmailerException $e) { // TODO: Inform user if something goes wrong } } }
/** * @ Send message about cancelation/modification on event to admins of building. */ function send_admin_notification($type, $event, $message = null, $orgdate = null) { if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && $GLOBALS['phpgw_info']['server']['smtp_server'])) { return; } $send = CreateObject('phpgwapi.send'); $config = CreateObject('phpgwapi.config', 'booking'); $config->read(); $from = isset($config->config_data['email_sender']) && $config->config_data['email_sender'] ? $config->config_data['email_sender'] : "noreply<noreply@{$GLOBALS['phpgw_info']['server']['hostname']}>"; $external_site_address = isset($config->config_data['external_site_address']) && $config->config_data['external_site_address'] ? $config->config_data['external_site_address'] : $GLOBALS['phpgw_info']['server']['webserver_url']; if (!$type) { $subject = $config->config_data['event_canceled_mail_subject']; } else { $subject = $config->config_data['event_edited_mail_subject']; } $body = '<b>Beksjed fra ' . $event['customer_organization_name'] . '</b><br />' . $message . '<br /><br/>'; $body .= '<b>Kontaktperson:</b> ' . $event['contact_name'] . '<br />'; $body .= '<b>Epost:</b> ' . $event['contact_email'] . '<br />'; $body .= '<b>Telefon:</b> ' . $event['contact_phone'] . '<br /><br />'; $body .= '<br /><b>Epost som er sendt til brukere av Hallen:</b><br />'; $mailadresses = $config->config_data['emails']; $mailadresses = explode("\n", $mailadresses); $link = $external_site_address . '/bookingfrontend/?menuaction=bookingfrontend.uibuilding.schedule&id='; $link .= $event['building_id'] . '&date=' . substr($event['from_'], 0, 10); if (!$type) { $body .= $config->config_data['event_canceled_mail_subject']; $body .= "<p>" . $config->config_data['event_canceled_mail']; } else { $body .= $config->config_data['event_edited_mail_subject']; $body .= "<p>" . $config->config_data['event_edited_mail']; } if ($_POST['org_from'] < $event['from_'] && $_POST['org_to'] == $event['to_']) { $event['from_'] = $_POST['org_from']; $event['to_'] = $event['from_']; $freetime = pretty_timestamp($event['from_']) . ' til ' . pretty_timestamp($event['to_']); } elseif ($_POST['org_from'] == $event['from_'] && $_POST['org_to'] > $event['to_']) { $event['from_'] = $event['to_']; $event['to_'] = $_POST['org_to']; $freetime = pretty_timestamp($event['from_']) . ' til ' . pretty_timestamp($event['to_']); } elseif ($_POST['org_from'] < $event['from_'] && $_POST['org_to'] > $event['to_']) { $freetime = pretty_timestamp($_POST['org_from']) . ' til ' . pretty_timestamp($event['from_']) . " og \n"; $freetime .= pretty_timestamp($event['to_']) . ' til ' . pretty_timestamp($_POST['org_to']); } else { $freetime = pretty_timestamp($event['from_']) . ' til ' . pretty_timestamp($event['to_']) . "\n"; } $body .= '</p><p>' . $event['customer_organization_name'] . ' har avbestilt tid i ' . $event['building_name'] . ':<br />'; $body .= implode(", ", $this->so->get_resources(implode(",", $event['resources']))) . ' den ' . $freetime; $body .= ' - <a href="' . $link . '">' . lang('Check calendar') . '</a></p>'; $body .= "<p>" . $config->config_data['application_mail_signature'] . "</p>"; foreach ($mailadresses as $adr) { try { $send->msg('email', $adr, $subject, $body, '', '', '', $from, '', 'html'); } catch (phpmailerException $e) { // TODO: Inform user if something goes wrong } } }
public function associated() { $associations = $this->assoc_bo->read(); foreach ($associations['results'] as &$association) { $association['from_'] = pretty_timestamp($association['from_']); $association['to_'] = pretty_timestamp($association['to_']); $association['link'] = self::link(array('menuaction' => 'booking.ui' . $association['type'] . '.edit', 'id' => $association['id'])); $association['dellink'] = self::link(array('menuaction' => 'booking.ui' . $association['type'] . '.delete', 'event_id' => $association['id'], 'application_id' => $association['application_id'])); $association['type'] = lang($association['type']); } return $this->yui_results($associations); }
private function create_body_text($from, $to, $where, $who, $id, $secret, $type, $external_site_address) { $config = CreateObject('phpgwapi.config', 'booking'); $config->read(); $body = "Informasjon om kommende arrangement:\n"; $body .= "Hvor: %WHERE%\n"; $body .= "Når: %WHEN%\n"; if (strlen($who) > 0) { $body .= "Hvem: %WHO%\n"; } if ($config->config_data['metatag_author'] != '') { $body .= "\n" . $config->config_data['metatag_author']; } else { $body .= "\nAktivby "; } $body .= " fører statistikk på bruk av lokaler og ber derfor om at dere \n"; $body .= "\netter arrangementet melder inn korrekt deltakertall til oss.\n"; $body .= "Du kan gjøre dette ved å klikke på linken nedenfor.\n\n%URL%"; $body = str_replace('%URL%', $external_site_address . '/bookingfrontend/?menuaction=bookingfrontend.ui' . $type . '.report_numbers&id=' . $id . '&secret=' . $secret, $body); $body = str_replace('%WHO%', $who, $body); $body = str_replace('%WHERE%', $where, $body); $body = str_replace('%WHEN%', pretty_timestamp($from) . ' - ' . pretty_timestamp($to), $body); return $body; }
public function info() { $config = CreateObject('phpgwapi.config', 'booking'); $config->read(); if ($config->config_data['user_can_delete_bookings'] != 'yes') { $user_can_delete_bookings = 0; } else { $user_can_delete_bookings = 1; } $event = $this->bo->read_single(intval(phpgw::get_var('id', 'GET'))); unset($event['comments']); $resources = $this->resource_bo->so->read(array('filters' => array('id' => $event['resources']), 'sort' => 'name')); if ($event['customer_organization_number'] != '') { $orginfo = $this->bo->so->get_org($event['customer_organization_number']); if ($orginfo != array()) { $event['customer_organization_id'] = $orginfo['id']; $event['customer_organization_name'] = $orginfo['name']; $orginfo['link'] = self::link(array('menuaction' => 'bookingfrontend.uiorganization.show', 'id' => $orginfo['id'])); } } else { $orginfo = array(); } $event['resources'] = $resources['results']; $res_names = array(); foreach ($event['resources'] as $res) { $res_names[] = $res['name']; } $event['resource_info'] = join(', ', $res_names); $event['building_link'] = self::link(array('menuaction' => 'bookingfrontend.uibuilding.show', 'id' => $event['resources'][0]['building_id'])); $event['when'] = pretty_timestamp($event['from_']) . ' - ' . pretty_timestamp($event['to_']); $bouser = CreateObject('bookingfrontend.bouser'); if ($bouser->is_organization_admin($event['customer_organization_id'])) { $event['edit_link'] = self::link(array('menuaction' => 'bookingfrontend.uievent.edit', 'id' => $event['id'])); $event['cancel_link'] = self::link(array('menuaction' => 'bookingfrontend.uievent.cancel', 'id' => $event['id'])); } self::render_template('event_info', array('event' => $event, 'orginfo' => $orginfo, 'user_can_delete_bookings' => $user_can_delete_bookings)); $GLOBALS['phpgw']->xslttpl->set_output('wml'); // Evil hack to disable page chrome }
public function index_json() { $start = phpgw::get_var('startIndex', 'int', 'REQUEST', 0); $results = phpgw::get_var('results', 'int', 'REQUEST', null); $query = phpgw::get_var('query'); $sort = phpgw::get_var('sort'); $dir = phpgw::get_var('dir'); /* * Due to problem on order with offset - we need to set an additional parameter in some cases * http://stackoverflow.com/questions/13580826/postgresql-repeating-rows-from-limit-offset */ switch ($sort) { case 'cost': $_sort = array('cost', 'id'); break; case 'reservation_type': $_sort = array('reservation_type', 'id'); break; case 'building_name': $_sort = array('building_name', 'id'); break; case 'organization_name': $_sort = array('organization_name', 'id'); break; case 'contact_name': $_sort = array('contact_name', 'id'); break; case 'customer_type': $_sort = array('customer_type', 'id'); break; case 'from_': $_sort = array('from_', 'id'); break; case 'to_': $_sort = array('to_', 'id'); break; case 'exported': $_sort = array('exported', 'id'); break; case 'export_file_id': $_sort = array('export_file_id', 'id'); break; default: $_sort = $sort; break; } $filters = array(); foreach ($this->bo->so->get_field_defs() as $field => $params) { if (phpgw::get_var("filter_{$field}")) { $filters[$field] = phpgw::get_var("filter_{$field}"); } } $to = strtotime(phpgw::get_var('filter_to', 'string', 'REQUEST', null)); $filter_to = date("Y-m-d", $to); if ($filter_to) { $filters['where'][] = "%%table%%" . sprintf(".to_ <= '%s 23:59:59'", $GLOBALS['phpgw']->db->db_addslashes($filter_to)); } if (!isset($GLOBALS['phpgw_info']['user']['apps']['admin']) && !$this->bo->has_role(booking_sopermission::ROLE_MANAGER)) { // users with the booking role admin should have access to all buildings $accessable_buildings = $this->bo->accessable_buildings($GLOBALS['phpgw_info']['user']['id']); // if no buildings are searched for, show all accessable buildings if (!isset($filters['building_id'])) { $filters['building_id'] = $accessable_buildings; } else { // before displaying search result, check if the building search for is accessable if (!in_array($filters['building_id'], $accessable_buildings)) { $filters['building_id'] = -1; unset($filters['building_name']); } } } if (!isset($_SESSION['showall'])) { $filters['active'] = "1"; } if (!isset($_SESSION['show_all_completed_reservations'])) { $filters['exported'] = ''; } $params = array('start' => $start, 'results' => $results, 'query' => $query, 'sort' => $_sort, 'dir' => $dir, 'filters' => $filters); $reservations = $this->bo->so->read($params); array_walk($reservations["results"], array($this, "_add_links"), $this->module . ".uicompleted_reservation.show"); foreach ($reservations["results"] as &$reservation) { if (!empty($reservation['exported'])) { $reservation['exported'] = array('href' => $this->link_to('show', array('ui' => 'completed_reservation_export', 'id' => $reservation['exported'])), 'label' => (string) $reservation['exported']); } else { $reservation['exported'] = array('label' => lang('No')); } $reservation['reservation_type'] = array('href' => $this->link_to($reservation['reservation_type'] == 'event' ? 'edit' : 'show', array('ui' => $reservation['reservation_type'], 'id' => $reservation['reservation_id'])), 'label' => lang($reservation['reservation_type'])); if (isset($reservation['export_file_id']) && !empty($reservation['export_file_id'])) { $reservation['export_file_id'] = array('label' => (string) $reservation['export_file_id'], 'href' => $this->link_to('show', array('ui' => 'completed_reservation_export_file', 'id' => $reservation['export_file_id']))); } else { $reservation['export_file_id'] = array('label' => lang("Not Generated")); } if (empty($reservation['invoice_file_order_id'])) { $reservation['invoice_file_order_id'] = lang("Not Generated"); } $this->db =& $GLOBALS['phpgw']->db; if ($reservation['reservation_type']['label'] == 'Arrangement') { $sql = "select description,contact_name from bb_event where id=" . $reservation['reservation_id']; $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1); $this->db->next_record(); $reservation['event_id'] = $reservation['reservation_id']; $reservation['description'] = $this->db->f('description', false); $reservation['contact_name'] = $this->db->f('contact_name', false); } elseif ($reservation['reservation_type']['label'] == 'Booking') { $sql = "select application_id from bb_booking where id=" . $reservation['reservation_id']; $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1); $this->db->next_record(); if (!$this->db->f('application_id', false)) { $reservation['contact_name'] = ''; } else { $sql = "select contact_name from bb_application where id=" . $this->db->f('application_id', false); $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1); $this->db->next_record(); $reservation['contact_name'] = $this->db->f('contact_name', false); } $reservation['event_id'] = ''; $reservation['description'] = ''; } else { $sql = "select application_id from bb_allocation where id=" . $reservation['reservation_id']; $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1); $this->db->next_record(); if (!$this->db->f('application_id', false)) { $reservation['contact_name'] = ''; } else { $sql = "select contact_name from bb_application where id=" . $this->db->f('application_id', false); $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1); $this->db->next_record(); $reservation['contact_name'] = $this->db->f('contact_name', false); } $reservation['event_id'] = ''; $reservation['description'] = ''; } $reservation['from_'] = substr($reservation['from_'], 0, -3); $reservation['to_'] = substr($reservation['to_'], 0, -3); $reservation['from_'] = pretty_timestamp($reservation['from_']); $reservation['to_'] = pretty_timestamp($reservation['to_']); $reservation['customer_type'] = lang($reservation['customer_type']); $this->add_current_customer_identifier_info($reservation); $reservation['customer_identifier'] = isset($reservation['customer_identifier_label']) ? $reservation['customer_identifier_value'] : lang('None'); } $results = $this->yui_results($reservations); return $results; }
public function show() { $id = intval(phpgw::get_var('id', 'GET')); $system_message = $this->bo->read_single(phpgw::get_var('id', 'GET')); $system_message['system_messages_link'] = self::link(array('menuaction' => $this->module . '.uisystem_message.index')); $system_message['system_message_link'] = self::link(array('menuaction' => $this->module . '.uisystem_message.show', 'id' => $system_message['system_message_id'])); $system_message['back_link'] = self::link(array('menuaction' => $this->module . '.uisystem_message.index')); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_POST['status'] == 'CLOSED') { $system_message['status'] = 'CLOSED'; $receipt = $this->bo->update($system_message); $this->redirect(array('menuaction' => 'booking.uisystem_message.show', 'id' => $receipt['id'], 'warnings' => $errors)); } } $system_message['created'] = pretty_timestamp($system_message['created']); $system_message['type'] = lang($system_message['type']); $system_message['status'] = lang($system_message['status']); $data = array('system_message' => $system_message); $loggedin = (int) true; // FIXME: Some sort of authentication! self::render_template('system_message', array('system_message' => $system_message, 'loggedin' => $loggedin)); }