fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [14564] bookingfrontend: formatting code


From: Sigurd Nes
Subject: [Fmsystem-commits] [14564] bookingfrontend: formatting code
Date: Thu, 10 Dec 2015 14:34:03 +0000

Revision: 14564
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14564
Author:   sigurdne
Date:     2015-12-10 14:34:02 +0000 (Thu, 10 Dec 2015)
Log Message:
-----------
bookingfrontend: formatting code

Modified Paths:
--------------
    branches/dev-syncromind/bookingfrontend/change.php
    branches/dev-syncromind/bookingfrontend/frontend.php
    branches/dev-syncromind/bookingfrontend/inc/class.bobuilding.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.bouser.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.menu.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uiallocation.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uibooking.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uibuilding.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uicontactperson.inc.php
    
branches/dev-syncromind/bookingfrontend/inc/class.uidocument_building.inc.php
    
branches/dev-syncromind/bookingfrontend/inc/class.uidocument_resource.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uidocumentation.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uievent.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uigroup.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uiorganization.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uiresource.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
    branches/dev-syncromind/bookingfrontend/inc/class.uisystem_message.inc.php
    
branches/dev-syncromind/bookingfrontend/inc/custom/default/Altinn2_Bergen_kommune.php
    
branches/dev-syncromind/bookingfrontend/inc/custom/default/Altinn_Bergen_kommune.php
    branches/dev-syncromind/bookingfrontend/inc/custom/default/MinId.php
    branches/dev-syncromind/bookingfrontend/inc/hook_config.inc.php
    branches/dev-syncromind/bookingfrontend/index.php
    branches/dev-syncromind/bookingfrontend/js/bookingfrontend/application.js
    branches/dev-syncromind/bookingfrontend/js/bookingfrontend/booking.js
    
branches/dev-syncromind/bookingfrontend/js/bookingfrontend/booking_massupdate.js
    branches/dev-syncromind/bookingfrontend/js/bookingfrontend/event.js
    branches/dev-syncromind/bookingfrontend/js/bookingfrontend/schedule.js
    branches/dev-syncromind/bookingfrontend/login.php
    branches/dev-syncromind/bookingfrontend/logout.php
    branches/dev-syncromind/bookingfrontend/templates/base/access_denied.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/allocation_cancel.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/allocation_delete.xsl
    
branches/dev-syncromind/bookingfrontend/templates/base/allocation_delete_preview.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/allocation_info.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/application.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/application_edit.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/application_new.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/booking.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/booking_cancel.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/booking_delete.xsl
    
branches/dev-syncromind/bookingfrontend/templates/base/booking_delete_preview.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/booking_edit.xsl
    
branches/dev-syncromind/bookingfrontend/templates/base/booking_edit_preview.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/booking_info.xsl
    
branches/dev-syncromind/bookingfrontend/templates/base/booking_massupdate.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/booking_new.xsl
    
branches/dev-syncromind/bookingfrontend/templates/base/booking_new_preview.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/building.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/building_schedule.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/config.tpl
    branches/dev-syncromind/bookingfrontend/templates/base/datatable_jquery.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/event_delete.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/event_edit.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/event_info.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/group.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/group_edit.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/organization.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/organization_edit.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/report_numbers.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/resource.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/resource_schedule.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/system_message.xsl

Modified: branches/dev-syncromind/bookingfrontend/change.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/change.php  2015-12-10 13:28:01 UTC 
(rev 14563)
+++ branches/dev-syncromind/bookingfrontend/change.php  2015-12-10 14:34:02 UTC 
(rev 14564)
@@ -1,31 +1,31 @@
 <?php
        $phpgw_info = array();
-       
+
        $GLOBALS['phpgw_info']['flags'] = array
-       (
+               (
                'disable_template_class' => true,
-               'login'                  => true,
-               'currentapp'             => 'login',
-               'noheader'               => true
+               'login'                                  => true,
+               'currentapp'                     => 'login',
+               'noheader'                               => true
        );
 
        $GLOBALS['phpgw_info']['flags']['session_name'] = 
'bookingfrontendsession';
-       
+
        if(file_exists('../header.inc.php'))
        {
                include_once('../header.inc.php');
                $GLOBALS['phpgw']->sessions = createObject('phpgwapi.sessions');
        }
-       
-       $login = "bookingguest";
-       $passwd = "bkbooking";
 
-       $_POST['submitit'] = "";
-       $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, 
$passwd);
-       
$GLOBALS['phpgw']->session->appsession('tenant_id','property',$tenant_id);
-       
+       $login   = "bookingguest";
+       $passwd  = "bkbooking";
+
+       $_POST['submitit']               = "";
+       $GLOBALS['sessionid']    = $GLOBALS['phpgw']->session->create($login, 
$passwd);
+       $GLOBALS['phpgw']->session->appsession('tenant_id', 'property', 
$tenant_id);
+
        $GLOBALS['phpgw']->hooks->process('login');
-       
+
        $bouser = CreateObject('bookingfrontend.bouser');
        $bouser->change_org(phpgw::get_var('orgnumber', 'string'));
 

Modified: branches/dev-syncromind/bookingfrontend/frontend.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/frontend.php        2015-12-10 
13:28:01 UTC (rev 14563)
+++ branches/dev-syncromind/bookingfrontend/frontend.php        2015-12-10 
14:34:02 UTC (rev 14564)
@@ -1,14 +1,14 @@
 <?php
-       $phpgw_info = array();
-       $GLOBALS['phpgw_info']['flags'] = array
-       (
+       $phpgw_info                                                             
                 = array();
+       $GLOBALS['phpgw_info']['flags']                                  = array
+               (
                'disable_template_class' => true,
-               'login'                  => true,
-               'currentapp'             => 'login',
-               'noheader'                               => true,
-               'nonavbar'                               => true,
+               'login'                                  => true,
+               'currentapp'                     => 'login',
+               'noheader'                               => true,
+               'nonavbar'                               => true,
        );
-       $GLOBALS['phpgw_info']['flags']['session_name'] = 
'bookingfrontendsession';
+       $GLOBALS['phpgw_info']['flags']['session_name']  = 
'bookingfrontendsession';
        include_once('../header.inc.php');
        $GLOBALS['phpgw']->redirect_link('/bookingfrontend/');
        exit;

Modified: branches/dev-syncromind/bookingfrontend/inc/class.bobuilding.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.bobuilding.inc.php        
2015-12-10 13:28:01 UTC (rev 14563)
+++ branches/dev-syncromind/bookingfrontend/inc/class.bobuilding.inc.php        
2015-12-10 14:34:02 UTC (rev 14564)
@@ -1,13 +1,12 @@
 <?php
        phpgw::import_class('booking.bocommon');
-       
+
        class bookingfrontend_bobuilding extends booking_bocommon
        {
+
                function __construct()
                {
                        parent::__construct();
                        $this->so = CreateObject('booking.sobuilding');
                }
-               
-               
-       }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php  
2015-12-10 13:28:01 UTC (rev 14563)
+++ branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php  
2015-12-10 14:34:02 UTC (rev 14564)
@@ -1,17 +1,18 @@
 <?php
        phpgw::import_class('booking.bocommon');
-       
+
        class bookingfrontend_bosearch extends booking_bocommon
        {
+
                function __construct()
                {
                        parent::__construct();
-                       $this->sobuilding = CreateObject('booking.sobuilding');
-                       $this->soorganization = 
CreateObject('booking.soorganization');
-                       $this->soresource = CreateObject('booking.soresource');
-                       $this->soevent = CreateObject('booking.soevent');
+                       $this->sobuilding                = 
CreateObject('booking.sobuilding');
+                       $this->soorganization    = 
CreateObject('booking.soorganization');
+                       $this->soresource                = 
CreateObject('booking.soresource');
+                       $this->soevent                   = 
CreateObject('booking.soevent');
                }
-               
+
                function search($searchterm, $activity_top_level, $building_id, 
$filter_part_of_town)
                {
                        $building_filter = array();
@@ -22,10 +23,10 @@
                        }
                        else
                        {
-                               $types = array('building','resource'); //default
+                               $types = array('building', 'resource'); 
//default
                        }
 
-                       $bui_result = $org_result = $res_result = $event_result 
= array();
+                       $bui_result              = $org_result           = 
$res_result           = $event_result         = array();
 
                        if(in_array('building', $types))
                        {
@@ -37,43 +38,48 @@
 
                                if($activity_top_level && !$building_id)
                                {
-                                       $buildings = 
$this->sobuilding->get_buildings_from_activity($activity_top_level);
-                                       $_filter_building['id'] = $buildings;
+                                       $buildings                              
 = $this->sobuilding->get_buildings_from_activity($activity_top_level);
+                                       $_filter_building['id']  = $buildings;
                                }
                                if($building_id)
                                {
                                        $_filter_building['id'] = $building_id;
                                }
 
-                               $bui_result = 
$this->sobuilding->read(array("query"=>$searchterm, "sort"  => "name", "dir" => 
"asc",  "filters" => $_filter_building));
+                               $bui_result = 
$this->sobuilding->read(array("query" => $searchterm, "sort" => "name",
+                                       "dir" => "asc", "filters" => 
$_filter_building));
                                foreach($bui_result['results'] as &$bui)
-                {
-                                       $building_filter[] = $bui['id'];
-                                       $bui['type'] = "building";
-                    $bui['link'] = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uibuilding.show', 'id' => $bui['id']));
-                    $bui['img_container'] = "building-" . $bui['id'];
-                    $bui['img_url'] = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uidocument_building.index_images', 'filter_owner_id' => 
$bui['id'], 'phpgw_return_as' => 'json', 'results' => '1'));
-                                       if ( trim($bui['homepage']) != '' && 
!preg_match("/^http|https:\/\//", trim($bui['homepage'])) )
+                               {
+                                       $building_filter[]               = 
$bui['id'];
+                                       $bui['type']                     = 
"building";
+                                       $bui['link']                     = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uibuilding.show',
+                                               'id' => $bui['id']));
+                                       $bui['img_container']    = "building-" 
. $bui['id'];
+                                       $bui['img_url']                  = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uidocument_building.index_images',
+                                               'filter_owner_id' => 
$bui['id'], 'phpgw_return_as' => 'json', 'results' => '1'));
+                                       if(trim($bui['homepage']) != '' && 
!preg_match("/^http|https:\/\//", trim($bui['homepage'])))
                                        {
-                                               $bui['homepage'] = 
'http://'.$bui['homepage'];
+                                               $bui['homepage'] = 'http://' . 
$bui['homepage'];
                                        }
-                }
-            }
+                               }
+                       }
 
                        if(in_array('organization', $types))
                        {
-                $org_result = 
$this->soorganization->read(array("query"=>$searchterm, "sort"  => "name", 
"dir" => "asc", "filters" => array("active" => "1")));
-                foreach($org_result['results'] as &$org)
-                {
-                    $org['type'] = "organization";
-                    $org['description'] = 
nl2br(strip_tags($org['description']));
-                    $org['link'] = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uiorganization.show', 'id' => $org['id']));
-                                       if ( trim($org['homepage']) != '' && 
!preg_match("/^http|https:\/\//", trim($org['homepage'])) )
+                               $org_result = 
$this->soorganization->read(array("query" => $searchterm, "sort" => "name",
+                                       "dir" => "asc", "filters" => 
array("active" => "1")));
+                               foreach($org_result['results'] as &$org)
+                               {
+                                       $org['type']             = 
"organization";
+                                       $org['description']      = 
nl2br(strip_tags($org['description']));
+                                       $org['link']             = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uiorganization.show',
+                                               'id' => $org['id']));
+                                       if(trim($org['homepage']) != '' && 
!preg_match("/^http|https:\/\//", trim($org['homepage'])))
                                        {
-                                               $org['homepage'] = 
'http://'.$org['homepage'];
+                                               $org['homepage'] = 'http://' . 
$org['homepage'];
                                        }
-                }
-            }
+                               }
+                       }
 
                        if(in_array('resource', $types))
                        {
@@ -94,36 +100,40 @@
                                {
                                        $_filter_resource['part_of_town_id'] = 
$filter_part_of_town;
                                }
-               
-                               $res_result = 
$this->soresource->read(array("query"=>$searchterm, "sort"  => "name", "dir" => 
"asc",  "filters" => $_filter_resource ));
-                foreach($res_result['results'] as &$res)
-                {
-                    $res['name'] = $res['building_name']. ' / ' . $res['name'];
-                    $res['type'] = "resource";
-                    $res['link'] = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uiresource.show', 'id' => $res['id']));
-                    $res['img_container'] = "resource-" . $res['id'];
-                    $res['img_url'] = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uidocument_resource.index_images', 'filter_owner_id' => 
$res['id'], 'phpgw_return_as' => 'json', 'results' => '1'));
-                }
-            }
 
+                               $res_result = 
$this->soresource->read(array("query" => $searchterm, "sort" => "name",
+                                       "dir" => "asc", "filters" => 
$_filter_resource));
+                               foreach($res_result['results'] as &$res)
+                               {
+                                       $res['name']                     = 
$res['building_name'] . ' / ' . $res['name'];
+                                       $res['type']                     = 
"resource";
+                                       $res['link']                     = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uiresource.show',
+                                               'id' => $res['id']));
+                                       $res['img_container']    = "resource-" 
. $res['id'];
+                                       $res['img_url']                  = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uidocument_resource.index_images',
+                                               'filter_owner_id' => 
$res['id'], 'phpgw_return_as' => 'json', 'results' => '1'));
+                               }
+                       }
+
                        if(in_array('event', $types))
                        {
-                               $now = date('Y-m-d');
-                               $expired_conditions = "(bb_event.active != 0 
AND bb_event.completed = 0 AND bb_event.from_ > '{$now}' AND 
bb_event.description != '')";
-                $event_result = 
$this->soevent->read(array("query"=>$searchterm, "sort"  => "name", "dir" => 
"asc",  "filters" => array('where' => $expired_conditions)));
-                foreach($event_result['results'] as &$event)
-                {
-                    $event['name'] = $event['building_name']. ' / ' . 
$event['description'];
-                    $event['type'] = "Event";
-                                       $date = 
date('Y-m-d',strtotime($event['from_']));                                       
                        
-                                       $event_res = 
$this->soresource->read(array('filters' => array('id' => 
$event['resources'][0])));
-                    $event['link'] = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uibuilding.schedule', 'id' => 
$event_res['results'][0]['building_id'], 'date' => $date));
-                }
-            }
+                               $now                             = 
date('Y-m-d');
+                               $expired_conditions      = "(bb_event.active != 
0 AND bb_event.completed = 0 AND bb_event.from_ > '{$now}' AND 
bb_event.description != '')";
+                               $event_result            = 
$this->soevent->read(array("query" => $searchterm, "sort" => "name",
+                                       "dir" => "asc", "filters" => 
array('where' => $expired_conditions)));
+                               foreach($event_result['results'] as &$event)
+                               {
+                                       $event['name']   = 
$event['building_name'] . ' / ' . $event['description'];
+                                       $event['type']   = "Event";
+                                       $date                    = 
date('Y-m-d', strtotime($event['from_']));
+                                       $event_res               = 
$this->soresource->read(array('filters' => array('id' => 
$event['resources'][0])));
+                                       $event['link']   = 
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' => 
'bookingfrontend.uibuilding.schedule',
+                                               'id' => 
$event_res['results'][0]['building_id'], 'date' => $date));
+                               }
+                       }
 
-                       $final_array = array_merge_recursive($bui_result, 
$org_result, $res_result, $event_result);
-                       $final_array['total_records_sum']       =       
array_sum((array)$final_array['total_records']);
+                       $final_array                                            
 = array_merge_recursive($bui_result, $org_result, $res_result, $event_result);
+                       $final_array['total_records_sum']        = 
array_sum((array)$final_array['total_records']);
                        return $final_array;
                }
-       }
-
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/bookingfrontend/inc/class.bouser.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.bouser.inc.php    
2015-12-10 13:28:01 UTC (rev 14563)
+++ branches/dev-syncromind/bookingfrontend/inc/class.bouser.inc.php    
2015-12-10 14:34:02 UTC (rev 14564)
@@ -1,16 +1,17 @@
 <?php
+
        class bookingfrontend_bouser
        {
-               const ORGNR_SESSION_KEY = 'orgnr';
+
+               const ORGNR_SESSION_KEY  = 'orgnr';
                const ORGARRAY_SESSION_KEY = 'orgarray';
-               
-               public $orgnr = null;
-               public $orgname = null;
 
+               public $orgnr    = null;
+               public $orgname  = null;
                protected
-                       $default_module = 'bookingfrontend',
-                       $module,
-                       $config;
+               $default_module = 'bookingfrontend',
+               $module,
+               $config;
 
                /**
                 * Debug for testing
@@ -19,37 +20,38 @@
                 */
                public $debug = false;
 
-               public function __construct() {
+               public function __construct()
+               {
                        $this->set_module();
-                       $this->orgnr = $this->get_user_orgnr_from_session();
-                       $this->orgname = 
$this->get_orgname_from_db($this->get_user_orgnr_from_session());
-                       $this->config           = 
CreateObject('phpgwapi.config','bookingfrontend');
+                       $this->orgnr     = $this->get_user_orgnr_from_session();
+                       $this->orgname   = 
$this->get_orgname_from_db($this->get_user_orgnr_from_session());
+                       $this->config    = CreateObject('phpgwapi.config', 
'bookingfrontend');
                        $this->config->read();
                }
 
-               protected function get_orgname_from_db($orgnr) 
+               protected function get_orgname_from_db($orgnr)
                {
                        $this->db = & $GLOBALS['phpgw']->db;
-                       $this->db->limit_query("select name from 
bb_organization where organization_number ='" .$orgnr."'", 0, __LINE__, 
__FILE__, 1);
+                       $this->db->limit_query("select name from 
bb_organization where organization_number ='" . $orgnr . "'", 0, __LINE__, 
__FILE__, 1);
                        if(!$this->db->next_record())
                        {
-                return $orgnr;
+                               return $orgnr;
                        }
                        return $this->db->f('name', false);
+               }
 
-               }
                protected function get_organizations()
                {
-            $results = array();
-                       $this->db = & $GLOBALS['phpgw']->db;
+                       $results         = array();
+                       $this->db        = & $GLOBALS['phpgw']->db;
                        $this->db->query("select organization_number from 
bb_organization ORDER by organization_number ASC", __LINE__, __FILE__);
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $results[] = 
$this->db->f('organization_number', false);
                        }
                        return $results;
+               }
 
-               }
                protected function set_module($module = null)
                {
                        $this->module = is_string($module) ? $module : 
$this->default_module;
@@ -60,32 +62,32 @@
                        return $this->module;
                }
 
