public function edit()
 {
     date_default_timezone_set("Europe/Oslo");
     $date = new DateTime(phpgw::get_var('date'));
     $system_message = array();
     $system_message['building_id'] = intval(phpgw::get_var('building_id', 'GET'));
     $system_message['building_name'] = phpgw::get_var('building_name', 'GET');
     $system_message['cancel_link'] = self::link(array('menuaction' => $this->module . '.uisearch.index'));
     $system_message['created'] = $date->format('Y-m-d  H:m');
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $system_message = array_merge($system_message, extract_values($_POST, array('time', 'title', 'message', 'name', 'phone', 'email')));
         if ($system_message['message'] == '') {
             $errors['system_message'] = lang('Missing title');
         } elseif ($system_message['title'] == '') {
             $errors['system_message'] = lang('Missing message');
         } elseif ($system_message['name'] == '') {
             $errors['system_message'] = lang('Missing name');
         }
         if (!$errors) {
             $system_message['title'] = $system_message['building_name'] . " - " . $system . $system_message['title'];
             $receipt = $this->bo->add($system_message);
             $this->redirect(array('menuaction' => $this->module . '.uibuilding.show.index', 'id' => $system_message['building_id']));
         }
     }
     $this->flash_form_errors($errors);
     $this->use_yui_editor();
     self::render_template('system_message', array('system_message' => $system_message));
 }
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $resource = $this->bo->read_single($id);
     $resource['id'] = $id;
     $resource['building_link'] = self::link(array('menuaction' => 'booking.uibuilding.show', 'id' => $resource['id']));
     $resource['buildings_link'] = self::link(array('menuaction' => 'booking.uibuilding.index'));
     $resource['cancel_link'] = self::link(array('menuaction' => 'booking.uiresource.index'));
     $resource['types'] = $this->resource_types();
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $resource = array_merge($resource, extract_values($_POST, $this->fields));
         $errors = $this->bo->validate($resource);
         if (!$errors) {
             $receipt = $this->bo->update($resource);
             $this->redirect(array('menuaction' => 'booking.uiresource.show', 'id' => $resource['id']));
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'resource_new.js');
     phpgwapi_yui::load_widget('datatable');
     phpgwapi_yui::load_widget('autocomplete');
     $activity_data = $this->activity_bo->fetch_activities();
     foreach ($activity_data['results'] as $acKey => $acValue) {
         $activity_data['results'][$acKey]['resource_id'] = $resource['activity_id'];
     }
     $this->use_yui_editor();
     self::render_template('resource_form', array('resource' => $resource, 'activitydata' => $activity_data));
 }
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     if ($id) {
         $person = $this->bo->read_single($id);
         $person['id'] = $id;
         $person['contactpersons_link'] = self::link(array('menuaction' => 'booking.uicontactperson.index'));
         $person['edit_link'] = self::link(array('menuaction' => 'booking.uicontactperson.edit', 'id' => $person['id']));
     } else {
         $person = array();
     }
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $person = array_merge($person, extract_values($_POST, array('ssn', 'name', 'homepage', 'phone', 'email', 'description')));
         $errors = $this->bo->validate($person);
         if (!$errors) {
             if ($id) {
                 $receipt = $this->bo->update($person);
             } else {
                 $receipt = $this->bo->add($person);
             }
             $this->redirect(array('menuaction' => $this->module . '.uicontactperson.show', 'id' => $receipt['id']));
         }
     }
     $this->flash_form_errors($errors);
     self::add_stylesheet('phpgwapi/js/yahoo/assets/skins/sam/skin.css');
     self::add_javascript('yahoo', 'yahoo/yahoo-dom-event', 'yahoo-dom-event.js');
     self::add_javascript('yahoo', 'yahoo/element', 'element-min.js');
     self::add_javascript('yahoo', 'yahoo/dom', 'dom-min.js');
     self::add_javascript('yahoo', 'yahoo/container', 'container_core-min.js');
     self::add_javascript('yahoo', 'yahoo/editor', 'simpleeditor-min.js');
     self::add_template_file("contactperson_fields");
     self::render_template('contactperson_edit', array('person' => $person));
 }
Exemplo n.º 4
0
 function generate_allocation($season_id, $date, $to, $interval, $write = false)
 {
     $season = $this->so->read_single($season_id);
     $this->authorize_write($season_id);
     $valid = array();
     $invalid = array();
     do {
         $wday = $date->format('N');
         $tallocations = $this->so_wtemplate_alloc->read(array('filters' => array('season_id' => $season_id, 'wday' => $wday), 'sort' => 'from_'));
         foreach ($tallocations['results'] as $talloc) {
             $allocation = extract_values($talloc, array('season_id', 'organization_id', 'cost', 'resources', 'organization_name'));
             $allocation['active'] = '1';
             $allocation['from_'] = $date->format("Y-m-d") . ' ' . $talloc['from_'];
             $allocation['to_'] = $date->format("Y-m-d") . ' ' . $talloc['to_'];
             $allocation['building_name'] = $season['building_name'];
             $allocation['completed'] = 1;
             $errors = $this->bo_allocation->validate($allocation);
             if (!$errors) {
                 $valid[] = $allocation;
             } elseif (count($this->bo_allocation->filter_conflict_errors($errors)) === 0) {
                 $invalid[] = $allocation;
             } else {
                 throw new UnexpectedValueException('Encountered an unexpected validation error');
             }
         }
         if ($date->format('N') == 7) {
             if ($interval == 2) {
                 $date->modify('+7 days');
             } elseif ($interval == 3) {
                 $date->modify('+14 days');
             } elseif ($interval == 4) {
                 $date->modify('+21 days');
             }
         }
         $date->modify('+1 day');
         if ($date->format('Y-m-d') > $to->format('Y-m-d')) {
             if ($write) {
                 $this->so->db->transaction_begin();
                 foreach ($valid as $alloc) {
                     $this->bo_allocation->add($alloc);
                 }
                 $this->so->db->transaction_commit();
             }
             return array('valid' => $valid, 'invalid' => $invalid);
         }
     } while (true);
 }