-               public function log_in() 
+               public function log_in()
                {
                        $this->log_off();
 
-                       $authentication_method  = 
isset($this->config->config_data['authentication_method']) && 
$this->config->config_data['authentication_method'] ? 
$this->config->config_data['authentication_method'] : '';
-                       
+                       $authentication_method = 
isset($this->config->config_data['authentication_method']) && 
$this->config->config_data['authentication_method'] ? 
$this->config->config_data['authentication_method'] : '';
+
                        if(!$authentication_method)
                        {
-                               throw new LogicException('authentication_method 
not chosen');                   
+                               throw new LogicException('authentication_method 
not chosen');
                        }
-                       
-                       $file = 
PHPGW_SERVER_ROOT."/bookingfrontend/inc/custom/default/{$authentication_method}";
 
+                       $file = PHPGW_SERVER_ROOT . 
"/bookingfrontend/inc/custom/default/{$authentication_method}";
+
                        if(!is_file($file))
                        {
-                               throw new LogicException("authentication method 
\"{$authentication_method}\" not available");                   
+                               throw new LogicException("authentication method 
\"{$authentication_method}\" not available");
                        }
 
                        require_once $file;
 
                        $external_user = new bookingfrontend_external_user();
-                       
-                       $this->orgnr = $external_user->get_user_org_id();
-                       $this->orgname = 
$this->get_orgname_from_db($this->orgnr);
 
-                       if ($this->is_logged_in())
+                       $this->orgnr     = $external_user->get_user_org_id();
+                       $this->orgname   = 
$this->get_orgname_from_db($this->orgnr);
+
+                       if($this->is_logged_in())
                        {
                                $this->write_user_orgnr_to_session();
                        }
@@ -102,27 +104,31 @@
                        return $this->is_logged_in();
                }
 
-               public function change_org($orgnumber) 
+               public function change_org($orgnumber)
                {
-                       $orgs = 
phpgwapi_cache::session_get($this->get_module(), self::ORGARRAY_SESSION_KEY);
+                       $orgs    = 
phpgwapi_cache::session_get($this->get_module(), self::ORGARRAY_SESSION_KEY);
                        $orglist = array();
-                       foreach ($orgs as $org) {
+                       foreach($orgs as $org)
+                       {
                                $orglist[] = $org['orgnumber'];
                        }
-                       if (in_array($orgnumber,$orglist)) {
+                       if(in_array($orgnumber, $orglist))
+                       {
 
-                               $this->orgnr = $orgnumber;
-                               $this->orgname = 
$this->get_orgname_from_db($this->orgnr);
+                               $this->orgnr     = $orgnumber;
+                               $this->orgname   = 
$this->get_orgname_from_db($this->orgnr);
 
-                               if ($this->is_logged_in())
+                               if($this->is_logged_in())
                                {
                                        $this->write_user_orgnr_to_session();
                                }
 
                                return $this->is_logged_in();
-                       } else {
+                       }
+                       else
+                       {
 
-                               if ($this->is_logged_in())
+                               if($this->is_logged_in())
                                {
                                        $this->write_user_orgnr_to_session();
                                }
@@ -130,7 +136,7 @@
                                return $this->is_logged_in();
                        }
                }
-               
+
                public function log_off()
                {
                        $this->clear_user_orgnr();
@@ -140,8 +146,8 @@
 
                protected function clear_user_orgnr()
                {
-                       $this->orgnr = null;
-                       $this->orgname = null;
+                       $this->orgnr     = null;
+                       $this->orgname   = null;
                }
 
                public function get_user_orgnr()
@@ -161,18 +167,19 @@
                public function is_organization_admin($organization_id = null)
                {
                        // FIXME!!!!!! REMOVE THIS ONCE ALTINN IS OPERATIONAL
-                       if (strcmp($_SERVER['SERVER_NAME'], 'dev.redpill.se') 
== 0 || strcmp($_SERVER['SERVER_NAME'], 'bk.localhost') == 0)
+                       if(strcmp($_SERVER['SERVER_NAME'], 'dev.redpill.se') == 
0 || strcmp($_SERVER['SERVER_NAME'], 'bk.localhost') == 0)
                        {
                                //return true;
                        }
                        // FIXME!!!!!! REMOVE THIS ONCE ALTINN IS OPERATIONAL
-                       if(!$this->is_logged_in()) {
+                       if(!$this->is_logged_in())
+                       {
                                //return false;
                        }
-                       $so = CreateObject('booking.soorganization');
-                       $organization = $so->read_single($organization_id);
+                       $so                              = 
CreateObject('booking.soorganization');
+                       $organization    = $so->read_single($organization_id);
 
-                       if ($organization['organization_number'] == '')
+                       if($organization['organization_number'] == '')
                        {
                                return false;
                        }
@@ -183,22 +190,23 @@
                public function is_group_admin($group_id = null)
                {
                        // FIXME!!!!!! REMOVE THIS ONCE ALTINN IS OPERATIONAL
-                       if (strcmp($_SERVER['SERVER_NAME'], 'dev.redpill.se') 
== 0 || strcmp($_SERVER['SERVER_NAME'], 'bk.localhost') == 0)
+                       if(strcmp($_SERVER['SERVER_NAME'], 'dev.redpill.se') == 
0 || strcmp($_SERVER['SERVER_NAME'], 'bk.localhost') == 0)
                        {
                                //return true;
                        }
                        // FIXME!!!!!! REMOVE THIS ONCE ALTINN IS OPERATIONAL
-                       if(!$this->is_logged_in()) {
+                       if(!$this->is_logged_in())
+                       {
                                //return false;
                        }
-                       $so = CreateObject('booking.sogroup');
-                       $group = $so->read_single($group_id);
+                       $so              = CreateObject('booking.sogroup');
+                       $group   = $so->read_single($group_id);
                        return 
$this->is_organization_admin($group['organization_id']);
                }
 
                protected function write_user_orgnr_to_session()
                {
-                       if (!$this->is_logged_in())
+                       if(!$this->is_logged_in())
                        {
                                throw new LogicException('Cannot write orgnr to 
session unless user is logged on');
                        }
@@ -210,115 +218,130 @@
                {
                        phpgwapi_cache::session_clear($this->get_module(), 
self::ORGNR_SESSION_KEY);
                }
+
                protected function clear_user_orglist_from_session()
                {
 #                      phpgwapi_cache::session_clear($this->get_module(), 
self::ORGARRAY_SESSION_KEY);
                }
-               
+
                protected function get_user_orgnr_from_session()
                {
-                       try {
+                       try
+                       {
                                return 
createObject('booking.sfValidatorNorwegianOrganizationNumber')->clean(phpgwapi_cache::session_get($this->get_module(),
 self::ORGNR_SESSION_KEY));
-                       } catch (sfValidatorError $e) {
+                       }
+                       catch(sfValidatorError $e)
+                       {
                                return null;
                        }
                }
-       
-        protected function get_breg_orgs($fodselsnr) {
-            $breg_conn = 
pg_connect("host=".$GLOBALS['phpgw_domain']['default']['db_host']." port=5432 
dbname=breg user=".$GLOBALS['phpgw_domain']['default']['db_user']." 
password=".$GLOBALS['phpgw_domain']['default']['db_pass']) or die('connection 
failed');
-            $sql = "SELECT distinct orgnr FROM breg.personcurrent WHERE 
fodselsnr ='".$fodselsnr."'";
-            $results = pg_query($breg_conn, $sql);
-            $orgs = pg_fetch_all($results);
-            print_r($sql);
-            print_r($orgs);
-            pg_close($breg_conn);
-            return $orgs;
-        }
+
+               protected function get_breg_orgs($fodselsnr)
+               {
+                       $breg_conn       = pg_connect("host=" . 
$GLOBALS['phpgw_domain']['default']['db_host'] . " port=5432 dbname=breg user=" 
. $GLOBALS['phpgw_domain']['default']['db_user'] . " password=" . 
$GLOBALS['phpgw_domain']['default']['db_pass']) or die('connection failed');
+                       $sql             = "SELECT distinct orgnr FROM 
breg.personcurrent WHERE fodselsnr ='" . $fodselsnr . "'";
+                       $results         = pg_query($breg_conn, $sql);
+                       $orgs            = pg_fetch_all($results);
+                       print_r($sql);
+                       print_r($orgs);
+                       pg_close($breg_conn);
+                       return $orgs;
+               }
+
                protected function get_user_orgnr_from_auth_header()
                {
-                       $config         = 
CreateObject('phpgwapi.config','bookingfrontend');
+                       $config = CreateObject('phpgwapi.config', 
'bookingfrontend');
                        $config->read();
-            if ($config->config_data['authentication_method'] === 'MinId.php') 
{
-                $ipdp = sha1($_SERVER['HTTP_UID']);
-                $bregorgs = $this->get_breg_orgs($ipdp);
-                $myorgnr = array();
-                if ($bregorgs == array()) {
-                               $external_user = (object) 'ciao'; 
$external_user->login = '000000000';
-                } else {
-                    foreach ($bregorgs as $org) {
-                        $myorgnr[] = $org['orgnr'];
-                    }
-                    if (count($myorgnr) > 1) {
-                        $external_user = (object) 'ciao'; 
$external_user->login = $myorgnr[0];
-                                               $orgs = array();
-                                               foreach ($myorgnr as $org) {
+                       if($config->config_data['authentication_method'] === 
'MinId.php')
+                       {
+                               $ipdp            = sha1($_SERVER['HTTP_UID']);
+                               $bregorgs        = $this->get_breg_orgs($ipdp);
+                               $myorgnr         = array();
+                               if($bregorgs == array())
+                               {
+                                       $external_user                   = 
(object)'ciao';$external_user->login  = '000000000';
+                               }
+                               else
+                               {
+                                       foreach($bregorgs as $org)
+                                       {
+                                               $myorgnr[] = $org['orgnr'];
+                                       }
+                                       if(count($myorgnr) > 1)
+                                       {
+                                               $external_user                  
 = (object)'ciao';$external_user->login  = $myorgnr[0];
+                                               $orgs                           
         = array();
+                                               foreach($myorgnr as $org)
+                                               {
                                                        $orgs[] = 
array('orgnumber' => $org, 'orgname' => $this->get_orgname_from_db($org));
                                                }
                                                
phpgwapi_cache::session_set($this->get_module(), self::ORGARRAY_SESSION_KEY, 
$orgs);
-                    }
-                    elseif (count($myorgnr) > 0) {
-                                       
phpgwapi_cache::session_set($this->get_module(), self::ORGARRAY_SESSION_KEY, 
NULL);
-                               $external_user = (object) 'ciao'; 
$external_user->login = $myorgnr[0];
-                    }
-                }
-            } else {
+                                       }
+                                       elseif(count($myorgnr) > 0)
+                                       {
+                                               
phpgwapi_cache::session_set($this->get_module(), self::ORGARRAY_SESSION_KEY, 
NULL);
+                                               $external_user                  
 = (object)'ciao';$external_user->login  = $myorgnr[0];
+                                       }
+                               }
+                       }
+                       else
+                       {
 
-                       $header_key = isset($config->config_data['header_key']) 
&& $config->config_data['header_key'] ? $config->config_data['header_key'] : 
'Osso-User-Dn';
-                       $header_regular_expression = 
isset($config->config_data['header_regular_expression']) && 
$config->config_data['header_regular_expression'] ? 
$config->config_data['header_regular_expression'] : '/^cn=(.*),cn=users.*$/';
+                               $header_key                                     
 = isset($config->config_data['header_key']) && 
$config->config_data['header_key'] ? $config->config_data['header_key'] : 
'Osso-User-Dn';
+                               $header_regular_expression       = 
isset($config->config_data['header_regular_expression']) && 
$config->config_data['header_regular_expression'] ? 
$config->config_data['header_regular_expression'] : '/^cn=(.*),cn=users.*$/';
 
-                       $headers = getallheaders();
+                               $headers = getallheaders();
 
-                       if(isset($config->config_data['debug']) && 
$config->config_data['debug'])
-                       {
-                               $this->debug = true;
-                               echo 'headers:<br>';
-                               _debug_array($headers);
-                       }
-    
-                       if(isset($headers[$header_key]) && 
$headers[$header_key])
-                       {
-                               $matches = array();
-                               
preg_match_all($header_regular_expression,$headers[$header_key], $matches);
-                               $userid = $matches[1][0];
-    
-                               if($this->debug)
-                               {
-                                       echo 'matches:<br>';
-                                       _debug_array($matches);
-                               }
-    
-                       }
+                               if(isset($config->config_data['debug']) && 
$config->config_data['debug'])
+                               {
+                                       $this->debug = true;
+                                       echo 'headers:<br>';
+                                       _debug_array($headers);
+                               }
 
-                       $options = array();
-                       $options['soap_version'] = SOAP_1_1;
-                       $options['location']    = 
isset($config->config_data['soap_location']) && 
$config->config_data['soap_location'] ? $config->config_data['soap_location'] : 
'';// 'http://soat1a.srv.bergenkom.no:8888/gateway/services/BrukerService-v1';
-                       $options['uri']                 = 
isset($config->config_data['soap_uri']) && $config->config_data['soap_uri'] ? 
$config->config_data['soap_uri'] : '';// 'http://soat1a.srv.bergenkom.no';
-                       $options['trace']               = 1;
+                               if(isset($headers[$header_key]) && 
$headers[$header_key])
+                               {
+                                       $matches = array();
+                                       
preg_match_all($header_regular_expression, $headers[$header_key], $matches);
+                                       $userid  = $matches[1][0];
 
-                       if(isset($config->config_data['soap_proxy_host']) && 
$config->config_data['soap_proxy_host'])
-                       {
-                               $options['proxy_host']  = 
$config->config_data['soap_proxy_host'];
-                       }
+                                       if($this->debug)
+                                       {
+                                               echo 'matches:<br>';
+                                               _debug_array($matches);
+                                       }
+                               }
 
-                       if(isset($config->config_data['soap_proxy_port']) && 
$config->config_data['soap_proxy_port'])
-                       {
-                               $options['proxy_port']  = 
$config->config_data['soap_proxy_port'];
-                       }
-                       $options['encoding']    = 
isset($config->config_data['soap_encoding']) && 
$config->config_data['soap_encoding'] ? $config->config_data['soap_encoding'] : 
'UTF-8';
-                       $options['login']               = 
isset($config->config_data['soap_login']) && $config->config_data['soap_login'] 
? $config->config_data['soap_login'] : '';
-                       $options['password']    = 
isset($config->config_data['soap_password']) && 
$config->config_data['soap_password'] ? $config->config_data['soap_password'] : 
'';
+                               $options                                 = 
array();
+                               $options['soap_version'] = SOAP_1_1;
+                               $options['location']     = 
isset($config->config_data['soap_location']) && 
$config->config_data['soap_location'] ? $config->config_data['soap_location'] : 
'';// 'http://soat1a.srv.bergenkom.no:8888/gateway/services/BrukerService-v1';
+                               $options['uri']                  = 
isset($config->config_data['soap_uri']) && $config->config_data['soap_uri'] ? 
$config->config_data['soap_uri'] : '';// 'http://soat1a.srv.bergenkom.no';
+                               $options['trace']                = 1;
 
-                       $wsdl = isset($config->config_data['soap_wsdl']) && 
$config->config_data['soap_wsdl'] ? $config->config_data['soap_wsdl'] : '';// 
'http://soat1a.srv.bergenkom.no:8888/gateway/services/BrukerService-v1?wsdl';
+                               
if(isset($config->config_data['soap_proxy_host']) && 
$config->config_data['soap_proxy_host'])
+                               {
+                                       $options['proxy_host'] = 
$config->config_data['soap_proxy_host'];
+                               }
 
-                       $authentication_method  = 
isset($config->config_data['authentication_method']) && 
$config->config_data['authentication_method'] ? 
$config->config_data['authentication_method'] : '';
+                               
if(isset($config->config_data['soap_proxy_port']) && 
$config->config_data['soap_proxy_port'])
+                               {
+                                       $options['proxy_port'] = 
$config->config_data['soap_proxy_port'];
+                               }
+                               $options['encoding'] = 
isset($config->config_data['soap_encoding']) && 
$config->config_data['soap_encoding'] ? $config->config_data['soap_encoding'] : 
'UTF-8';
+                               $options['login']        = 
isset($config->config_data['soap_login']) && $config->config_data['soap_login'] 
? $config->config_data['soap_login'] : '';
+                               $options['password'] = 
isset($config->config_data['soap_password']) && 
$config->config_data['soap_password'] ? $config->config_data['soap_password'] : 
'';
 
-                       require_once 
PHPGW_SERVER_ROOT."/bookingfrontend/inc/custom/default/{$authentication_method}";
-                       
-                       $external_user = new booking_external_user($wsdl, 
$options, $userid, $this->debug);
-                       // test values
-                       //$external_user = (object) 'ciao'; 
$external_user->login = 994239929;
-            }
+                               $wsdl = 
isset($config->config_data['soap_wsdl']) && $config->config_data['soap_wsdl'] ? 
$config->config_data['soap_wsdl'] : '';// 
'http://soat1a.srv.bergenkom.no:8888/gateway/services/BrukerService-v1?wsdl';
 
+                               $authentication_method = 
isset($config->config_data['authentication_method']) && 
$config->config_data['authentication_method'] ? 
$config->config_data['authentication_method'] : '';
+
+                               require_once PHPGW_SERVER_ROOT . 
"/bookingfrontend/inc/custom/default/{$authentication_method}";
+
+                               $external_user = new 
booking_external_user($wsdl, $options, $userid, $this->debug);
+                               // test values
+                               //$external_user = (object) 'ciao'; 
$external_user->login = 994239929;
+                       }
+
                        if($this->debug)
                        {
                                echo 'External user:<br>';
@@ -328,7 +351,7 @@
                        {
                                return 
createObject('booking.sfValidatorNorwegianOrganizationNumber')->clean($external_user->login);
                        }
-                       catch (sfValidatorError $e)
+                       catch(sfValidatorError $e)
                        {
                                if($this->debug)
                                {
@@ -338,4 +361,4 @@
                                return null;
                        }
                }
-       }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/bookingfrontend/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.menu.inc.php      
2015-12-10 13:28:01 UTC (rev 14563)
+++ branches/dev-syncromind/bookingfrontend/inc/class.menu.inc.php      
2015-12-10 14:34:02 UTC (rev 14564)
@@ -1,27 +1,30 @@
 <?php
+
        class bookingfrontend_menu
        {
+
                function get_menu()
                {
-                       $incoming_app = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $GLOBALS['phpgw_info']['flags']['currentapp'] = 
'bookingfrontend';
+                       $incoming_app                                           
                         = $GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $GLOBALS['phpgw_info']['flags']['currentapp']    = 
'bookingfrontend';
 
                        $menus = array();
 
-                       if ( $GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin')
-                       || $GLOBALS['phpgw']->acl->check('admin', 
phpgwapi_acl::ADD, 'bookingfrontend'))
+                       if($GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin') || $GLOBALS['phpgw']->acl->check('admin', 
phpgwapi_acl::ADD, 'bookingfrontend'))
                        {
                                $menus['admin'] = array
-                               (
-                                       'index' => array
                                        (
-                                               'text'  => 
lang('Configuration'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index', 'appname' => 'bookingfrontend') )
+                                       'index'                  => array
+                                               (
+                                               'text'   => 
lang('Configuration'),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index',
+                                                       'appname' => 
'bookingfrontend'))
                                        ),
-                                       'metasettings'  => array
-                                       (
-                                               'text'  => lang('Metadata'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'booking.uimetasettings.index', 'appname' => 'booking') )
+                                       'metasettings'   => array
+                                               (
+                                               'text'   => lang('Metadata'),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'booking.uimetasettings.index',
+                                                       'appname' => 'booking'))
                                        ),
                                );
                        }
@@ -29,4 +32,4 @@
                        $GLOBALS['phpgw_info']['flags']['currentapp'] = 
$incoming_app;
                        return $menus;
                }
-       }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/bookingfrontend/inc/class.uiallocation.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uiallocation.inc.php      
2015-12-10 13:28:01 UTC (rev 14563)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uiallocation.inc.php      
2015-12-10 14:34:02 UTC (rev 14564)
@@ -3,363 +3,405 @@
 
        class bookingfrontend_uiallocation extends booking_uiallocation
        {
+
                public $public_functions = array
-               (
-                       'info'                          =>      true,
-                       'cancel'                                =>      true,
+                       (
+                       'info'   => true,
+                       'cancel' => true,
                );
 
                public function __construct()
                {
                        parent::__construct();
-                       $this->org_bo = CreateObject('booking.boorganization');
-                       $this->resource_bo = CreateObject('booking.boresource');
-                       $this->building_bo = CreateObject('booking.bobuilding');
+                       $this->org_bo                    = 
CreateObject('booking.boorganization');
+                       $this->resource_bo               = 
CreateObject('booking.boresource');
+                       $this->building_bo               = 
CreateObject('booking.bobuilding');
                        $this->system_message_bo = 
CreateObject('booking.bosystem_message');
-                       $this->organization_bo = 
CreateObject('booking.boorganization');
-                       $this->booking_bo = CreateObject('booking.bobooking');
-       }
+                       $this->organization_bo   = 
CreateObject('booking.boorganization');
+                       $this->booking_bo                = 
CreateObject('booking.bobooking');
+               }
 
-               public function building_users($building_id, $type=false, 
$activities=array() ) {
-            $contacts = array();
-                       $organizations = 
$this->organization_bo->find_building_users($building_id, $type, $activities);
-            foreach($organizations['results'] as $org)
-            {
-                if ($org['email'] != '' && strstr($org['email'], '@')) {
-                    if (!in_array($org['email'], $contacts)) {
-                        $contacts[] = $org['email'];
-                    }
-                }
-                if ($org['contacts'][0]['email'] != '' && 
strstr($org['contacts'][0]['email'], '@')) {
-                    if (!in_array($org['contacts'][0]['email'], $contacts)) {
-                        $contacts[] = $org['contacts'][0]['email']; 
-                    }
-                }
-                if ($org['contacts'][1]['email'] != '' && 
strstr($org['contacts'][1]['email'], '@')) {
-                    if (!in_array($org['contacts'][1]['email'], $contacts)) {
-                        $contacts[] = $org['contacts'][1]['email']; 
-                    }
-                }
-                $grp_con = 
$this->booking_bo->so->get_group_contacts_of_organization($org['id']);
-                foreach ($grp_con as $grp) {
-                    if (!in_array($grp['email'], $contacts) && 
strstr($grp['email'], '@')) {
-                        $contacts[] = $grp['email'];
-                    }
-                }
-            } 
+               public function building_users($building_id, $type = false, 
$activities = array())
+               {
+                       $contacts                = array();
+                       $organizations   = 
$this->organization_bo->find_building_users($building_id, $type, $activities);
+                       foreach($organizations['results'] as $org)
+                       {
+                               if($org['email'] != '' && strstr($org['email'], 
'@'))
+                               {
+                                       if(!in_array($org['email'], $contacts))
+                                       {
+                                               $contacts[] = $org['email'];
+                                       }
+                               }
+                               if($org['contacts'][0]['email'] != '' && 
strstr($org['contacts'][0]['email'], '@'))
+                               {
+                                       
if(!in_array($org['contacts'][0]['email'], $contacts))
+                                       {
+                                               $contacts[] = 
$org['contacts'][0]['email'];
+                                       }
+                               }
+                               if($org['contacts'][1]['email'] != '' && 
strstr($org['contacts'][1]['email'], '@'))
+                               {
+                                       
if(!in_array($org['contacts'][1]['email'], $contacts))
+                                       {
+                                               $contacts[] = 
$org['contacts'][1]['email'];
+                                       }
+                               }
+                               $grp_con = 
$this->booking_bo->so->get_group_contacts_of_organization($org['id']);
+                               foreach($grp_con as $grp)
+                               {
+                                       if(!in_array($grp['email'], $contacts) 
&& strstr($grp['email'], '@'))
+                                       {
+                                               $contacts[] = $grp['email'];
+                                       }
+                               }
+                       }
                        return $contacts;
                }
 
                public function cancel()
                {
-                       $config = CreateObject('phpgwapi.config','booking');
+                       $config = CreateObject('phpgwapi.config', 'booking');
                        $config->read();
 
-                       if ($config->config_data['user_can_delete_allocations'] 
!= 'yes') {
+                       if($config->config_data['user_can_delete_allocations'] 
!= 'yes')
+                       {
 
-                       $allocation = 
$this->bo->read_single(intval(phpgw::get_var('allocation_id', 'int')));
-                $organization = 
$this->organization_bo->read_single($allocation['organization_id']);
-                               $errors = array();
+                               $allocation              = 
$this->bo->read_single(intval(phpgw::get_var('allocation_id', 'int')));
+                               $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'];
+                                       $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;
+                                       $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']);
+                                       
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);
+                                       $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->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->flash_form_errors($errors);
-                               $allocation['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => 
$allocation['building_id']));
+                               $allocation['from_'] = 
pretty_timestamp($allocation['from_']);
+                               $allocation['to_']       = 
pretty_timestamp($allocation['to_']);
+                               
$GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 'date');
 
-                $allocation['from_'] = pretty_timestamp($allocation['from_']);
-                $allocation['to_'] = pretty_timestamp($allocation['to_']);
-                $GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 
'date');
-
 //                             $this->use_yui_editor();
-                
-                phpgwapi_jquery::init_ckeditor('field-message');
-                               self::render_template_xsl('allocation_cancel', 
array('allocation'=>$allocation));
 
-                       } else {
+                               phpgwapi_jquery::init_ckeditor('field-message');
+                               self::render_template_xsl('allocation_cancel', 
array('allocation' => $allocation));
+                       }
+                       else
+                       {
 
-                               $id = phpgw::get_var('allocation_id', 'int');
-                $from_date = phpgw::get_var('from_', 'string');
-                $to_date = phpgw::get_var('to_', 'string');
-                               $outseason = phpgw::get_var('outseason', 
'string');
-                               $recurring = phpgw::get_var('recurring', 
'string');
-                               $repeat_until = phpgw::get_var('repeat_until', 
'string');
-                               $field_interval = 
phpgw::get_var('field_interval', 'int');
-                               $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', 'string', 
'REQUEST', 1);
-                   $errors = array();
-                               $invalid_dates = array();
-                               $valid_dates = array();
+                               $id                              = 
phpgw::get_var('allocation_id', 'int');
+                               $from_date               = 
phpgw::get_var('from_', 'string');
+                               $to_date                 = 
phpgw::get_var('to_', 'string');
+                               $outseason               = 
phpgw::get_var('outseason', 'string');
+                               $recurring               = 
phpgw::get_var('recurring', 'string');
+                               $repeat_until    = 
phpgw::get_var('repeat_until', 'string');
+                               $field_interval  = 
phpgw::get_var('field_interval', 'int');
+                               $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', 'string', 'REQUEST', 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);
+                               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;         
+                               $maildata                                       
 = array();
+                               $maildata['outseason']           = $outseason;
+                               $maildata['recurring']           = $recurring;
+                               $maildata['repeat_until']        = 
$repeat_until;
+                               $maildata['field_interval']      = 
$field_interval;
 
                                if($_SERVER['REQUEST_METHOD'] == 'POST')
                                {
-                    $_POST['from_'] = date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['from_']));
-                    $_POST['to_'] = date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['to_']));
-                    $_POST['repeat_until'] = date("Y-m-d", 
phpgwapi_datetime::date_to_timestamp($_POST['repeat_until']));
-                    
-                                       $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 = '';
+                                       $_POST['from_']                  = 
date("Y-m-d H:i:s", phpgwapi_datetime::date_to_timestamp($_POST['from_']));
+                                       $_POST['to_']                    = 
date("Y-m-d H:i:s", phpgwapi_datetime::date_to_timestamp($_POST['to_']));
+                                       $_POST['repeat_until']   = 
date("Y-m-d", phpgwapi_datetime::date_to_timestamp($_POST['repeat_until']));
+
+                                       $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']);
+                                                       $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)." ";
+                                                       
$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; 
-                                               } 
+                                                       $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;
+                                                       $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)
+                                               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));
+                                                       $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;
-                            $fromdate = pretty_timestamp($fromdate);
-                            $todate = pretty_timestamp($todate);
-       
-                               $id = 
$this->bo->so->get_allocation_id($allocation);                
-                                                       if ($id) 
+                                                       $allocation['to_']      
 = $todate;
+                                                       $fromdate               
         = pretty_timestamp($fromdate);
+                                                       $todate                 
         = pretty_timestamp($todate);
+
+                                                       $id = 
$this->bo->so->get_allocation_id($allocation);
+                                                       if($id)
                                                        {
-                                                          $err  = 
$this->bo->so->check_for_booking($id);
+                                                               $err = 
$this->bo->so->check_for_booking($id);
                                                        }
-                                                       else 
+                                                       else
                                                        {
-                                                          $err = true;
+                                                               $err = true;
                                                        }
-       
-                                       if ($err) 
+
+                                                       if($err)
                                                        {
-                                                               
$invalid_dates[$i]['from_'] = $fromdate;
-                                                               
$invalid_dates[$i]['to_'] = $todate;
-                                                       } 
-                                                       else 
+                                                               
$invalid_dates[$i]['from_']      = $fromdate;
+                                                               
$invalid_dates[$i]['to_']        = $todate;
+                                                       }
+                                                       else
                                                        {
-                                                               
$valid_dates[$i]['from_'] = $fromdate;
-                                                               
$valid_dates[$i]['to_'] = $todate;
-                                                               if ($step == 3)
+                                                               
$valid_dates[$i]['from_']        = $fromdate;
+                                                               
$valid_dates[$i]['to_']          = $todate;
+                                                               if($step == 3)
                                                                {
-                                                                       
-                                       $this->bo->so->delete_allocation($id);
-                                   }                            
-                               }
+
+                                                                       
$this->bo->so->delete_allocation($id);
+                                                               }
+                                                       }
                                                        $i++;