Exemplo n.º 5
0
<?php

require_once 'includes/allspells.php';
require_once 'includes/allreputation.php';
$smarty->config_load($conf_file, 'spell');
@(list($s1, $s2, $s3) = extract_values($podrazdel));
$cache_key = cache_key($s1, $s2, $s3);
if (!($spells = load_cache(SPELL_LISTING, $cache_key))) {
    unset($spells);
    $spells = array();
    if ($s1 == 7) {
        // Классовые
        $title = $smarty->get_config_vars('Class_spells');
        $rows = $DB->select('
				SELECT ?#, s.`spellID`, sla.skillID
				FROM ?_spell s, ?_skill_line_ability sla, ?_spellicons i
				WHERE
					s.spellID = sla.spellID
					AND s.levelspell > 0
					AND i.id=s.spellicon
					{AND sla.classmask & ?d}
					{AND sla.skillID=?d}
				ORDER BY s.levelspell
				{LIMIT ?d}
			', $spell_cols[2], isset($s2) ? pow(2, $s2 - 1) : DBSIMPLE_SKIP, isset($s3) ? $s3 : DBSIMPLE_SKIP, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP);
    } elseif ($s1 > 0) {
        switch ($s1) {
            case 6:
                $title = $smarty->get_config_vars('Weapon_spells');
                break;
            case 8:
 protected function extract_form_data($defaults = array())
 {
     $organization = array_merge($defaults, extract_values($_POST, $this->fields));
     $this->extract_customer_identifier($organization);
     return $organization;
 }
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $building = $this->bo->read_single($id);
     $building['id'] = $id;
     $building['buildings_link'] = self::link(array('menuaction' => 'booking.uibuilding.index'));
     $building['cancel_link'] = self::link(array('menuaction' => 'booking.uibuilding.show', 'id' => $building['id']));
     $building['top-nav-bar-buildings'] = lang('Buildings');
     $config = CreateObject('phpgwapi.config', 'booking');
     $config->read();
     if ($config->config_data['extra_schedule'] == 'yes') {
         $building['extra'] = 1;
     } else {
         $building['extra'] = 0;
     }
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $building = array_merge($building, extract_values($_POST, $this->fields));
         $errors = $this->bo->validate($building);
         if (!$errors) {
             $receipt = $this->bo->update($building);
             $this->redirect(array('menuaction' => 'booking.uibuilding.show', 'id' => $receipt['id']));
         }
     }
     $this->flash_form_errors($errors);
     $this->use_yui_editor();
     self::render_template('building_form', array('building' => $building));
 }
Exemplo n.º 8
0
 public function check_active($url)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $activate = extract_values($_POST, array("status", "activate_id"));
         $this->bo->set_active(intval($activate['activate_id']), intval($activate['status']));
         $this->redirect(array('menuaction' => $url, 'id' => $activate['activate_id']));
     }
 }
Exemplo n.º 9
0
 protected function extract_form_data($defaults = array())
 {
     $entity = array_merge($defaults, extract_values($_POST, $this->fields));
     $this->agegroup_bo->extract_form_data($entity);
     $this->extract_customer_identifier($entity);
     return $entity;
 }
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $document = $this->bo->read_single($id);
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $document = array_merge($document, extract_values($_POST, $this->fields));
         $errors = $this->bo->validate($document);
         if (!$errors) {
             $receipt = $this->bo->update($document);
             $this->redirect('booking.uidocumentation.index');
         }
     }
     self::add_javascript('booking', 'booking', 'document.js');
     $this->flash_form_errors($errors);
     $this->add_default_display_data($document);
     self::render_template('documentation_form', array('document' => $document));
 }
Exemplo n.º 11
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $activity = $this->bo->read_single($id);
     $parent_activity = $this->bo->read_single($activity['parent_id']);
     $activities = $this->bo->fetch_activities();
     $activities = $activities['results'];
     $activity['id'] = $id;
     $activity['activities_link'] = self::link(array('menuaction' => 'booking.uiactivity.index'));
     $activity['building_link'] = self::link(array('menuaction' => 'booking.uibuilding.index'));
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if ($_POST['parent_id'] == '0') {
             $_POST['parent_id'] = null;
         }
         $activity = array_merge($activity, extract_values($_POST, array('name', 'active', 'description', 'parent_id')));
         $errors = $this->bo->validate($activity);
         if (!$errors) {
             $receipt = $this->bo->update($activity);
             $this->redirect(array('menuaction' => 'booking.uiactivity.index'));
         }
     }
     $this->flash_form_errors($errors);
     $activity['cancel_link'] = self::link(array('menuaction' => 'booking.uiactivity.index'));
     self::render_template('activity_edit', array('activity' => $activity, 'parent' => $parent_activity, 'activities' => $activities));
 }
Exemplo n.º 12
0
<?php