-                           }
-                                               if ($step == 3) 
+                                               }
+                                               if($step == 3)
                                                {
-                            $maildata = array();
-                            $maildata['outseason'] = 
phpgw::get_var('outseason','string');
-                            $maildata['recurring'] = 
phpgw::get_var('recurring', 'string');
-                            $maildata['repeat_until'] = 
phpgw::get_var('repeat_until', 'string');
-                                                       $maildata['delete'] = 
$valid_dates;
+                                                       $maildata               
                         = array();
+                                                       $maildata['outseason']  
         = phpgw::get_var('outseason', 'string');
+                                                       $maildata['recurring']  
         = phpgw::get_var('recurring', 'string');
+                                                       
$maildata['repeat_until']        = phpgw::get_var('repeat_until', 'string');
+                                                       $maildata['delete']     
                 = $valid_dates;
 
-                                                       $res_names = '';
+                                                       $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']);
+                                                       $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)." ";
+                                                       
$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_']);
+                                                       $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);
+                                                       
$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->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['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']));
-                
-                $allocation['from_'] = pretty_timestamp($allocation['from_']);
-                $allocation['to_'] = pretty_timestamp($allocation['to_']);
-                
-                $GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 
'date');
-       
-                               if ($step < 2) 
-                   {
-                    phpgwapi_jquery::init_ckeditor('field-message');
-                               self::render_template_xsl('allocation_delete', 
array('allocation' => $allocation,
-                                               'recurring' => $recurring,
-                                               'outseason' => $outseason,
-                                               'interval' => $field_interval,
-                                               'repeat_until' => $repeat_until,
-                       ));
-                   }
-                               elseif ($step == 2) 
-                   {
-                                       
self::render_template_xsl('allocation_delete_preview', array('allocation' => 
$allocation,
-                                               'step' => $step,
-                                               'recurring' => 
$_POST['recurring'],
-                                               'outseason' => 
$_POST['outseason'],
-                                               'interval' => 
$_POST['field_interval'],
-                                               'repeat_until' => 
pretty_timestamp($_POST['repeat_until']),
-                                               'from_date' => 
pretty_timestamp($from_date),
-                                               'to_date' => 
pretty_timestamp($to_date),
-                                               'message' => $_POST['message'],
-                                               'valid_dates' => $valid_dates,
-                                               'invalid_dates' => 
$invalid_dates
+                               $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']));
+
+                               $allocation['from_'] = 
pretty_timestamp($allocation['from_']);
+                               $allocation['to_']       = 
pretty_timestamp($allocation['to_']);
+
+                               
$GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 'date');
+
+                               if($step < 2)
+                               {
+                                       
phpgwapi_jquery::init_ckeditor('field-message');
+                                       
self::render_template_xsl('allocation_delete', array('allocation'        => 
$allocation,
+                                               'recurring'              => 
$recurring,
+                                               'outseason'              => 
$outseason,
+                                               'interval'               => 
$field_interval,
+                                               'repeat_until'   => 
$repeat_until,
                                        ));
-                   }                
-
+                               }
+                               elseif($step == 2)
+                               {
+                                       
self::render_template_xsl('allocation_delete_preview', array('allocation'       
 => $allocation,
+                                               'step'                   => 
$step,
+                                               'recurring'              => 
$_POST['recurring'],
+                                               'outseason'              => 
$_POST['outseason'],
+                                               'interval'               => 
$_POST['field_interval'],
+                                               'repeat_until'   => 
pretty_timestamp($_POST['repeat_until']),
+                                               'from_date'              => 
pretty_timestamp($from_date),
+                                               'to_date'                => 
pretty_timestamp($to_date),
+                                               'message'                => 
$_POST['message'],
+                                               'valid_dates'    => 
$valid_dates,
+                                               'invalid_dates'  => 
$invalid_dates
+                                       ));
+                               }
                        }
-        }              
+               }
 
                public function info()
                {
-                       $config = CreateObject('phpgwapi.config','booking');
+                       $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;
-            }
+                       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(phpgw::get_var('id', 'int'));
-                       $resources = 
$this->resource_bo->so->read(array('filters'=>array('id'=>$allocation['resources']),
 'sort'=>'name'));
+                       $allocation                              = 
$this->bo->read_single(phpgw::get_var('id', 'int'));
+                       $resources                               = 
$this->resource_bo->so->read(array('filters' => array('id' => 
$allocation['resources']),
+                               'sort' => 'name'));
                        $allocation['resources'] = $resources['results'];
-                       $res_names = array();
+                       $res_names                               = array();
                        foreach($allocation['resources'] as $res)
                        {
                                $res_names[] = $res['name'];
                        }
-                       $allocation['resource'] = phpgw::get_var('resource');
+                       $allocation['resource']          = 
phpgw::get_var('resource');
                        $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_xsl('allocation_info', 
array('allocation'=>$allocation, 'user_can_delete_allocations' => 
$user_can_delete_allocations));
+                       $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_xsl('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
                }
-       }
+       }
\ No newline at end of file