// Необходима функция iteminfo
require_once 'includes/allitems.php';
$smarty->config_load($conf_file, 'items');
// Разделяем из запроса класс, подкласс и тип вещей
@(list($class, $subclass, $type) = extract_values($podrazdel));
$cache_key = cache_key($class, $subclass, $type);
if (!($items = load_cache(7, $cache_key))) {
    unset($items);
    // Составляем запрос к БД, выполняющий поиск по заданным классу и подклассу
    $rows = $DB->select('
		SELECT ?#, i.entry, maxcount
			{, l.name_loc?d AS name_loc}
		FROM ?_icons, item_template i
			{LEFT JOIN (locales_item l) ON l.entry=i.entry AND ?d}
		WHERE
			id=displayid
			{ AND class = ? }
			{ AND subclass = ? }
			{ AND InventoryType = ? }
		ORDER BY quality DESC, name
		{ LIMIT ?d }
		', $item_cols[2], $_SESSION['locale'] ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] ? 1 : DBSIMPLE_SKIP, isset($class) ? $class : DBSIMPLE_SKIP, isset($subclass) ? $subclass : DBSIMPLE_SKIP, isset($type) ? $type : DBSIMPLE_SKIP, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP);
    $items = array();
    foreach ($rows as $row) {
        $items[] = iteminfo2($row);
    }
    save_cache(7, $cache_key, $items);
}
global $page;
Exemplo n.º 13
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $audience = $this->bo->read_single($id);
     $audience['id'] = $id;
     $audience['resource_link'] = self::link(array('menuaction' => 'booking.uiaudience.show', 'id' => $audience['id']));
     $audience['resources_link'] = self::link(array('menuaction' => 'booking.uiresource.index'));
     $audience['audience_link'] = self::link(array('menuaction' => 'booking.uiaudience.index'));
     $audience['building_link'] = self::link(array('menuaction' => 'booking.uibuilding.index'));
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $audience = array_merge($audience, extract_values($_POST, array('name', 'sort', 'description', 'active')));
         $errors = $this->bo->validate($audience);
         if (!$errors) {
             $audience = $this->bo->update($audience);
             $this->redirect(array('menuaction' => 'booking.uiaudience.index', 'id' => $audience['id']));
         }
     }
     $this->flash_form_errors($errors);
     $audience['cancel_link'] = self::link(array('menuaction' => 'booking.uiaudience.index'));
     self::render_template('audience_edit', array('audience' => $audience));
 }
Exemplo n.º 14
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     if ($id) {
         $group = $this->bo->read_single($id);
         $group['id'] = $id;
         $group['organization_link'] = $this->link_to('show', array('ui' => 'organization', 'id' => $group['organization_id']));
         $group['cancel_link'] = $this->link_to('show', array('id' => $id));
         if ($this->is_inline()) {
             $group['cancel_link'] = $this->link_to_parent();
         }
     } else {
         $group = array();
         $group['cancel_link'] = $this->link_to('index', array('ui' => 'organization'));
         if ($this->is_inline()) {
             $group['organization_link'] = $this->link_to_parent();
             $group['cancel_link'] = $this->link_to_parent();
             $this->apply_inline_params($group);
         }
     }
     $group['organizations_link'] = $this->link_to('index', array('ui' => 'organization'));
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $group = array_merge($group, extract_values($_POST, array('name' => 'string', 'shortname' => 'string', 'organization_id' => 'string', 'organization_name' => 'string', 'description' => 'html', 'contacts' => 'string', 'active' => 'int', 'activity_id' => 'int', 'show_in_portal' => 'int')));
         if (!isset($group["active"])) {
             $group['active'] = '1';
         }
         $errors = $this->bo->validate($group);
         if (strlen($_POST['name']) > 50) {
             $errors['name'] = lang('Lengt of name is to long, max 50 characters long');
         }
         if (strlen($_POST['shortname']) > 11) {
             $errors['shortname'] = lang('Lengt of shortname is to long, max 11 characters long');
         }
         if (!$errors) {
             if ($id) {
                 $receipt = $this->bo->update($group);
             } else {
                 $receipt = $this->bo->add($group);
             }
             $this->redirect_to_parent_if_inline();
             $this->redirect($this->link_to_params('show', array('id' => $receipt['id'])));
         }
     }
     $this->flash_form_errors($errors);
     if (is_array($parent_entity = $this->get_parent_if_inline())) {
         $group[$this->get_current_parent_type() . '_id'] = $parent_entity['id'];
         $group[$this->get_current_parent_type() . '_name'] = $parent_entity['name'];
     }
     $this->use_yui_editor();
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     self::render_template('group_edit', array('group' => $group, 'module' => $this->module, 'activities' => $activities));
 }
 public function add()
 {
     $errors = array();
     $permission = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $permission = extract_values($_POST, $this->fields);
         $errors = $this->bo->validate($permission);
         if (!$errors) {
             $receipt = $this->bo->add($permission);
             $this->redirect($this->generate_link_params('index'));
         }
     }
     self::add_javascript('booking', 'booking', 'permission_root.js');
     $this->add_default_display_data($permission);
     $this->flash_form_errors($errors);
     self::render_template('permission_root_form', array('permission' => $permission));
 }
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $allocation = $this->bo->read_single($id);
     $allocation['building'] = $this->building_bo->so->read_single($allocation['building_id']);
     $allocation['building_name'] = $allocation['building']['name'];
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         array_set_default($_POST, 'resources', array());
         $allocation = array_merge($allocation, extract_values($_POST, $this->fields));
         $organization = $this->organization_bo->read_single(intval(phpgw::get_var('organization_id', 'POST')));
         $errors = $this->bo->validate($allocation);
         if (!$errors) {
             try {
                 $receipt = $this->bo->update($allocation);
                 $this->bo->so->update_id_string();
                 $this->send_mailnotification_to_organization($organization, lang('Allocation changed'), phpgw::get_var('mail', 'POST'));
                 $this->redirect(array('menuaction' => 'booking.uiallocation.show', 'id' => $allocation['id']));
             } catch (booking_unauthorized_exception $e) {
                 $errors['global'] = lang('Could not update object due to insufficient permissions');
             }
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'allocation.js');
     $allocation['resources_json'] = json_encode(array_map('intval', $allocation['resources']));
     $allocation['cancel_link'] = self::link(array('menuaction' => 'booking.uiallocation.show', 'id' => $allocation['id']));
     $allocation['application_link'] = self::link(array('menuaction' => 'booking.uiapplication.show', 'id' => $allocation['application_id']));
     self::render_template('allocation_edit', array('allocation' => $allocation));
 }
Exemplo n.º 17
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $document = $this->bo->read_single($id);
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $document = array_merge($document, extract_values($_POST, $this->fields));
         $errors = $this->bo->validate($document);
         if (!$errors) {
             try {
                 $receipt = $this->bo->update($document);
                 $this->redirect_to_parent_if_inline();
                 $this->redirect($this->get_owner_typed_link_params('index'));
             } catch (booking_unauthorized_exception $e) {
                 $errors['global'] = lang('Could not update object due to insufficient permissions');
             }
         }
     }
     self::add_javascript('booking', 'booking', 'document.js');
     $this->add_default_display_data($document);
     $this->flash_form_errors($errors);
     self::render_template('document_form', array('document' => $document));
 }
Exemplo n.º 18
0
<?php

// Необходима функция questinfo
require_once 'includes/allquests.php';
$smarty->config_load($conf_file, 'quest');
// Разделяем из запроса класс и подкласс квестов
@(list($Type, $ZoneOrSort) = extract_values($podrazdel));
$cache_key = cache_key($Type, $ZoneOrSort);
if (!($quests = load_cache(QUEST_LISTING, $cache_key))) {
    unset($quests);
    $rows = $DB->select("\n\t\tSELECT q.?#\n\t\t{\n\t\t\t, l.Title_loc?d AS Title_loc\n\t\t}\n\t\tFROM quest_template q\n\t\t{ LEFT JOIN (locales_quest l) ON l.entry=q.entry AND ? }\n\t\tWHERE\n\t\t\t1 = 1\n\t\t\t{ AND ZoneOrSort = ? }\n\t\t\t{ AND ZoneOrSort IN (?a) }\n\t\t\tAND q.Title NOT IN ('','----','?????')\n\t\t\tAND q.Title NOT LIKE '<DEPRECATED>%'\n\t\t\tAND q.Title NOT LIKE '<NYI>%'\n\t\t\tAND q.Title NOT LIKE '<nyi>%'\n\t\t\tAND q.Title NOT LIKE '<TEST>%'\n\t\t\tAND q.Title NOT LIKE '<TXT>%'\n\t\t\tAND q.Title NOT LIKE '<UNUSED%'\n\t\tORDER BY Title\n\t\t{LIMIT ?d}\n\t\t", $quest_cols[2], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, isset($ZoneOrSort) ? $ZoneOrSort : DBSIMPLE_SKIP, !isset($ZoneOrSort) && isset($Type) ? $quest_class[$Type] : DBSIMPLE_SKIP, $AoWoWconf['limit'] > 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP);
    $quests = array();
    foreach ($rows as $row) {
        $quests[] = GetQuestInfo($row, QUEST_DATAFLAG_LISTINGS);
    }
    save_cache(QUEST_LISTING, $cache_key, $quests);
}
if (!($quests_tot = load_cache(QUEST_TOT, 'quest_tot'))) {
    unset($quests_tot);
    $quests_tot = $DB->select("\n\t\tSELECT COUNT(q.entry) as quest_tot\n\t\tFROM quest_template q\n\t\tWHERE\n\t\t\tq.Title NOT IN ('','----','?????')\n\t\t\tAND q.Title NOT LIKE '<DEPRECATED>%'\n\t\t\tAND q.Title NOT LIKE '<NYI>%'\n\t\t\tAND q.Title NOT LIKE '<nyi>%'\n\t\t\tAND q.Title NOT LIKE '<TEST>%'\n\t\t\tAND q.Title NOT LIKE '<TXT>%'\n\t\t\tAND q.Title NOT LIKE '<UNUSED%'\n\t\t");
    save_cache(QUEST_LISTING, 'quest_tot', $quests_tot[0]['quest_tot']);
}
global $page;
$page = array('Mapper' => false, 'Book' => false, 'Title' => $smarty->get_config_vars('Quests'), 'tab' => 0, 'type' => 0, 'typeid' => 0, 'path' => path(0, 3, $Type, $ZoneOrSort));
$smarty->assign('page', $page);
$smarty->assign('quests', $quests);
$smarty->assign('quests_tot', is_array($quests_tot) ? $quests_tot[0]['quest_tot'] : $quests_tot);
// Количество MySQL запросов
$smarty->assign('mysql', $DB->getStatistics());
// Загружаем страницу
$smarty->display('quests.tpl');
Exemplo n.º 19
0
<?php