Modified: 
branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php     
2015-12-10 13:28:01 UTC (rev 14563)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php     
2015-12-10 14:34:02 UTC (rev 14564)
@@ -3,12 +3,13 @@
 
        class bookingfrontend_uiapplication extends booking_uiapplication
        {
+
                public $public_functions = array
-               (
-                       'add'                   =>      true,
-                       'edit'                  =>      true,
-                       'show'                  =>      true,
-                       'get_activity_data'     => true
+                       (
+                       'add'                            => true,
+                       'edit'                           => true,
+                       'show'                           => true,
+                       'get_activity_data'      => true
                );
 
                function get_activity_data()
@@ -18,7 +19,7 @@
 
                function show()
                {
-                       $id = phpgw::get_var('id', 'int');
+                       $id                      = phpgw::get_var('id', 'int');
                        $application = $this->bo->read_single($id);
 
                        if($application['secret'] != phpgw::get_var('secret', 
'string'))
@@ -31,29 +32,28 @@
                                $this->add_comment($application, 
$_POST['comment']);
                                $this->set_display_in_dashboard($application, 
true, array('force' => true));
                                $application['frontend_modified'] = 'now';
-                $this->bo->send_admin_notification($application, 
$_POST['comment']);
+                               
$this->bo->send_admin_notification($application, $_POST['comment']);
 
                                $receipt = $this->bo->update($application);
-                               $this->redirect(array('menuaction' => 
$this->url_prefix . '.show', 'id'=>$application['id'], 
'secret'=>$application['secret']));
+                               $this->redirect(array('menuaction' => 
$this->url_prefix . '.show', 'id' => $application['id'],
+                                       'secret' => $application['secret']));
                        }
-                       
 
-                       $building_info = $this->bo->so->get_building_info($id);
-                       $application['building_id'] = $building_info['id'];
-                       $application['building_name'] = $building_info['name'];
 
-                       if ($_SERVER['REQUEST_METHOD'] == 'POST' && 
$_POST['print'])
+                       $building_info                                   = 
$this->bo->so->get_building_info($id);
+                       $application['building_id']              = 
$building_info['id'];
+                       $application['building_name']    = 
$building_info['name'];
+
+                       if($_SERVER['REQUEST_METHOD'] == 'POST' && 
$_POST['print'])
                        {
-                               $output_type = 'PDF';
-                               $jasper_parameters = 
sprintf("\"BK_BUILDING_NAME|%s;BK_APPLICATION_ID|%s\"",
-                                       $application['building_name'],
-                                       $id);
+                               $output_type             = 'PDF';
+                               $jasper_parameters       = 
sprintf("\"BK_BUILDING_NAME|%s;BK_APPLICATION_ID|%s\"", 
$application['building_name'], $id);
                                // DEBUG
                                // print_r($jasper_parameters);
                                // exit(0);
 
-                               $jasper_wrapper         = 
CreateObject('phpgwapi.jasper_wrapper');
-                               $report_source          = 
PHPGW_SERVER_ROOT.'/booking/jasper/templates/application.jrxml';
+                               $jasper_wrapper  = 
CreateObject('phpgwapi.jasper_wrapper');
+                               $report_source   = PHPGW_SERVER_ROOT . 
'/booking/jasper/templates/application.jrxml';
                                try
                                {
                                        
$jasper_wrapper->execute($jasper_parameters, $output_type, $report_source);
@@ -70,23 +70,20 @@
                        {
                                $resource_ids = $resource_ids . '&filter_id[]=' 
. $res;
                        }
-                       
-                       //Filter application comments only after update has 
been attempted unless 
+
+                       //Filter application comments only after update has 
been attempted unless
                        //you wish to delete the comments not matching the 
specified types
                        $this->filter_application_comments($application, 
array('comment'));
-            
-            $activity_path = 
$this->activity_bo->get_path($application['activity_id']);
-            $top_level_activity = $activity_path ? $activity_path[0]['id'] : 
-1;
-                       
-                       $application['resource_ids'] = $resource_ids;
-                       $agegroups = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
-                       $agegroups = $agegroups['results'];
-                       $audience = 
$this->audience_bo->fetch_target_audience($top_level_activity);
-                       $audience = $audience['results'];
-                       self::render_template_xsl('application', 
array('application' => $application, 'audience' => $audience, 'agegroups' => 
$agegroups, 'frontend'=>'true'));
-               }
-               
-               
 
+                       $activity_path           = 
$this->activity_bo->get_path($application['activity_id']);
+                       $top_level_activity      = $activity_path ? 
$activity_path[0]['id'] : -1;
 
-       }
+                       $application['resource_ids'] = $resource_ids;
+                       $agegroups                                       = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
+                       $agegroups                                       = 
$agegroups['results'];
+                       $audience                                        = 
$this->audience_bo->fetch_target_audience($top_level_activity);
+                       $audience                                        = 
$audience['results'];
+                       self::render_template_xsl('application', 
array('application' => $application,
+                               'audience' => $audience, 'agegroups' => 
$agegroups, 'frontend' => 'true'));
+               }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/bookingfrontend/inc/class.uibooking.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uibooking.inc.php 
2015-12-10 13:28:01 UTC (rev 14563)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uibooking.inc.php 
2015-12-10 14:34:02 UTC (rev 14564)
@@ -3,52 +3,55 @@
 
        class bookingfrontend_uibooking extends booking_uibooking
        {
+
                public $public_functions = array
-               (
-                       'building_schedule' =>  true,
-                       'building_extraschedule' =>  true,
-                       'resource_schedule' =>  true,
-                       'info'                          =>      true,
-                       'add' =>                                true,
-                       'show' =>                               true,
-                       'edit' =>                               true,
-                       'report_numbers' =>             true,
-                       'massupdate' =>                 true,
-                       'cancel' =>                     true,
+                       (
+                       'building_schedule'              => true,
+                       'building_extraschedule' => true,
+                       'resource_schedule'              => true,
+                       'info'                                   => true,
+                       'add'                                    => true,
+                       'show'                                   => true,
+                       'edit'                                   => true,
+                       'report_numbers'                 => true,
+                       'massupdate'                     => true,
+                       'cancel'                                 => true,
                );
 
                public function __construct()
                {
                        parent::__construct();
-                       $this->group_bo = CreateObject('booking.bogroup');
-                       $this->resource_bo = CreateObject('booking.boresource');
-                       $this->allocation_bo = 
CreateObject('booking.boallocation');
-                       $this->season_bo = CreateObject('booking.boseason');
-                       $this->building_bo = CreateObject('booking.bobuilding');
+                       $this->group_bo                  = 
CreateObject('booking.bogroup');
+                       $this->resource_bo               = 
CreateObject('booking.boresource');
+                       $this->allocation_bo     = 
CreateObject('booking.boallocation');
+                       $this->season_bo                 = 
CreateObject('booking.boseason');
+                       $this->building_bo               = 
CreateObject('booking.bobuilding');
                        $this->system_message_bo = 
CreateObject('booking.bosystem_message');
-                       $this->organization_bo = 
CreateObject('booking.boorganization');
+                       $this->organization_bo   = 
CreateObject('booking.boorganization');
                }
 
                private function item_link(&$item, $key)
                {
                        if(in_array($item['type'], array('allocation', 
'booking', 'event')))
-                               $item['info_url'] = 
$this->link(array('menuaction' => 'bookingfrontend.ui'.$item['type'].'.info', 
'id' => $item['id']));
+                               $item['info_url'] = 
$this->link(array('menuaction' => 'bookingfrontend.ui' . $item['type'] . 
'.info',
+                                       'id' => $item['id']));
                }
 
                public function building_schedule()
                {
-                   $date = new DateTime(phpgw::get_var('date'));
-                       $bookings = 
$this->bo->building_schedule(phpgw::get_var('building_id', 'int'), $date);
+                       $date            = new DateTime(phpgw::get_var('date'));
+                       $bookings        = 
$this->bo->building_schedule(phpgw::get_var('building_id', 'int'), $date);
                        foreach($bookings['results'] as &$row)
                        {
-                               $row['resource_link'] = 
$this->link(array('menuaction' => 'bookingfrontend.uiresource.schedule', 'id' 
=> $row['resource_id']));
+                               $row['resource_link'] = 
$this->link(array('menuaction' => 'bookingfrontend.uiresource.schedule',
+                                       'id' => $row['resource_id']));
                                array_walk($row, array($this, 'item_link'));
                        }
                        $data = array
-                       (
+                               (
                                'ResultSet' => array(
-                                       "totalResultsAvailable" => 
$bookings['total_records'], 
-                                       "Result" => $bookings['results']
+                                       "totalResultsAvailable"  => 
$bookings['total_records'],
+                                       "Result"                                
 => $bookings['results']
                                )
                        );
                        return $data;
@@ -56,18 +59,19 @@
 
                public function building_extraschedule()
                {
-                   $date = new DateTime(phpgw::get_var('date'));
-                       $bookings = 
$this->bo->building_extraschedule(phpgw::get_var('building_id', 'int'), $date);
+                       $date            = new DateTime(phpgw::get_var('date'));
+                       $bookings        = 
$this->bo->building_extraschedule(phpgw::get_var('building_id', 'int'), $date);
                        foreach($bookings['results'] as &$row)
                        {
-                               $row['resource_link'] = 
$this->link(array('menuaction' => 'bookingfrontend.uiresource.schedule', 'id' 
=> $row['resource_id']));
+                               $row['resource_link'] = 
$this->link(array('menuaction' => 'bookingfrontend.uiresource.schedule',
+                                       'id' => $row['resource_id']));
                                array_walk($row, array($this, 'item_link'));
                        }
                        $data = array
-                       (
+                               (
                                'ResultSet' => array(
-                                       "totalResultsAvailable" => 
$bookings['total_records'], 
-                                       "Result" => $bookings['results']
+                                       "totalResultsAvailable"  => 
$bookings['total_records'],
+                                       "Result"                                
 => $bookings['results']
                                )
                        );
                        return $data;
@@ -75,18 +79,19 @@
 
                public function resource_schedule()
                {
-                   $date = new DateTime(phpgw::get_var('date'));
-                       $bookings = 
$this->bo->resource_schedule(phpgw::get_var('resource_id', 'int'), $date);
+                       $date            = new DateTime(phpgw::get_var('date'));
+                       $bookings        = 
$this->bo->resource_schedule(phpgw::get_var('resource_id', 'int'), $date);
                        foreach($bookings['results'] as &$booking)
                        {
-                               $booking['link'] = 
$this->link(array('menuaction' => 'bookingfrontend.uibooking.show', 'id' => 
$booking['id']));
+                               $booking['link'] = 
$this->link(array('menuaction' => 'bookingfrontend.uibooking.show',
+                                       'id' => $booking['id']));
                                array_walk($booking, array($this, 'item_link'));
                        }
                        $data = array
-                       (
+                               (
                                'ResultSet' => array(
-                                       "totalResultsAvailable" => 
$bookings['total_records'], 
-                                       "Result" => $bookings['results']
+                                       "totalResultsAvailable"  => 
$bookings['total_records'],
+                                       "Result"                                
 => $bookings['results']
                                )
                        );
                        return $data;
@@ -94,55 +99,57 @@
 
                public function add()
                {
-                       $errors = array();
-                       $booking = array();
-                       $booking['building_id'] = phpgw::get_var('building_id', 
'int');
-                       $allocation_id = phpgw::get_var('allocation_id', 'int');
-            #The string replace is a workaround for a problem at Bergen 
Kommune 
-            $booking['from_'] = str_replace('%3A',':',phpgw::get_var('from_', 
'string', 'GET'));
-            $booking['to_'] = str_replace('%3A',':',phpgw::get_var('to_', 
'string', 'GET'));
-                       $time_from = explode(" ",phpgw::get_var('from_', 
'string', 'GET'));
-                       $time_to = explode(" ",phpgw::get_var('to_', 'string', 
'GET'));
+                       $errors                                  = array();
+                       $booking                                 = array();
+                       $booking['building_id']  = 
phpgw::get_var('building_id', 'int');
+                       $allocation_id                   = 
phpgw::get_var('allocation_id', 'int');
+                       #The string replace is a workaround for a problem at 
Bergen Kommune
+                       $booking['from_']                = str_replace('%3A', 
':', phpgw::get_var('from_', 'string', 'GET'));
+                       $booking['to_']                  = str_replace('%3A', 
':', phpgw::get_var('to_', 'string', 'GET'));
+                       $time_from                               = explode(" ", 
phpgw::get_var('from_', 'string', 'GET'));
+                       $time_to                                 = explode(" ", 
phpgw::get_var('to_', 'string', 'GET'));
 
-                       $step = phpgw::get_var('step', 'string', 'REQUEST', 1);
-                       $invalid_dates = array();
-                       $valid_dates = array();
+                       $step                    = phpgw::get_var('step', 
'string', 'REQUEST', 1);
+                       $invalid_dates   = array();
+                       $valid_dates     = array();
 
                        if($allocation_id)
                        {
-                               $allocation = 
$this->allocation_bo->read_single($allocation_id);
-                               $season = 
$this->season_bo->read_single($allocation['season_id']);
-                               $building = 
$this->building_bo->read_single($season['building_id']);
-                               $booking['season_id'] = $season['id'];
-                               $booking['building_id'] = $building['id'];
-                               $booking['building_name'] = $building['name'];
-                $booking['allocation_id'] = $allocation_id;
-                               array_set_default($booking, 'resources', array( 
phpgw::get_var('resource')));
-                       } else {
+                               $allocation                                     
 = $this->allocation_bo->read_single($allocation_id);
+                               $season                                         
 = $this->season_bo->read_single($allocation['season_id']);
+                               $building                                       
 = $this->building_bo->read_single($season['building_id']);
+                               $booking['season_id']            = 
$season['id'];
+                               $booking['building_id']          = 
$building['id'];
+                               $booking['building_name']        = 
$building['name'];
+                               $booking['allocation_id']        = 
$allocation_id;
+                               array_set_default($booking, 'resources', 
array(phpgw::get_var('resource')));
+                       }
+                       else
+                       {
                                $season = 
$this->season_bo->read_single($_POST['season_id']);
-            }
+                       }
                        if($_SERVER['REQUEST_METHOD'] == 'POST')
                        {
-                $_POST['repeat_until'] = ($_POST['repeat_until']) ? 
date("Y-m-d", phpgwapi_datetime::date_to_timestamp($_POST['repeat_until'])) : 
"";
-                
-                               $today = getdate();
+                               $_POST['repeat_until'] = 
($_POST['repeat_until']) ? date("Y-m-d", 
phpgwapi_datetime::date_to_timestamp($_POST['repeat_until'])) : "";
+
+                               $today   = getdate();
                                $booking = extract_values($_POST, 
$this->fields);
-                               if(strlen($_POST['from_']) < 6) 
+                               if(strlen($_POST['from_']) < 6)
                                {
-                                       $date_from = array($time_from[0], 
phpgw::get_var('from_'));
-                                       $booking['from_'] = join(" 
",$date_from);
-                                       $_POST['from_'] = join(" ",$date_from);
-                                       $date_to = array($time_to[0], 
phpgw::get_var('to_'));
-                                       $booking['to_'] = join(" ",$date_to); 
-                                       $_POST['to_'] = join(" ",$date_to);
-                               }                               
-                               $booking['building_name'] = $building['name'];
-                               $booking['building_id'] = $building['id'];
-                               $booking['active'] = '1';
-                               $booking['cost'] = 0;
-                               $booking['completed'] = '0';
-                               $booking['reminder'] = '1';
-                               $booking['secret'] = $this->generate_secret();
+                                       $date_from                       = 
array($time_from[0], phpgw::get_var('from_'));
+                                       $booking['from_']        = join(" ", 
$date_from);
+                                       $_POST['from_']          = join(" ", 
$date_from);
+                                       $date_to                         = 
array($time_to[0], phpgw::get_var('to_'));
+                                       $booking['to_']          = join(" ", 
$date_to);
+                                       $_POST['to_']            = join(" ", 
$date_to);
+                               }
+                               $booking['building_name']        = 
$building['name'];
+                               $booking['building_id']          = 
$building['id'];
+                               $booking['active']                       = '1';
+                               $booking['cost']                         = 0;
+                               $booking['completed']            = '0';
+                               $booking['reminder']             = '1';
+                               $booking['secret']                       = 
$this->generate_secret();
                                array_set_default($booking, 'audience', 
array());
                                array_set_default($booking, 'agegroups', 
array());
                                array_set_default($_POST, 'resources', array());
@@ -162,67 +169,70 @@
 #                                              $errors['booking'] = lang('Can 
not create a booking in the past');
 #                                      }
 #                              } 
-                               if (!$season['id'] &&  $_POST['outseason'] == 
'on')
+                               if(!$season['id'] && $_POST['outseason'] == 
'on')
                                {
                                        $errors['booking'] = lang('This booking 
is not connected to a season');
-                               }       
+                               }
 
-                               if (!$errors)
+                               if(!$errors)
                                {
                                        $step++;
                                }
 
-                               if (!$errors && $_POST['recurring'] != 'on' && 
$_POST['outseason'] != 'on' )
+                               if(!$errors && $_POST['recurring'] != 'on' && 
$_POST['outseason'] != 'on')
                                {
                                        $receipt = $this->bo->add($booking);
-                                       $this->redirect(array('menuaction' => 
'bookingfrontend.uibuilding.schedule', 'id'=>$booking['building_id']));
+                                       $this->redirect(array('menuaction' => 
'bookingfrontend.uibuilding.schedule',
+                                               'id' => 
$booking['building_id']));
                                }
-                               else if ( ($_POST['recurring'] == 'on' || 
$_POST['outseason'] == 'on')  && !$errors && $step > 1)
+                               else if(($_POST['recurring'] == 'on' || 
$_POST['outseason'] == 'on') && !$errors && $step > 1)
                                {
-                                       if ($_POST['recurring'] == 'on') {
-                                               $repeat_until = 
strtotime($_POST['repeat_until'])+60*60*24; 
-                                       } 
+                                       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_'];
-                                       } 
+                                               $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;
+                                       $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)
+                                       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));
-                                               $booking['from_'] = $fromdate;
-                                               $booking['to_'] = $todate;
-                        $fromdate = pretty_timestamp($fromdate);
-                        $todate = pretty_timestamp($todate);
+                                               $fromdate                       
 = date('Y-m-d H:i', strtotime($_POST['from_']) + ($interval * $i));
+                                               $todate                         
 = date('Y-m-d H:i', strtotime($_POST['to_']) + ($interval * $i));
+                                               $booking['from_']        = 
$fromdate;
+                                               $booking['to_']          = 
$todate;
+                                               $fromdate                       
 = pretty_timestamp($fromdate);
+                                               $todate                         
 = pretty_timestamp($todate);
 
                                                $err = 
$this->bo->validate($booking);
-                                               if ($err) 
+                                               if($err)
                                                {
-                                                       
$invalid_dates[$i]['from_'] = $fromdate;
-                                                       
$invalid_dates[$i]['to_'] = $todate;
-                                               } 
-                                               else 
+                                                       
$invalid_dates[$i]['from_']      = $fromdate;
+                                                       
$invalid_dates[$i]['to_']        = $todate;
+                                               }
+                                               else
                                                {
-                                                       
$valid_dates[$i]['from_'] = $fromdate;
-                                                       $valid_dates[$i]['to_'] 
= $todate;
-                                                       if ($step == 3)
+                                                       
$valid_dates[$i]['from_']        = $fromdate;
+                                                       $valid_dates[$i]['to_'] 
         = $todate;
+                                                       if($step == 3)
                                                        {
-                                                               
$booking['secret'] = $this->generate_secret();
-                                                               $receipt = 
$this->bo->add($booking);
+                                                               
$booking['secret']       = $this->generate_secret();
+                                                               $receipt        
                 = $this->bo->add($booking);
                                                        }
                                                }
                                                $i++;
                                        }
-                                       if ($step == 3) 
+                                       if($step == 3)
                                        {
-                                               
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 
'id'=>$booking['building_id']));
+                                               
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                                                       'id' => 
$booking['building_id']));
                                        }
                                }
                        }