require_once 'includes/allachievements.php';
$smarty->config_load($conf_file, 'achievement');
@(list($category) = extract_values($podrazdel));
$cache_key = cache_key($category);
if (!($achievements = load_cache(24, $cache_key))) {
    unset($achievements);
    $rows = $DB->select('
			SELECT a.id, a.faction, a.name_loc?d AS name, a.description_loc?d AS description, a.category, a.points, s.iconname, z.areatableID
			FROM ?_spellicons s, ?_achievement a
			LEFT JOIN (?_zones z) ON a.map != -1 AND a.map = z.mapID
			WHERE
				a.icon = s.id
				{ AND a.category = ? }
			GROUP BY a.id
			ORDER BY a.`order` ASC
		', $_SESSION['locale'], $_SESSION['locale'], isset($category) ? $category : DBSIMPLE_SKIP);
    if ($rows) {
        $achievements = array();
        $achievements['data'] = array();
        foreach ($rows as $row) {
            $achievements['data'][] = achievementinfo2($row);
        }
        if (isset($category)) {
            $catrow = $DB->selectRow('
					SELECT c1.id, c1.name_loc?d AS name, c2.id AS id2
					FROM ?_achievementcategory c1
					LEFT JOIN (?_achievementcategory c2) ON c1.parentAchievement != -1 AND c1.parentAchievement = c2.id
					WHERE
						c1.id = ?
 public function cancel()
 {
     $config = CreateObject('phpgwapi.config', 'booking');
     $config->read();
     if ($config->config_data['user_can_delete_allocations'] != 'yes') {
         $allocation = $this->bo->read_single(intval(phpgw::get_var('allocation_id', 'GET')));
         $organization = $this->organization_bo->read_single($allocation['organization_id']);
         $errors = array();
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $outseason = $_POST['outseason'];
             $recurring = $_POST['recurring'];
             $repeat_until = $_POST['repeat_until'];
             $field_interval = $_POST['field_interval'];
             $maildata = array();
             $maildata['outseason'] = $outseason;
             $maildata['recurring'] = $recurring;
             $maildata['repeat_until'] = $repeat_until;
             $maildata['field_interval'] = $field_interval;
             date_default_timezone_set("Europe/Oslo");
             $date = new DateTime(phpgw::get_var('date'));
             $system_message = array();
             $system_message['building_id'] = intval($allocation['building_id']);
             $system_message['building_name'] = $this->bo->so->get_building($system_message['building_id']);
             $system_message['created'] = $date->format('Y-m-d  H:m');
             $system_message = array_merge($system_message, extract_values($_POST, array('message')));
             $system_message['type'] = 'cancelation';
             $system_message['status'] = 'NEW';
             $system_message['name'] = $allocation['organization_name'] . ' - ' . $organization['contacts'][0]['name'];
             $system_message['phone'] = $organization['contacts'][0]['phone'];
             $system_message['email'] = $organization['contacts'][0]['email'];
             $system_message['title'] = lang('Cancelation of allocation from') . " " . $allocation['organization_name'];
             $link = self::link(array('menuaction' => 'booking.uiallocation.delete', 'allocation_id' => $allocation['id'], 'outseason' => $outseason, 'recurring' => $recurring, 'repeat_until' => $repeat_until, 'field_interval' => $field_interval));
             if (strpos($link, '/portico/bookingfrontend') !== false) {
                 $link = mb_strcut($link, 24, strlen($link));
                 $link = "/portico" . $link;
             } else {
                 $link = mb_strcut($link, 16, strlen($link));
             }
             $system_message['link'] = $link;
             $system_message['message'] = $system_message['message'] . "<br /><br />" . lang('To cancel allocation use this link') . " - <a href='" . $link . "'>" . lang('Delete') . "</a>";
             $this->bo->send_admin_notification($allocation, $maildata, $system_message);
             $this->system_message_bo->add($system_message);
             $this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $system_message['building_id']));
         }
         $this->flash_form_errors($errors);
         $allocation['cancel_link'] = self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $allocation['building_id']));
         $this->use_yui_editor();
         self::render_template('allocation_cancel', array('allocation' => $allocation));
     } else {
         $id = intval(phpgw::get_var('allocation_id', 'GET'));
         $from_date = phpgw::get_var('from_', 'GET');
         $to_date = phpgw::get_var('to_', 'GET');
         $outseason = phpgw::get_var('outseason', 'GET');
         $recurring = phpgw::get_var('recurring', 'GET');
         $repeat_until = phpgw::get_var('repeat_until', 'GET');
         $field_interval = intval(phpgw::get_var('field_interval', 'GET'));
         $allocation = $this->bo->read_single($id);
         $organization = $this->organization_bo->read_single($allocation['organization_id']);
         $season = $this->season_bo->read_single($allocation['season_id']);
         $step = phpgw::get_var('step', 'str', 'POST');
         if (!isset($step)) {
             $step = 1;
         }
         $errors = array();
         $invalid_dates = array();
         $valid_dates = array();
         if ($config->config_data['split_pool'] == 'yes') {
             $split = 1;
         } else {
             $split = 0;
         }
         $resources = $allocation['resources'];
         $activity = $this->organization_bo->so->get_resource_activity($resources);
         $mailadresses = $this->building_users($allocation['building_id'], $split, $activity);
         $maildata = array();
         $maildata['outseason'] = $outseason;
         $maildata['recurring'] = $recurring;
         $maildata['repeat_until'] = $repeat_until;
         $maildata['field_interval'] = $field_interval;
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $from_date = $_POST['from_'];
             $to_date = $_POST['to_'];
             if ($_POST['recurring'] != 'on' && $_POST['outseason'] != 'on') {
                 $err = $this->bo->so->check_for_booking($id);
                 if ($err) {
                     $errors['booking'] = lang('Could not delete allocation due to a booking still use it');
                 } else {
                     $res_names = '';
                     date_default_timezone_set("Europe/Oslo");
                     $date = new DateTime(phpgw::get_var('date'));
                     $system_message = array();
                     $system_message['building_id'] = intval($allocation['building_id']);
                     $system_message['building_name'] = $this->bo->so->get_building($system_message['building_id']);
                     $system_message['created'] = $date->format('Y-m-d  H:m');
                     $system_message = array_merge($system_message, extract_values($_POST, array('message')));
                     $system_message['type'] = 'cancelation';
                     $system_message['status'] = 'NEW';
                     $system_message['name'] = $allocation['organization_name'] . ' - ' . $organization['contacts'][0]['name'];
                     $system_message['phone'] = $organization['contacts'][0]['phone'];
                     $system_message['email'] = $organization['contacts'][0]['email'];
                     $system_message['title'] = lang('Cancelation of allocation from') . " " . $allocation['organization_name'];
                     foreach ($allocation['resources'] as $res) {
                         $res_names = $res_names . $this->bo->so->get_resource($res) . " ";
                     }
                     $info_deleted = lang("Allocation deleted on") . " " . $system_message['building_name'] . ":<br />" . $res_names . " - " . pretty_timestamp($allocation['from_']) . " - " . pretty_timestamp($allocation['to_']);
                     $system_message['message'] = $system_message['message'] . "<br />" . $info_deleted;
                     $this->system_message_bo->add($system_message);
                     $this->bo->send_admin_notification($allocation, $maildata, $system_message);
                     $this->bo->send_notification($allocation, $maildata, $mailadresses);
                     $this->bo->so->delete_allocation($id);
                     $this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $allocation['building_id']));
                 }
             } else {
                 $step++;
                 if ($_POST['recurring'] == 'on') {
                     $repeat_until = strtotime($_POST['repeat_until']) + 60 * 60 * 24;
                 } else {
                     $repeat_until = strtotime($season['to_']) + 60 * 60 * 24;
                     $_POST['repeat_until'] = $season['to_'];
                 }
                 $max_dato = strtotime($_POST['to_']);
                 // highest date from input
                 $interval = $_POST['field_interval'] * 60 * 60 * 24 * 7;
                 // weeks in seconds
                 $i = 0;
                 // calculating valid and invalid dates from the first booking's to-date to the repeat_until date is reached
                 // the form from step 1 should validate and if we encounter any errors they are caused by double bookings.
                 while ($max_dato + $interval * $i <= $repeat_until) {
                     $fromdate = date('Y-m-d H:i', strtotime($_POST['from_']) + $interval * $i);
                     $todate = date('Y-m-d H:i', strtotime($_POST['to_']) + $interval * $i);
                     $allocation['from_'] = $fromdate;
                     $allocation['to_'] = $todate;
                     $id = $this->bo->so->get_allocation_id($allocation);
                     if ($id) {
                         $err = $this->bo->so->check_for_booking($id);
                     } else {
                         $err = true;
                     }
                     if ($err) {
                         $invalid_dates[$i]['from_'] = $fromdate;
                         $invalid_dates[$i]['to_'] = $todate;
                     } else {
                         $valid_dates[$i]['from_'] = $fromdate;
                         $valid_dates[$i]['to_'] = $todate;
                         if ($step == 3) {
                             $this->bo->so->delete_allocation($id);
                         }
                     }
                     $i++;
                 }
                 if ($step == 3) {
                     $maildata = array();
                     $maildata['outseason'] = phpgw::get_var('outseason', 'GET');
                     $maildata['recurring'] = phpgw::get_var('recurring', 'GET');
                     $maildata['repeat_until'] = phpgw::get_var('repeat_until', 'GET');
                     $maildata['delete'] = $valid_dates;
                     $res_names = '';
                     date_default_timezone_set("Europe/Oslo");
                     $date = new DateTime(phpgw::get_var('date'));
                     $system_message = array();
                     $system_message['building_id'] = intval($allocation['building_id']);
                     $system_message['building_name'] = $this->bo->so->get_building($system_message['building_id']);
                     $system_message['created'] = $date->format('Y-m-d  H:m');
                     $system_message = array_merge($system_message, extract_values($_POST, array('message')));
                     $system_message['type'] = 'cancelation';
                     $system_message['status'] = 'NEW';
                     $system_message['name'] = ' ';
                     $system_message['phone'] = ' ';
                     $system_message['email'] = ' ';
                     $system_message['title'] = lang('Cancelation of allocation from') . " " . $allocation['organization_name'];
                     foreach ($allocation['resources'] as $res) {
                         $res_names = $res_names . $this->bo->so->get_resource($res) . " ";
                     }
                     $info_deleted = lang("Allocations deleted on ") . $system_message['building_name'] . ":<br />";
                     foreach ($valid_dates as $valid_date) {
                         $info_deleted = $info_deleted . "<br />" . $res_names . " - " . pretty_timestamp($valid_date['from_']) . " - " . pretty_timestamp($valid_date['to_']);
                     }
                     $system_message['message'] = $system_message['message'] . "<br />" . $info_deleted;
                     $this->bo->send_admin_notification($allocation, $maildata, $system_message);
                     $this->bo->send_notification($allocation, $maildata, $mailadresses);
                     $this->system_message_bo->add($system_message);
                     $this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $allocation['building_id']));
                 }
             }
         }
         $this->flash_form_errors($errors);
         self::add_javascript('booking', 'booking', 'allocation.js');
         $allocation['resources_json'] = json_encode(array_map('intval', $allocation['resources']));
         #				$allocation['cancel_link'] = self::link(array('menuaction' => 'bookingfrontend.uiallocation.show', 'id' => $allocation['id']));
         $allocation['cancel_link'] = self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => $allocation['building_id'], 'date' => $allocation['from_']));
         $allocation['application_link'] = self::link(array('menuaction' => 'bookingfrontend.uiapplication.show', 'id' => $allocation['application_id']));
         if ($step < 2) {
             self::render_template('allocation_delete', array('allocation' => $allocation, 'recurring' => $recurring, 'outseason' => $outseason, 'interval' => $field_interval, 'repeat_until' => $repeat_until));
         } elseif ($step == 2) {
             self::render_template('allocation_delete_preview', array('allocation' => $allocation, 'step' => $step, 'recurring' => $_POST['recurring'], 'outseason' => $_POST['outseason'], 'interval' => $_POST['field_interval'], 'repeat_until' => $_POST['repeat_until'], 'from_date' => $from_date, 'to_date' => $to_date, 'message' => $_POST['message'], 'valid_dates' => $valid_dates, 'invalid_dates' => $invalid_dates));
         }
     }
 }
 public function add()
 {
     //Values passed in from the "Export"-action in uicompleted_reservation.index
     $export = extract_values($_GET, $this->fields);
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $export = array();
         $export = extract_values($_POST, $this->fields);
         //Fill in a dummy value (so as to temporarily pass validation), this will then be
         //automatically filled in by bo->add process later on.
         $export['from_'] = date('Y-m-d H:i:s');
         $errors = $this->bo->validate($export);
         if (!$errors) {
             try {
                 $receipt = $this->bo->add($export);
                 $this->redirect_to('index');
             } catch (booking_unauthorized_exception $e) {
                 $errors['global'] = lang('Could not add object due to insufficient permissions');
             }
         }
     }
     if (!isset($export['to_']) || empty($export['to_'])) {
         $export['to_'] = date('Y-m-d');
     }
     $this->pre_validate($export);
     $this->flash_form_errors($errors);
     $cancel_params = array('ui' => 'completed_reservation');
     if ($export_key = $this->get_export_key()) {
         $cancel_params['export_key'] = $export_key;
     }
     $export['cancel_link'] = $this->link_to('index', $cancel_params);
     $this->render_template('completed_reservation_export_form', array('new_form' => true, 'export' => $export));
 }
 public function add()
 {
     $account_code_set = array();
     $config = CreateObject('phpgwapi.config', 'booking');
     $config->read();
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $account_code_set = extract_values($_POST, $this->fields);
         $account_code_set['active'] = '1';
         if ($config->config_data['external_format'] == 'KOMMFAKT') {
             $account_code_set['article'] = '1';
             $account_code_set['service'] = '1';
             $account_code_set['project_number'] = '1';
             $account_code_set['unit_number'] = '1';
             $account_code_set['unit_prefix'] = '1';
         }
         $errors = $this->bo->validate($account_code_set);
         if (!$errors) {
             try {
                 $receipt = $this->bo->add($account_code_set);
                 $this->redirect_to('index');
             } catch (booking_unauthorized_exception $e) {
                 $errors['global'] = lang('Could not add object due to insufficient permissions');
             }
         }
     }
     $this->add_default_display_data($account_code_set);
     if ($config->config_data['external_format'] != 'KOMMFAKT') {
         $account_code_set['project_number'] = '9';
     }
     $account_code_set['cancel_link'] = $this->link_to('index');
     $this->flash_form_errors($errors);
     self::render_template('account_code_set_form', array('new_form' => true, 'account_code_set' => $account_code_set, 'config_data' => $config->config_data));
 }
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     if ($id) {
         $system_message = $this->bo->read_single($id);
         $system_message['id'] = $id;
         $system_message['cancel_link'] = self::link(array('menuaction' => 'booking.uisystem_message.index'));
     } else {
         date_default_timezone_set("Europe/Oslo");
         $date = new DateTime(phpgw::get_var('date'));
         $system_message = array();
         $system_message['building_id'] = intval(phpgw::get_var('building_id', 'GET'));
         $system_message['building_name'] = $this->bo->so->get_building($system_message['building_id']);
         $system_message['created'] = $date->format('Y-m-d  H:m');
         $system_message['cancel_link'] = self::link(array('menuaction' => 'booking.uisystem_message.index'));
     }
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $system_message = array_merge($system_message, extract_values($_POST, array('name' => 'string', 'time' => 'string', 'title' => 'string', 'message' => 'html', 'phone' => 'string', 'email' => 'email')));
         if (!isset($system_message["Status"])) {
             $system_message['status'] = 'NEW';
         }
         if ($system_message['message'] == '') {
             $errors['system_message'] = lang('No message');
         }
         if (!$errors) {
             if ($id) {
                 $receipt = $this->bo->update($system_message);
             } else {
                 $receipt = $this->bo->add($system_message);
             }
             $this->redirect(array('menuaction' => 'booking.uisystem_message.edit', 'id' => $receipt['id'], 'warnings' => $errors));
         }
     }
     $this->flash_form_errors($errors);
     $this->use_yui_editor();
     self::render_template('system_message_edit', array('system_message' => $system_message, 'module' => $this->module));
 }