@@ -231,327 +241,341 @@
                        self::add_javascript('bookingfrontend', 
'bookingfrontend', 'booking.js');
                        array_set_default($booking, 'resources', array());
 
-            if(!$activity_id)
+                       if(!$activity_id)
                        {
                                $activity_id = phpgw::get_var('activity_id', 
'int', 'REQUEST', -1);
                        }
-            $activity_path = $this->activity_bo->get_path($activity_id);
-            $top_level_activity = $activity_path ? $activity_path[0]['id'] : 
-1;
-            
-                       $booking['resources_json'] = 
json_encode(array_map('intval', $booking['resources']));
-                       $booking['cancel_link'] = self::link(array('menuaction' 
=> 'bookingfrontend.uibuilding.schedule', 'id'=> $booking['building_id']));
-                       $agegroups = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
-                       $agegroups = $agegroups['results'];
-                       $audience = 
$this->audience_bo->fetch_target_audience($top_level_activity);
-                       $audience = $audience['results'];
-            $booking['audience_json'] = 
json_encode(array_map('intval',$booking['audience']));
-                       $activities = $this->activity_bo->fetch_activities();
-                       $activities = $activities['results'];
-                       $groups = 
$this->group_bo->so->read(array('filters'=>array('organization_id'=>$allocation['organization_id'],
 'active'=>1)));
-                       $groups = $groups['results'];
-            $booking['organization_name'] = $allocation['organization_name'];
-                       $resources_full = 
$this->resource_bo->so->read(array('filters'=>array('id'=>$booking['resources']),
 'sort'=>'name'));
-                       $res_names = array();
+                       $activity_path           = 
$this->activity_bo->get_path($activity_id);
+                       $top_level_activity      = $activity_path ? 
$activity_path[0]['id'] : -1;
+
+                       $booking['resources_json']               = 
json_encode(array_map('intval', $booking['resources']));
+                       $booking['cancel_link']                  = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                               'id' => $booking['building_id']));
+                       $agegroups                                              
 = $this->agegroup_bo->fetch_age_groups($top_level_activity);
+                       $agegroups                                              
 = $agegroups['results'];
+                       $audience                                               
 = $this->audience_bo->fetch_target_audience($top_level_activity);
+                       $audience                                               
 = $audience['results'];
+                       $booking['audience_json']                = 
json_encode(array_map('intval', $booking['audience']));
+                       $activities                                             
 = $this->activity_bo->fetch_activities();
+                       $activities                                             
 = $activities['results'];
+                       $groups                                                 
 = $this->group_bo->so->read(array('filters' => array('organization_id' => 
$allocation['organization_id'],
+                                       'active' => 1)));
+                       $groups                                                 
 = $groups['results'];
+                       $booking['organization_name']    = 
$allocation['organization_name'];
+                       $resources_full                                  = 
$this->resource_bo->so->read(array('filters' => array(
+                                       'id' => $booking['resources']), 'sort' 
=> 'name'));
+                       $res_names                                              
 = array();
                        foreach($resources_full['results'] as $res)
                        {
-                               $res_names[] = array('id' => $res['id'],'name' 
=> $res['name']);
+                               $res_names[] = array('id' => $res['id'], 'name' 
=> $res['name']);
                        }
-            
-            $GLOBALS['phpgw']->jqcal->add_listener('field_from', 'time');
-            $GLOBALS['phpgw']->jqcal->add_listener('field_to', 'time');
-            $GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 
'date');
-            
-            $booking['from_'] = pretty_timestamp($booking['from_']);
-            $booking['to_'] = pretty_timestamp($booking['to_']);
-            
-            phpgwapi_jquery::formvalidator_generate(array('location', 'date', 
'security', 'file'), 'booking_form');
-            
-                       if ($step < 2) 
+
+                       $GLOBALS['phpgw']->jqcal->add_listener('field_from', 
'time');
+                       $GLOBALS['phpgw']->jqcal->add_listener('field_to', 
'time');
+                       
$GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 'date');
+
+                       $booking['from_']        = 
pretty_timestamp($booking['from_']);
+                       $booking['to_']          = 
pretty_timestamp($booking['to_']);
+
+                       
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
+                               'file'), 'booking_form');
+
+                       if($step < 2)
                        {
-                               self::render_template_xsl('booking_new', 
array('booking' => $booking, 
-                                       'activities' => $activities, 
-                                       'agegroups' => $agegroups, 
-                                       'audience' => $audience, 
-                                       'groups' => $groups, 
-                                       'step' => $step, 
-                                       'interval' => $_POST['field_interval'],
-                                       'repeat_until' => 
pretty_timestamp($_POST['repeat_until']),
-                                       'recurring' => $_POST['recurring'],
-                                       'outseason' => $_POST['outseason'],
-                                       'date_from' => $time_from[0],
-                                       'date_to' => $time_to[0],
-                                       'res_names' => $res_names)
+                               self::render_template_xsl('booking_new', 
array('booking'                 => $booking,
+                                       'activities'     => $activities,
+                                       'agegroups'              => $agegroups,
+                                       'audience'               => $audience,
+                                       'groups'                 => $groups,
+                                       'step'                   => $step,
+                                       'interval'               => 
$_POST['field_interval'],
+                                       'repeat_until'   => 
pretty_timestamp($_POST['repeat_until']),
+                                       'recurring'              => 
$_POST['recurring'],
+                                       'outseason'              => 
$_POST['outseason'],
+                                       'date_from'              => 
$time_from[0],
+                                       'date_to'                => $time_to[0],
+                                       'res_names'              => $res_names)
                                );
-                       } 
-                       else if ($step == 2) 
+                       }
+                       else if($step == 2)
                        {
-                               
self::render_template_xsl('booking_new_preview', array('booking' => $booking, 
-                                       'activities' => $activities,
-                                       'agegroups' => $agegroups,
-                                       'audience' => $audience,
-                                       'step' => $step,
-                                       'recurring' => $_POST['recurring'],
-                                       'outseason' => $_POST['outseason'],
-                                       'interval' => $_POST['field_interval'],
-                                       'repeat_until' => 
pretty_timestamp($_POST['repeat_until']),
-                                       'from_date' => $_POST['from_'],
-                                       'to_date' => $_POST['to_'],
-                                       'valid_dates' => $valid_dates,
-                                       'invalid_dates' => $invalid_dates,
-                                       'groups' => $groups)
+                               
self::render_template_xsl('booking_new_preview', array('booking'                
 => $booking,
+                                       'activities'     => $activities,
+                                       'agegroups'              => $agegroups,
+                                       'audience'               => $audience,
+                                       'step'                   => $step,
+                                       'recurring'              => 
$_POST['recurring'],
+                                       'outseason'              => 
$_POST['outseason'],
+                                       'interval'               => 
$_POST['field_interval'],
+                                       'repeat_until'   => 
pretty_timestamp($_POST['repeat_until']),
+                                       'from_date'              => 
$_POST['from_'],
+                                       'to_date'                => 
$_POST['to_'],
+                                       'valid_dates'    => $valid_dates,
+                                       'invalid_dates'  => $invalid_dates,
+                                       'groups'                 => $groups)
                                );
                        }
                }
 
                public function report_numbers()
                {
-                       $step = 1;
-                       $id = phpgw::get_var('id', 'int');
+                       $step    = 1;
+                       $id              = phpgw::get_var('id', 'int');
                        $booking = $this->bo->read_single($id);
-            
-            $activity_path = 
$this->activity_bo->get_path($booking['activity_id']);
-            $top_level_activity = $activity_path ? $activity_path[0]['id'] : 
-1;
-            
-                       $agegroups = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
-                       $agegroups = $agegroups['results'];
-                       $building = 
$this->building_bo->read_single($booking['building_id']);
-            
-                       if ($booking['secret'] != phpgw::get_var('secret', 
'string'))
+
+                       $activity_path           = 
$this->activity_bo->get_path($booking['activity_id']);
+                       $top_level_activity      = $activity_path ? 
$activity_path[0]['id'] : -1;
+
+                       $agegroups       = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
+                       $agegroups       = $agegroups['results'];
+                       $building        = 
$this->building_bo->read_single($booking['building_id']);
+
+                       if($booking['secret'] != phpgw::get_var('secret', 
'string'))
                        {
                                $step = -1; // indicates that an error message 
should be displayed in the template
-                               self::render_template_xsl('report_numbers', 
array('event_object' => $booking, 'agegroups' => $agegroups, 'building' => 
$building, 'step' => $step));
+                               self::render_template_xsl('report_numbers', 
array('event_object' => $booking,
+                                       'agegroups' => $agegroups, 'building' 
=> $building, 'step' => $step));
                                return false;
                        }
 
                        if($_SERVER['REQUEST_METHOD'] == 'POST')
                        {
                                //reformatting the post variable to fit the 
booking object
-                               $temp_agegroup = array();
-                               $sexes = array('male', 'female');
+                               $temp_agegroup   = array();
+                               $sexes                   = array('male', 
'female');
                                foreach($sexes as $sex)
                                {
                                        $i = 0;
-                                       foreach(phpgw::get_var($sex, 
'string','POST') as $agegroup_id => $value)
+                                       foreach(phpgw::get_var($sex, 'string', 
'POST') as $agegroup_id => $value)
                                        {
-                                               
$temp_agegroup[$i]['agegroup_id'] = $agegroup_id;
-                                               $temp_agegroup[$i][$sex] = 
$value;
+                                               
$temp_agegroup[$i]['agegroup_id']        = $agegroup_id;
+                                               $temp_agegroup[$i][$sex]        
                 = $value;
                                                $i++;
                                        }
                                }
 
-                               $booking['agegroups'] = $temp_agegroup;
-                               $booking['reminder'] = 2; // status set to 
delivered
-                               $errors = $this->bo->validate($booking);
+                               $booking['agegroups']    = $temp_agegroup;
+                               $booking['reminder']     = 2; // status set to 
delivered
+                               $errors                                  = 
$this->bo->validate($booking);
                                if(!$errors)
                                {
                                        $receipt = $this->bo->update($booking);
                                        $step++;
                                }
-                       } 
-                       self::render_template_xsl('report_numbers', 
array('event_object' => $booking, 'agegroups' => $agegroups, 'building' => 
$building, 'step' => $step));
+                       }
+                       self::render_template_xsl('report_numbers', 
array('event_object' => $booking,
+                               'agegroups' => $agegroups, 'building' => 
$building, 'step' => $step));
                }
 
                public function edit()
                {
-                       $id = phpgw::get_var('id', 'int');
-                       $booking = $this->bo->read_single($id);
-                       $booking['building'] = 
$this->building_bo->so->read_single($booking['building_id']);
-                       $booking['building_name'] = 
$booking['building']['name'];
-                       $group = 
$this->group_bo->read_single($booking['group_id']);
-                       $errors = array();
-                       $update_count = 0;
-                       $today = getdate();
-                       $step = phpgw::get_var('step', 'int');
+                       $id                                                     
 = phpgw::get_var('id', 'int');
+                       $booking                                         = 
$this->bo->read_single($id);
+                       $booking['building']             = 
$this->building_bo->so->read_single($booking['building_id']);
+                       $booking['building_name']        = 
$booking['building']['name'];
+                       $group                                           = 
$this->group_bo->read_single($booking['group_id']);
+                       $errors                                          = 
array();
+                       $update_count                            = 0;
+                       $today                                           = 
getdate();
+                       $step                                            = 
phpgw::get_var('step', 'int');
 
                        if($_SERVER['REQUEST_METHOD'] == 'POST')
                        {
-                $_POST['from_'] = ($_POST['from_']) ? date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['from_'])) : "";
-                $_POST['to_'] = ($_POST['to_']) ? date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['to_'])) : "";
-                $_POST['repeat_until'] = ($_POST['repeat_until']) ? 
date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['repeat_until'])) : "";
+                               $_POST['from_']                  = 
($_POST['from_']) ? date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['from_'])) : "";
+                               $_POST['to_']                    = 
($_POST['to_']) ? date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['to_'])) : "";
+                               $_POST['repeat_until']   = 
($_POST['repeat_until']) ? date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['repeat_until'])) : "";
 
-                               if (!($_POST['recurring'] == 'on' || 
$_POST['outseason'] == 'on')){
+                               if(!($_POST['recurring'] == 'on' || 
$_POST['outseason'] == 'on'))
+                               {
 
                                        array_set_default($_POST, 'resources', 
array());
                                        $booking = array_merge($booking, 
extract_values($_POST, $this->fields));
                                        
$this->agegroup_bo->extract_form_data($booking);
-                                       $errors = $this->bo->validate($booking);
-                               
+                                       $errors  = 
$this->bo->validate($booking);
+
 #                                      if (strtotime($_POST['from_']) < 
($today[0]-60*60*24*7*2))
 #                                      {
 #                                              $errors['booking'] = lang('You 
cant edit a booking that is older than 2 weeks');
 #                                      }                                       
                                        
-                                       if (!$errors) {
+                                       if(!$errors)
+                                       {
                                                $receipt = 
$this->bo->update($booking);
-                                               
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 
'id'=>$booking['building_id']));
+                                               
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                                                       'id' => 
$booking['building_id']));
                                        }
-                               } 
-                               else 
+                               }
+                               else
                                {
                                        $step++;
 
-                                       if (strtotime($_POST['from_']) < 
($today[0]-60*60*24*7*2) && $step != 3)
-                                       {                                       
+                                       if(strtotime($_POST['from_']) < 
($today[0] - 60 * 60 * 24 * 7 * 2) && $step != 3)
+                                       {
                                                $errors['booking'] = lang('You 
cant update bookings that is older than 2 weeks');
                                        }
 
-                                       if (!$errors)
+                                       if(!$errors)
                                        {
 
-                        $max_dato = strtotime($_POST['to_']); // highest date 
from input
+                                               $max_dato = 
strtotime($_POST['to_']); // highest date from input
 
-                        $season = 
$this->season_bo->read_single($booking['season_id']);
+                                               $season = 
$this->season_bo->read_single($booking['season_id']);
 
-                                               if ($_POST['recurring'] == 
'on') {
-                                                       $repeat_until = 
strtotime($_POST['repeat_until'])+60*60*24; 
-                                               } 
+                                               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_'];
-                                               } 
+                                                       $repeat_until           
         = strtotime($season['to_']) + 60 * 60 * 24;
+                                                       $_POST['repeat_until']  
 = $season['to_'];
+                                               }
 
                                                $where_clauses[] = 
sprintf("bb_booking.from_ >= '%s 00:00:00'", date('Y-m-d', 
strtotime($booking['from_'])));
-                                               if ($_POST['recurring'] == 
'on') {
+                                               if($_POST['recurring'] == 'on')
+                                               {
                                                        $where_clauses[] = 
sprintf("bb_booking.to_ < '%s 00:00:00'", date('Y-m-d', $repeat_until));
                                                }
-                        $where_clauses[] = sprintf("EXTRACT(DOW FROM 
bb_booking.from_) in (%s)",date('w', strtotime($booking['from_'])));
-                        $where_clauses[] = sprintf("EXTRACT(HOUR FROM 
bb_booking.from_) = %s",date('H', strtotime($booking['from_'])));
-                        $where_clauses[] = sprintf("EXTRACT(MINUTE FROM 
bb_booking.from_) = %s",date('i', strtotime($booking['from_'])));
-                        $where_clauses[] = sprintf("EXTRACT(HOUR FROM 
bb_booking.to_) = %s",date('H', strtotime($booking['to_'])));
-                        $where_clauses[] = sprintf("EXTRACT(MINUTE FROM 
bb_booking.to_) = %s",date('i', strtotime($booking['to_'])));
-                        $params['sort'] = 'from_';
-                                               $params['filters']['where'] = 
$where_clauses;
-                                               $params['filters']['season_id'] 
= $booking['season_id'];
-                                               $params['filters']['group_id'] 
= $booking['group_id'];
-                        $bookings = $this->bo->so->read($params);
+                                               $where_clauses[]                
                 = sprintf("EXTRACT(DOW FROM bb_booking.from_) in (%s)", 
date('w', strtotime($booking['from_'])));
+                                               $where_clauses[]                
                 = sprintf("EXTRACT(HOUR FROM bb_booking.from_) = %s", 
date('H', strtotime($booking['from_'])));
+                                               $where_clauses[]                
                 = sprintf("EXTRACT(MINUTE FROM bb_booking.from_) = %s", 
date('i', strtotime($booking['from_'])));
+                                               $where_clauses[]                
                 = sprintf("EXTRACT(HOUR FROM bb_booking.to_) = %s", date('H', 
strtotime($booking['to_'])));
+                                               $where_clauses[]                
                 = sprintf("EXTRACT(MINUTE FROM bb_booking.to_) = %s", 
date('i', strtotime($booking['to_'])));
+                                               $params['sort']                 
                 = 'from_';
+                                               $params['filters']['where']     
         = $where_clauses;
+                                               $params['filters']['season_id'] 
 = $booking['season_id'];
+                                               $params['filters']['group_id']  
 = $booking['group_id'];
+                                               $bookings                       
                         = $this->bo->so->read($params);
 
-                                               if ($step == 2)
+                                               if($step == 2)
                                                {
-                                                       $_SESSION['audience'] = 
$_POST['audience'];
-                                                       $_SESSION['male'] = 
$_POST['male'];
-                                                       $_SESSION['female'] = 
$_POST['female'];
-                            $_SESSION['from'] = 
mb_strcut($_POST['from_'],11,strlen($_POST['from_']));
-                            $_SESSION['to'] = 
mb_strcut($_POST['to_'],11,strlen($_POST['to_']));
+                                                       $_SESSION['audience']   
 = $_POST['audience'];
+                                                       $_SESSION['male']       
         = $_POST['male'];
+                                                       $_SESSION['female']     
         = $_POST['female'];
+                                                       $_SESSION['from']       
         = mb_strcut($_POST['from_'], 11, strlen($_POST['from_']));
+                                                       $_SESSION['to']         
         = mb_strcut($_POST['to_'], 11, strlen($_POST['to_']));
                                                }
-                        if ($step == 3)
+                                               if($step == 3)
                                                {
                                                        
foreach($bookings['results'] as $b)
                                                        {
                                                                //reformatting 
the post variable to fit the booking object
-                                                               $temp_agegroup 
= array();
-                                                               $sexes = 
array('male', 'female');
+                                                               $temp_agegroup  
 = array();
+                                                               $sexes          
         = array('male', 'female');
                                                                foreach($sexes 
as $sex)
                                                                {
                                                                        $i = 0;
                                                                        
foreach($_SESSION[$sex] as $agegroup_id => $value)
                                                                        {
-                                                                               
$temp_agegroup[$i]['agegroup_id'] = $agegroup_id;
-                                                                               
$temp_agegroup[$i][$sex] = $value;
+                                                                               
$temp_agegroup[$i]['agegroup_id']        = $agegroup_id;
+                                                                               
$temp_agegroup[$i][$sex]                         = $value;
                                                                                
$i++;
                                                                        }
                                                                }
-                                                               $b['agegroups'] 
= $temp_agegroup;
-                                                               $b['audience'] 
= $_SESSION['audience'];
-                                                               $b['group_id'] 
=$_POST['group_id'];
-                                                               
$b['activity_id'] = $_POST['activity_id'];
-                                $b['from_'] = 
mb_strcut($b['from_'],0,11).$_SESSION['from'];
-                                $b['to_'] = 
mb_strcut($b['to_'],0,11).$_SESSION['to'];
-                                $errors = $this->bo->validate($b);
+                                                               $b['agegroups'] 
         = $temp_agegroup;
+                                                               $b['audience']  
         = $_SESSION['audience'];
+                                                               $b['group_id']  
         = $_POST['group_id'];
+                                                               
$b['activity_id']        = $_POST['activity_id'];
+                                                               $b['from_']     
                 = mb_strcut($b['from_'], 0, 11) . $_SESSION['from'];
+                                                               $b['to_']       
                 = mb_strcut($b['to_'], 0, 11) . $_SESSION['to'];
+                                                               $errors         
                 = $this->bo->validate($b);
                                                                if(!$errors)
                                                                {
-                                    $receipt = $this->bo->update($b);
+                                                                       
$receipt = $this->bo->update($b);
                                                                        
$update_count++;
                                                                }
                                                        }
-                            unset($_SESSION['female']);
+                                                       
unset($_SESSION['female']);
                                                        
unset($_SESSION['male']);
                                                        
unset($_SESSION['audience']);
-
                                                }
-                    }
+                                       }
                                }
                        }
                        $this->flash_form_errors($errors);
                        self::add_javascript('bookingfrontend', 
'bookingfrontend', 'booking.js');
-                       if ($step < 2) {
-                               $booking['resources_json'] = 
json_encode(array_map('intval', $booking['resources']));
-                               $booking['organization_name'] = 
$group['organization_name'];
-                $booking['organization_id'] = $group['organization_id'];
+                       if($step < 2)
+                       {
+                               $booking['resources_json']               = 
json_encode(array_map('intval', $booking['resources']));
+                               $booking['organization_name']    = 
$group['organization_name'];
+                               $booking['organization_id']              = 
$group['organization_id'];
                        }
 
-            $activity_path = 
$this->activity_bo->get_path($booking['activity_id']);
-            $top_level_activity = $activity_path ? $activity_path[0]['id'] : 
-1;
-            
-                       $booking['cancel_link'] = self::link(array('menuaction' 
=> 'bookingfrontend.uibuilding.schedule', 'id' => $booking['building_id']));
-                       $agegroups = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
-                       $agegroups = $agegroups['results'];
-                       $audience = 
$this->audience_bo->fetch_target_audience($top_level_activity);
-                       $audience = $audience['results'];
-                       $activities = $this->activity_bo->fetch_activities();
-                       $activities = $activities['results'];
-            $booking['audience_json'] = 
json_encode(array_map('intval',$booking['audience']));
-                       $group = 
$this->group_bo->so->read_single($booking['group_id']);
-                       $groups = 
$this->group_bo->so->read(array('filters'=>array('organization_id'=>$group['organization_id'],
 'active'=>1)));
-                       $groups =  $groups['results'];
+                       $activity_path           = 
$this->activity_bo->get_path($booking['activity_id']);
+                       $top_level_activity      = $activity_path ? 
$activity_path[0]['id'] : -1;
 
-            $GLOBALS['phpgw']->jqcal->add_listener('field_from', 'datetime');
-            $GLOBALS['phpgw']->jqcal->add_listener('field_to', 'datetime');
-            
-            $GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 
'date');
-            
-            $booking['from_'] = pretty_timestamp($booking['from_']);
-            $booking['to_'] = pretty_timestamp($booking['to_']);
-            
-            foreach($bookings['results'] as &$b)
+                       $booking['cancel_link']          = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                               'id' => $booking['building_id']));
+                       $agegroups                                       = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
+                       $agegroups                                       = 
$agegroups['results'];
+                       $audience                                        = 
$this->audience_bo->fetch_target_audience($top_level_activity);
+                       $audience                                        = 
$audience['results'];
+                       $activities                                      = 
$this->activity_bo->fetch_activities();
+                       $activities                                      = 
$activities['results'];
+                       $booking['audience_json']        = 
json_encode(array_map('intval', $booking['audience']));
+                       $group                                           = 
$this->group_bo->so->read_single($booking['group_id']);
+                       $groups                                          = 
$this->group_bo->so->read(array('filters' => array('organization_id' => 
$group['organization_id'],
+                                       'active' => 1)));
+                       $groups                                          = 
$groups['results'];
+
+                       $GLOBALS['phpgw']->jqcal->add_listener('field_from', 
'datetime');
+                       $GLOBALS['phpgw']->jqcal->add_listener('field_to', 
'datetime');
+
+                       
$GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 'date');
+
+                       $booking['from_']        = 
pretty_timestamp($booking['from_']);
+                       $booking['to_']          = 
pretty_timestamp($booking['to_']);
+
+                       foreach($bookings['results'] as &$b)
                        {
-                               $b['from_'] = pretty_timestamp($b['from_']);
-                               $b['to_'] = pretty_timestamp($b['to_']);
+                               $b['from_']      = 
pretty_timestamp($b['from_']);
+                               $b['to_']        = pretty_timestamp($b['to_']);
                        }