Exemplo n.º 24
0
<?php

$smarty->config_load($conf_file, 'factions');
@(list($c1, $c2) = extract_values($podrazdel));
$category = $c2 ? $c2 : $c1;
$cache_key = cache_key($category);
if (!($factions = load_cache(FACTION_LISTING, $cache_key))) {
    unset($factions);
    $factions = $DB->select('
			SELECT f1.factionID AS entry, f1.team, TRIM(f1.name_loc?d) AS name, f1.side, { f2.?# }{ ?d } AS category2, ?d AS category
			FROM ?_factions f1
			{ LEFT JOIN (?_factions f2) ON f1.team <> ?d }
			WHERE
				f1.reputationListID != -1
				{ AND f1.team = f2.?# }
				{ AND f1.team = ? }
			ORDER BY name
		', $_SESSION['locale'], !isset($category) ? 'factionID' : DBSIMPLE_SKIP, isset($category) ? intval($c1) : DBSIMPLE_SKIP, intval($c2), !isset($category) ? 0 : DBSIMPLE_SKIP, !isset($category) ? 'factionID' : DBSIMPLE_SKIP, isset($category) ? $category : DBSIMPLE_SKIP);
    if ($c1 && !$c2) {
        $entrys = array();
        foreach ($factions as $f) {
            $entrys[] = $f['entry'];
        }
        $factions = array_merge($factions, $DB->select('
				SELECT f1.factionID AS entry, f1.team, f1.name_loc?d AS name, f1.side, f1.team AS category2, ?d AS category
				FROM ?_factions f1
				WHERE
					f1.reputationListID != -1
					{ AND f1.team IN (?a) }
			', $_SESSION['locale'], intval($c2), !empty($entrys) ? $entrys : DBSIMPLE_SKIP));
    }
Exemplo n.º 25
0
                 $names = extract_values($_REQUEST['names'], 'str');
                 $locations = extract_values($_REQUEST['locations'], 'str');
                 $epiweeks = extract_values($_REQUEST['epiweeks'], 'int');
                 // get the data
                 $epidata = get_sensors($names, $locations, $epiweeks);
                 store_result($data, $epidata);
             } else {
                 $data['message'] = 'unauthenticated';
             }
         }
     } else {
         if ($source === 'nowcast') {
             if (require_all($data, array('locations', 'epiweeks'))) {
                 // parse the request
                 $locations = extract_values($_REQUEST['locations'], 'str');
                 $epiweeks = extract_values($_REQUEST['epiweeks'], 'int');
                 // get the data
                 $epidata = get_nowcast($locations, $epiweeks);
                 store_result($data, $epidata);
             }
         } else {
             if ($source === 'meta') {
                 // get the data
                 $epidata = get_meta();
                 store_result($data, $epidata);
             } else {
                 $data['message'] = 'no data source specified';
             }
         }
     }
 }
Exemplo n.º 26
0
 public function wtemplate_alloc_json()
 {
     $season_id = intval(phpgw::get_var('season_id', 'GET'));
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $alloc = extract_values($_POST, $this->wtemplate_alloc_fields);
         $alloc['season_id'] = $season_id;
         $errors = $this->bo->validate_wtemplate_alloc($alloc);
         if (!$errors && $alloc['id']) {
             $receipt = $this->bo->update_wtemplate_alloc($alloc);
         } else {
             if (!$errors && !$alloc['id']) {
                 $receipt = $this->bo->add_wtemplate_alloc($alloc);
             }
         }
         return $errors;
     }
     $id = intval(phpgw::get_var('id', 'GET'));
     $alloc = $this->bo->wtemplate_alloc_read_single($id);
     return $alloc;
 }
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $application = $this->bo->read_single($id);
     $this->check_application_assigned_to_current_user($application);
     $building_info = $this->bo->so->get_building_info($id);
     $application['building_id'] = $building_info['id'];
     $application['building_name'] = $building_info['name'];
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         array_set_default($_POST, 'resources', array());
         array_set_default($_POST, 'accepted_documents', array());
         $application = array_merge($application, extract_values($_POST, $this->fields));
         $application['message'] = $_POST['comment'];
         $this->agegroup_bo->extract_form_data($application);
         $this->extract_customer_identifier($application);
         if ($application['frontend_modified'] == '') {
             unset($application['frontend_modified']);
         }
         $errors = $this->validate($application);
         foreach ($_POST['from_'] as &$from) {
             $timestamp = strtotime($from);
             $from = date("Y-m-d H:i:s", $timestamp);
         }
         foreach ($_POST['to_'] as &$to) {
             $timestamp = strtotime($to);
             $to = date("Y-m-d H:i:s", $timestamp);
         }
         $application['dates'] = array_map(array(self, '_combine_dates'), $_POST['from_'], $_POST['to_']);
         if (!$errors) {
             $receipt = $this->bo->update($application);
             $this->bo->send_notification($application);
             $this->redirect(array('menuaction' => $this->url_prefix . '.show', 'id' => $application['id']));
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'application.js');
     $this->set_case_officer($application);
     $application['resources_json'] = json_encode(array_map('intval', $application['resources']));
     $application['accepted_documents_json'] = json_encode($application['accepted_documents']);
     $application['cancel_link'] = self::link(array('menuaction' => 'booking.uiapplication.index'));
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     $agegroups = $this->agegroup_bo->fetch_age_groups();
     $agegroups = $agegroups['results'];
     $audience = $this->audience_bo->fetch_target_audience();
     $audience = $audience['results'];
     $this->install_customer_identifier_ui($application);
     $application['customer_identifier_types']['ssn'] = 'Date of birth or SSN';
     self::render_template('application_edit', array('application' => $application, 'activities' => $activities, 'agegroups' => $agegroups, 'audience' => $audience));
 }
Exemplo n.º 28
0
<?php

// Необходима функция creatureinfo
require_once 'includes/allnpcs.php';
require_once 'includes/allreputation.php';
$smarty->config_load($conf_file, 'npc');
@(list($type) = extract_values($podrazdel));
$cache_key = cache_key($type);
if (!($npcs = load_cache(NPC_LISTING, $cache_key))) {
    unset($npcs);
    $rows = $DB->select('
		SELECT c.?#, c.entry
		{
			, l.name_loc?d AS name_loc
			, l.subname_loc?d AS subname_loc
		}
		FROM ?_factiontemplate, creature_template c
		{ LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? }
		WHERE
			factiontemplateID=faction_A
			{AND type=?}
		ORDER BY minlevel DESC, name
		{LIMIT ?d}
		', $npc_cols[0], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $type != '' ? $type : DBSIMPLE_SKIP, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP);
    $npcs = array();
    foreach ($rows as $row) {
        $npcs[] = creatureinfo2($row);
    }
    save_cache(NPC_LISTING, $cache_key, $npcs);
}
if (!($npc_tot = load_cache(NPC_TOT, 'npc_tot'))) {
Exemplo n.º 29
0
 public function edit()
 {
     $id = intval(phpgw::get_var('id', 'GET'));
     $booking = $this->bo->read_single($id);
     $booking['group'] = $this->group_bo->so->read_single($booking['group_id']);
     $booking['organization_id'] = $booking['group']['organization_id'];
     $booking['organization_name'] = $booking['group']['organization_name'];
     $booking['building'] = $this->building_bo->so->read_single($booking['building_id']);
     $booking['building_name'] = $booking['building']['name'];
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         array_set_default($_POST, 'resources', array());
         $booking = array_merge($booking, extract_values($_POST, $this->fields));
         $booking['allocation_id'] = $booking['allocation_id'] ? $booking['allocation_id'] : null;
         $this->agegroup_bo->extract_form_data($booking);
         $group = $this->group_bo->read_single(intval(phpgw::get_var('group_id', 'GET')));
         $errors = $this->bo->validate($booking);
         if (!$errors) {
             try {
                 $receipt = $this->bo->update($booking);
                 $this->send_mailnotification_to_group($group, lang('Booking changed'), phpgw::get_var('mail', 'POST'));
                 $this->redirect(array('menuaction' => 'booking.uibooking.show', 'id' => $booking['id']));
             } catch (booking_unauthorized_exception $e) {
                 $errors['global'] = lang('Could not update object due to insufficient permissions');
             }
         }
     }
     $this->flash_form_errors($errors);
     self::add_javascript('booking', 'booking', 'booking.js');
     $booking['resources_json'] = json_encode(array_map('intval', $booking['resources']));
     $booking['cancel_link'] = self::link(array('menuaction' => 'booking.uibooking.show', 'id' => $booking['id']));
     $booking['application_link'] = self::link(array('menuaction' => 'booking.uiapplication.show', 'id' => $booking['application_id']));
     $agegroups = $this->agegroup_bo->fetch_age_groups();
     $agegroups = $agegroups['results'];
     $audience = $this->audience_bo->fetch_target_audience();
     $audience = $audience['results'];
     $activities = $this->activity_bo->fetch_activities();
     $activities = $activities['results'];
     self::render_template('booking_edit', array('booking' => $booking, 'activities' => $activities, 'agegroups' => $agegroups, 'audience' => $audience));
 }