-            
-            phpgwapi_jquery::formvalidator_generate(array('location', 'date', 
'security', 'file'), 'booking_form');
-            
-                       if ($step < 2) 
+
+                       
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
+                               'file'), 'booking_form');
+
+                       if($step < 2)
                        {
-                               self::render_template_xsl('booking_edit', 
array('booking' => $booking, 
-                                       'activities' => $activities, 
-                                       'agegroups' => $agegroups, 
-                                       'audience' => $audience, 
-                                       'groups' => $groups, 
-                                       'step' => $step, 
-                                       'repeat_until' => 
$_POST['repeat_until'],
-                                       'recurring' => $_POST['recurring'],
-                                       'outseason' => $_POST['outseason'],
-                                       )
+                               self::render_template_xsl('booking_edit', 
array('booking'                => $booking,
+                                       'activities'     => $activities,
+                                       'agegroups'              => $agegroups,
+                                       'audience'               => $audience,
+                                       'groups'                 => $groups,
+                                       'step'                   => $step,
+                                       'repeat_until'   => 
$_POST['repeat_until'],
+                                       'recurring'              => 
$_POST['recurring'],
+                                       'outseason'              => 
$_POST['outseason'],
+                               )
                                );
-                       } 
-                       else if ($step >= 2) 
+                       }
+                       else if($step >= 2)
                        {
-                               
self::render_template_xsl('booking_edit_preview', array('booking' => $booking, 
-                                       'bookings' => $bookings,
-                                       'agegroups' => $agegroups,
-                                       'audience' => $audience,
-                                       'groups' => $groups,
-                                       'activities' => $activities,
-                                       'step' => $step,
-                                       'repeat_until' => 
pretty_timestamp($_POST['repeat_until']),
-                                       'recurring' => $_POST['recurring'],
-                                       'outseason' => $_POST['outseason'],
-                                       'group_id' => $_POST['group_id'],
-                                       'activity_id' => $_POST['activity_id'],
-                                       'update_count' => $update_count)
+                               
self::render_template_xsl('booking_edit_preview', array('booking'               
 => $booking,
+                                       'bookings'               => $bookings,
+                                       'agegroups'              => $agegroups,
+                                       'audience'               => $audience,
+                                       'groups'                 => $groups,
+                                       'activities'     => $activities,
+                                       'step'                   => $step,
+                                       'repeat_until'   => 
pretty_timestamp($_POST['repeat_until']),
+                                       'recurring'              => 
$_POST['recurring'],
+                                       'outseason'              => 
$_POST['outseason'],
+                                       'group_id'               => 
$_POST['group_id'],
+                                       'activity_id'    => 
$_POST['activity_id'],
+                                       'update_count'   => $update_count)
                                );
                        }
                }
 
                public function massupdate()
                {
-                       $id = phpgw::get_var('id', 'int');
-                       $booking = $this->bo->read_single($id);
-                       $booking['building'] = 
$this->building_bo->so->read_single($booking['building_id']);
-                       $booking['building_name'] = 
$booking['building']['name'];
-                       $allocation = 
$this->allocation_bo->read_single($booking['allocation_id']);
-                       $errors = array();
-                       $update_count = 0;
+                       $id                                                     
 = phpgw::get_var('id', 'int');
+                       $booking                                         = 
$this->bo->read_single($id);
+                       $booking['building']             = 
$this->building_bo->so->read_single($booking['building_id']);
+                       $booking['building_name']        = 
$booking['building']['name'];
+                       $allocation                                      = 
$this->allocation_bo->read_single($booking['allocation_id']);
+                       $errors                                          = 
array();
+                       $update_count                            = 0;
                        if($_SERVER['REQUEST_METHOD'] == 'POST')
                        {
                                $step = phpgw::get_var('step', 'int', 'POST');
@@ -559,48 +583,48 @@
 
                                $season = 
$this->season_bo->read_single($booking['season_id']);
 
-                $where_clauses[] = sprintf("EXTRACT(DOW FROM bb_booking.from_) 
in (%s)",date('w', strtotime($booking['from_'])));
-                $where_clauses[] = sprintf("EXTRACT(HOUR FROM 
bb_booking.from_) = %s",date('H', strtotime($booking['from_'])));
-                $where_clauses[] = sprintf("EXTRACT(MINUTE FROM 
bb_booking.from_) = %s",date('i', strtotime($booking['from_'])));
-                $where_clauses[] = sprintf("EXTRACT(HOUR FROM bb_booking.to_) 
= %s",date('H', strtotime($booking['to_'])));
-                $where_clauses[] = sprintf("EXTRACT(MINUTE FROM 
bb_booking.to_) = %s",date('i', strtotime($booking['to_'])));
-                $where_clauses[] = sprintf("bb_booking.from_ >= '%s 
00:00:00'", date('Y-m-d'));
-                $params['sort'] = 'from_';
-                               $params['filters']['where'] = $where_clauses;
-                               $params['filters']['season_id'] = 
$booking['season_id'];
-                               $params['filters']['group_id'] = 
$booking['group_id'];
-                               $booking = $this->bo->so->read($params);
+                               $where_clauses[]                                
 = sprintf("EXTRACT(DOW FROM bb_booking.from_) in (%s)", date('w', 
strtotime($booking['from_'])));
+                               $where_clauses[]                                
 = sprintf("EXTRACT(HOUR FROM bb_booking.from_) = %s", date('H', 
strtotime($booking['from_'])));
+                               $where_clauses[]                                
 = sprintf("EXTRACT(MINUTE FROM bb_booking.from_) = %s", date('i', 
strtotime($booking['from_'])));
+                               $where_clauses[]                                
 = sprintf("EXTRACT(HOUR FROM bb_booking.to_) = %s", date('H', 
strtotime($booking['to_'])));
+                               $where_clauses[]                                
 = sprintf("EXTRACT(MINUTE FROM bb_booking.to_) = %s", date('i', 
strtotime($booking['to_'])));
+                               $where_clauses[]                                
 = sprintf("bb_booking.from_ >= '%s 00:00:00'", date('Y-m-d'));
+                               $params['sort']                                 
 = 'from_';
+                               $params['filters']['where']              = 
$where_clauses;
+                               $params['filters']['season_id']  = 
$booking['season_id'];
+                               $params['filters']['group_id']   = 
$booking['group_id'];
+                               $booking                                        
         = $this->bo->so->read($params);
 
-                               if ($step == 2)
+                               if($step == 2)
                                {
-                                       $_SESSION['audience'] = 
$_POST['audience'];
-                                       $_SESSION['male'] = $_POST['male'];
-                                       $_SESSION['female'] = $_POST['female'];
+                                       $_SESSION['audience']    = 
$_POST['audience'];
+                                       $_SESSION['male']                = 
$_POST['male'];
+                                       $_SESSION['female']              = 
$_POST['female'];
                                }
 
-                               if ($step == 3)
+                               if($step == 3)
                                {
                                        foreach($booking['results'] as $b)
                                        {
                                                //reformatting the post 
variable to fit the booking object
-                                               $temp_agegroup = array();
-                                               $sexes = array('male', 
'female');
+                                               $temp_agegroup   = array();
+                                               $sexes                   = 
array('male', 'female');
                                                foreach($sexes as $sex)
                                                {
                                                        $i = 0;
                                                        foreach($_SESSION[$sex] 
as $agegroup_id => $value)
                                                        {
-                                                               
$temp_agegroup[$i]['agegroup_id'] = $agegroup_id;
-                                                               
$temp_agegroup[$i][$sex] = $value;
+                                                               
$temp_agegroup[$i]['agegroup_id']        = $agegroup_id;
+                                                               
$temp_agegroup[$i][$sex]                         = $value;
                                                                $i++;
                                                        }
                                                }
 
-                                               $b['agegroups'] = 
$temp_agegroup;
-                                               $b['audience'] = 
$_SESSION['audience'];
-                                               $b['group_id'] 
=$_POST['group_id'];
-                                               $b['activity_id'] = 
$_POST['activity_id'];
-                                               $errors = 
$this->bo->validate($b);
+                                               $b['agegroups']          = 
$temp_agegroup;
+                                               $b['audience']           = 
$_SESSION['audience'];
+                                               $b['group_id']           = 
$_POST['group_id'];
+                                               $b['activity_id']        = 
$_POST['activity_id'];
+                                               $errors                         
 = $this->bo->validate($b);
                                                if(!$errors)
                                                {
                                                        $receipt = 
$this->bo->update($b);
@@ -611,116 +635,140 @@
                                        unset($_SESSION['male']);
                                        unset($_SESSION['audience']);
                                }
-                foreach($booking['results'] as &$b)
-                {
-                    $b['from_'] = pretty_timestamp($b['from_']);
-                    $b['to_'] = pretty_timestamp($b['to_']);
-                }
+                               foreach($booking['results'] as &$b)
+                               {
+                                       $b['from_']      = 
pretty_timestamp($b['from_']);
+                                       $b['to_']        = 
pretty_timestamp($b['to_']);
+                               }
                        }
 
                        $this->flash_form_errors($errors);
-            
-            $activity_path = 
$this->activity_bo->get_path($booking['activity_id']);
-            $top_level_activity = $activity_path ? $activity_path[0]['id'] : 
-1;
-            
-                       $agegroups = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
-                       $agegroups = $agegroups['results'];
-                       $audience = 
$this->audience_bo->fetch_target_audience($top_level_activity);
-                       $audience = $audience['results'];
-            $booking['audience_json'] = 
json_encode(array_map('intval',$booking['audience']));
 
-                       $group = 
$this->group_bo->so->read_single($booking['group_id']);
-                       $groups = 
$this->group_bo->so->read(array('filters'=>array('organization_id'=>$group['organization_id'],
 'active'=>1)));
-                       $groups =  $groups['results'];
+                       $activity_path           = 
$this->activity_bo->get_path($booking['activity_id']);
+                       $top_level_activity      = $activity_path ? 
$activity_path[0]['id'] : -1;
 
-                       $activities = $this->activity_bo->fetch_activities();
-                       $activities = $activities['results'];
+                       $agegroups                                       = 
$this->agegroup_bo->fetch_age_groups($top_level_activity);
+                       $agegroups                                       = 
$agegroups['results'];
+                       $audience                                        = 
$this->audience_bo->fetch_target_audience($top_level_activity);
+                       $audience                                        = 
$audience['results'];
+                       $booking['audience_json']        = 
json_encode(array_map('intval', $booking['audience']));
 
-            self::add_javascript('bookingfrontend', 'bookingfrontend', 
'booking_massupdate.js');
-            
-            phpgwapi_jquery::formvalidator_generate(array('location', 'date', 
'security', 'file'), 'booking_form');
+                       $group   = 
$this->group_bo->so->read_single($booking['group_id']);
+                       $groups  = $this->group_bo->so->read(array('filters' => 
array('organization_id' => $group['organization_id'],
+                                       'active' => 1)));
+                       $groups  = $groups['results'];
 
-                       self::render_template_xsl('booking_massupdate',
-                                       array('booking' => $booking,
-                                                 'agegroups' => $agegroups,
-                                                 'audience' => $audience,
-                                                 'groups' => $groups,
-                                                 'activities' => $activities,
-                                                 'step' => $step,
-                                                 'group_id' => 
$_POST['group_id'],
-                                                 'activity_id' => 
$_POST['activity_id'],
-                                                 'update_count' => 
$update_count,
-                                               )
-                                       );
+                       $activities      = 
$this->activity_bo->fetch_activities();
+                       $activities      = $activities['results'];
+
+                       self::add_javascript('bookingfrontend', 
'bookingfrontend', 'booking_massupdate.js');
+
+                       
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
+                               'file'), 'booking_form');
+
+                       self::render_template_xsl('booking_massupdate', 
array('booking'          => $booking,
+                               'agegroups'              => $agegroups,
+                               'audience'               => $audience,
+                               'groups'                 => $groups,
+                               'activities'     => $activities,
+                               'step'                   => $step,
+                               'group_id'               => $_POST['group_id'],
+                               'activity_id'    => $_POST['activity_id'],
+                               'update_count'   => $update_count,
+                       )
+                       );
                }
 
-               public function building_users($building_id, $group_id, 
$type=false, $activities=array()) {
-            $contacts = array();
-                       $organizations = 
$this->organization_bo->find_building_users($building_id, $type, $activities);
-            foreach($organizations['results'] as $org)
-            {
-                if ($org['email'] != '' && strstr($org['email'], '@')) {
-                    if (!in_array($org['email'], $contacts)) {
-                        $contacts[] = $org['email'];
-                    }
-                }
-                if ($org['contacts'][0]['email'] != '' && 
strstr($org['contacts'][0]['email'], '@')) {
-                    if (!in_array($org['contacts'][0]['email'], $contacts)) {
-                        $contacts[] = $org['contacts'][0]['email']; 
-                    }
-                }
-                if ($org['contacts'][1]['email'] != '' && 
strstr($org['contacts'][1]['email'], '@')) {
-                    if (!in_array($org['contacts'][1]['email'], $contacts)) {
-                        $contacts[] = $org['contacts'][1]['email']; 
-                    }
-                }
-                $grp_con = 
$this->bo->so->get_group_contacts_of_organization($org['id']);
-                foreach ($grp_con as $grp) {
-                    if ($grp['email'] != '' && strstr($grp['email'], '@') && 
$grp['group_id'] != $group_id ) {
-                        if (!in_array($grp['email'], $contacts)) {
-                            $contacts[] = $grp['email'];
-                        }
-                    }
-                }
-            } 
+               public function building_users($building_id, $group_id, $type = 
false, $activities = array())
+               {
+                       $contacts                = array();
+                       $organizations   = 
$this->organization_bo->find_building_users($building_id, $type, $activities);
+                       foreach($organizations['results'] as $org)
+                       {
+                               if($org['email'] != '' && strstr($org['email'], 
'@'))
+                               {
+                                       if(!in_array($org['email'], $contacts))
+                                       {
+                                               $contacts[] = $org['email'];
+                                       }
+                               }
+                               if($org['contacts'][0]['email'] != '' && 
strstr($org['contacts'][0]['email'], '@'))
+                               {
+                                       
if(!in_array($org['contacts'][0]['email'], $contacts))
+                                       {
+                                               $contacts[] = 
$org['contacts'][0]['email'];
+                                       }
+                               }
+                               if($org['contacts'][1]['email'] != '' && 
strstr($org['contacts'][1]['email'], '@'))
+                               {
+                                       
if(!in_array($org['contacts'][1]['email'], $contacts))
+                                       {
+                                               $contacts[] = 
$org['contacts'][1]['email'];
+                                       }
+                               }
+                               $grp_con = 
$this->bo->so->get_group_contacts_of_organization($org['id']);
+                               foreach($grp_con as $grp)
+                               {
+                                       if($grp['email'] != '' && 
strstr($grp['email'], '@') && $grp['group_id'] != $group_id)
+                                       {
+                                               if(!in_array($grp['email'], 
$contacts))
+                                               {
+                                                       $contacts[] = 
$grp['email'];
+                                               }
+                                       }
+                               }
+                       }
                        return $contacts;
                }
 
-               public function resource_users($resources, $group_id) {
-                       $contacts = array();
-                       $orglist = array();
-                       foreach($resources as $res){
+               public function resource_users($resources, $group_id)
+               {
+                       $contacts        = array();
+                       $orglist         = array();
+                       foreach($resources as $res)
+                       {
                                $cres = $this->resource_bo->read_single($res);
-                               if($cres['organizations_ids'] != '') {
-                                       $orglist .= 
$cres['organizations_ids'].',';
+                               if($cres['organizations_ids'] != '')
+                               {
+                                       $orglist .= $cres['organizations_ids'] 
. ',';
                                }
                        }
                        $orgs = explode(",", rtrim($orglist, ","));
 
 
-                       $organizations = 
$this->organization_bo->so->read(array('filters'=>array('id'=>$orgs), 
'sort'=>'name'));
+                       $organizations = 
$this->organization_bo->so->read(array('filters' => array('id' => $orgs),
+                               'sort' => 'name'));
                        foreach($organizations['results'] as $org)
                        {
-                               if ($org['email'] != '' && 
strstr($org['email'], '@')) {
-                                       if (!in_array($org['email'], 
$contacts)) {
+                               if($org['email'] != '' && strstr($org['email'], 
'@'))
+                               {
+                                       if(!in_array($org['email'], $contacts))
+                                       {
                                                $contacts[] = $org['email'];
                                        }
                                }
-                               if ($org['contacts'][0]['email'] != '' && 
strstr($org['contacts'][0]['email'], '@')) {
-                                       if 
(!in_array($org['contacts'][0]['email'], $contacts)) {
-                                               $contacts[] =  
$org['contacts'][0]['email'];
+                               if($org['contacts'][0]['email'] != '' && 
strstr($org['contacts'][0]['email'], '@'))
+                               {
+                                       
if(!in_array($org['contacts'][0]['email'], $contacts))
+                                       {
+                                               $contacts[] = 
$org['contacts'][0]['email'];
                                        }
                                }
-                               if ($org['contacts'][1]['email'] != '' && 
strstr($org['contacts'][1]['email'], '@')) {
-                                       if 
(!in_array($org['contacts'][1]['email'], $contacts)) {
+                               if($org['contacts'][1]['email'] != '' && 
strstr($org['contacts'][1]['email'], '@'))
+                               {
+                                       
if(!in_array($org['contacts'][1]['email'], $contacts))
+                                       {
                                                $contacts[] = 
$org['contacts'][1]['email'];
                                        }
                                }
                                $grp_con = 
$this->bo->so->get_group_contacts_of_organization($org['id']);
-                               foreach ($grp_con as $grp) {
-                                       if ($grp['email'] != '' && 
strstr($grp['email'], '@') && $grp['group_id'] != $group_id ) {
-                                               if (!in_array($grp['email'], 
$contacts)) {
-                                                       $contacts[] =  
$grp['email'];
+                               foreach($grp_con as $grp)
+                               {
+                                       if($grp['email'] != '' && 
strstr($grp['email'], '@') && $grp['group_id'] != $group_id)
+                                       {
+                                               if(!in_array($grp['email'], 
$contacts))
+                                               {
+                                                       $contacts[] = 
$grp['email'];
                                                }
                                        }
                                }
@@ -728,388 +776,419 @@
                        return $contacts;
                }
 
-               public function organization_users($group_id) {
+               public function organization_users($group_id)
+               {
 
-            $contacts = array();
-            $groups = 
$this->bo->so->get_all_group_of_organization_from_groupid($group_id);
-            foreach($groups as $grp) {
-                if ($grp['email'] != '' && strstr($grp['email'], '@') && 
$grp['group_id'] != $group_id ) {
-                    if (!in_array($grp['email'], $contacts)) {
-                        $contacts[] = $grp['email'];
-                    }
-                }
-            }
+                       $contacts        = array();
+                       $groups          = 
$this->bo->so->get_all_group_of_organization_from_groupid($group_id);
+                       foreach($groups as $grp)
+                       {
+                               if($grp['email'] != '' && strstr($grp['email'], 
'@') && $grp['group_id'] != $group_id)
+                               {
+                                       if(!in_array($grp['email'], $contacts))
+                                       {
+                                               $contacts[] = $grp['email'];
+                                       }
+                               }
+                       }
                        return $contacts;
-        }
+               }
+
                public function cancel()
                {
-                       $config = CreateObject('phpgwapi.config','booking');
+                       $config = CreateObject('phpgwapi.config', 'booking');
                        $config->read();
 
-                       if ($config->config_data['user_can_delete_bookings'] != 
'yes') {
+                       if($config->config_data['user_can_delete_bookings'] != 
'yes')
+                       {
 
-                       $booking = $this->bo->read_single(phpgw::get_var('id', 
'int'));
-                               $errors = array();
+                               $booking = 
$this->bo->read_single(phpgw::get_var('id', 'int'));
+                               $errors  = array();
                                if($_SERVER['REQUEST_METHOD'] == 'POST')
-                   {
-                   
-                       $from = $_POST['from_'];
-                       $to =  $_POST['to_'];
-                       $organization_id = $_POST['organization_id'];
-                       $outseason = $_POST['outseason'];
-                       $recurring = $_POST['recurring'];
-                       $repeat_until = $_POST['repeat_until'];
-                       $field_interval = $_POST['field_interval'];
-                       $delete_allocation = $_POST['delete_allocation'];
-                    $allocation = 
$this->allocation_bo->read_single($booking['allocation_id']);
+                               {
 
-                    $maildata = array();
-                    $maildata['outseason'] = $outseason;
-                    $maildata['recurring'] = $recurring;
-                    $maildata['repeat_until'] = $repeat_until;
-                    $maildata['delete_allocation'] = $delete_allocation;
+                                       $from                            = 
$_POST['from_'];
+                                       $to                                     
 = $_POST['to_'];
+                                       $organization_id         = 
$_POST['organization_id'];
+                                       $outseason                       = 
$_POST['outseason'];
+                                       $recurring                       = 
$_POST['recurring'];
+                                       $repeat_until            = 
$_POST['repeat_until'];
+                                       $field_interval          = 
$_POST['field_interval'];
+                                       $delete_allocation       = 
$_POST['delete_allocation'];
+                                       $allocation                      = 
$this->allocation_bo->read_single($booking['allocation_id']);
 
+                                       $maildata                               
                 = array();
+                                       $maildata['outseason']                  
 = $outseason;
+                                       $maildata['recurring']                  
 = $recurring;
+                                       $maildata['repeat_until']               
 = $repeat_until;
+                                       $maildata['delete_allocation']   = 
$delete_allocation;
 
-                    date_default_timezone_set("Europe/Oslo");
-                                       $date = new 
DateTime(phpgw::get_var('date'));
-                                       $system_message = array();
-                                       $system_message['building_id'] = 
intval($booking['building_id']);
+
+                                       
date_default_timezone_set("Europe/Oslo");
+                                       $date                                   
                 = new DateTime(phpgw::get_var('date'));
+                                       $system_message                         
         = array();
+                                       $system_message['building_id']   = 
intval($booking['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'] = 
$booking['group_name'];
-                                       $system_message['phone'] = ' ';
-                                       $system_message['email'] = ' ';
-                                       $system_message['title'] = 
lang('Cancelation of booking from')." ".$booking['group_name'];
+                                       $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']                 
 = $booking['group_name'];
+                                       $system_message['phone']                
 = ' ';
+                                       $system_message['email']                
 = ' ';
+                                       $system_message['title']                
 = lang('Cancelation of booking from') . " " . $booking['group_name'];
 
-                       $link = self::link(array('menuaction' => 
'booking.uibooking.delete','id' => $booking['id'], 'outseason' => $outseason, 
'recurring' => $recurring, 'repeat_until' => $repeat_until, 'field_interval' => 
$field_interval, 'delete_allocation' => $delete_allocation));
-                       $link = mb_strcut($link,16,strlen($link));
-                       $system_message['message'] = 
$system_message['message']."\n\n".lang('To cancel booking use this link')." - 
<a href='".$link."'>".lang('Delete')."</a>";
-                    $this->bo->send_admin_notification($booking, $maildata, 
$system_message, $allocation);
-                                       $receipt = 
$this->system_message_bo->add($system_message);
-                                       $this->redirect(array('menuaction' =>  
'bookingfrontend.uibuilding.schedule', 'id' => $system_message['building_id']));
+                                       $link                                   
         = self::link(array('menuaction' => 'booking.uibooking.delete', 'id' => 
$booking['id'],
+                                               'outseason' => $outseason, 
'recurring' => $recurring, 'repeat_until' => $repeat_until,
+                                               'field_interval' => 
$field_interval, 'delete_allocation' => $delete_allocation));
+                                       $link                                   
         = mb_strcut($link, 16, strlen($link));
+                                       $system_message['message']       = 
$system_message['message'] . "\n\n" . lang('To cancel booking use this link') . 
" - <a href='" . $link . "'>" . lang('Delete') . "</a>";
+                                       
$this->bo->send_admin_notification($booking, $maildata, $system_message, 
$allocation);
+                                       $receipt                                
         = $this->system_message_bo->add($system_message);
+                                       $this->redirect(array('menuaction' => 
'bookingfrontend.uibuilding.schedule',
+                                               'id' => 
$system_message['building_id']));
+                               }
 
-                   }
-                
-                $booking['from_'] = pretty_timestamp($booking['from_']);
-                $booking['to_'] = pretty_timestamp($booking['to_']);
-                
-                $GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 
'date');
-                $booking['resources_json'] = json_encode(array_map('intval', 
$booking['resources']));
-                
-                   $this->flash_form_errors($errors);
-                               $allocation['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 'id' => 
$allocation['building_id']));
-       
+                               $booking['from_']        = 
pretty_timestamp($booking['from_']);
+                               $booking['to_']          = 
pretty_timestamp($booking['to_']);
+
+                               
$GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 'date');
+                               $booking['resources_json'] = 
json_encode(array_map('intval', $booking['resources']));
+
+                               $this->flash_form_errors($errors);
+                               $allocation['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                                       'id' => $allocation['building_id']));
+
 //                             $this->use_yui_editor();
-                
-                phpgwapi_jquery::init_ckeditor('field-message');
-                               self::render_template_xsl('booking_cancel', 
array('booking'=>$booking));
 
-                       } else {
-       
-                               $id = phpgw::get_var('id', 'int');
-                               $outseason = phpgw::get_var('outseason', 
'string');
-                               $recurring = phpgw::get_var('recurring', 
'string');
-                               $repeat_until = phpgw::get_var('repeat_until', 
'string');
-                               $field_interval = 
phpgw::get_var('field_interval', 'int');
-                               $delete_allocation = 
phpgw::get_var('delete_allocation');
-                               $booking = $this->bo->read_single($id);
-                   $allocation = 
$this->allocation_bo->read_single($booking['allocation_id']);
-                   $season = 
$this->season_bo->read_single($booking['season_id']);
-                               $step = phpgw::get_var('step', 'int', 'POST');
-                       if ($step)
+                               phpgwapi_jquery::init_ckeditor('field-message');
+                               self::render_template_xsl('booking_cancel', 
array('booking' => $booking));
+                       }
+                       else
+                       {
+
+                               $id                                      = 
phpgw::get_var('id', 'int');
+                               $outseason                       = 
phpgw::get_var('outseason', 'string');
+                               $recurring                       = 
phpgw::get_var('recurring', 'string');
+                               $repeat_until            = 
phpgw::get_var('repeat_until', 'string');
+                               $field_interval          = 
phpgw::get_var('field_interval', 'int');
+                               $delete_allocation       = 
phpgw::get_var('delete_allocation');
+                               $booking                         = 
$this->bo->read_single($id);
+                               $allocation                      = 
$this->allocation_bo->read_single($booking['allocation_id']);
+                               $season                          = 
$this->season_bo->read_single($booking['season_id']);
+                               $step                            = 
phpgw::get_var('step', 'int', 'POST');
+                               if($step)
                                {
                                        $step = 1;
                                }
-                   $errors = array();
-                               $invalid_dates = array();
-                               $valid_dates = array();
-                   $allocation_delete = array();
-                   $allocation_keep = array();
+                               $errors                          = array();
+                               $invalid_dates           = array();
+                               $valid_dates             = array();
+                               $allocation_delete       = array();
+                               $allocation_keep         = array();
 
-                if ($config->config_data['split_pool'] == 'yes')
-                {
-                    $split = 1;
-                }
+                               if($config->config_data['split_pool'] == 'yes')
+                               {
+                                       $split = 1;
+                               }
                                else
                                {
-                    $split = 0;
-                }
-                $resources = $booking['resources'];
-                
$activity=$this->organization_bo->so->get_resource_activity($resources);
-                $mailadresses = 
$this->building_users($booking['building_id'],$booking['group_id'], $split, 
$activity);
+                                       $split = 0;
+                               }
+                               $resources               = 
$booking['resources'];
+                               $activity                = 
$this->organization_bo->so->get_resource_activity($resources);
+                               $mailadresses    = 
$this->building_users($booking['building_id'], $booking['group_id'], $split, 
$activity);
 
-                               $extra_mailadresses = 
$this->resource_users($resources, $booking['group_id']);
-                               $mailadresses = array_merge($mailadresses, 
$extra_mailadresses);
+                               $extra_mailadresses      = 
$this->resource_users($resources, $booking['group_id']);
+                               $mailadresses            = 
array_merge($mailadresses, $extra_mailadresses);
 
-                $maildata = array();
-                $maildata['outseason'] = $outseason;           
-                $maildata['recurring'] = $recurring;           
-                $maildata['repeat_until'] = $repeat_until;
-                $maildata['delete_allocation'] = $delete_allocation;
+                               $maildata                                       
         = array();
+                               $maildata['outseason']                   = 
$outseason;
+                               $maildata['recurring']                   = 
$recurring;
+                               $maildata['repeat_until']                = 
$repeat_until;
+                               $maildata['delete_allocation']   = 
$delete_allocation;
 
                                if($_SERVER['REQUEST_METHOD'] == 'POST')
                                {
-                    $_POST['from_'] = date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['from_']));
-                    $_POST['to_'] = date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['to_']));
-                    $_POST['repeat_until'] = date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['repeat_until']));
-                    
-                                       $from_date = $_POST['from_'];
-                                       $to_date = $_POST['to_'];
-                                       $info_deleted = '';
-                                       $inf_del = '';
+                                       $_POST['from_']                  = 
date("Y-m-d H:i:s", phpgwapi_datetime::date_to_timestamp($_POST['from_']));
+                                       $_POST['to_']                    = 
date("Y-m-d H:i:s", phpgwapi_datetime::date_to_timestamp($_POST['to_']));
+                                       $_POST['repeat_until']   = date("Y-m-d 
H:i:s", phpgwapi_datetime::date_to_timestamp($_POST['repeat_until']));
 
-                                       if ($_POST['recurring'] != 'on' && 
$_POST['outseason'] != 'on' )
-                       {
+                                       $from_date               = 
$_POST['from_'];
+                                       $to_date                 = 
$_POST['to_'];
+                                       $info_deleted    = '';
+                                       $inf_del                 = '';
 
-                           if ($_POST['delete_allocation'] != 'on') {
+                                       if($_POST['recurring'] != 'on' && 
$_POST['outseason'] != 'on')
+                                       {
 
-                                   $inf_del = "Booking";
-                            $maildata['allocation'] = 0;                       
     
-                                                   
$this->bo->so->delete_booking($id);
-                           }
-                           else
-                           {
-                               $allocation_id = $booking['allocation_id'];
-                               $this->bo->so->delete_booking($id);
-                               $err  = 
$this->allocation_bo->so->check_for_booking($allocation_id);
-                               if ($err)
-                               {
-                                           $inf_del = "Booking";
-                                $maildata['allocation'] = 0;                   
         
-                                   $errors['booking'] = lang('Could not delete 
allocation due to a booking still use it');
-                               }
-                               else
+                                               if($_POST['delete_allocation'] 
!= 'on')
+                                               {
+
+                                                       $inf_del                
                 = "Booking";
+                                                       $maildata['allocation'] 
 = 0;
+                                                       
$this->bo->so->delete_booking($id);
+                                               }
+                                               else
+                                               {
+                                                       $allocation_id   = 
$booking['allocation_id'];
+                                                       
$this->bo->so->delete_booking($id);
+                                                       $err                    
 = $this->allocation_bo->so->check_for_booking($allocation_id);
+                                                       if($err)
                                                        {
-                                       $inf_del = "Booking and allocation";
-                                $maildata['allocation'] = 1;                   
         
-                                   $err = 
$this->allocation_bo->so->delete_allocation($allocation_id);
-                               }
+                                                               $inf_del        
                         = "Booking";
+                                                               
$maildata['allocation']  = 0;
+                                                               
$errors['booking']               = lang('Could not delete allocation due to a 
booking still use it');
+                                                       }
+                                                       else
+                                                       {
+                                                               $inf_del        
                         = "Booking and allocation";
+                                                               
$maildata['allocation']  = 1;
+                                                               $err            
                         = 
$this->allocation_bo->so->delete_allocation($allocation_id);
+                                                       }
+                                               }
 
-                           }
-
-                                               $res_names = '';
+                                               $res_names                      
                         = '';
                                                
date_default_timezone_set("Europe/Oslo");
-                                               $date = new 
DateTime(phpgw::get_var('date'));
-                                               $system_message = array();
-                                               $system_message['building_id'] 
= intval($booking['building_id']);
+                                               $date                           
                         = new DateTime(phpgw::get_var('date'));
+                                               $system_message                 
                 = array();
+                                               $system_message['building_id']  
 = intval($booking['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'] = 
$booking['group_name'];
-                                               $system_message['phone'] = ' ';
-                                               $system_message['email'] = ' ';
-                                               $system_message['title'] = 
lang("Cancelation of ".$inf_del." from")." 
".$this->bo->so->get_organization($booking['group_id'])." - 
".$booking['group_name'];
-                                               foreach ($booking['resources'] 
as $res) {
-                                                       $res_names = 
$res_names.$this->bo->so->get_resource($res)." ";
+                                               $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']         
         = $booking['group_name'];
+                                               $system_message['phone']        
         = ' ';
+                                               $system_message['email']        
         = ' ';
+                                               $system_message['title']        
         = lang("Cancelation of " . $inf_del . " from") . " " . 
$this->bo->so->get_organization($booking['group_id']) . " - " . 
$booking['group_name'];
+                                               foreach($booking['resources'] 
as $res)
+                                               {
+                                                       $res_names = $res_names 
. $this->bo->so->get_resource($res) . " ";
                                                }
-                                               $info_deleted = lang("Deleted 
on")." ".$system_message['building_name'].":<br />".$res_names." - 
".pretty_timestamp($booking['from_'])." - ".pretty_timestamp($booking['to_']);
-                        $this->bo->send_admin_notification($booking, 
$maildata, $system_message, $allocation);
-                        $this->bo->send_notification($booking, $allocation, 
$maildata, $mailadresses);
-                                   $system_message['message'] = 
$system_message['message']."<br />".$info_deleted;
-                                               $receipt = 
$this->system_message_bo->add($system_message);
+                                               $info_deleted                   
         = lang("Deleted on") . " " . $system_message['building_name'] . ":<br 
/>" . $res_names . " - " . pretty_timestamp($booking['from_']) . " - " . 
pretty_timestamp($booking['to_']);
+                                               
$this->bo->send_admin_notification($booking, $maildata, $system_message, 
$allocation);
+                                               
$this->bo->send_notification($booking, $allocation, $maildata, $mailadresses);
+                                               $system_message['message']      
 = $system_message['message'] . "<br />" . $info_deleted;
+                                               $receipt                        
                 = $this->system_message_bo->add($system_message);
 
-                        $this->redirect(array('menuaction' => 
'bookingfrontend.uibuilding.schedule', 'id'=>$booking['building_id']));
-                       } 
-                       else
-                       {
-                           $step++;
-                                               if ($_POST['recurring'] == 
'on') {
-                                                               $repeat_until = 
strtotime($_POST['repeat_until'])+60*60*24; 
-                                               } 
+                                               
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                                                       'id' => 
$booking['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;
+                                                       $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)
+
+                                               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));
-                                                       $booking['from_'] = 
$fromdate;
-                                                       $booking['to_'] = 
$todate;
-                                                       $info_deleted = '';
-                                                       $inf_del = '';
-                            
-                            $fromdate = pretty_timestamp($fromdate);
-                            $todate = pretty_timestamp($todate);
-       
-                               $id = $this->bo->so->get_booking_id($booking);  
              
-                               if($id) {
-                                   $aid = $this->bo->so->check_allocation($id);
-                               } else {
-                                   $aid = 
$this->bo->so->check_for_booking($booking);    
-                               }
-                                   
-                                       if ($id) 
+                                                       $fromdate               
         = date('Y-m-d H:i', strtotime($_POST['from_']) + ($interval * $i));
+                                                       $todate                 
         = date('Y-m-d H:i', strtotime($_POST['to_']) + ($interval * $i));
+                                                       $booking['from_']       
 = $fromdate;
+                                                       $booking['to_']         
 = $todate;
+                                                       $info_deleted           
 = '';
+                                                       $inf_del                
         = '';
+
+                                                       $fromdate        = 
pretty_timestamp($fromdate);
+                                                       $todate          = 
pretty_timestamp($todate);
+
+                                                       $id = 
$this->bo->so->get_booking_id($booking);
+                                                       if($id)
                                                        {
-                                                               
$valid_dates[$i]['from_'] = $fromdate;
-                                                               
$valid_dates[$i]['to_'] = $todate;
-                                                               if ($step == 3)
+                                                               $aid = 
$this->bo->so->check_allocation($id);
+                                                       }
+                                                       else
+                                                       {
+                                                               $aid = 
$this->bo->so->check_for_booking($booking);
+                                                       }
+
+                                                       if($id)
+                                                       {
+                                                               
$valid_dates[$i]['from_']        = $fromdate;
+                                                               
$valid_dates[$i]['to_']          = $todate;
+                                                               if($step == 3)
                                                                {
-                                                   $inf_del = "Bookings";
-                                       $stat = 
$this->bo->so->delete_booking($id);
-                                   }                            
-                               }
-                               if ($_POST['delete_allocation'] == 'on')        
                 {
-                                                       if (!$aid) 
-                                                       {
-                                                               
$allocation_keep[$i]['from_'] = $fromdate;
-                                                               
$allocation_keep[$i]['to_'] = $todate;
-                                                       } 
-                                                       else 
-                                                       {
-                                                               
$allocation_delete[$i]['from_'] = $fromdate;
-                                                               
$allocation_delete[$i]['to_'] = $todate;
-                                                               if ($step == 3)
-                                                               {
-                                                      $inf_del = "Bookings and 
allocations";
-                                          $stat = 
$this->bo->so->delete_allocation($aid);
-                                       }                            
-                                   }
-                               }
+                                                                       
$inf_del = "Bookings";
+                                                                       $stat   
 = $this->bo->so->delete_booking($id);
+                                                               }
+                                                       }
+                                                       
if($_POST['delete_allocation'] == 'on')
+                                                       {
+                                                               if(!$aid)
+                                                               {
+                                                                       
$allocation_keep[$i]['from_']    = $fromdate;
+                                                                       
$allocation_keep[$i]['to_']              = $todate;
+                                                               }
+                                                               else
+                                                               {
+                                                                       
$allocation_delete[$i]['from_']  = $fromdate;
+                                                                       
$allocation_delete[$i]['to_']    = $todate;
+                                                                       
if($step == 3)
+                                                                       {
+                                                                               
$inf_del = "Bookings and allocations";
+                                                                               
$stat    = $this->bo->so->delete_allocation($aid);
+                                                                       }
+                                                               }
+                                                       }
                                                        $i++;
-                           }
-                                               if ($step == 3) 
+                                               }
+                                               if($step == 3)
                                                {
-                            $maildata = array();
-                            $maildata['outseason'] = 
phpgw::get_var('outseason','string');
-                            $maildata['recurring'] = 
phpgw::get_var('recurring', 'string');
-                            $maildata['repeat_until'] = 
phpgw::get_var('repeat_until', 'string');
-                            $maildata['delete_allocation'] = 
phpgw::get_var('delete_allocation');
-                                                       $maildata['keep'] = 
$allocation_keep;
-                                                       $maildata['delete'] = 
$allocation_delete;
+                                                       $maildata               
                                 = array();
+                                                       $maildata['outseason']  
                 = phpgw::get_var('outseason', 'string');
+                                                       $maildata['recurring']  
                 = phpgw::get_var('recurring', 'string');
+                                                       
$maildata['repeat_until']                = phpgw::get_var('repeat_until', 
'string');
+                                                       
$maildata['delete_allocation']   = phpgw::get_var('delete_allocation');
+                                                       $maildata['keep']       
                         = $allocation_keep;
+                                                       $maildata['delete']     
                         = $allocation_delete;
 
-                            $res_names = '';
+                                                       $res_names              
                                 = '';
                                                        
date_default_timezone_set("Europe/Oslo");
-                                                       $date = new 
DateTime(phpgw::get_var('date'));
-                                                       $system_message = 
array();
-                                                       
$system_message['building_id'] = intval($booking['building_id']);
+                                                       $date                   
                                 = new DateTime(phpgw::get_var('date'));
+                                                       $system_message         
                         = array();
+                                                       
$system_message['building_id']   = intval($booking['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'] 
= $booking['group_name'];
-                                                       
$system_message['phone'] = ' ';
-                                                       
$system_message['email'] = ' ';
-                                                       
$system_message['title'] = lang("Cancelation of ".$inf_del." from")." 
".$this->bo->so->get_organization($booking['group_id'])." - 
".$booking['group_name'];
-                                                       foreach 
($booking['resources'] as $res) {
-                                                               $res_names = 
$res_names.$this->bo->so->get_resource($res)." ";
+                                                       
$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'] 
                 = $booking['group_name'];
+                                                       
$system_message['phone']                 = ' ';
+                                                       
$system_message['email']                 = ' ';
+                                                       
$system_message['title']                 = lang("Cancelation of " . $inf_del . 
" from") . " " . $this->bo->so->get_organization($booking['group_id']) . " - " 
. $booking['group_name'];
+                                                       
foreach($booking['resources'] as $res)
+                                                       {
+                                                               $res_names = 
$res_names . $this->bo->so->get_resource($res) . " ";
                                                        }
-                                                       $info_deleted = 
lang($inf_del." 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_']);
+                                                       $info_deleted = 
lang($inf_del . " 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($booking, 
$maildata, $system_message, $allocation, $valid_dates);
-                            $this->bo->send_notification($booking, 
$allocation, $maildata, $mailadresses, $valid_dates);
-                                                       $receipt = 
$this->system_message_bo->add($system_message);
-                                                       
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule', 
'id'=>$allocation['building_id']));
+                                                       
$system_message['message']       = $system_message['message'] . "<br />" . 
$info_deleted;
+                                                       
$this->bo->send_admin_notification($booking, $maildata, $system_message, 
$allocation, $valid_dates);
+                                                       
$this->bo->send_notification($booking, $allocation, $maildata, $mailadresses, 
$valid_dates);
+                                                       $receipt                
                         = $this->system_message_bo->add($system_message);
+                                                       
$this->redirect(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                                                               'id' => 
$allocation['building_id']));
                                                }
-                       }
+                                       }
                                }
-       
+
                                $this->flash_form_errors($errors);
-                               if 
($config->config_data['user_can_delete_allocations'] != 'yes')
+                               
if($config->config_data['user_can_delete_allocations'] != 'yes')
                                {
                                        $user_can_delete_allocations = 0;
-                               
-                               } else {
+                               }
+                               else
+                               {
                                        $user_can_delete_allocations = 1;
                                }
-                
-                $booking['from_'] = pretty_timestamp($booking['from_']);
-                $booking['to_'] = pretty_timestamp($booking['to_']);
-                
+
+                               $booking['from_']        = 
pretty_timestamp($booking['from_']);
+                               $booking['to_']          = 
pretty_timestamp($booking['to_']);
+
 //                             self::add_javascript('booking', 'booking', 
'booking.js');
-                               $booking['resources_json'] = 
json_encode(array_map('intval', $booking['resources']));
+                               $booking['resources_json']       = 
json_encode(array_map('intval', $booking['resources']));
 #                              $booking['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibooking.show', 'id' => 
$booking['id']));
-                $booking['cancel_link'] = self::link(array('menuaction' => 
'bookingfrontend.uibuilding.schedule', 'id' => $booking['building_id'], 'date' 
=> $booking['from_']));
-                               $booking['booking_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibooking.show', 'id' => 
$booking['id']));
-                
-                $GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 
'date');
-                
-                               if ($step < 2) 
-                   {
-                    phpgwapi_jquery::init_ckeditor('field-message');
-                               self::render_template_xsl('booking_delete', 
array('booking' => $booking,
-                                               'recurring' => $recurring,
-                                               'outseason' => $outseason,
-                                               'interval' => $field_interval,
-                                               'repeat_until' => $repeat_until,
-                           'delete_allocation' => $delete_allocation,
-                                               'user_can_delete_allocations' 
=> $user_can_delete_allocations
-                       ));
-                   }
-                               elseif ($step == 2) 
-                   {
-                                       
self::render_template_xsl('booking_delete_preview', array('booking' => $booking,
-                                               'step' => $step,
-                                               'recurring' => 
$_POST['recurring'],
-                                               'outseason' => 
$_POST['outseason'],
-                                               'interval' => 
$_POST['field_interval'],
-                                               'repeat_until' => 
pretty_timestamp($_POST['repeat_until']),
-                                               'from_date' => 
pretty_timestamp($from_date),
-                                               'to_date' => 
pretty_timestamp($to_date),
-                           'delete_allocation' => $_POST['delete_allocation'],
-                                               'user_can_delete_allocations' 
=> $user_can_delete_allocations,
-                                               'allocation_keep' => 
$allocation_keep,
-                                               'allocation_delete' => 
$allocation_delete,
-                                               'message' => $_POST['message'],
-                                               'valid_dates' => $valid_dates,
-                                               'invalid_dates' => 
$invalid_dates
-                                       ));
-                   }                
+                               $booking['cancel_link']          = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                                       'id' => $booking['building_id'], 'date' 
=> $booking['from_']));
+                               $booking['booking_link']         = 
self::link(array('menuaction' => 'bookingfrontend.uibooking.show',
+                                       'id' => $booking['id']));
 
+                               
$GLOBALS['phpgw']->jqcal->add_listener('field_repeat_until', 'date');
 
+                               if($step < 2)
+                               {
+                                       
phpgwapi_jquery::init_ckeditor('field-message');
+                                       
self::render_template_xsl('booking_delete', array('booking'                     
                         => $booking,
+                                               'recurring'                     
                         => $recurring,
+                                               'outseason'                     
                         => $outseason,
+                                               'interval'                      
                         => $field_interval,
+                                               'repeat_until'                  
                 => $repeat_until,
+                                               'delete_allocation'             
                 => $delete_allocation,
+                                               'user_can_delete_allocations'   
 => $user_can_delete_allocations
+                                       ));
+                               }
+                               elseif($step == 2)
+                               {
+                                       
self::render_template_xsl('booking_delete_preview', array('booking'             
                                 => $booking,
+                                               'step'                          
                         => $step,
+                                               'recurring'                     
                         => $_POST['recurring'],
+                                               'outseason'                     
                         => $_POST['outseason'],
+                                               'interval'                      
                         => $_POST['field_interval'],
+                                               'repeat_until'                  
                 => pretty_timestamp($_POST['repeat_until']),
+                                               'from_date'                     
                         => pretty_timestamp($from_date),
+                                               'to_date'                       
                         => pretty_timestamp($to_date),
+                                               'delete_allocation'             
                 => $_POST['delete_allocation'],
+                                               'user_can_delete_allocations'   
 => $user_can_delete_allocations,
+                                               'allocation_keep'               
                 => $allocation_keep,
+                                               'allocation_delete'             
                 => $allocation_delete,
+                                               'message'                       
                         => $_POST['message'],
+                                               'valid_dates'                   
                 => $valid_dates,
+                                               'invalid_dates'                 
                 => $invalid_dates
+                                       ));
+                               }
                        }
-        }              
+               }
 
                public function info()
                {
-                       $config = CreateObject('phpgwapi.config','booking');
+                       $config = CreateObject('phpgwapi.config', 'booking');
                        $config->read();
-                       if ($config->config_data['user_can_delete_bookings'] != 
'yes')
+                       if($config->config_data['user_can_delete_bookings'] != 
'yes')
                        {
                                $user_can_delete_bookings = 0;
-                       
-                       } else {
+                       }
+                       else
+                       {
                                $user_can_delete_bookings = 1;
                        }
-                       $booking = $this->bo->read_single(phpgw::get_var('id', 
'int'));
-                       $booking['group'] = 
$this->group_bo->read_single($booking['group_id']);
-                       $resources = 
$this->resource_bo->so->read(array('filters'=>array('id'=>$booking['resources']),
 'sort'=>'name'));
-                       $booking['resources'] = $resources['results'];
-                       $res_names = array();
+                       $booking                                 = 
$this->bo->read_single(phpgw::get_var('id', 'int'));
+                       $booking['group']                = 
$this->group_bo->read_single($booking['group_id']);
+                       $resources                               = 
$this->resource_bo->so->read(array('filters' => array('id' => 
$booking['resources']),
+                               'sort' => 'name'));
+                       $booking['resources']    = $resources['results'];
+                       $res_names                               = array();
                        foreach($booking['resources'] as $res)
                        {
                                $res_names[] = $res['name'];
                        }
-                       $booking['resource_info'] = join(', ', $res_names);
-                       $booking['building_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.show', 'id' => 
$booking['resources'][0]['building_id']));
-                       $booking['org_link'] = self::link(array('menuaction' => 
'bookingfrontend.uiorganization.show', 'id' => 
$booking['group']['organization_id']));
-                       $booking['group_link'] = self::link(array('menuaction' 
=> 'bookingfrontend.uigroup.show', 'id' => $booking['group']['id']));
-                       
+                       $booking['resource_info']        = join(', ', 
$res_names);

@@ Diff output truncated at 153600 characters. @@



reply via email to

[Prev in Thread] Current Thread [Next in Thread]