fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12975] Syncromind: Merge 12786:12974 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [12975] Syncromind: Merge 12786:12974 from trunk
Date: Thu, 09 Apr 2015 13:36:50 +0000

Revision: 12975
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12975
Author:   sigurdne
Date:     2015-04-09 13:36:49 +0000 (Thu, 09 Apr 2015)
Log Message:
-----------
Syncromind: Merge 12786:12974 from trunk

Modified Paths:
--------------
    branches/dev-syncromind/admin/inc/class.menu.inc.php
    branches/dev-syncromind/admin/inc/class.uiaccounts.inc.php
    branches/dev-syncromind/admin/setup/phpgw_no.lang
    branches/dev-syncromind/admin/templates/base/cats.xsl
    branches/dev-syncromind/booking/inc/class.async_task_send_reminder.inc.php
    branches/dev-syncromind/booking/inc/class.boallocation.inc.php
    branches/dev-syncromind/booking/inc/class.boapplication.inc.php
    branches/dev-syncromind/booking/inc/class.bobooking.inc.php
    branches/dev-syncromind/booking/inc/class.bocommon.inc.php
    branches/dev-syncromind/booking/inc/class.bodocument_view.inc.php
    branches/dev-syncromind/booking/inc/class.boevent.inc.php
    branches/dev-syncromind/booking/inc/class.boorganization.inc.php
    branches/dev-syncromind/booking/inc/class.customer_identifier.inc.php
    branches/dev-syncromind/booking/inc/class.menu.inc.php
    branches/dev-syncromind/booking/inc/class.soallocation.inc.php
    branches/dev-syncromind/booking/inc/class.soapplication.inc.php
    branches/dev-syncromind/booking/inc/class.sobooking.inc.php
    branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
    branches/dev-syncromind/booking/inc/class.socommon.inc.php
    
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export.inc.php
    
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export_file.inc.php
    branches/dev-syncromind/booking/inc/class.soevent.inc.php
    branches/dev-syncromind/booking/inc/class.sogroup.inc.php
    branches/dev-syncromind/booking/inc/class.soorganization.inc.php
    branches/dev-syncromind/booking/inc/class.soresource.inc.php
    branches/dev-syncromind/booking/inc/class.uiaccount_code_set.inc.php
    branches/dev-syncromind/booking/inc/class.uiallocation.inc.php
    branches/dev-syncromind/booking/inc/class.uiapplication.inc.php
    branches/dev-syncromind/booking/inc/class.uibooking.inc.php
    branches/dev-syncromind/booking/inc/class.uibuilding.inc.php
    branches/dev-syncromind/booking/inc/class.uicommon.inc.php
    branches/dev-syncromind/booking/inc/class.uicompleted_reservation.inc.php
    
branches/dev-syncromind/booking/inc/class.uicompleted_reservation_export.inc.php
    
branches/dev-syncromind/booking/inc/class.uicompleted_reservation_export_file.inc.php
    branches/dev-syncromind/booking/inc/class.uievent.inc.php
    branches/dev-syncromind/booking/inc/class.uigroup.inc.php
    branches/dev-syncromind/booking/inc/class.uiorganization.inc.php
    branches/dev-syncromind/booking/inc/class.uiresource.inc.php
    branches/dev-syncromind/booking/inc/class.uiseason.inc.php
    branches/dev-syncromind/booking/jasper/templates/logo.png
    branches/dev-syncromind/booking/js/booking/application.js
    branches/dev-syncromind/booking/js/booking/common.js
    branches/dev-syncromind/booking/js/booking/schedule.js
    branches/dev-syncromind/booking/setup/default_records.inc.php
    branches/dev-syncromind/booking/setup/phpgw_no.lang
    branches/dev-syncromind/booking/setup/setup.inc.php
    branches/dev-syncromind/booking/setup/tables_current.inc.php
    branches/dev-syncromind/booking/setup/tables_update.inc.php
    branches/dev-syncromind/booking/templates/base/account_code_dimension.xsl
    branches/dev-syncromind/booking/templates/base/account_code_set.xsl
    branches/dev-syncromind/booking/templates/base/account_code_set_form.xsl
    branches/dev-syncromind/booking/templates/base/allocation_delete_preview.xsl
    branches/dev-syncromind/booking/templates/base/application.xsl
    branches/dev-syncromind/booking/templates/base/application_edit.xsl
    branches/dev-syncromind/booking/templates/base/application_new.xsl
    branches/dev-syncromind/booking/templates/base/booking_delete.xsl
    branches/dev-syncromind/booking/templates/base/building.xsl
    branches/dev-syncromind/booking/templates/base/building_form.xsl
    branches/dev-syncromind/booking/templates/base/css/base.css
    branches/dev-syncromind/booking/templates/base/organization_edit.xsl
    branches/dev-syncromind/booking/templates/base/resource_form.xsl
    branches/dev-syncromind/booking/templates/base/settings.xsl
    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.uievent.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/custom/default/Altinn2_Bergen_kommune.php
    branches/dev-syncromind/bookingfrontend/setup/phpgw_no.lang
    branches/dev-syncromind/bookingfrontend/setup/setup.inc.php
    branches/dev-syncromind/bookingfrontend/templates/base/config.tpl
    branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
    branches/dev-syncromind/catch/setup/setup.inc.php
    branches/dev-syncromind/catch/setup/tables_current.inc.php
    branches/dev-syncromind/catch/setup/tables_update.inc.php
    branches/dev-syncromind/controller/inc/class.menu.inc.php
    branches/dev-syncromind/controller/inc/class.socheck_list.inc.php
    branches/dev-syncromind/controller/inc/class.socontrol.inc.php
    branches/dev-syncromind/controller/inc/class.uicalendar.inc.php
    branches/dev-syncromind/controller/inc/class.uicheck_list.inc.php
    
branches/dev-syncromind/controller/inc/component/class.check_list_status_info.inc.php
    
branches/dev-syncromind/controller/inc/component/class.check_list_status_manager.inc.php
    
branches/dev-syncromind/controller/inc/component/class.month_calendar.inc.php
    branches/dev-syncromind/controller/inc/component/class.year_calendar.inc.php
    branches/dev-syncromind/controller/inc/model/class.check_list.inc.php
    branches/dev-syncromind/controller/inc/model/class.component.inc.php
    branches/dev-syncromind/controller/setup/phpgw_no.lang
    branches/dev-syncromind/controller/setup/setup.inc.php
    branches/dev-syncromind/controller/setup/tables_current.inc.php
    branches/dev-syncromind/controller/setup/tables_update.inc.php
    
branches/dev-syncromind/controller/templates/base/calendar/check_list_status_manager.xsl
    
branches/dev-syncromind/controller/templates/base/calendar/nav_calendar_month.xsl
    
branches/dev-syncromind/controller/templates/base/calendar/nav_calendar_year.xsl
    
branches/dev-syncromind/controller/templates/base/calendar/view_calendar_month.xsl
    
branches/dev-syncromind/controller/templates/base/calendar/view_calendar_month_for_locations.xsl
    
branches/dev-syncromind/controller/templates/base/calendar/view_calendar_year.xsl
    
branches/dev-syncromind/controller/templates/base/calendar/view_calendar_year_for_locations.xsl
    
branches/dev-syncromind/controller/templates/base/check_list/add_check_list.xsl
    
branches/dev-syncromind/controller/templates/base/check_list/view_control_details.xsl
    
branches/dev-syncromind/controller/templates/base/check_list/view_control_info.xsl
    branches/dev-syncromind/controller/templates/base/component.xsl
    branches/dev-syncromind/controller/templates/base/config.tpl
    branches/dev-syncromind/home.php
    branches/dev-syncromind/phpgwapi/inc/accounts/class.accounts_sql.inc.php
    
branches/dev-syncromind/phpgwapi/inc/class.vfs_fileoperation_braArkiv.inc.php
    branches/dev-syncromind/phpgwapi/inc/class.vfs_sql.inc.php
    branches/dev-syncromind/phpgwapi/templates/bkbooking/head.inc.php
    branches/dev-syncromind/phpgwapi/templates/bkbooking/head.tpl
    branches/dev-syncromind/property/inc/class.boadmin_entity.inc.php
    branches/dev-syncromind/property/inc/class.boentity.inc.php
    branches/dev-syncromind/property/inc/class.soadmin_entity.inc.php
    branches/dev-syncromind/property/inc/class.sodocument.inc.php
    branches/dev-syncromind/property/inc/class.soentity.inc.php
    branches/dev-syncromind/property/inc/class.uiadmin_entity.inc.php
    branches/dev-syncromind/property/inc/class.uidocument.inc.php
    branches/dev-syncromind/property/inc/class.uientity.inc.php
    
branches/dev-syncromind/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
    branches/dev-syncromind/property/setup/phpgw_no.lang
    branches/dev-syncromind/property/setup/setup.inc.php
    branches/dev-syncromind/property/setup/tables_current.inc.php
    branches/dev-syncromind/property/setup/tables_update.inc.php
    branches/dev-syncromind/property/templates/base/admin_entity.xsl
    branches/dev-syncromind/property/templates/base/async.xsl
    branches/dev-syncromind/property/templates/base/entity.xsl
    branches/dev-syncromind/rental/inc/class.socontract.inc.php
    branches/dev-syncromind/rental/inc/class.socontract_price_item.inc.php
    branches/dev-syncromind/rental/inc/class.uibilling.inc.php
    branches/dev-syncromind/rental/inc/model/class.invoice.inc.php
    branches/dev-syncromind/rental/templates/base/billing_step2.php
    branches/dev-syncromind/setup/index.php
    branches/dev-syncromind/setup/templates/base/setup_main.tpl
    branches/dev-syncromind/sms/inc/class.sms.inc.php
    branches/dev-syncromind/sms/inc/class.uisms.inc.php

Added Paths:
-----------
    branches/dev-syncromind/admin/templates/base/home_screen_message.xsl
    branches/dev-syncromind/booking/inc/class.sopermission_event.inc.php
    branches/dev-syncromind/booking/inc/class.uiapplication_settings.inc.php
    branches/dev-syncromind/booking/inc/class.uievent_mail_settings.inc.php
    branches/dev-syncromind/booking/inc/class.uimail_settings.inc.php
    branches/dev-syncromind/booking/inc/class.uimetasettings.inc.php
    branches/dev-syncromind/booking/jasper/templates/logo.jpg
    branches/dev-syncromind/booking/templates/base/application_settings.xsl
    branches/dev-syncromind/booking/templates/base/event_mail_settings.xsl
    branches/dev-syncromind/booking/templates/base/mail_settings.xsl
    branches/dev-syncromind/booking/templates/base/metasettings.xsl
    branches/dev-syncromind/bookingfrontend/change.php
    branches/dev-syncromind/bookingfrontend/inc/custom/default/MinId.php
    branches/dev-syncromind/bookingfrontend/templates/fjell/
    branches/dev-syncromind/bookingfrontend/templates/stavanger/
    branches/dev-syncromind/controller/inc/class.uicomponent.inc.php
    branches/dev-syncromind/controller/inc/hook_config.inc.php
    branches/dev-syncromind/phpgwapi/inc/soap_client/
    branches/dev-syncromind/property/inc/soap_client/bra5/
    branches/dev-syncromind/setup/templates/base/setup_svn_blocks.tpl

Removed Paths:
-------------
    branches/dev-syncromind/phpgwapi/inc/class.vfs_braArkiv.inc.php

Property Changed:
----------------
    branches/dev-syncromind/
    branches/dev-syncromind/booking/
    branches/dev-syncromind/bookingfrontend/


Property changes on: branches/dev-syncromind
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785
   + /branches/stavangerkommune:12743-12875
/trunk:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785,12787-12974

Modified: branches/dev-syncromind/admin/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind/admin/inc/class.menu.inc.php        2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/admin/inc/class.menu.inc.php        2015-04-09 
13:36:49 UTC (rev 12975)
@@ -113,6 +113,16 @@
                                                                
array('menuaction' => 'admin.uiaccounts.global_message'))
                                );
                        }
+                        
+                        if ( $GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin'))
+                       {
+                               $menus['admin']['home_screen_message'] = array
+                               (
+                                       'text'  => 
$GLOBALS['phpgw']->translation->translate('home screen message', array(), true),
+                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php',
+                                                               
array('menuaction' => 'admin.uiaccounts.home_screen_message'))
+                               );
+                       }
 
                        if (! $GLOBALS['phpgw']->acl->check('account_access', 
phpgwapi_acl::READ, 'admin'))
                        {

Modified: branches/dev-syncromind/admin/inc/class.uiaccounts.inc.php
===================================================================
--- branches/dev-syncromind/admin/inc/class.uiaccounts.inc.php  2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/admin/inc/class.uiaccounts.inc.php  2015-04-09 
13:36:49 UTC (rev 12975)
@@ -56,7 +56,8 @@
                        'sync_accounts_contacts'        => true,
                        'clear_user_cache'                      => true,
                        'clear_cache'                           => true,
-                       'global_message'                        => true
+                       'global_message'                        => true,
+                        'home_screen_message'                   => true
                );
 
                /**
@@ -1564,7 +1565,56 @@
                        $GLOBALS['phpgw']->xslttpl->add_file('global_message');
                        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('global_message' => $data));
                }
+                
+                /**
+               * Set a message on bottom of home-screen
+               *
+               * @return void
+               */
 
+               function home_screen_message()
+               {
+                       if(     !$GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin') )
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/admin/index.php');
+                       }
+                        
+                        if(phpgw::get_var('msg_title', 'string'))
+                        {
+                                $msg_title = phpgw::get_var('msg_title', 
'string');
+                        }
+                        else
+                        {
+                                $msg_title = lang("important message");
+                        }
+                        
+                       if(phpgw::get_var('message', 'string'))
+                       {
+                                phpgwapi_cache::system_set('phpgwapi', 
'phpgw_home_screen_message_title',$msg_title);
+                               phpgwapi_cache::system_set('phpgwapi', 
'phpgw_home_screen_message',phpgw::get_var('message', 'html'));                 
 
+                       }
+
+                       if(phpgw::get_var('delete_message', 'bool'))
+                       {
+                                phpgwapi_cache::system_clear('phpgwapi', 
'phpgw_home_screen_message_title');
+                               phpgwapi_cache::system_clear('phpgwapi', 
'phpgw_home_screen_message');
+                       }
+
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('administration');
+
+                       $data = array
+                       (
+                                'value_title'          => 
phpgwapi_cache::system_get('phpgwapi', 'phpgw_home_screen_message_title'),
+                               'value_message'         => 
phpgwapi_cache::system_get('phpgwapi', 'phpgw_home_screen_message'),
+                               'form_action'           => 
$GLOBALS['phpgw']->link('/index.php',
+                                                                               
array('menuaction' => 'admin.uiaccounts.home_screen_message')),
+                               'lang_cancel'           => lang('cancel'),
+                               'lang_submit'           => lang('submit')
+                       );
+                       
$GLOBALS['phpgw']->xslttpl->add_file('home_screen_message');
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('home_screen_message' => $data));
+               }
+
                /**
                 * Render a confirmation form for clear all cache (user,and 
system)
                 *

Modified: branches/dev-syncromind/admin/setup/phpgw_no.lang
===================================================================
--- branches/dev-syncromind/admin/setup/phpgw_no.lang   2015-04-09 11:54:43 UTC 
(rev 12974)
+++ branches/dev-syncromind/admin/setup/phpgw_no.lang   2015-04-09 13:36:49 UTC 
(rev 12975)
@@ -36,3 +36,6 @@
 view sessions  admin   no      Vis sessions
 you must enter a password      admin   no      Du må skrive inn et passord
 you must select a file type    admin   no      Du må velge en filtype
+home screen message    admin   no      Melding på hjemmeskjerm
+title  admin   no      Overskrift
+important message      admin   no      Viktig informasjon

Modified: branches/dev-syncromind/admin/templates/base/cats.xsl
===================================================================
--- branches/dev-syncromind/admin/templates/base/cats.xsl       2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/admin/templates/base/cats.xsl       2015-04-09 
13:36:49 UTC (rev 12975)
@@ -15,21 +15,21 @@
 
        <xsl:template match="cat_list">
                <center>
-               <table border="0" cellspacing="2" cellpadding="2" 
class="pure-table pure-table-bordered">
-                       <tr>
-                               <td colspan="5" width="100%">
-                                       <xsl:call-template name="nextmatchs"/>
-                               </td>
-                       </tr>
-                       <tr>
-                               <td colspan="5" width="100%" align="right">
-                                       <xsl:call-template name="search_field"/>
-                               </td>
-                       </tr>
-                               <xsl:apply-templates select="cat_header"/>
-                               <xsl:apply-templates select="cat_data"/>
-                               <xsl:apply-templates select="cat_add"/>
-               </table>
+                       <table border="0" cellspacing="2" cellpadding="2" 
class="pure-table pure-table-bordered">
+                               <tr>
+                                       <td colspan="5" width="100%">
+                                               <xsl:call-template 
name="nextmatchs"/>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td colspan="5" width="100%" 
align="right">
+                                               <xsl:call-template 
name="search_field"/>
+                                       </td>
+                               </tr>
+                                       <xsl:apply-templates 
select="cat_header"/>
+                                       <xsl:apply-templates select="cat_data"/>
+                       </table>
+                       <xsl:apply-templates select="cat_add"/>
                </center>
        </xsl:template>
 
@@ -103,31 +103,29 @@
 <!-- BEGIN cat_add -->
 
        <xsl:template match="cat_add">
-                       <tr height="50" valign="bottom">
-                       <xsl:variable name="action_url"><xsl:value-of 
select="action_url"/></xsl:variable>
-                       <form method="post" action="{$action_url}">
-                               <td colspan="2">
-                               <xsl:variable name="lang_add"><xsl:value-of 
select="lang_add"/></xsl:variable>
-                                       <input type="submit" name="add" 
value="{$lang_add}" onMouseout="window.status='';return true;">
-                                               <xsl:attribute 
name="onMouseover">
-                                                       
<xsl:text>window.status='</xsl:text>
+               <xsl:variable name="action_url"><xsl:value-of 
select="action_url"/></xsl:variable>
+               <form method="post" action="{$action_url}">
+                       <table>
+                               <tr height="50" valign="bottom">
+                                       <td colspan="2">
+                                       <xsl:variable 
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
+                                               <input type="submit" name="add" 
value="{$lang_add}">
+                                                       <xsl:attribute 
name="title">
                                                                <xsl:value-of 
select="lang_add_statustext"/>
-                                                       <xsl:text>'; return 
true;</xsl:text>
-                                               </xsl:attribute>
-                                       </input>
-                               </td>
-                               <td colspan="3" align="right">
-                               <xsl:variable name="lang_done"><xsl:value-of 
select="lang_done"/></xsl:variable>
-                                       <input type="submit" name="done" 
value="{$lang_done}" onMouseout="window.status='';return true;">
-                                               <xsl:attribute 
name="onMouseover">
-                                                       
<xsl:text>window.status='</xsl:text>
-                                                               <xsl:value-of 
select="lang_done_statustext"/>
-                                                       <xsl:text>'; return 
true;</xsl:text>
-                                               </xsl:attribute>
-                                       </input>
-                               </td>
-                       </form>
-                       </tr>
+                                                       </xsl:attribute>
+                                               </input>
+                                       </td>
+                                       <td colspan="3" align="right">
+                                       <xsl:variable 
name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
+                                               <input type="submit" 
name="done" value="{$lang_done}">
+                                                       <xsl:attribute 
name="title">
+                                                                       
<xsl:value-of select="lang_done_statustext"/>
+                                                       </xsl:attribute>
+                                               </input>
+                                       </td>
+                               </tr>
+                       </table>
+               </form>
        </xsl:template>
 
 <!-- END cat_list -->
@@ -135,14 +133,14 @@
 <!-- BEGIN cat_edit -->
 
        <xsl:template match="cat_edit" xmlns:php="http://php.net/xsl";>
+               <xsl:variable name="edit_url" select="edit_url"/>
+               <form method="post" action="{$edit_url}">
                <table cellpadding="2" cellspacing="2" align="center">
                        <tr>
                                <td colspan="3" align="center">
                                        <xsl:value-of select="message"/>
                                </td>
                        </tr>
-                       <xsl:variable name="edit_url" select="edit_url"/>
-                       <form method="post" action="{$edit_url}">
                        <tr>
                                <td width="23%" colspan="2">
                                        <xsl:value-of select="lang_parent"/>
@@ -194,37 +192,31 @@
                                        <xsl:variable 
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
                                        <xsl:variable 
name="old_parent"><xsl:value-of select="old_parent"/></xsl:variable>
                                        <input type="hidden" 
name="values[old_parent]" value="{$old_parent}"/>
-                                       <input type="submit" 
name="values[save]" value="{$lang_save}" onMouseout="window.status='';return 
true;">
-                                               <xsl:attribute 
name="onMouseover">
-                                                       
<xsl:text>window.status='</xsl:text>
-                                                               <xsl:value-of 
select="lang_save_statustext"/>
-                                                       <xsl:text>'; return 
true;</xsl:text>
+                                       <input type="submit" 
name="values[save]" value="{$lang_save}">
+                                               <xsl:attribute name="title">
+                                                       <xsl:value-of 
select="lang_save_statustext"/>
                                                </xsl:attribute>
                                        </input>
                                </td>
                                <td>
                                <xsl:variable name="lang_apply" 
select="lang_apply"/>
-                                       <input type="submit" 
name="values[apply]" value="{$lang_apply}" onMouseout="window.status='';return 
true;">
-                                               <xsl:attribute 
name="onMouseover">
-                                                       
<xsl:text>window.status='</xsl:text>
-                                                               <xsl:value-of 
select="lang_apply_statustext"/>
-                                                       <xsl:text>'; return 
true;</xsl:text>
+                                       <input type="submit" 
name="values[apply]" value="{$lang_apply}">
+                                               <xsl:attribute name="title">
+                                                       <xsl:value-of 
select="lang_apply_statustext"/>
                                                </xsl:attribute>
                                        </input>
                                </td>
                                <td align="right">
                                <xsl:variable name="lang_cancel"><xsl:value-of 
select="lang_cancel"/></xsl:variable>
-                                       <input type="submit" 
name="values[cancel]" value="{$lang_cancel}" 
onMouseout="window.status='';return true;">
-                                               <xsl:attribute 
name="onMouseover">
-                                                       
<xsl:text>window.status='</xsl:text>
-                                                               <xsl:value-of 
select="lang_cancel_statustext"/>
-                                                       <xsl:text>'; return 
true;</xsl:text>
+                                       <input type="submit" 
name="values[cancel]" value="{$lang_cancel}">
+                                               <xsl:attribute name="title">
+                                                       <xsl:value-of 
select="lang_cancel_statustext"/>
                                                </xsl:attribute>
                                        </input>
                                </td>
                        </tr>
-                       </form>
                </table>
+               </form>
        </xsl:template>
 
        <xsl:template match="options">

Copied: branches/dev-syncromind/admin/templates/base/home_screen_message.xsl 
(from rev 12974, trunk/admin/templates/base/home_screen_message.xsl)
===================================================================
--- branches/dev-syncromind/admin/templates/base/home_screen_message.xsl        
                        (rev 0)
+++ branches/dev-syncromind/admin/templates/base/home_screen_message.xsl        
2015-04-09 13:36:49 UTC (rev 12975)
@@ -0,0 +1,56 @@
+<!-- $Id: global_message.xsl 9282 2012-05-04 13:11:20Z sigurdne $ -->
+
+       <xsl:template name="dummy">
+               <xsl:apply-templates select="home_screen_message"/>
+       </xsl:template>
+
+       <xsl:template match="home_screen_message" 
xmlns:php="http://php.net/xsl";>
+               <h1><xsl:value-of select="php:function('lang', 'home screen 
message')" /></h1>
+               <form method="post" action="{form_action}">
+                       <table>
+                                <tr>
+                                       <td valign="top">
+                                                               <xsl:value-of 
select="php:function('lang', 'title')" />
+                                       </td>
+                                       <td>
+                                                <xsl:variable 
name="value_title"><xsl:value-of select="value_title" /></xsl:variable>
+                                               <input type="text" 
name="msg_title" id="msg_title" value="{value_title}" />
+                                       </td>
+                               </tr>
+                                <tr>
+                                    <td colspan="2">&nbsp;</td>
+                                </tr>
+                               <tr>
+                                       <td valign="top">
+                                                               <xsl:value-of 
select="php:function('lang', 'message')" />
+                                       </td>
+                                       <td>
+                                               <textarea cols="40" rows="6" 
id='message' name="message" wrap="virtual">
+                                                       <xsl:attribute 
name="title">
+                                               <xsl:value-of 
select="php:function('lang', 'home screen message')" />
+                                                       </xsl:attribute>
+                                                       <xsl:value-of 
select="value_message" disable-output-escaping="yes" />
+                                               </textarea>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               <xsl:value-of 
select="php:function('lang', 'delete message')" />
+                                       </td>
+                                       <td>
+                                               <input type="checkbox" 
name="delete_message" value="1" >
+                                                       <xsl:attribute 
name="title">
+                                                               <xsl:value-of 
select="php:function('lang', 'delete message')" />
+                                                       </xsl:attribute>
+                                               </input>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               <input type="submit" 
name="confirm" value="{lang_submit}"/>
+                                               <input type="submit" 
name="cancel" value="{lang_cancel}" />
+                                       </td>
+                               </tr>
+                       </table>
+               </form>
+       </xsl:template>


Property changes on: branches/dev-syncromind/booking
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/stavangerkommune/booking:9468-12740,12743-12875
/trunk/booking:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785,12787-12974

Modified: 
branches/dev-syncromind/booking/inc/class.async_task_send_reminder.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.async_task_send_reminder.inc.php  
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.async_task_send_reminder.inc.php  
2015-04-09 13:36:49 UTC (rev 12975)
@@ -111,14 +111,23 @@
 
                private function create_body_text($from, $to, $where, $who, 
$id, $secret, $type, $external_site_address)
                {
-                       $body = "Informasjon om kommende arrangement:\n";
+            $config    = CreateObject('phpgwapi.config','booking');
+            $config->read();
+
+            $body = "Informasjon om kommende arrangement:\n";
                        $body .= "Hvor: %WHERE%\n";
                        $body .= "Når:  %WHEN%\n";
                        if (strlen($who) > 0)
                        {
                                $body .= "Hvem: %WHO%\n";
                        }
-                       $body .= "\nBergen kommune fører statistikk på bruk av 
lokaler og ber derfor om at dere \n";
+            if ($config->config_data['metatag_author'] != '') {
+                $body .= "\n".$config->config_data['metatag_author'];
+            } else {
+                $body .= "\nAktivby ";
+            }
+
+                       $body .= " fører statistikk på bruk av lokaler og ber 
derfor om at dere \n";
                        $body .= "\netter arrangementet melder inn korrekt 
deltakertall til oss.\n";
                        $body .= "Du kan gjøre dette ved å klikke på linken 
nedenfor.\n\n%URL%";
 

Modified: branches/dev-syncromind/booking/inc/class.boallocation.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boallocation.inc.php      
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.boallocation.inc.php      
2015-04-09 13:36:49 UTC (rev 12975)
@@ -10,6 +10,162 @@
                }
                
                /**
+                * @ Send message about cancelation to users of building. 
+                */
+               function send_notification($allocation, $maildata, 
$mailadresses)
+               {
+                       if 
(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server']))
+                               return;
+                       $send = CreateObject('phpgwapi.send');
+
+                       $config = CreateObject('phpgwapi.config','booking');
+                       $config->read();
+
+                       $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+                       $external_site_address = 
isset($config->config_data['external_site_address']) && 
$config->config_data['external_site_address'] ? 
$config->config_data['external_site_address'] : 
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+            if($maildata['outseason'] != 'on' && $maildata['recurring'] != 
'on')
+            {
+                $res_names = '';
+                               foreach ($allocation['resources'] as $res) {
+                                       $res_names = 
$res_names.$this->so->get_resource($res)." ";
+                               }
+                               $info_deleted = ':<p>';
+                               $info_deleted = $info_deleted."".$res_names." - 
";
+                $info_deleted .= pretty_timestamp($allocation['from_'])." - ";
+                $info_deleted .= pretty_timestamp($allocation['to_']);
+                           $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                $link .= 
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
+                $link .= 
urlencode($allocation['from_']).'&to_[]='.urlencode($allocation['to_']).'&resource='.$allocation['resources'][0];
                    
+                $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+
+                       $subject = 
$config->config_data['allocation_canceled_mail_subject'];
+                $body = "<p>".$config->config_data['allocation_canceled_mail'];
+                $body .= '<br />'.$allocation['organization_name'].' har 
avbestilt tid i '.$allocation['building_name'];
+                       $body .= $info_deleted.'</p>';
+
+            } else {
+                $res_names = '';
+                               foreach ($allocation['resources'] as $res) {
+                                       $res_names = 
$res_names.$this->so->get_resource($res)." ";
+                               }
+                               $info_deleted = ':<p>';
+                               foreach ($maildata['delete'] as $valid_date) {
+                                       $info_deleted = 
$info_deleted."".$res_names." - ";
+                    $info_deleted .= pretty_timestamp($valid_date['from_'])." 
- ";
+                    $info_deleted .= pretty_timestamp($valid_date['to_']);
+                           $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                    $link .= 
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
+                    $link .= 
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$allocation['resources'][0];
                    
+                    $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+                               }
+
+                       $subject = 
$config->config_data['allocation_canceled_mail_subject'];
+                $body = "<p>".$config->config_data['allocation_canceled_mail'];
+                $body .= '<br />'.$allocation['organization_name'].' har 
avbestilt tid i '.$allocation['building_name'];
+                       $body .= $info_deleted.'</p>';
+
+            }
+
+
+                       $body .= 
"<p>".$config->config_data['application_mail_signature']."</p>";
+
+            foreach ($mailadresses as $adr)
+            {
+                       try
+                       {
+                                   $send->msg('email', $adr, $subject, $body, 
'', '', '', $from, '', 'html');
+                       }
+                       catch (phpmailerException $e)
+                       {
+                               // TODO: Inform user if something goes wrong
+                       }
+            }
+
+               }
+
+        function send_admin_notification($allocation, $maildata, 
$system_message)
+        {
+            if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server']))
+                return;
+            $send = CreateObject('phpgwapi.send');
+
+            $config    = CreateObject('phpgwapi.config','booking');
+            $config->read();
+
+            $mailadresses = $config->config_data['emails'];
+            $mailadresses = explode("\n",$mailadresses);
+
+            $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+            $external_site_address = 
isset($config->config_data['external_site_address']) && 
$config->config_data['external_site_address'] ? 
$config->config_data['external_site_address'] : 
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+            $subject = $system_message['title'];
+            $body = '<b>Beksjed fra '.$system_message['name'].'</b><br 
/>'.$system_message['message'].'<br /><br /><b>Epost som er sendt til brukere 
av Hallen:</b><br />';
+
+
+            if ($config->config_data['user_can_delete_allocations'] == 'yes') {
+                if($maildata['outseason'] != 'on' && $maildata['recurring'] != 
'on')
+                {
+                    $res_names = '';
+                    foreach ($allocation['resources'] as $res) {
+                        $res_names = 
$res_names.$this->so->get_resource($res)." ";
+                    }
+                    $info_deleted = ':<p>';
+                    $info_deleted = $info_deleted."".$res_names." - ";
+                    $info_deleted .= pretty_timestamp($allocation['from_'])." 
- ";
+                    $info_deleted .= pretty_timestamp($allocation['to_']);
+                    $link = 
$external_site_address.'/?menuaction=booking.uiapplication.add&building_id=';
+                    $link .= 
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
+                    $link .= 
urlencode($allocation['from_']).'&to_[]='.urlencode($allocation['to_']).'&resource='.$allocation['resources'][0];
+                    $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+
+                    $body .= 
"<p>".$config->config_data['allocation_canceled_mail'];
+                    $body .= '<br />'.$allocation['organization_name'].' har 
avbestilt tid i '.$allocation['building_name'];
+                    $body .= $info_deleted.'</p>';
+
+                } else {
+                    $res_names = '';
+                    foreach ($allocation['resources'] as $res) {
+                        $res_names = 
$res_names.$this->so->get_resource($res)." ";
+                    }
+                    $info_deleted = ':<p>';
+                    foreach ($maildata['delete'] as $valid_date) {
+                        $info_deleted = $info_deleted."".$res_names." - ";
+                        $info_deleted .= 
pretty_timestamp($valid_date['from_'])." - ";
+                        $info_deleted .= pretty_timestamp($valid_date['to_']);
+                        $link = 
$external_site_address.'/?menuaction=booking.uiapplication.add&building_id=';
+                        $link .= 
$allocation['building_id'].'&building_name='.urlencode($allocation['building_name']).'&from_[]=';
+                        $link .= 
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$allocation['resources'][0];
+                        $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply 
for time').'</a><br />';
+                    }
+
+                    $body .= 
"<p>".$config->config_data['allocation_canceled_mail'];
+                    $body .= '<br />'.$allocation['organization_name'].' har 
avbestilt tid i '.$allocation['building_name'];
+                    $body .= $info_deleted.'</p>';
+                }
+            } else {
+                $body .= "<p>Det er ikke sendt noen beskjed til brukere.</p>";
+            }
+            $body .= 
"<p>".$config->config_data['application_mail_signature']."</p>";
+
+            foreach ($mailadresses as $adr)
+            {
+                try
+                {
+                    $send->msg('email', $adr, $subject, $body, '', '', '', 
$from, '', 'html');
+                }
+                catch (phpmailerException $e)
+                {
+                    // TODO: Inform user if something goes wrong
+                }
+            }
+
+        }
+
+
+               /**
                 * @see bocommon_authorized
                 */
                protected function include_subject_parent_roles(array 
$for_object = null)

Modified: branches/dev-syncromind/booking/inc/class.boapplication.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boapplication.inc.php     
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.boapplication.inc.php     
2015-04-09 13:36:49 UTC (rev 12975)
@@ -1,15 +1,17 @@
 <?php
        phpgw::import_class('booking.bocommon');
-       
+
        class booking_boapplication extends booking_bocommon
        {
                function __construct()
                {
                        parent::__construct();
+            $this->activity_bo = CreateObject('booking.boactivity');
+            $this->organization_bo = CreateObject('booking.boorganization');
                        $this->so = CreateObject('booking.soapplication');
                }
 
-               function send_notification($application, $created=false)
+               function send_notification($application, $created=false, 
$assocciated=false)
                {
                        if 
(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server']))
                                return;
@@ -20,34 +22,82 @@
                        $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
                        $external_site_address = 
isset($config->config_data['external_site_address']) && 
$config->config_data['external_site_address'] ? 
$config->config_data['external_site_address'] : 
$GLOBALS['phpgw_info']['server']['webserver_url'];
 
+                       $subject = 
$config->config_data['application_mail_subject'];
 
-                       $subject = 'Melding fra Bergen kommune - AktivBy';
                        $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.show&id='.$application['id'].'&secret='.$application['secret'];
 
                        if ($created) {
-                               $body = '<p>Din søknad om leie/lån er 
mottatt.</p>';
-                               $body .= '<p>Praktisk informasjon finner du i 
dokumenter knyttet til bygget, ref. juridiske betingelser pk.8 i søknad.</p>';
-                               $body .= '<p>Klikk på linken under for å se på, 
redigere eller ha dialog med saksbehandler om din søknad.</p>';
-                               $body .= '<p><a href="'.$link.'">Link til 
AktivBy: søknad #'.$application['id'].'</a></p>';
+                               $body = 
"<pre>".$config->config_data['application_mail_created']."</pre>";
+                               $body .= '<p><a href="'.$link.'">Link til 
'.$config->config_data['application_mail_systemname'].': søknad 
#'.$application['id'].'</a></p>';
 
                        } elseif ($application['status'] == 'PENDING') {
-                               $body = '<p>Din søknad i AktivBy? om leie/lån 
er '.lang($application['status']).'.<br />Saksbehandler trenger ytterligere 
informasjon, ber om at du klikker på linken under og gir nødvendig 
tilbakemeldinger slik at saken kan ferdigbehandles.</p>';
-                               $body .= '<p><a href="'.$link.'">Link til 
AktivBy: søknad #'.$application['id'].'</a></p>';
+                               $body = "<p>Din søknad i 
".$config->config_data['application_mail_systemname']." om leie/lån er 
".lang($application['status']);
+                               $body .= 
"</p><pre>".$config->config_data['application_mail_pending']."</pre>";
+                               $body .= '<p><a href="'.$link.'">Link til 
'.$config->config_data['application_mail_systemname'].': søknad 
#'.$application['id'].'</a></p>';
                                if ($application['comment'] != '') {
                                        $body .= '<p>Kommentar fra 
saksbehandler:<br />'.$application['comment'].'</p>';
                                }
                        } elseif ($application['status'] == 'ACCEPTED') {
-                               $body = '<p>Din søknad i AktivBy om leie/lån er 
'.lang($application['status']).'.<br /> For å skrive ut en bekreftelse eller ha 
dialog med saksbehandler bruk <a href="'.$link.'">Link til AktivBy: søknad 
#'.$application['id'].'</a></p>';
+                               $accepted = 
$this->so->get_accepted($application['id']);
+                               $adates = "";
+                               foreach ($accepted as $key => $date) {
+                                               if($key === 0)
+                                                       $adates .= implode(" - 
",$date)."\n";
+                                               else
+                                                       $adates .= 
"\t".implode(" - ",$date)."\n";
+                               }
+                               $rejected = 
$this->so->get_rejected($application['id']);
+                               $rdates = "";
+                               foreach ($rejected as $key => $date) {
+                                               if($key === 0)
+                                                       $rdates .= implode(" - 
",$date)."\n";
+                                               else
+                                                       $rdates .= 
"\t".implode(" - ",$date)."\n";
+                               }
+
+                               $body = "<p>Din søknad i 
".$config->config_data['application_mail_systemname']." om leie/lån er 
".lang($application['status']);
+                               $body .= 
'</p><pre>'.$config->config_data['application_mail_accepted'].'<br /><a 
href="'.$link.'">Link til 
'.$config->config_data['application_mail_systemname'].': søknad 
#'.$application['id'].'</a></pre>';
+                               $body .= "<pre>Godkjent: ".$adates."</pre>";
+                               $body .= "<pre>Avvist: ".$rdates."</pre>";
+
                                if ($application['comment'] != '') {
-                                       $body .= '<p>Kommentar fra 
saksbehandler:<br />'.$application['comment'].'</p>';
+                                       $body .= "<p>Kommentar fra 
saksbehandler:<br />".$application['comment']."</p>";
                                }
+
+                               $buildingemail = 
$this->get_tilsyn_email($application['building_name']);
+                               if ($buildingemail['email1'] != '' || 
$buildingemail['email2'] != '' || $buildingemail['email3'] != '') {
+                                       $resourcename = 
implode(",",$this->get_resource_name($application['resources']));
+                                       $bsubject = 
$config->config_data['application_mail_subject'].": En søknad om leie/lån av 
".$resourcename." på ".$application['building_name']." er godkjent";
+                                       $bbody = 
"<p>".$application['contact_name']." sin søknad  om leie/lån av 
".$resourcename." på ".$application['building_name']."</p>";
+                                       $bbody .= "<p>Den ".$adates."er 
Godkjent</p>";
+                    $bbody .= "<p><b>Ekstra informasjon fra søker:</b><br 
/>".$application['equipment']."</p>";
+
+                                       foreach ($buildingemail as $bemail)
+                                       {
+                                               try
+                                               {
+                                                       $send->msg('email', 
$bemail, $bsubject, $bbody, '', '', '', $from, '', 'html');
+                                               }
+                                               catch (phpmailerException $e)
+                                               {
+                                               // TODO: Inform user if 
something goes wrong
+                                               }
+
+                                       }
+                               }
                        } elseif ($application['status'] == 'REJECTED') {
-                               $body = '<p>Din søknad i AktivBy om leie/lån er 
'.lang($application['status']).'.<br />For ytterligere informasjon se <a 
href="'.$link.'">Link til AktivBy: søknad #'.$application['id'].'</a></p>';
+                               $body = "<p>Din søknad i 
".$config->config_data['application_mail_systemname']." om leie/lån er 
".lang($application['status']);
+                               $body .= 
'</p><pre>'.$config->config_data['application_mail_rejected'].' <a 
href="'.$link.'">Link til 
'.$config->config_data['application_mail_systemname'].': søknad 
#'.$application['id'].'</a></pre>';
                                if ($application['comment'] != '') {
                                        $body .= '<p>Kommentar fra 
saksbehandler:<br />'.$application['comment'].'</p>';
                                }
-                       }
-                       $body .= '<p>Med vennlig hilsen AktivBy - Bergen 
Kommune</p>';
+                       } else {
+                $subject = 
$config->config_data['application_comment_mail_subject'];
+                $body = 
"<pre><p>".$config->config_data['application_comment_added_mail']."</p>";
+                $body .= '<p>Kommentar fra saksbehandler:<br 
/>'.$application['comment'].'</p></pre>';
+                $body .= '<p><a href="'.$link.'">Link til 
'.$config->config_data['application_mail_systemname'].': søknad 
#'.$application['id'].'</a></p>';
+            }
+                       $body .= 
"<p>".$config->config_data['application_mail_signature']."</p>";
 
                        try
                        {
@@ -58,8 +108,65 @@
                                // TODO: Inform user if something goes wrong
                        }
                }
-               
-               /**
+
+        /**
+         * @ Send message about comment on application to case officer.
+         */
+        function send_admin_notification($application, $message = null)
+        {
+            if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server']))
+                return;
+            $send = CreateObject('phpgwapi.send');
+
+            $config = CreateObject('phpgwapi.config', 'booking');
+            $config->read();
+
+            $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+            $external_site_address = 
isset($config->config_data['external_site_address']) && 
$config->config_data['external_site_address'] ? 
$config->config_data['external_site_address'] : 
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+            $subject = 
$config->config_data['application_comment_mail_subject_caseofficer'];
+
+            $mailadresses = $config->config_data['emails'];
+            $mailadresses = explode("\n", $mailadresses);
+
+            if ($GLOBALS['phpgw_info']['server']['webserver_url'] != '' && 
isset($config->config_data['external_site_address']))
+                $link = $external_site_address . 
$GLOBALS['phpgw_info']['server']['webserver_url'] . 
'/index.php?menuaction=booking.uiapplication.show&id=' . $application['id'];
+            else
+                $link = $external_site_address . 
'/index.php?menuaction=booking.uiapplication.show&id=' . $application['id'];
+
+            $activity = 
$this->activity_bo->read_single($application['activity_id']);
+
+            if (strlen($application['customer_organization_number']) == 9) {
+                $orgid = 
$this->organization_bo->so->get_orgid($application['customer_organization_number']);
+                $organization = $this->organization_bo->read_single($orgid);
+                $body = '<b>Kommentar fra ' . $organization['name'] . '</b><br 
/>' . $message . '<br /><br/>';
+            } else {
+                $body = '<b>Kommentar fra 
'.$application['contact_name'].'</b><br />'.$message.'<br /><br/>';
+            }
+
+            $body .= '<b>Bygg: </b>'.$application['building_name'].'<br />';
+            $body .= '<b>Aktivitet: </b>'.$activity['name'].'<br /><br />';
+            $body .= '<b>Kontaktperson:</b> 
'.$application['contact_name'].'<br />';
+            $body .= '<b>Epost:</b> '.$application['contact_email'].'<br />';
+            $body .= '<b>Telefon:</b> '.$application['contact_phone'].'<br 
/><br />';
+            $body .= '<a href="'.$link.'">Lenke til søknad</a><br /><br />';
+
+            foreach ($mailadresses as $adr)
+            {
+                try
+                {
+                    $send->msg('email', $adr, $subject, $body, '', '', '', 
$from, '', 'html');
+                }
+                catch (phpmailerException $e)
+                {
+                    // TODO: Inform user if something goes wrong
+                }
+            }
+        }
+
+
+        /**
                * Returns an array of application ids from applications 
assocciated with buildings
                * which the given user has access to
                *
@@ -70,6 +177,11 @@
                        $applications = array();
                        $this->db = & $GLOBALS['phpgw']->db;
 
+#                      $sql = "select distinct ap.id
+#                                      from bb_application ap
+#                                      inner join bb_application_resource ar 
on ar.application_id = ap.id
+#                                      inner join bb_resource re on re.id = 
ar.resource_id
+#                                      inner join bb_building bu on bu.id = 
re.building_id";
                        $sql = "select distinct ap.id
                                        from bb_application ap
                                        inner join bb_application_resource ar 
on ar.application_id = ap.id
@@ -93,20 +205,19 @@
 
                        if (!isset($params['filters'])) $params['filters'] = 
array();
                        $where_clauses = !isset($params['filters']['where']) ? 
array() : (array)$params['filters']['where'];
-                       
+
                        if (!is_null($for_case_officer_id[0])) {
                                $where_clauses[] = 
"(%%table%%.display_in_dashboard = 1 AND %%table%%.case_officer_id = 
".intval($for_case_officer_id[1]).')';
                        } else {
                                $where_clauses[] = "(%%table%%.case_officer_id 
= ".intval($for_case_officer_id[1]).')';
                        }
 
-                       
                        if ($building_id = phpgw::get_var('filter_building_id', 
'int', 'GET', false)) {
                                $where_clauses[] = "(%%table%%.id IN (SELECT 
DISTINCT a.id FROM bb_application a, bb_application_resource ar, bb_resource r 
WHERE ar.application_id = a.id AND ar.resource_id = r.id AND r.building_id = 
".intval($building_id)."))";
                        }
-                       
+
                        if ( $status = phpgw::get_var('status') != '') {
-                    $params['filters']['status'] = phpgw::get_var('status');   
    
+                    $params['filters']['status'] = phpgw::get_var('status');
                        }
 
                        $params['filters']['where'] = $where_clauses;
@@ -123,4 +234,4 @@
                        parent::__construct();
                        $this->so = new booking_soapplication_association();
                }
-       }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/booking/inc/class.bobooking.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.bobooking.inc.php 2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.bobooking.inc.php 2015-04-09 
13:36:49 UTC (rev 12975)
@@ -29,8 +29,251 @@
                        $this->event_so = CreateObject('booking.soevent');
                        $this->season_bo = CreateObject('booking.boseason');
                }
-               
+
                /**
+                * @ Send message about cancelation to users of building. 
+                */
+               function send_notification($booking, $allocation, $maildata, 
$mailadresses, $valid_dates=null)
+               {
+                       if 
(!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server']))
+                               return;
+                       $send = CreateObject('phpgwapi.send');
+
+                       $config = CreateObject('phpgwapi.config','booking');
+                       $config->read();
+
+                       $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+                       $external_site_address = 
isset($config->config_data['external_site_address']) && 
$config->config_data['external_site_address'] ? 
$config->config_data['external_site_address'] : 
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+
+            if(($maildata['outseason'] != 'on' && $maildata['recurring'] != 
'on' && $maildata['delete_allocation'] != 'on') || 
+                ($maildata['outseason'] != 'on' && $maildata['recurring'] != 
'on' && $maildata['delete_allocation'] == 'on' && 
+                 $maildata['allocation'] == 0))
+            {
+                           $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+                $link .= 
urlencode($booking['from_']).'&to_[]='.urlencode($booking['to_']).'&resource='.$booking['resources'][0];
+
+                       $subject = 
$config->config_data['booking_canceled_mail_subject'];
+
+                $body = "<p>".$config->config_data['booking_canceled_mail'];
+                $body .= '</p><p>'.$booking['group_name'].' har avbestilt tid 
i '.$booking['building_name'].':<br />';
+                $body .= $this->so->get_resource($booking['resources'][0]).' 
den '.pretty_timestamp($booking['from_']);
+                $body .=' til '.pretty_timestamp($booking['to_']); 
+                       $body .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a></p>';
+
+            } elseif (($maildata['outseason'] == 'on' || 
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] != 'on') {
+                $res_names = '';
+                               foreach ($booking['resources'] as $res) {
+                                       $res_names = 
$res_names.$this->so->get_resource($res)." ";
+                               }
+                               $info_deleted = ':<p>';
+                               foreach ($valid_dates as $valid_date) {
+                               $info_deleted = $info_deleted."".$res_names." - 
";
+                    $info_deleted .= pretty_timestamp($valid_date['from_'])." 
- ";
+                    $info_deleted .= pretty_timestamp($valid_date['to_']);
+                           $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                    $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']);
+                    $link .= 
'&from_[]='.urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+                    $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+                               }
+
+                       $subject = 
$config->config_data['booking_canceled_mail_subject'];
+
+                $body = "<p>".$config->config_data['booking_canceled_mail'];
+                $body .= '<br />'.$booking['group_name'].' har avbestilt tid i 
'.$booking['building_name'];
+                $body .= $info_deleted.'</p>';
+
+            } elseif (($maildata['outseason'] == 'on' || 
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] == 'on') {
+                $res_names = '';
+                               foreach ($booking['resources'] as $res) {
+                                       $res_names = 
$res_names.$this->so->get_resource($res)." ";
+                               }
+                               $info_deleted = ':<p>';
+                               foreach ($valid_dates as $valid_date) {
+                    if (!in_array($valid_date,$maildata['delete'])) {
+                                       $info_deleted = 
$info_deleted."".$res_names." - ";
+                        $info_deleted .= 
pretty_timestamp($valid_date['from_'])." - ";
+                        $info_deleted .= pretty_timestamp($valid_date['to_']);
+                                   $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                        $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+                        $link .= 
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+                        $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply 
for time').'</a><br />';
+                    }
+                               }
+                               foreach ($maildata['delete'] as $valid_date) {
+                                       $info_deleted = 
$info_deleted."".$res_names." - ";
+                    $info_deleted .= pretty_timestamp($valid_date['from_'])." 
- ";
+                    $info_deleted .= pretty_timestamp($valid_date['to_']);
+                           $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                    $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+                    $link .= 
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
                    
+                    $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+                               }
+                
+
+                       $subject = 
$config->config_data['allocation_canceled_mail_subject'];
+                $body = "<p>".$config->config_data['allocation_canceled_mail'];
+                $body .= '<br />'.$booking['group_name'].' har avbestilt tid i 
'.$booking['building_name'];
+                       $body .= $info_deleted.'</p>';
+
+            } else {
+                $res_names = '';
+                               foreach ($booking['resources'] as $res) {
+                                       $res_names = 
$res_names.$this->so->get_resource($res)." ";
+                               }
+                               $info_deleted = ':<p>';
+                foreach ($maildata['delete'] as $valid_date) {
+                                       $info_deleted = 
$info_deleted."".$res_names." - ";
+                    $info_deleted .= pretty_timestamp($allocation['from_'])." 
- ";
+                    $info_deleted .= pretty_timestamp($allocation['to_']);
+                               $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                    $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+                    $link .= 
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+                    $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+                }
+                       $subject = 
$config->config_data['allocation_canceled_mail_subject'];
+                $body = "<p>".$config->config_data['allocation_canceled_mail'];
+                $body .= '<br />'.$booking['group_name'].' har avbestilt tid i 
'.$booking['building_name'];
+                       $body .= $info_deleted.'</p>';
+            }
+
+                       $body .= 
"<p>".$config->config_data['application_mail_signature']."</p>";
+            
+            foreach ($mailadresses as $adr)
+            {
+                       try
+                       {
+                                   $send->msg('email', $adr, $subject, $body, 
'', '', '', $from, '', 'html');
+                       }
+                       catch (phpmailerException $e)
+                       {
+                               // TODO: Inform user if something goes wrong
+                       }
+            }
+               }
+
+        function send_admin_notification($booking, $maildata, $system_message, 
$allocation, $valid_dates=null)
+        {
+            if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server']))
+                return;
+            $send = CreateObject('phpgwapi.send');
+
+            $config    = CreateObject('phpgwapi.config','booking');
+            $config->read();
+
+            $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+            $external_site_address = 
isset($config->config_data['external_site_address']) && 
$config->config_data['external_site_address'] ? 
$config->config_data['external_site_address'] : 
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+            $subject = $system_message['title'];
+            $body = '<b>Beksjed fra '.$system_message['name'].'</b><br 
/>'.$system_message['message'].'<br /><br /><b>Epost som er sendt til brukere 
av Hallen:</b><br />';
+            $mailadresses = $config->config_data['emails'];
+            $mailadresses = explode("\n",$mailadresses);
+
+            if(($maildata['outseason'] != 'on' && $maildata['recurring'] != 
'on' && $maildata['delete_allocation'] != 'on') ||
+                ($maildata['outseason'] != 'on' && $maildata['recurring'] != 
'on' && $maildata['delete_allocation'] == 'on' &&
+                    $maildata['allocation'] == 0))
+            {
+                $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+                $link .= 
urlencode($booking['from_']).'&to_[]='.urlencode($booking['to_']).'&resource='.$booking['resources'][0];
+
+                $body .= "<p>".$config->config_data['booking_canceled_mail'];
+                $body .= '</p><p>'.$booking['group_name'].' har avbestilt tid 
i '.$booking['building_name'].':<br />';
+                $body .= $this->so->get_resource($booking['resources'][0]).' 
den '.pretty_timestamp($booking['from_']);
+                $body .=' til '.pretty_timestamp($booking['to_']);
+                $body .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a></p>';
+
+            } elseif (($maildata['outseason'] == 'on' || 
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] != 'on') {
+                $res_names = '';
+                foreach ($booking['resources'] as $res) {
+                    $res_names = $res_names.$this->so->get_resource($res)." ";
+                }
+                $info_deleted = ':<p>';
+                foreach ($valid_dates as $valid_date) {
+                    $info_deleted = $info_deleted."".$res_names." - ";
+                    $info_deleted .= pretty_timestamp($valid_date['from_'])." 
- ";
+                    $info_deleted .= pretty_timestamp($valid_date['to_']);
+                    $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                    $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']);
+                    $link .= 
'&from_[]='.urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+                    $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+                }
+
+                $body .= "<p>".$config->config_data['booking_canceled_mail'];
+                $body .= '<br />'.$booking['group_name'].' har avbestilt tid i 
'.$booking['building_name'];
+                $body .= $info_deleted.'</p>';
+
+            } elseif (($maildata['outseason'] == 'on' || 
$maildata['recurring'] == 'on') && $maildata['delete_allocation'] == 'on') {
+                $res_names = '';
+                foreach ($booking['resources'] as $res) {
+                    $res_names = $res_names.$this->so->get_resource($res)." ";
+                }
+                $info_deleted = ':<p>';
+                foreach ($valid_dates as $valid_date) {
+                    if (!in_array($valid_date,$maildata['delete'])) {
+                        $info_deleted = $info_deleted."".$res_names." - ";
+                        $info_deleted .= 
pretty_timestamp($valid_date['from_'])." - ";
+                        $info_deleted .= pretty_timestamp($valid_date['to_']);
+                        $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                        $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+                        $link .= 
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+                        $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply 
for time').'</a><br />';
+                    }
+                }
+                foreach ($maildata['delete'] as $valid_date) {
+                    $info_deleted = $info_deleted."".$res_names." - ";
+                    $info_deleted .= pretty_timestamp($valid_date['from_'])." 
- ";
+                    $info_deleted .= pretty_timestamp($valid_date['to_']);
+                    $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                    $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']).'&from_[]=';
+                    $link .= 
urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+                    $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+                }
+
+
+                $body .= 
"<p>".$config->config_data['allocation_canceled_mail'];
+                $body .= '<br />'.$booking['group_name'].' har avbestilt tid i 
'.$booking['building_name'];
+                $body .= $info_deleted.'</p>';
+
+            } else {
+                $res_names = '';
+                foreach ($booking['resources'] as $res) {
+                    $res_names = $res_names.$this->so->get_resource($res)." ";
+                }
+                $info_deleted = ':<p>';
+                foreach ($maildata['delete'] as $valid_date) {
+                    $info_deleted = $info_deleted."".$res_names." - ";
+                    $info_deleted .= pretty_timestamp($allocation['from_'])." 
- ";
+                    $info_deleted .= pretty_timestamp($allocation['to_']);
+                    $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+                    $link .= 
$booking['building_id'].'&building_name='.urlencode($booking['building_name']);
+                    $link .= 
'&from_[]='.urlencode($valid_date['from_']).'&to_[]='.urlencode($valid_date['to_']).'&resource='.$booking['resources'][0];
+                    $info_deleted .= ' - <a href="'.$link.'">'.lang('Apply for 
time').'</a><br />';
+                }
+                $body .= 
"<p>".$config->config_data['allocation_canceled_mail'];
+                $body .= '<br />'.$booking['group_name'].' har avbestilt tid i 
'.$booking['building_name'];
+                $body .= $info_deleted.'</p>';
+            }
+
+            $body .= 
"<p>".$config->config_data['application_mail_signature']."</p>";
+            foreach ($mailadresses as $adr)
+            {
+                try
+                {
+                    $send->msg('email', $adr, $subject, $body, '', '', '', 
$from, '', 'html');
+                }
+                catch (phpmailerException $e)
+                {
+                    // TODO: Inform user if something goes wrong
+                }
+            }
+        }
+
+
+               /**
                 * @see bocommon_authorized
                 */
                protected function include_subject_parent_roles(array 
$for_object = null)
@@ -176,11 +419,315 @@
                 *
                 * @return array containing values from $array for the keys in 
$keys.
                 */
-               function building_schedule($building_id, $date)
+
+//        todo: remove debug kode
+        function building_schedule($building_id, $date)
+        {
+//            echo "debug:\n";
+            $from = clone $date;
+            $from->setTime(0, 0, 0);
+            // Make sure $from is a monday
+            if($from->format('w') != 1)
+            {
+                $from->modify('last monday');
+            }
+            $to = clone $from;
+            $to->modify('+7 days');
+            $allocation_ids = 
$this->so->allocation_ids_for_building($building_id, $from, $to);
+            $allocations = $this->allocation_so->read(array('filters'=> 
array('id' => $allocation_ids)));
+            $allocations = $allocations['results'];
+            foreach($allocations as &$allocation)
+            {
+                $allocation['name'] = $allocation['organization_name'];
+                $allocation['shortname'] = 
$allocation['organization_shortname'];
+                $allocation['type'] = 'allocation';
+            }
+
+            $booking_ids = $this->so->booking_ids_for_building($building_id, 
$from, $to);
+            $bookings = $this->so->read(array('filters'=> array('id' => 
$booking_ids)));
+            $bookings = $bookings['results'];
+            foreach($bookings as &$booking)
+            {
+                $booking['name'] = $booking['group_name'];
+                $booking['shortname'] = $booking['group_shortname'];
+                $booking['type'] = 'booking';
+                unset($booking['audience']);
+                unset($booking['agegroups']);
+            }
+
+            $allocations = $this->split_allocations($allocations, $bookings);
+
+            $event_ids = $this->so->event_ids_for_building($building_id, 
$from, $to);
+            $events = $this->event_so->read(array('filters'=> array('id' => 
$event_ids)));
+            $events = $events['results'];
+            foreach($events as &$event)
+            {
+
+                $event['name'] = $event['description'];
+                $event['type'] = 'event';
+                unset($event['comments']);
+                unset($event['audience']);
+                unset($event['agegroups']);
+                unset($event['dates']);
+
+            }
+
+            $bookings = array_merge($allocations, $bookings);
+//            echo "before rem\n";
+            $bookings = $this->_remove_event_conflicts($bookings, $events);
+//            echo "after rem\n";
+
+            $bookings = array_merge($events, $bookings);
+
+            $resource_ids = $this->so->resource_ids_for_bookings($booking_ids);
+            $resource_ids = array_merge($resource_ids, 
$this->so->resource_ids_for_allocations($allocation_ids));
+            $resource_ids = array_merge($resource_ids, 
$this->so->resource_ids_for_events($event_ids));
+            $resources = $this->resource_so->read(array('filters' => 
array('id' => $resource_ids, 'active' => 1)));
+            $resources = $resources['results'];
+
+            foreach ($resources as $key => $row) {
+                $sort[$key] = $row['sort'];
+            }
+
+            // Sort the resources with sortkey ascending
+            // Add $resources as the last parameter, to sort by the common key
+            array_multisort($sort, SORT_ASC, $resources);
+            $bookings = $this->_split_multi_day_bookings($bookings, $from, 
$to);
+            $results = build_schedule_table($bookings, $resources);
+//            exit;
+            return array('total_records'=>count($results), 
'results'=>$results);
+        }
+
+               function building_infoscreen_schedule($building_id, $date, $res 
= False)
                {
+                       $from = clone $date;
+                       $from->setTime(0, 0, 0);
+                       // Make sure $from is a monday
+                       if($from->format('w') != 1)
+                       {
+                               $from->modify('last monday');
+                       }
+            $to = clone $from;
+            $to->modify('+7 days');
+            $to->modify('-1 minute');
 
+            if ($res != False){
+                $resources = $this->so->get_screen_resources($building_id, 
$res);
+                if (count($resources) > 0)
+                    $resources = "AND bb_resource.id IN (".implode(",", 
$resources).")";
+                else
+                    $resources = '';
+            }
+            $allocations = $this->so->get_screen_allocation($building_id, 
$from, $to, $resources);
+            $bookings = $this->so->get_screen_booking($building_id, $from, 
$to, $resources);
+            $events = $this->so->get_screen_event($building_id, $from, $to, 
$resources);
 
-            $from = clone $date;
+            $results = array();
+
+            foreach($allocations as &$allocation)
+                       {
+                               $allocation['name'] = 
$allocation['organization_name'];
+                               $allocation['shortname'] = 
$allocation['organization_shortname'];
+                $allocation['type'] = 'allocation';
+
+                $datef = strtotime($allocation['from_']);
+                $allocation['weekday'] = date('D',$datef);
+                       }
+
+                       foreach($bookings as &$booking)
+                       {
+                               $booking['name'] = $booking['group_name'];
+                               $booking['shortname'] = 
$booking['group_shortname'];
+                               $booking['type'] = 'booking';
+
+                $datef = strtotime($booking['from_']);
+                $booking['weekday'] = date('D',$datef);
+            }
+
+            foreach($events as &$event)
+            {
+                $event['name'] = substr($event['description'], 0, 34);
+                $event['shortname'] = substr($event['description'], 0, 12);
+                $event['type'] = 'event';
+                $datef = strtotime($event['from_']);
+                $event['weekday'] = date('D',$datef);
+            }
+
+            $allocations = $this->split_allocations2($allocations, $bookings);
+            $bookings = array_merge($allocations, $bookings);
+            $bookings = $this->_remove_event_conflicts2($bookings, $events);
+            $bookings = array_merge($bookings, $events);
+            $bookings = $this->_split_multi_day_bookings2($bookings, $from, 
$to);
+
+            foreach($bookings as &$allocation)
+            {
+                $datef = strtotime($allocation['from_']);
+                $datet = strtotime($allocation['to_']);
+                $timef = date('H:i:s',$datef);
+                $timet = date('H:i:s',$datet);
+                $weekday = $allocation['weekday'];
+                $resname = $allocation['resource_name'];
+                $ft = $timef;
+                $from = explode(':',$timef);
+                $to = explode(':',$timet);
+                $from  = $from[0]*60+$from[1];
+                $to  = $to[0]*60+$to[1];
+                if ($to == 0)
+                    $to = 24*60;
+                $colspan = ($to-$from)/30;
+
+                $allocation['colspan'] = $colspan;
+                $results[$weekday][$resname][$ft] = $allocation;
+            }
+
+            foreach ($results as &$day) {
+                foreach ($day as &$res) {
+                    ksort($res);
+                }
+            }
+
+                       return array('total_records'=>count($results), 
'results'=>$results);
+               }
+
+        function split_allocations2($allocations, $all_bookings)
+        {
+            function get_from2($a) {return $a['from_'];};
+            function get_to2($a) {return $a['to_'];};
+            $new_allocations = array();
+            foreach($allocations as $allocation)
+            {
+                // $ Find all associated bookings
+                $bookings = array();
+
+                foreach($all_bookings as $b)
+                {
+                    if($b['allocation_id'] == $allocation['id'])
+                        $bookings[] = $b;
+                }
+                $times = array($allocation['from_'], $allocation['to_']);
+
+                $times = array_merge(array_map("get_from2", $bookings), 
$times);
+                $times = array_merge(array_map("get_to2", $bookings), $times);
+                $times = array_unique($times);
+                sort($times);
+                while(count($times) >= 2)
+                {
+                    $from_ = $times[0];
+                    $to_ = $times[1];
+                    $resources = array($allocation['resource_id']);
+                    foreach($all_bookings as $b)
+                    {
+
+                        if(($b['from_'] >= $from_ && $b['from_'] < $to_) || 
($b['to_'] > $from_ && $b['to_'] <= $to_) || ($b['from_'] <= $from_ && 
$b['to_'] >= $to_))
+                            $resources = array_minus($resources, 
array($b['resource_id']));
+                    }
+                    if($resources)
+                    {
+                        $a = $allocation;
+                        $a['from_'] = $times[0];
+                        $a['to_'] = $times[1];
+                        $new_allocations[] = $a;
+                    }
+                    array_shift($times);
+                }
+            }
+            return $new_allocations;
+        }
+
+        function _remove_event_conflicts2($bookings, &$events)
+        {
+            $new_bookings = array();
+            foreach($bookings as $b)
+            {
+                $keep = true;
+                foreach($events as &$e)
+                {
+                    if((($b['from_'] >= $e['from_'] && $b['from_'] < 
$e['to_']) ||
+                            ($b['to_'] > $e['from_'] && $b['to_'] <= 
$e['to_']) ||
+                            ($b['from_'] <= $e['from_'] && $b['to_'] >= 
$e['to_'])) && ( $b['resource_id'] == $e['resource_id']))
+                    {
+                        $keep = false;
+                        break;
+                    }
+                }
+                if($keep)
+                {
+                    $new_bookings[] = $b;
+                }
+            }
+            return $new_bookings;
+        }
+
+        function _split_multi_day_bookings2($bookings, $t0, $t1)
+        {
+            if($t1->format('H:i') == '00:00')
+                $t1->modify('-1 day');
+            $new_bookings = array();
+            foreach($bookings as $booking)
+            {
+                $from = new DateTime($booking['from_']);
+                $to = new DateTime($booking['to_']);
+                // Basic one-day booking
+                if($from->format('Y-m-d') == $to->format('Y-m-d'))
+                {
+                    $booking['date'] = $from->format('Y-m-d');
+                    $booking['weekday']  = 
date_format(date_create($booking['date']), 'D');
+                    $booking['from_'] = $from->format('H:i');
+                    $booking['to_'] = $to->format('H:i');
+                    // We need to use 24:00 instead of 00:00 to sort correctly
+                    $booking['to_'] = $booking['to_'] == '00:00' ? '24:00' : 
$booking['to_'];
+                    $new_bookings[] = $booking;
+                }
+                // Multi-day booking
+                else
+                {
+                    $start = clone max($from, $t0);
+                    $end = clone min($to, $t1);
+                    $date = clone $start;
+                    do
+                    {
+                        $new_booking = $booking;
+                        $new_booking['date'] = $date->format('Y-m-d');
+                        $new_booking['weekday']  = date_format($date, 'D');
+                        $new_booking['from_'] = '00:00';
+                        $new_booking['to_'] = '00:00';
+                        if($new_booking['date'] == $from->format('Y-m-d'))
+                        {
+                            $new_booking['from_'] = $from->format('H:i');
+                        }
+                        else if($new_booking['date'] == $to->format('Y-m-d'))
+                        {
+                            $new_booking['to_'] = $to->format('H:i');
+                        }
+                        // We need to use 24:00 instead of 00:00 to sort 
correctly
+                        $new_booking['to_'] = $new_booking['to_'] == '00:00' ? 
'24:00' : $new_booking['to_'];
+                        $new_bookings[] = $new_booking;
+
+                        if($date->format('Y-m-d') == $end->format('Y-m-d'))
+                        {
+                            break;
+                        }
+
+                        //             if($date->getTimestamp() > 
$end->getTimestamp()) // > php 5.3.0
+                        if($date->format("U") > $end->format("U"))
+                        {
+                            throw new InvalidArgumentException('start time( ' 
. $date->format('Y-m-d') . ' ) later than end time( ' . $end->format('Y-m-d') . 
" ) for {$booking['type']}#{$booking['id']}::{$booking['name']}");
+                        }
+
+                        $date->modify('+1 day');
+                    }
+                    while(true);
+                }
+            }
+            return $new_bookings;
+        }
+
+               function building_extraschedule($building_id, $date)
+               {
+                       $config = CreateObject('phpgwapi.config','booking');
+                       $config->read();
+
+                       $from = clone $date;
                        $from->setTime(0, 0, 0);
                        // Make sure $from is a monday
                        if($from->format('w') != 1)
@@ -190,7 +737,10 @@
                        $to = clone $from;
                        $to->modify('+7 days');
                        $allocation_ids = 
$this->so->allocation_ids_for_building($building_id, $from, $to);
-                       $allocations = 
$this->allocation_so->read(array('filters'=> array('id' => $allocation_ids)));
+            
+            $orgids = explode(",", $config->config_data['extra_schedule_ids']);
+            
+                       $allocations = 
$this->allocation_so->read(array('filters'=> array('id' => $allocation_ids, 
'organization_id' => $orgids), 'sort'=>'from_'));
                        $allocations = $allocations['results'];
                        foreach($allocations as &$allocation)
                        {
@@ -200,7 +750,7 @@
                        }
 
                        $booking_ids = 
$this->so->booking_ids_for_building($building_id, $from, $to);
-                       $bookings = $this->so->read(array('filters'=> 
array('id' => $booking_ids)));
+                       $bookings = $this->so->read(array('filters'=> 
array('id' => $booking_ids), 'sort'=>'from_'));
                        $bookings = $bookings['results'];
                        foreach($bookings as &$booking)
                        {
@@ -214,7 +764,7 @@
                        $allocations = $this->split_allocations($allocations, 
$bookings);
 
                        $event_ids = 
$this->so->event_ids_for_building($building_id, $from, $to);
-                       $events = $this->event_so->read(array('filters'=> 
array('id' => $event_ids)));
+                       $events = $this->event_so->read(array('filters'=> 
array('id' => $event_ids), 'sort'=>'from_'));
                        $events = $events['results'];
                        foreach($events as &$event)
                        {
@@ -228,7 +778,6 @@
 
                        $bookings = array_merge($allocations, $bookings);
                        $bookings = $this->_remove_event_conflicts($bookings, 
$events);
-                       $bookings = array_merge($events, $bookings);
 
                        $resource_ids = 
$this->so->resource_ids_for_bookings($booking_ids);
                        $resource_ids = array_merge($resource_ids, 
$this->so->resource_ids_for_allocations($allocation_ids));
@@ -257,199 +806,324 @@
                 *
                 * @return array containg values from $array for the keys in 
$keys.
                 */
-               function resource_schedule($resource_id, $date)
-               {
-                       $from = clone $date;
-                       $from->setTime(0, 0, 0);
-                       // Make sure $from is a monday
-                       if($from->format('w') != 1)
-                       {
-                               $from->modify('last monday');
-                       }
-                       $to = clone $from;
-                       $to->modify('+7 days');
-                       $resource = 
$this->resource_so->read_single($resource_id);
-                       $allocation_ids = 
$this->so->allocation_ids_for_resource($resource_id, $from, $to);
-                       $allocations = 
$this->allocation_so->read(array('filters'=> array('id' => $allocation_ids)));
-                       $allocations = $allocations['results'];
-                       foreach($allocations as &$allocation)
-                       {
-                               $allocation['name'] = 
$allocation['organization_name'];
-                               $allocation['shortname'] = 
$allocation['organization_shortname'];
-                               $allocation['type'] = 'allocation';
-                       }
-                       $booking_ids = 
$this->so->booking_ids_for_resource($resource_id, $from, $to);
-                       $bookings = $this->so->read(array('filters'=> 
array('id' => $booking_ids)));
-                       $bookings = $bookings['results'];
-                       foreach($bookings as &$booking)
-                       {
-                               $booking['name'] = $booking['group_name'];
-                               $booking['shortname'] = 
$booking['group_shortname'];
-                               $booking['type'] = 'booking';
-                       }
-                       $allocations = $this->split_allocations($allocations, 
$bookings);
+        function resource_schedule($resource_id, $date)
+        {
+            $from = clone $date;
+            $from->setTime(0, 0, 0);
+            // Make sure $from is a monday
+            if($from->format('w') != 1)
+            {
+                $from->modify('last monday');
+            }
+            $to = clone $from;
+            $to->modify('+7 days');
+            $resource = $this->resource_so->read_single($resource_id);
+            $allocation_ids = 
$this->so->allocation_ids_for_resource($resource_id, $from, $to);
+            $allocations = $this->allocation_so->read(array('filters'=> 
array('id' => $allocation_ids)));
+            $allocations = $allocations['results'];
+            foreach($allocations as &$allocation)
+            {
+                $allocation['name'] = $allocation['organization_name'];
+                $allocation['shortname'] = 
$allocation['organization_shortname'];
+                $allocation['type'] = 'allocation';
+            }
+            $booking_ids = $this->so->booking_ids_for_resource($resource_id, 
$from, $to);
+            $bookings = $this->so->read(array('filters'=> array('id' => 
$booking_ids)));
+            $bookings = $bookings['results'];
+            foreach($bookings as &$booking)
+            {
+                $booking['name'] = $booking['group_name'];
+                $booking['shortname'] = $booking['group_shortname'];
+                $booking['type'] = 'booking';
+            }
+            $allocations = $this->split_allocations($allocations, $bookings);
 
-                       $event_ids = 
$this->so->event_ids_for_resource($resource_id, $from, $to);
-                       $events = $this->event_so->read(array('filters'=> 
array('id' => $event_ids)));
-                       $events = $events['results'];
-                       foreach($events as &$event)
-                       {
-                               $event['name'] = $event['description'];
-                               $event['type'] = 'event';
-                       }
-                       $bookings = array_merge($allocations, $bookings);
-                       $bookings = $this->_remove_event_conflicts($bookings, 
$events);
-                       $bookings = array_merge($events, $bookings);
-                       
-                       $bookings = $this->_split_multi_day_bookings($bookings, 
$from, $to);
-                       $results = build_schedule_table($bookings, 
array($resource));
-                       return array('total_records'=>count($results), 
'results'=>$results);
-               }
+            $event_ids = $this->so->event_ids_for_resource($resource_id, 
$from, $to);
+            $events = $this->event_so->read(array('filters'=> array('id' => 
$event_ids)));
+            $events = $events['results'];
+            foreach($events as &$event)
+            {
+                $event['name'] = $event['description'];
+                $event['type'] = 'event';
+            }
+            $bookings = array_merge($allocations, $bookings);
+            $bookings = $this->_remove_event_conflicts($bookings, $events);
+            $bookings = array_merge($events, $bookings);
 
-               /**
-                * Split allocations overlapped by bookings into multiple 
allocations
-                * to avoid overlaps
-                */
-               function split_allocations($allocations, $all_bookings)
-               {
-                       function get_from2($a) {return $a['from_'];};
-                       function get_to2($a) {return $a['to_'];};
-                       $new_allocations = array();
-                       foreach($allocations as $allocation)
-                       {
-                               // $ Find all associated bookings
-                               $bookings = array();
-                               foreach($all_bookings as $b)
-                               {
-                                       if($b['allocation_id'] == 
$allocation['id'])
-                                               $bookings[] = $b;
-                               }
-                               $times = array($allocation['from_'], 
$allocation['to_']);
-                               $times = array_merge(array_map("get_from2", 
$bookings), $times);
-                               $times = array_merge(array_map("get_to2", 
$bookings), $times);
-                               $times = array_unique($times);
-                               sort($times);
-                               while(count($times) >= 2)
-                               {
-                                       $from_ = $times[0];
-                                       $to_ = $times[1];
-                                       $resources = $allocation['resources'];
-                                       $used = array();
-                                       foreach($all_bookings as $b)
-                                       {
-                                               
-                                               if(($b['from_'] >= $from_ && 
$b['from_'] < $to_) || ($b['to_'] > $from_ && $b['to_'] <= $to_) || 
($b['from_'] <= $from_ && $b['to_'] >= $to_))
-                                                       $resources = 
array_minus($resources, $b['resources']);
-                                       }
-                                       if($resources)
-                                       {
-                                               $a = $allocation;
-                                               $a['from_'] = $times[0];
-                                               $a['to_'] = $times[1];
-                                               $new_allocations[] = $a;
-                                       }
-                                       array_shift($times);
-                               }
-                       }
-                       return $new_allocations;
-               }
+            $bookings = $this->_split_multi_day_bookings($bookings, $from, 
$to);
+            $results = build_schedule_table($bookings, array($resource));
+            return array('total_records'=>count($results), 
'results'=>$results);
+        }
 
-               /**
-                * Split Multi-day bookings into separate single-day bookings
-               **/
-               function _split_multi_day_bookings($bookings, $t0, $t1)
-               {
-                       if($t1->format('H:i') == '00:00')
-                               $t1->modify('-1 day');
-                       $new_bookings = array();
-                       foreach($bookings as $booking)
-                       {
-                               $from = new DateTime($booking['from_']);
-                               $to = new DateTime($booking['to_']);
-                               // Basic one-day booking
-                               if($from->format('Y-m-d') == 
$to->format('Y-m-d'))
-                               {
-                                       $booking['date'] = 
$from->format('Y-m-d');
-                                       $booking['wday']  = 
date_format(date_create($booking['date']), 'D');
-                                       $booking['from_'] = 
$from->format('H:i');
-                                       $booking['to_'] = $to->format('H:i');
-                                       // We need to use 24:00 instead of 
00:00 to sort correctly
-                                       $booking['to_'] = $booking['to_'] == 
'00:00' ? '24:00' : $booking['to_'];
-                                       $new_bookings[] = $booking;
-                               }
-                               // Multi-day booking
-                               else
-                               {
-                                       $start = clone max($from, $t0);
-                                       $end = clone min($to, $t1);
-                                       $date = clone $start;
-                                       do
-                                       {
-                                               $new_booking = $booking;
-                                               $new_booking['date'] = 
$date->format('Y-m-d');
-                                               $new_booking['wday']  = 
date_format($date, 'D');
-                                               $new_booking['from_'] = '00:00';
-                                               $new_booking['to_'] = '00:00';
-                                               if($new_booking['date'] == 
$from->format('Y-m-d'))
-                                               {
-                                                       $new_booking['from_'] = 
$from->format('H:i');
-                                               }
-                                               else if($new_booking['date'] == 
$to->format('Y-m-d'))
-                                               {
-                                                       $new_booking['to_'] = 
$to->format('H:i');
-                                               }
-                                               // We need to use 24:00 instead 
of 00:00 to sort correctly
-                                               $new_booking['to_'] = 
$new_booking['to_'] == '00:00' ? '24:00' : $new_booking['to_'];
-                                               $new_bookings[] = $new_booking;
+        /**
+         * Split allocations overlapped by bookings into multiple allocations
+         * to avoid overlaps
+         */
+        function split_allocations($allocations, $all_bookings)
+        {
+            function get_from2($a) {return $a['from_'];};
+            function get_to2($a) {return $a['to_'];};
+            $new_allocations = array();
+            foreach($allocations as $allocation)
+            {
+                // $ Find all associated bookings
+                $bookings = array();
+                foreach($all_bookings as $b)
+                {
+                    if($b['allocation_id'] == $allocation['id'])
+                        $bookings[] = $b;
+                }
+                $times = array($allocation['from_'], $allocation['to_']);
+                $times = array_merge(array_map("get_from2", $bookings), 
$times);
+                $times = array_merge(array_map("get_to2", $bookings), $times);
+                $times = array_unique($times);
+                sort($times);
+                while(count($times) >= 2)
+                {
+                    $from_ = $times[0];
+                    $to_ = $times[1];
+                    $resources = $allocation['resources'];
+                    $used = array();
+                    foreach($all_bookings as $b)
+                    {
 
-                                               if($date->format('Y-m-d') == 
$end->format('Y-m-d'))
-                                               {
-                                                       break;
-                                               }
+                        if(($b['from_'] >= $from_ && $b['from_'] < $to_) || 
($b['to_'] > $from_ && $b['to_'] <= $to_) || ($b['from_'] <= $from_ && 
$b['to_'] >= $to_))
+                            $resources = array_minus($resources, 
$b['resources']);
+                    }
+                    if($resources)
+                    {
+                        $a = $allocation;
+                        $a['from_'] = $times[0];
+                        $a['to_'] = $times[1];
+                        $new_allocations[] = $a;
+                    }
+                    array_shift($times);
+                }
+            }
+            return $new_allocations;
+        }
 
-                               //              if($date->getTimestamp() > 
$end->getTimestamp()) // > php 5.3.0
-                                               if($date->format("U") > 
$end->format("U"))
-                                               {
-                                                       throw new 
InvalidArgumentException('start time( ' . $date->format('Y-m-d') . ' ) later 
than end time( ' . $end->format('Y-m-d') . " ) for 
{$booking['type']}#{$booking['id']}::{$booking['name']}");
-                                               }
+        /**
+         * Split Multi-day bookings into separate single-day bookings
+         **/
+        function _split_multi_day_bookings($bookings, $t0, $t1)
+        {
+            if($t1->format('H:i') == '00:00')
+                $t1->modify('-1 day');
+            $new_bookings = array();
+            foreach($bookings as $booking)
+            {
+                $from = new DateTime($booking['from_']);
+                $to = new DateTime($booking['to_']);
+                // Basic one-day booking
+                if($from->format('Y-m-d') == $to->format('Y-m-d'))
+                {
+                    $booking['date'] = $from->format('Y-m-d');
+                    $booking['wday']  = 
date_format(date_create($booking['date']), 'D');
+                    $booking['from_'] = $from->format('H:i');
+                    $booking['to_'] = $to->format('H:i');
+                    // We need to use 24:00 instead of 00:00 to sort correctly
+                    $booking['to_'] = $booking['to_'] == '00:00' ? '24:00' : 
$booking['to_'];
+                    $new_bookings[] = $booking;
+                }
+                // Multi-day booking
+                else
+                {
+                    $start = clone max($from, $t0);
+                    $end = clone min($to, $t1);
+                    $date = clone $start;
+                    do
+                    {
+                        $new_booking = $booking;
+                        $new_booking['date'] = $date->format('Y-m-d');
+                        $new_booking['wday']  = date_format($date, 'D');
+                        $new_booking['from_'] = '00:00';
+                        $new_booking['to_'] = '00:00';
+                        if($new_booking['date'] == $from->format('Y-m-d'))
+                        {
+                            $new_booking['from_'] = $from->format('H:i');
+                        }
+                        else if($new_booking['date'] == $to->format('Y-m-d'))
+                        {
+                            $new_booking['to_'] = $to->format('H:i');
+                        }
+                        // We need to use 24:00 instead of 00:00 to sort 
correctly
+                        $new_booking['to_'] = $new_booking['to_'] == '00:00' ? 
'24:00' : $new_booking['to_'];
+                        $new_bookings[] = $new_booking;
 
-                                               $date->modify('+1 day');
-                                       }
-                                       while(true);
-                               }
-                       }
-                       return $new_bookings;
-               }
+                        if($date->format('Y-m-d') == $end->format('Y-m-d'))
+                        {
+                            break;
+                        }
 
-               function _remove_event_conflicts($bookings, &$events)
-               {
-                       foreach($events as &$e)
-                       {
-                               $e['conflicts'] = array();
-                       }
-                       $new_bookings = array();
-                       foreach($bookings as $b)
-                       {
-                               $keep = true;
-                               foreach($events as &$e)
-                               {
-                                       if((($b['from_'] >= $e['from_'] && 
$b['from_'] < $e['to_']) || 
-                                          ($b['to_'] > $e['from_'] && 
$b['to_'] <= $e['to_']) || 
-                                          ($b['from_'] <= $e['from_'] && 
$b['to_'] >= $e['to_'])) && (array_intersect($b['resources'], $e['resources']) 
!= array()))
-                                       {
-                                               $keep = false;
-                                               $e['conflicts'][] = $b;
-                                               break;
-                                       }
-                               }
-                               if($keep)
-                               {
-                                       $new_bookings[] = $b;
-                               }
-                       }
-                       return $new_bookings;
-               }
-               
+                        //             if($date->getTimestamp() > 
$end->getTimestamp()) // > php 5.3.0
+                        if($date->format("U") > $end->format("U"))
+                        {
+                            throw new InvalidArgumentException('start time( ' 
. $date->format('Y-m-d') . ' ) later than end time( ' . $end->format('Y-m-d') . 
" ) for {$booking['type']}#{$booking['id']}::{$booking['name']}");
+                        }
+
+                        $date->modify('+1 day');
+                    }
+                    while(true);
+                }
+            }
+            return $new_bookings;
+        }
+
+        function _remove_event_conflicts($bookings, &$events)
+        {
+            foreach($events as &$e)
+            {
+                $e['conflicts'] = array();
+            }
+            $new_bookings = array();
+            $last = array();
+            foreach($bookings as $b)
+            {
+                if ($last) {
+                    foreach ($last as $l) {
+//                        echo $l['id']."-".$l['from_']."-".$l['to_']."\n";
+                        $new_bookings[] = $l;
+                    }
+                    $last = array();
+                }
+                $keep = true;
+//                $i = 0;
+                foreach($events as &$e)
+                {
+
+//                    echo $b['id']."\tfrom: ".substr($b['from_'],11,19)." to: 
".substr($b['to_'],11,19)."\n";
+//                    echo $e['id']."\tfrom: ".substr($e['from_'],11,19)." to: 
".substr($e['to_'],11,19)." ".$e['name']."\n";
+
+                    if((($b['from_'] >= $e['from_'] && $b['from_'] < 
$e['to_']) ||
+                            ($b['to_'] > $e['from_'] && $b['to_'] <= 
$e['to_']) ||
+                            ($b['from_'] <= $e['from_'] && $b['to_'] >= 
$e['to_'])) && (array_intersect($b['resources'], $e['resources']) != array()))
+                    {
+//                        echo "##$i\n";
+                        $keep = false;
+                        $e['conflicts'][] = $b;
+
+                        $bf = $b['from_'];
+                        $bt = $b['to_'];
+                        $ef = $e['from_'];
+                        $et = $e['to_'];
+                        $tmp = $b;
+
+                        if ($last) {
+                            $ilast = $last;
+                            $last = array();
+                            foreach ($ilast as $l) {
+                                $lf = $l['from_'];
+                                $lt = $l['to_'];
+                                $tmp = $l;
+                                if ($ef <= $lf && $et >= $lt) {
+//                                    echo "B0: break ef <= bf && et >= 
bt\n\n";
+                                    $last[] = $l;
+                                    break;
+                                } elseif (($ef >= $lf) && ($et > $lt)) {
+//                                    echo "B1: (ef >= lf) && (et > lt)\n";
+                                    $tmp['from_'] = $lf;
+                                    $tmp['to_'] = $ef;
+                                    $last[] = $tmp;
+                                } elseif (($ef <= $lf) && ($et < $lt)) {
+//                                    echo "B2: (ef <= lf) && (et < lt)\n";
+                                    $tmp['from_'] = $et;
+                                    $tmp['to_'] = $lt;
+                                    $last[] = $tmp;
+                                } elseif (($ef > $lf) && ($et < $lt)) {
+//                                    echo "B3: (ef > lf) && (et < lt)\n";
+                                    $tmp['from_'] = $lf;
+                                    $tmp['to_'] = $ef;
+                                    $last[] = $tmp;
+                                    $tmp['from_'] = $et;
+                                    $tmp['to_'] = $lt;
+                                    $last[] = $tmp;
+                                } else {
+//                                    echo "B4: else break\n\n";
+                                    $last[] = $l;
+                                    break;
+                                }
+                            }
+                        } else {
+                            if ($ef <= $bf && $et >= $bt) {
+//                                echo "A0: break ef <= bf && et >= bt\n\n";
+                                break;
+                            } elseif (($ef >= $bf) && ($et > $bt)) {
+//                                echo "A1: (ef >= bf) && (et > bt)\n";
+                                $tmp['from_'] = $bf;
+                                $tmp['to_'] = $ef;
+                                $last[] = $tmp;
+                            } elseif (($ef <= $bf) && ($et < $bt)) {
+//                                echo "A2: (ef <= bf) && (et < bt)\n";
+                                $tmp['from_'] = $et;
+                                $tmp['to_'] = $bt;
+                                $last[] = $tmp;
+                            } elseif (($ef > $bf) && ($et < $bt)) {
+//                                echo "A3: (ef > bf) && (et < bt)\n";
+                                $tmp['from_'] = $bf;
+                                $tmp['to_'] = $ef;
+                                $last[] = $tmp;
+                                $tmp['from_'] = $et;
+                                $tmp['to_'] = $bt;
+                                $last[] = $tmp;
+                            } else {
+//                                echo "A4: else break\n\n";
+                                break;
+                            }
+                        }
+//                        print_r($last);
+                    }
+//                    $i+=1;
+                }
+
+                if($last)
+                {
+                    foreach ($last as $l) {
+//                        echo $l['id']."-".$l['from_']."-".$l['to_']."\n";
+                        $new_bookings[] = $l;
+                    }
+                    $last = array();
+                }
+
+                if($keep)
+                {
+                    $new_bookings[] = $b;
+                }
+            }
+//            print_r($new_bookings);
+            return $new_bookings;
+//            exit;
+        }
+
+      function _remove_event_conflicts_org($bookings, &$events)
+      {
+          foreach($events as &$e)
+          {
+              $e['conflicts'] = array();
+          }
+          $new_bookings = array();
+          foreach($bookings as $b)
+          {
+              $keep = true;
+              foreach($events as &$e)
+              {
+                  if((($b['from_'] >= $e['from_'] && $b['from_'] < $e['to_']) 
||
+                          ($b['to_'] > $e['from_'] && $b['to_'] <= $e['to_']) 
||
+                          ($b['from_'] <= $e['from_'] && $b['to_'] >= 
$e['to_'])) && (array_intersect($b['resources'], $e['resources']) != array()))
+                  {
+                      $keep = false;
+                      $e['conflicts'][] = $b;
+                      break;
+                  }
+              }
+              if($keep)
+              {
+                  $new_bookings[] = $b;
+              }
+          }
+          return $new_bookings;
+      }
+
                public function complete_expired(&$bookings) {
                        $this->so->complete_expired($bookings);
                }

Modified: branches/dev-syncromind/booking/inc/class.bocommon.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.bocommon.inc.php  2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.bocommon.inc.php  2015-04-09 
13:36:49 UTC (rev 12975)
@@ -71,7 +71,9 @@
                        }
                        
                        if(!isset($_SESSION['showall'])) {
-                               $filters['active'] = "1";
+                               if(!isset($filters['application_id'])) {
+                                       $filters['active'] = "1";
+                               }
                        }
                        
                        return array(

Modified: branches/dev-syncromind/booking/inc/class.bodocument_view.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.bodocument_view.inc.php   
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.bodocument_view.inc.php   
2015-04-09 13:36:49 UTC (rev 12975)
@@ -12,11 +12,10 @@
                public function read_regulations() {
                        $params = $this->build_default_read_params();
                        !isset($params['filters']) AND $params['filters'] = 
array();
-                       
-                       $params['filters']['category'] = 
array(booking_sodocument::CATEGORY_REGULATION, 
booking_sodocument::CATEGORY_HMS_DOCUMENT);
-                       
+                       $params['filters']['category'] = 
array(booking_sodocument::CATEGORY_REGULATION,
+                booking_sodocument::CATEGORY_HMS_DOCUMENT,
+                booking_sodocument::CATEGORY_PRICE_LIST);
                        $where_filter = array();
-                       
                        if ($owner_filters = phpgw::get_var('owner', 'string')) 
{
                                foreach($owner_filters as $filter) {
                                        list($owner_type, $owner_id) = 
explode('::', $filter);
@@ -25,9 +24,7 @@
                                        $where_filter[] = 
"(%%table%%.type=$owner_type AND %%table%%.owner_id = $owner_id)";
                                }
                        }
-                       
                        $params['filters']['where'] = 
array('('.join($where_filter, ' OR ').')');
-                       
                        return $this->so->read($params);
                }
        }
\ No newline at end of file

Modified: branches/dev-syncromind/booking/inc/class.boevent.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boevent.inc.php   2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.boevent.inc.php   2015-04-09 
13:36:49 UTC (rev 12975)
@@ -1,19 +1,233 @@
 <?php
-       phpgw::import_class('booking.bocommon');
-       
-       class booking_boevent extends booking_bocommon
-       {
-               function __construct()
-               {
-                       parent::__construct();
-                       $this->so = CreateObject('booking.soevent');
-               }
-               
-               public function complete_expired(&$events) {
-                       $this->so->complete_expired($events);
-               }
-               
-               public function find_expired() {
-                       return $this->so->find_expired();
-               }
-       }
+phpgw::import_class('booking.bocommon_authorized');
+
+class booking_boevent extends booking_bocommon_authorized
+{
+    const ROLE_ADMIN = 'organization_admin';
+
+    function __construct()
+    {
+        parent::__construct();
+        $this->so = CreateObject('booking.soevent');
+    }
+    /**
+     * @see booking_bocommon_authorized
+     */
+    protected function get_subject_roles($for_object = null, 
$initial_roles=array())
+    {
+        if ($this->current_app() == 'bookingfrontend') {
+            $bouser = CreateObject('bookingfrontend.bouser');
+
+            if (is_array($for_object) && 
$for_object['customer_organization_number']) {
+                $org = 
$this->so->get_org($for_object['customer_organization_number']);
+                $for_object['customer_organization_id'] = $org['id'];
+                $for_object['customer_organization_name'] = $org['name'];
+            }
+
+            $org_id = is_array($for_object) ? 
$for_object['customer_organization_id'] : (!is_null($for_object) ? $for_object 
: null);
+
+            if ($bouser->is_organization_admin($org_id)) {
+                $initial_roles[] = array('role' => self::ROLE_ADMIN);
+            }
+        }
+        return parent::get_subject_roles($for_object, $initial_roles);
+    }
+
+    /**
+     * @see bocommon_authorized
+     */
+    protected function get_object_role_permissions(array $forObject, 
$defaultPermissions)
+    {
+        if ($this->current_app() == 'booking') {
+            $defaultPermissions[booking_sopermission::ROLE_DEFAULT] = array
+            (
+                'read'                 => true,
+                'delete'       => true,
+                'write'        => true,
+                'create'       => true,
+            );
+        }
+
+        if ($this->current_app() == 'bookingfrontend') {
+            $defaultPermissions[self::ROLE_ADMIN] = array
+            (
+                'write' => 
array_fill_keys(array('active','description','from_','to_','contact_name','contact_email',
+                    
'contact_phone','activity_name','audience','agegroups','is_public'), true),
+            );
+        }
+
+        return $defaultPermissions;
+    }
+
+    /**
+     * @see bocommon_authorized
+     */
+    protected function get_collection_role_permissions($defaultPermissions)
+    {
+        if ($this->current_app() == 'booking')
+        {
+            $defaultPermissions[booking_sopermission::ROLE_DEFAULT]['create'] 
= true;
+            $defaultPermissions[booking_sopermission::ROLE_DEFAULT]['write'] = 
true;
+        }
+
+        return $defaultPermissions;
+    }
+
+    public function get_permissions(array $entity)
+    {
+        return parent::get_permissions($entity);
+    }
+
+    public function complete_expired(&$events) {
+        $this->so->complete_expired($events);
+    }
+
+    public function find_expired() {
+        return $this->so->find_expired();
+    }
+
+    /**
+     * @ Send message about cancelation/modification on event to users of 
building.
+     */
+    function send_notification($type, $event, $mailadresses, $orgdate = null)
+    {
+        if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server']))
+            return;
+        $send = CreateObject('phpgwapi.send');
+
+        $config        = CreateObject('phpgwapi.config','booking');
+        $config->read();
+
+        $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+        $external_site_address = 
isset($config->config_data['external_site_address']) && 
$config->config_data['external_site_address'] ? 
$config->config_data['external_site_address'] : 
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+//        $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uiapplication.add&building_id=';
+//        $link .= 
$event['building_id'].'&building_name='.urlencode($event['building_name']).'&from_[]=';
+//        $link .= 
urlencode($event['from_']).'&to_[]='.urlencode($event['to_']).'&resource='.implode(",",$event['resources']);
+
+        $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uibuilding.schedule&id=';
+        $link .= $event['building_id'].'&date='.substr($event['from_'], 0, 10);
+        $body = "";
+        $subject = "";
+        if (!$type) {
+            $subject .= $config->config_data['event_canceled_mail_subject'];
+            $body .= "<p>".$config->config_data['event_canceled_mail'];
+        } else {
+            $subject .= $config->config_data['event_edited_mail_subject'];
+            $body .= "<p>".$config->config_data['event_edited_mail'];
+        }
+
+        if ($_POST['org_from'] < $event['from_'] && $_POST['org_to'] == 
$event['to_']) {
+            $event['from_'] = $_POST['org_from'];
+            $event['to_'] = $event['from_'];
+            $freetime = pretty_timestamp($event['from_']).' til 
'.pretty_timestamp($event['to_']);
+        }
+        elseif ($_POST['org_from'] == $event['from_'] && $_POST['org_to'] > 
$event['to_']) {
+            $event['from_'] = $event['to_'];
+            $event['to_'] = $_POST['org_to'];
+            $freetime = pretty_timestamp($event['from_']).' til 
'.pretty_timestamp($event['to_']);
+        }
+        elseif ($_POST['org_from'] < $event['from_'] && $_POST['org_to'] > 
$event['to_']) {
+            $freetime = pretty_timestamp($_POST['org_from']).' til 
'.pretty_timestamp($event['from_'])." og \n";
+            $freetime .= pretty_timestamp($event['to_']).' til 
'.pretty_timestamp($_POST['org_to']);
+        } else {
+            $freetime = pretty_timestamp($event['from_']).' til 
'.pretty_timestamp($event['to_'])."\n";
+        }
+
+        $body .= '</p><p>'.$event['customer_organization_name'].' har 
avbestilt tid i '.$event['building_name'].':<br />';
+        $body .= implode(", 
",$this->so->get_resources(implode(",",$event['resources']))).' den '.$freetime;
+        $body .= ' - <a href="'.$link.'">'.lang('Check calendar').'</a></p>';
+        $body .= 
"<p>".$config->config_data['application_mail_signature']."</p>";
+
+        foreach ($mailadresses as $adr)
+        {
+            try
+            {
+                $send->msg('email', $adr, $subject, $body, '', '', '', $from, 
'', 'html');
+            }
+            catch (phpmailerException $e)
+            {
+                // TODO: Inform user if something goes wrong
+            }
+        }
+    }
+
+    /**
+     * @ Send message about cancelation/modification on event to admins of 
building.
+     */
+    function send_admin_notification($type, $event, $message = null, $orgdate 
= null)
+    {
+        if (!(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server']))
+            return;
+        $send = CreateObject('phpgwapi.send');
+
+        $config        = CreateObject('phpgwapi.config','booking');
+        $config->read();
+
+        $from = isset($config->config_data['email_sender']) && 
$config->config_data['email_sender'] ? $config->config_data['email_sender'] : 
"noreply<address@hidden'phpgw_info']['server']['hostname']}>";
+
+        $external_site_address = 
isset($config->config_data['external_site_address']) && 
$config->config_data['external_site_address'] ? 
$config->config_data['external_site_address'] : 
$GLOBALS['phpgw_info']['server']['webserver_url'];
+
+        if (!$type) {
+            $subject = $config->config_data['event_canceled_mail_subject'];
+        } else {
+            $subject = $config->config_data['event_edited_mail_subject'];
+        }
+
+        $body = '<b>Beksjed fra 
'.$event['customer_organization_name'].'</b><br />'.$message.'<br /><br/>';
+        $body .= '<b>Kontaktperson:</b> '.$event['contact_name'].'<br />';
+        $body .= '<b>Epost:</b> '.$event['contact_email'].'<br />';
+        $body .= '<b>Telefon:</b> '.$event['contact_phone'].'<br /><br />';
+        $body .= '<br /><b>Epost som er sendt til brukere av Hallen:</b><br 
/>';
+
+        $mailadresses = $config->config_data['emails'];
+        $mailadresses = explode("\n",$mailadresses);
+
+        $link = 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.uibuilding.schedule&id=';
+        $link .= $event['building_id'].'&date='.substr($event['from_'], 0, 10);
+
+        if (!$type) {
+            $body .= $config->config_data['event_canceled_mail_subject'];
+            $body .= "<p>".$config->config_data['event_canceled_mail'];
+        } else {
+            $body .= $config->config_data['event_edited_mail_subject'];
+            $body .= "<p>".$config->config_data['event_edited_mail'];
+        }
+
+        if ($_POST['org_from'] < $event['from_'] && $_POST['org_to'] == 
$event['to_']) {
+            $event['from_'] = $_POST['org_from'];
+            $event['to_'] = $event['from_'];
+            $freetime = pretty_timestamp($event['from_']).' til 
'.pretty_timestamp($event['to_']);
+        }
+        elseif ($_POST['org_from'] == $event['from_'] && $_POST['org_to'] > 
$event['to_']) {
+            $event['from_'] = $event['to_'];
+            $event['to_'] = $_POST['org_to'];
+            $freetime = pretty_timestamp($event['from_']).' til 
'.pretty_timestamp($event['to_']);
+        }
+        elseif ($_POST['org_from'] < $event['from_'] && $_POST['org_to'] > 
$event['to_']) {
+            $freetime = pretty_timestamp($_POST['org_from']).' til 
'.pretty_timestamp($event['from_'])." og \n";
+            $freetime .= pretty_timestamp($event['to_']).' til 
'.pretty_timestamp($_POST['org_to']);
+        } else {
+            $freetime = pretty_timestamp($event['from_']).' til 
'.pretty_timestamp($event['to_'])."\n";
+        }
+
+        $body .= '</p><p>'.$event['customer_organization_name'].' har 
avbestilt tid i '.$event['building_name'].':<br />';
+        $body .= implode(", 
",$this->so->get_resources(implode(",",$event['resources']))).' den '.$freetime;
+        $body .= ' - <a href="'.$link.'">'.lang('Check calendar').'</a></p>';
+        $body .= 
"<p>".$config->config_data['application_mail_signature']."</p>";
+
+        foreach ($mailadresses as $adr)
+        {
+            try
+            {
+                $send->msg('email', $adr, $subject, $body, '', '', '', $from, 
'', 'html');
+            }
+            catch (phpmailerException $e)
+            {
+                // TODO: Inform user if something goes wrong
+            }
+        }
+    }
+
+}
\ No newline at end of file

Modified: branches/dev-syncromind/booking/inc/class.boorganization.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boorganization.inc.php    
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.boorganization.inc.php    
2015-04-09 13:36:49 UTC (rev 12975)
@@ -51,7 +51,7 @@
                        if ($this->current_app() == 'bookingfrontend') {        
             
                                $defaultPermissions[self::ROLE_ADMIN] = array
                                (
-                                       'write' => 
array_fill_keys(array('name','homepage','phone','email','description','street','zip_code','district','city','active','organization_number'),
 true),
+                                       'write' => 
array_fill_keys(array('name','homepage','phone','email','description','street','zip_code','district','city','active','organization_number','contacts'),
 true),
                                );
                        }
                        
@@ -103,8 +103,8 @@
                /**
                 * @see soorganization
                 */
-               function find_building_users($building_id)
+               function find_building_users($building_id, $split = false, 
$activities = array())
                {
-                       return $this->so->find_building_users($building_id, 
$this->build_default_read_params());
+                       return $this->so->find_building_users($building_id, 
$this->build_default_read_params(), $split, $activities);
                }
        }

Modified: branches/dev-syncromind/booking/inc/class.customer_identifier.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.customer_identifier.inc.php       
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.customer_identifier.inc.php       
2015-04-09 13:36:49 UTC (rev 12975)
@@ -177,16 +177,16 @@
                                Event.addListener(select_input, 'change', 
function(e) {
                                        
enableCustField(this[this.selectedIndex].value);
                                });
-                               
+
                                // Wouldn't work in IE6:
                                // Dom.batch(items, function(opt) {
-                               //      Event.addListener(opt, 'click', 
function(e) { 
+                               //      Event.addListener(opt, 'click', 
function(e) {
                                //              enableCustField(this.value);
                                //      })
                                // });
                        })();
 JST;
-                       
+
                        if (is_array($entity)) {
                                $this->add_current_identifier_info($entity);
                        }

Modified: branches/dev-syncromind/booking/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.menu.inc.php      2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.menu.inc.php      2015-04-09 
13:36:49 UTC (rev 12975)
@@ -212,7 +212,13 @@
                             'text'  => lang('Free time'),
                             'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'booking.uireports.freetime') ),
                                                        'image' => 
array('property', 'report'),
-                        )
+                        ),
+#                        'free_time2' => array
+#                        (
+#                            'text'  => lang('Free time2'),
+#                            'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'booking.uireports.freetime2') ),
+#                                                      'image' => 
array('property', 'report'),
+#                        )
                     )       
                 ),      
                        );
@@ -265,6 +271,21 @@
                                                                'text'  => 
lang('Documentation'),
                                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'booking.uidocumentation.index', 'appname' => 'booking') )
                                                        ),
+                                                       'mail_settings' => array
+                                                       (
+                                                               'text'  => 
lang('Mail Settings'),
+                                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'booking.uimail_settings.index', 'appname' => 'booking') )
+                                                       ),
+                                                       'event_mail_settings'   
=> array
+                                                       (
+                                                               'text'  => 
lang('Event Mail Settings'),
+                                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'booking.uievent_mail_settings.index', 'appname' => 'booking') )
+                                                       ),
+                                                       'application_settings'  
=> array
+                                                       (
+                                                               'text'  => 
lang('Application Settings'),
+                                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'booking.uiapplication_settings.index', 'appname' => 'booking') )
+                                                       ),
                                                        'office'        => array
                                                        (
                                                                'text'  => 
lang('office'),

Modified: branches/dev-syncromind/booking/inc/class.soallocation.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.soallocation.inc.php      
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.soallocation.inc.php      
2015-04-09 13:36:49 UTC (rev 12975)
@@ -239,7 +239,7 @@
             $season_id = $allocation['season_id'];
             $resources = implode(",", $allocation['resources']);
 
-            $sql = "SELECT id FROM bb_allocation ba2 WHERE ba2.from_ = ($from) 
AND ba2.to_ = ($to) AND ba2.organization_id = ($org_id) AND ba2.season_id = 
($season_id) AND EXISTS ( SELECT 1 FROM bb_allocation  a,bb_allocation_resource 
b WHERE a.id = b.allocation_id AND b.resource_id IN ($resources))";
+            $sql = "SELECT id FROM bb_allocation ba2 JOIN 
bb_allocation_resource bar2 ON (ba2.id = bar2.allocation_id) WHERE ba2.from_ = 
($from) AND ba2.to_ = ($to) AND ba2.organization_id = ($org_id) AND 
ba2.season_id = ($season_id) AND  bar2.resource_id IN ($resources)";
 
                        $this->db->limit_query($sql, 0,__LINE__, __FILE__,1);
                        if(!$this->db->next_record())
@@ -271,6 +271,7 @@
                        $table_name = $this->table_name;
                        $sql = "DELETE FROM $table_name WHERE id = ($id)";
                        $db->query($sql, __LINE__, __FILE__);
+                       return True;
                }
 
                public function update_id_string() 

Modified: branches/dev-syncromind/booking/inc/class.soapplication.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.soapplication.inc.php     
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.soapplication.inc.php     
2015-04-09 13:36:49 UTC (rev 12975)
@@ -40,6 +40,7 @@
                                                        'column'        => 
'name'
                                        )),
                                        'description'   => array('type' => 
'string', 'query' => true, 'required' => true),
+                    'equipment'        => array('type' => 'string', 'query' => 
true, 'required' => false),
                                        'contact_name'  => array('type' => 
'string', 'query' => true, 'required'=> true),
                                        'contact_email' => array('type' => 
'string', 'required'=> true, 'sf_validator' => 
createObject('booking.sfValidatorEmail', array(), array('invalid' => '%field% 
is invalid'))),
                                        'contact_phone' => array('type' => 
'string'),
@@ -116,6 +117,74 @@
                                                 'name' => $this->db->f('name', 
false));
                }
 
+               function get_accepted($id)
+               {
+                       $sql = "SELECT bad.from_, bad.to_
+                                       FROM bb_application ba, 
bb_application_date bad, bb_event be
+                                       WHERE ba.id=($id)
+                                       AND ba.id=bad.application_id
+                                       AND ba.id=be.application_id
+                                       AND be.from_=bad.from_
+                                       AND be.to_=bad.to_";
+                       $results = array();             
+                       $this->db->query($sql,__LINE__, __FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $results[] = array('from_' => 
$this->db->f('from_', false),
+                                                          'to_' => 
$this->db->f('to_', false));
+                       }
+                       return $results;
+               }
+
+               function get_rejected($id)
+               {
+                       $sql = "SELECT bad.from_, bad.to_ FROM bb_application 
ba, bb_application_date bad 
+                                       WHERE ba.id=($id)
+                                       AND ba.id=bad.application_id
+                                       AND bad.id NOT IN (SELECT bad.id
+                                       FROM bb_application ba, 
bb_application_date bad, bb_event be
+                                       WHERE ba.id=($id) 
+                                       AND ba.id=bad.application_id
+                                       AND ba.id=be.application_id
+                                       AND be.from_=bad.from_
+                                       AND be.to_=bad.to_)";
+                       $results = array();             
+                       $this->db->query($sql,__LINE__, __FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $results[] = array('from_' => 
$this->db->f('from_', false),
+                                                          'to_' => 
$this->db->f('to_', false));
+                       }
+                       return $results;
+               }
+
+               function get_tilsyn_email($id)
+               {
+                       $sql = "SELECT tilsyn_email, tilsyn_email2, email FROM 
bb_building where id=(select id from bb_building where name = '$id' AND active 
= 1)";
+                       $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
+                       if(!$this->db->next_record())
+                       {
+                               return False;
+                       }
+                       return array('email1' => $this->db->f('tilsyn_email', 
false),
+                                                'email2' => 
$this->db->f('tilsyn_email2', false),
+                         'email3' => $this->db->f('email', false));
+
+               }
+
+               function get_resource_name($id)
+               {
+                       $list = implode(",",$id);
+                       $results = array();             
+                       $this->db->query("SELECT name FROM bb_resource where id 
IN ($list)",__LINE__, __FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $results[] = $this->db->f('name', false);
+                       }
+                       return $results;
+
+               }
+               
                function get_building($id)
                {
                        $this->db->limit_query("SELECT name FROM bb_building 
where id=" . intval($id), 0, __LINE__, __FILE__, 1);
@@ -139,6 +208,38 @@
                        return $results;
                }
 
+               function set_inactive($id,$type)
+               {
+                       if ($type == 'event') {
+                               $sql = "UPDATE bb_event SET active = 0 where id 
= ($id)";
+               } elseif ($type == 'allocation') {
+                               $sql = "UPDATE bb_allocation SET active = 0 
where id = ($id)";
+                       } elseif ($type == 'booking') {
+                               $sql = "UPDATE bb_booking SET active = 0 where 
id = ($id)";
+                       } else {
+                               throw new UnexpectedValueException('Encountered 
an unexpected error');
+                       }
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       return;
+
+               }
+
+               function set_active($id,$type)
+               {
+                       if ($type == 'event') {
+                               $sql = "UPDATE bb_event SET active = 1 where id 
= ($id)";
+               } elseif ($type == 'allocation') {
+                               $sql = "UPDATE bb_allocation SET active = 1 
where id = ($id)";
+                       } elseif ($type == 'booking') {
+                               $sql = "UPDATE bb_booking SET active = 1 where 
id = ($id)";
+                       } else {
+                               throw new UnexpectedValueException('Encountered 
an unexpected error');
+                       }
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       return;
+
+               }
+
         function get_activities_main_level()
         {
                    $results = array();
@@ -169,10 +270,37 @@
                        $sql = "UPDATE $table_name SET id_string = cast(id AS 
varchar)";
                        $db->query($sql, __LINE__, __FILE__);
                }
-             
 
+        function check_collision($resources, $from_, $to_)
+        {
+            $rids = join(',', array_map("intval", $resources));
+            $sql  =  "SELECT ba.id
+                      FROM bb_allocation ba, bb_allocation_resource bar
+                      WHERE ba.id = bar.allocation_id
+                      AND bar.resource_id in ($rids)
+                      AND ((ba.from_ < '$from_' AND ba.to_ > '$from_')
+                      OR (ba.from_ >= '$from_' AND ba.to_ <= '$to_')
+                      OR (ba.from_ < '$to_' AND ba.to_ > '$to_'))
+                      UNION
+                      SELECT be.id
+                      FROM bb_event be, bb_event_resource ber, bb_event_date 
bed
+                      WHERE be.id = ber.event_id
+                      AND be.id = bed.event_id
+                      AND ber.resource_id in ($rids)
+                      AND ((bed.from_ < '$from_' AND bed.to_ > '$from_')
+                      OR (bed.from_ >= '$from_' AND bed.to_ <= '$to_')
+                      OR (bed.from_ < '$to_' AND bed.to_ > '$to_'))";
 
-               
+            $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
+
+            if(!$this->db->next_record())
+            {
+                return False;
+            }
+            return True;
+
+        }
+
                /**
                 * Check if a given timespan is available for bookings or 
allocations
                 *
@@ -186,7 +314,7 @@
                {
                        $rids = join(',', array_map("intval", $resources));
                        $nrids = count($resources);
-                       $this->db->query("SELECT id FROM bb_season 
+                       $this->db->query("SELECT id FROM bb_season
                                          WHERE id IN (SELECT season_id 
                                                                       FROM 
bb_season_resource 
                                                                       WHERE 
resource_id IN ($rids,-1) 
@@ -213,7 +341,8 @@
                                        'id'                                    
=> array('type' => 'int'),
                                        'application_id'                => 
array('type' => 'int'),
                                        'type'  => array('type' => 'string', 
'required' => true),
-                                       'from_' => array('type' => 'timestamp'),
-                                       'to_'   => array('type' => 
'timestamp')));
+                                       'from_' => array('type' => 
'timestamp','query' => true),
+                                       'to_'   => array('type' => 'timestamp'),
+                                       'active' => array('type' => 'int')));
                }
        }

Modified: branches/dev-syncromind/booking/inc/class.sobooking.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.sobooking.inc.php 2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.sobooking.inc.php 2015-04-09 
13:36:49 UTC (rev 12975)
@@ -255,7 +255,7 @@
                        $end = $end->format('Y-m-d H:i');
                        $building_id = intval($building_id);
                        $results = array();
-                       $this->db->query("SELECT bb_allocation.id AS id FROM 
bb_allocation JOIN bb_season ON (bb_allocation.season_id=bb_season.id AND 
bb_allocation.active=1) WHERE bb_season.building_id=$building_id AND 
((bb_allocation.from_ >= '$start' AND bb_allocation.from_ < '$end') OR 
(bb_allocation.to_ > '$start' AND bb_allocation.to_ <= '$end') OR 
(bb_allocation.from_ < '$start' AND bb_allocation.to_ > '$end'))", __LINE__, 
__FILE__);
+                       $this->db->query("SELECT bb_allocation.id AS id FROM 
bb_allocation JOIN bb_season ON (bb_allocation.season_id=bb_season.id AND 
bb_allocation.active=1) WHERE bb_season.building_id=$building_id AND 
bb_season.active=1 AND bb_season.status='PUBLISHED' AND ((bb_allocation.from_ 
>= '$start' AND bb_allocation.from_ < '$end') OR (bb_allocation.to_ > '$start' 
AND bb_allocation.to_ <= '$end') OR (bb_allocation.from_ < '$start' AND 
bb_allocation.to_ > '$end'))", __LINE__, __FILE__);
                        while ($this->db->next_record())
                        {
                                $results[] = 
$this->_unmarshal($this->db->f('id', false), 'int');
@@ -269,7 +269,7 @@
                        $end = $end->format('Y-m-d H:i');
                        $building_id = intval($building_id);
                        $results = array();
-                       $this->db->query("SELECT bb_booking.id AS id FROM 
bb_booking JOIN bb_season ON (bb_booking.season_id=bb_season.id AND 
bb_booking.active=1) WHERE bb_season.building_id=$building_id AND 
((bb_booking.from_ >= '$start' AND bb_booking.from_ < '$end') OR 
(bb_booking.to_ > '$start' AND bb_booking.to_ <= '$end') OR (bb_booking.from_ < 
'$start' AND bb_booking.to_ > '$end'))", __LINE__, __FILE__);
+                       $this->db->query("SELECT bb_booking.id AS id FROM 
bb_booking JOIN bb_season ON (bb_booking.season_id=bb_season.id AND 
bb_booking.active=1) WHERE bb_season.building_id=$building_id AND 
bb_season.active=1 AND bb_season.status='PUBLISHED' AND ((bb_booking.from_ >= 
'$start' AND bb_booking.from_ < '$end') OR (bb_booking.to_ > '$start' AND 
bb_booking.to_ <= '$end') OR (bb_booking.from_ < '$start' AND bb_booking.to_ > 
'$end'))", __LINE__, __FILE__);
                        while ($this->db->next_record())
                        {
                                $results[] = 
$this->_unmarshal($this->db->f('id', false), 'int');
@@ -297,7 +297,7 @@
                        $end = $end->format('Y-m-d H:i');
                        $resource_id = intval($resource_id);
                        $results = array();
-                       $this->db->query("SELECT id FROM bb_allocation JOIN 
bb_allocation_resource ON (allocation_id=id AND resource_id=$resource_id) WHERE 
active=1 AND ((from_ >= '$start' AND from_ < '$end') OR (to_ > '$start' AND to_ 
<= '$end') OR (from_ < '$start' AND to_ > '$end'))", __LINE__, __FILE__);
+                       $this->db->query("SELECT bb_allocation.id AS id FROM 
bb_allocation JOIN bb_allocation_resource ON (allocation_id=id AND 
resource_id=$resource_id) JOIN bb_resource as res ON ( res.id=$resource_id) 
JOIN bb_season ON (bb_allocation.season_id=bb_season.id AND 
bb_allocation.active=1) WHERE bb_season.building_id=res.building_id AND 
bb_season.active=1 AND bb_season.status='PUBLISHED' AND ((bb_allocation.from_ 
>= '$start'AND bb_allocation.from_ < '$end') OR (bb_allocation.to_ > '$start' 
AND bb_allocation.to_ <= '$end') OR (bb_allocation.from_ < '$start' AND 
bb_allocation.to_ > '$end'))", __LINE__, __FILE__);
                        while ($this->db->next_record())
                        {
                                $results[] = 
$this->_unmarshal($this->db->f('id', false), 'int');
@@ -311,7 +311,7 @@
                        $end = $end->format('Y-m-d H:i');
                        $resource_id = intval($resource_id);
                        $results = array();
-                       $this->db->query("SELECT id FROM bb_booking JOIN 
bb_booking_resource ON (booking_id=id AND resource_id=$resource_id) WHERE 
active=1 AND ((from_ >= '$start' AND from_ < '$end') OR (to_ > '$start' AND to_ 
<= '$end') OR (from_ < '$start' AND to_ > '$end'))", __LINE__, __FILE__);
+                       $this->db->query("SELECT bb_booking.id AS id FROM 
bb_booking JOIN bb_booking_resource ON (booking_id=id AND 
resource_id=$resource_id) JOIN bb_resource as res ON ( res.id=$resource_id) 
JOIN bb_season ON (bb_booking.season_id=bb_season.id AND bb_booking.active=1) 
WHERE bb_season.building_id=res.building_id AND bb_season.active=1 AND 
bb_season.status='PUBLISHED' AND ((bb_booking.from_ >= '$start' AND 
bb_booking.from_ < '$end') OR (bb_booking.to_ > '$start' AND bb_booking.to_ <= 
'$end') OR (bb_booking.from_ < '$start' AND bb_booking.to_ > '$end'))", 
__LINE__, __FILE__);
                        while ($this->db->next_record())
                        {
                                $results[] = 
$this->_unmarshal($this->db->f('id', false), 'int');
@@ -336,9 +336,6 @@
                
                public function get_booking_id($booking)
         {
-                       $table_name = $this->table_name;
-                       $db = $this->db;
-
             $from = "'".$booking['from_']."'";
             $to = "'".$booking['to_']."'";
             $gid = $booking['group_id'];
@@ -357,9 +354,6 @@
 
         public function check_allocation($id)
         {
-                       $table_name = $this->table_name;
-                       $db = $this->db;
-
             $sql = "SELECT allocation_id as aid FROM bb_booking WHERE 
allocation_id = ( SELECT allocation_id FROM bb_booking WHERE id = ($id) ) GROUP 
BY allocation_id HAVING count(id) < 2";
 
                        $this->db->limit_query($sql, 0,__LINE__, __FILE__,1);
@@ -444,6 +438,16 @@
                        return $this->db->f('name', false);
                }
 
+               function get_groups_of_organization($grp_id)
+               {
+                       $this->db->limit_query("select organization_id from 
bb_group where id=($grp_id)", 0, __LINE__, __FILE__, 1);
+                       if(!$this->db->next_record())
+                       {
+                               return False;
+                       }
+                       return $this->db->f('organization_id', false);
+               }
+
                function get_resource($id)
                {
                        $this->db->limit_query("SELECT name FROM bb_resource 
where id=" . intval($id), 0, __LINE__, __FILE__, 1);
@@ -474,16 +478,32 @@
                        return $this->db->f('id', false);
                }
 
-               function get_group_of_organization($id)
+               public function get_group_contacts_of_organization($id)
                {
             $results = array();
-                       $this->db->query("SELECT id FROM bb_group WHERE active 
= 1 and organization_id=". intval($id), __LINE__, __FILE__);
+            $sql = "SELECT 
bb_group_contact.id,bb_group_contact.group_id,bb_group_contact.email FROM 
bb_group,bb_group_contact WHERE bb_group.id=bb_group_contact.group_id AND 
bb_group.active = 1 AND bb_group.organization_id=(".intval($id).")";
+                       $this->db->query($sql, __LINE__, __FILE__);
                        while ($this->db->next_record())
                        {
-                               $results[] = $this->db->f('id', false);
+                               $results[] = array('id' => $this->db->f('id', 
false),
+                                   'group_id' => $this->db->f('group_id', 
false),
+                                   'email' => $this->db->f('email', false));
                        }
                        return $results;
                }
+               public function get_all_group_of_organization_from_groupid($id)
+               {
+            $results = array();
+            $sql = "SELECT 
bb_group_contact.id,bb_group_contact.group_id,bb_group_contact.email FROM 
bb_group,bb_group_contact WHERE bb_group.id=bb_group_contact.group_id AND 
bb_group.active = 1 AND bb_group.organization_id=(select organization_id from 
bb_group where id=(".intval($id)."))";
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $results[] = array('id' => $this->db->f('id', 
false),
+                                   'group_id' => $this->db->f('group_id', 
false),
+                                   'email' => $this->db->f('email', false));
+                       }
+                       return $results;
+               }
 
                function get_organizations()
                {
@@ -537,4 +557,183 @@
                                }
                        }
                }
+
+
+        function get_screen_resources($building_id, $res = False){
+            $building_id = intval($building_id);
+            if (intval($res) == 1) {
+                $type =  "AND ba.name IN ('Idrett','Friidrett','Svømming')";
+            } elseif (intval($res) == 2){
+                $type =  "AND ba.name IN ('Barnehage','Styrkerom','Møterom')";
+            } else {
+                $type = '';
+            }
+            $results = array();
+            $sql = "SELECT br.id
+                    FROM bb_resource br, bb_activity ba
+                    WHERE ba.id = br.activity_id ".$type."
+                    AND br.building_id = ".$building_id."
+                    AND br.active = 1
+                    ORDER by br.sort";
+
+            $this->db->query($sql, __LINE__, __FILE__);
+            while ($this->db->next_record())
+            {
+                $results[] = $this->db->f('id', false);
+            }
+            return $results;
+        }
+
+        function get_screen_allocation($building_id, $start, $end, $resources 
= False)
+        {
+            $start = $start->format('Y-m-d H:i');
+            $end = $end->format('Y-m-d H:i');
+            $building_id = intval($building_id);
+            $results = array();
+            $sql = "SELECT
+                    bb_allocation.id AS id,
+                    bb_allocation.building_name AS building_name,
+                    bb_allocation.from_ AS from_,
+                    bb_allocation.to_ AS to_,
+                    bb_allocation.organization_id AS organization_id,
+                    bb_resource.id AS resource_id,
+                    bb_resource.name AS resource_name,
+                    bb_resource.sort AS sort,
+                    bb_resource.building_id AS building_id,
+                    bb_organization.name AS organization_name,
+                    bb_organization.shortname AS organization_shortname
+                    FROM bb_allocation
+                    INNER JOIN bb_allocation_resource ON (bb_allocation.id = 
bb_allocation_resource.allocation_id)
+                    INNER JOIN bb_resource ON  
(bb_allocation_resource.resource_id  = bb_resource.id)
+                    INNER JOIN bb_organization ON  (bb_organization.id  = 
bb_allocation.organization_id)
+                    WHERE bb_allocation.from_ > '".$start."' AND 
bb_allocation.to_ < '".$end."'
+                    AND bb_resource.building_id = (".$building_id.")
+                     ".$resources."
+                    AND bb_allocation.active = 1
+                    ORDER BY building_name, sort, from_;";
+            $this->db->query($sql, __LINE__, __FILE__);
+            while ($this->db->next_record())
+            {
+                $results[] = array(
+                                    'id' => $this->db->f('id', false),
+                                    'building_id' => 
$this->db->f('building_id', false),
+                                    'resource_id' => 
$this->db->f('resource_id', false),
+                                    'organization_id' => 
$this->db->f('organization_id', false),
+                                    'building_name' => 
$this->db->f('building_name', false),
+                                    'resource_name' => 
$this->db->f('resource_name', false),
+                                    'organization_name' => 
$this->db->f('organization_name', false),
+                                    'organization_shortname' => 
$this->db->f('organization_shortname', false),
+                                    'from_' => $this->db->f('from_', false),
+                                    'to_' => $this->db->f('to_', false),
+                                  );
+            }
+            return $results;
+        }
+
+        function get_screen_booking($building_id, $start, $end, $resources = 
False)
+        {
+            $start = $start->format('Y-m-d H:i');
+            $end = $end->format('Y-m-d H:i');
+            $building_id = intval($building_id);
+
+            $results = array();
+            $sql = "SELECT
+                    bb_booking.id AS id,
+                    bb_booking.allocation_id AS allocation_id,
+                    bb_booking.building_name as buidling_name,
+                    bb_booking.from_ AS from_,
+                    bb_booking.to_ AS to_,
+                    bb_booking.group_id AS group_id,
+                    bb_resource.id AS resource_id,
+                    bb_resource.name AS resource_name,
+                    bb_resource.sort AS sort,
+                    bb_resource.building_id AS building_id,
+                    bb_group.name AS group_name,
+                    bb_group.shortname AS group_shortname
+                    FROM bb_booking
+                    INNER JOIN bb_booking_resource ON 
(bb_booking_resource.booking_id = bb_booking.id)
+                    INNER JOIN bb_resource ON  
(bb_booking_resource.resource_id  = bb_resource.id)
+                    INNER JOIN bb_group ON (bb_group.id = bb_booking.group_id)
+                    WHERE bb_booking.from_ > '".$start."' AND bb_booking.to_ < 
'".$end."'
+                    AND bb_resource.building_id = (".$building_id.")
+                     ".$resources."
+                    AND bb_booking.active = 1
+                    ORDER BY building_name,sort, from_;";
+            $this->db->query($sql, __LINE__, __FILE__);
+            while ($this->db->next_record())
+            {
+                $results[] = array(
+                    'id' => $this->db->f('id', false),
+                    'building_id' => $this->db->f('building_id', false),
+                    'resource_id' => $this->db->f('resource_id', false),
+                    'group_id' => $this->db->f('group_id', false),
+                    'allocation_id' => $this->db->f('allocation_id', false),
+                    'building_name' => $this->db->f('building_name', false),
+                    'resource_name' => $this->db->f('resource_name', false),
+                    'group_name' => $this->db->f('group_name', false),
+                    'group_shortname' => $this->db->f('group_shortname', 
false),
+                    'from_' => $this->db->f('from_', false),
+                    'to_' => $this->db->f('to_', false),
+                );
+            }
+            return $results;
+        }
+
+        function get_screen_event($building_id, $start, $end, $resources = '')
+        {
+            $start = $start->format('Y-m-d H:i:s');
+
+            $test = $end->format('H:i');
+
+            if ($test != '00:00') {
+                $end = $end->format('Y-m-d H:i:s');
+
+            } else {
+                $end = $end->format('Y-m-d').' 24:00:00';
+            }
+
+            $building_id = intval($building_id);
+            $results = array();
+            $sql = "SELECT
+                    bb_event.id AS id,
+                    bb_event.building_name as building_name,
+                    bb_event.description as description,
+                    bb_event.from_ AS from_,
+                    bb_event.to_ AS to_,
+                    bb_resource.sort AS sort,
+                    bb_resource.id AS resource_id,
+                    bb_resource.name AS resource_name,
+                    bb_resource.building_id AS building_id
+                    FROM bb_event
+                    INNER JOIN bb_event_resource ON 
(bb_event_resource.event_id = bb_event.id)
+                    INNER JOIN bb_resource ON (bb_resource.id = 
bb_event_resource.resource_id)
+                    WHERE
+                    (
+                    (bb_event.from_ >= '".$start."' AND bb_event.to_ <= 
'".$end."')
+                    OR (bb_event.from_ < '".$start."' AND bb_event.to_ <= 
'".$end."' AND bb_event.to_ > '".$start."')
+                    OR (bb_event.from_ >='".$start."' AND bb_event.from_ < 
'".$end."' AND bb_event.to_ > '".$end."')
+                    OR (bb_event.from_ < '".$start."' AND bb_event.to_ > 
'".$end."')
+                    )
+                    AND bb_resource.building_id = (".$building_id.")
+                     ".$resources."
+                    AND bb_event.active = 1
+                    ORDER BY building_name,sort,from_;";
+            $this->db->query($sql, __LINE__, __FILE__);
+            while ($this->db->next_record())
+            {
+                $results[] = array(
+                    'id' => $this->db->f('id', false),
+                    'building_id' => $this->db->f('building_id', false),
+                    'resource_id' => $this->db->f('resource_id', false),
+                    'building_name' => $this->db->f('building_name', false),
+                    'resource_id' => $this->db->f('resource_id', false),
+                    'resource_name' => $this->db->f('resource_name', false),
+                    'description' => $this->db->f('description', false),
+                    'from_' => $this->db->f('from_', false),
+                    'to_' => $this->db->f('to_', false),
+                );
+            }
+            return $results;
+        }
+
        }

Modified: branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.sobuilding.inc.php        
2015-04-09 11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.sobuilding.inc.php        
2015-04-09 13:36:49 UTC (rev 12975)
@@ -10,12 +10,20 @@
                                        'id' => array('type' => 'int'),
                                        'name' => array('type' => 'string', 
'query' => true, 'required' => true),
                                        'homepage' => array('type' => 'string'),
+                                       'calendar_text' => array('type' => 
'string'),
                                        'description' => array('type' => 
'string'),
                                        'phone' => array('type' => 'string'),
                                        'email' => array('type' => 'string'),
+                                       'tilsyn_name' => array('type' => 
'string'),
+                                       'tilsyn_phone' => array('type' => 
'string'),
+                                       'tilsyn_email' => array('type' => 
'string'),
+                                       'tilsyn_name2' => array('type' => 
'string'),
+                                       'tilsyn_phone2' => array('type' => 
'string'),
+                                       'tilsyn_email2' => array('type' => 
'string'),
                                        'deactivate_calendar' => array('type' 
=> 'int'),
                                        'deactivate_application' => 
array('type' => 'int'),
                                        'deactivate_sendmessage' => 
array('type' => 'int'),
+                                       'extra_kalendar' => array('type' => 
'int'),
                                        'location_code' =>array('type' => 
'string', 'required' => false),
                                        'street'                => array('type' 
=> 'string', 'query' => true),
                                        'zip_code'              => array('type' 
=> 'string'),
@@ -25,6 +33,29 @@
                                )
                        );
                }
+
+               function get_endofseason($id)
+               {
+                       $this->db->limit_query("SELECT to_ FROM bb_season WHERE 
status = 'PUBLISHED' AND active=1 AND building_id =" . intval($id) . "ORDER BY 
to_ DESC", 0, __LINE__, __FILE__, 1);
+                       if(!$this->db->next_record())
+                       {
+                return false;        
+               }
+                       return $this->db->f('to_', false);
+               }
+
+               function get_metainfo($id)
+               {
+                       $this->db->limit_query("SELECT name, district, city, 
description FROM bb_building where id=" . intval($id), 0, __LINE__, __FILE__, 
1);
+                       if(!$this->db->next_record())
+                       {
+                               return False;
+                       }
+                       return array('name' => $this->db->f('name', false),
+                                                 'district' => 
$this->db->f('district', false),
+                                                 'city' => 
$this->db->f('city', false),
+                                                 'description' => 
$this->db->f('description', false));
+               }
                
                /**
                 * Returns buildings used by the organization with the 
specified id

Modified: branches/dev-syncromind/booking/inc/class.socommon.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.socommon.inc.php  2015-04-09 
11:54:43 UTC (rev 12974)
+++ branches/dev-syncromind/booking/inc/class.socommon.inc.php  2015-04-09 
13:36:49 UTC (rev 12975)
@@ -404,7 +404,6 @@
                        $dir = isset($params['dir']) && $params['dir'] ? 
$params['dir'] : 'asc';
                        $query = isset($params['query']) && $params['query'] ? 
$params['query'] : null;
                        $filters = isset($params['filters']) && 
$params['filters'] ? $params['filters'] : array();
-
                        $cols_joins = $this->_get_cols_and_joins();
                        $cols = join(',', $cols_joins[0]);
                        $joins = join(' ', $cols_joins[1]);

Modified: 
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export.inc.php
===================================================================
--- 
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export.inc.php
    2015-04-09 11:54:43 UTC (rev 12974)
+++ 
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export.inc.php
    2015-04-09 13:36:49 UTC (rev 12975)
@@ -283,7 +283,21 @@
                 * @return array with three elements where index 0: total_rows, 
index 1: total_cost, index 2: formatted data
                 */
                public function export_external(array &$reservations, array 
$account_codes) {
-                       $export_format = 'agresso';
+                       $config = CreateObject('phpgwapi.config','booking');
+                       $config->read();
+
+            if ($config->config_data['external_format'] == 'CSV')
+            {
+                $export_format = 'csv';
+            }
+            elseif ($config->config_data['external_format'] == 'AGRESSO')
+            {
+                       $export_format = 'agresso';
+                       } 
+            elseif ($config->config_data['external_format'] == 'KOMMFAKT')
+            {
+                       $export_format = 'kommfakt';
+                       } 
                        
                        if (is_array($reservations)) {
                                if (count($external_reservations = 
array_filter($reservations, array($this, 'select_external'))) > 0) {
@@ -292,12 +306,33 @@
                                                throw new 
UnexpectedValueException("Unable to find sequential number generator for 
external export");
                                        }
                                        
-                                       return $this->build_export_result(
+                    if ($config->config_data['external_format'] == 'CSV')
+                    {
+                                       return $this->build_export_result(
+                                               $export_format,
+                                               
count(array_filter($internal_reservations, array($this, 'not_free'))),
+                                               
$this->calculate_total_cost($internal_reservations),
+                                               
$this->format_csv($internal_reservations, $account_codes, $number_generator)
+                                               );
+                    }
+                    elseif ($config->config_data['external_format'] == 
'AGRESSO')
+                    {
+                                               return 
$this->build_export_result(
                                                $export_format,
                                                
count(array_filter($external_reservations, array($this, 'not_free'))),
                                                
$this->calculate_total_cost($external_reservations),
                                                
$this->format_agresso($external_reservations, $account_codes, $number_generator)
-                                       );
+                                               );
+                                       }
+                    elseif ($config->config_data['external_format'] == 
'KOMMFAKT')
+                    {
+                                               return 
$this->build_export_result(
+                                               $export_format,
+                                               
count(array_filter($external_reservations, array($this, 'not_free'))),
+                                               
$this->calculate_total_cost($external_reservations),
+                                               
$this->format_kommfakt($external_reservations, $account_codes, 
$number_generator)
+                                               );
+                                       }
                                }
                        }
                        return $this->build_export_result($export_format, 0, 
0.0);
@@ -314,10 +349,14 @@
             {
                 $export_format = 'csv';
             }
-            elseif ($config->config_data['internal_format'] == 'AGGRESSO')
+            elseif ($config->config_data['internal_format'] == 'AGRESSO')
             {
                        $export_format = 'agresso';
                        } 
+            elseif ($config->config_data['internal_format'] == 'KOMMFAKT')
+            {
+                       $export_format = 'kommfakt';
+                       } 
                        
                        if (is_array($reservations)) {
                                if (count($internal_reservations = 
array_filter($reservations, array($this, 'select_internal'))) > 0) {
@@ -334,7 +373,7 @@
                                                
$this->format_csv($internal_reservations, $account_codes, $number_generator)
                                                );
                         }
-                        elseif ($config->config_data['internal_format'] == 
'AGGRESSO')
+                        elseif ($config->config_data['internal_format'] == 
'AGRESSO')
                         {
                                                return 
$this->build_export_result(
                                                $export_format,
@@ -343,6 +382,15 @@
                                                
$this->format_agresso($internal_reservations, $account_codes, $number_generator)
                                                );
                         }
+                        elseif ($config->config_data['internal_format'] == 
'KOMMFAKT')
+                        {
+                                               return 
$this->build_export_result(
+                                               $export_format,
+                                               
count(array_filter($internal_reservations, array($this, 'not_free'))),
+                                               
$this->calculate_total_cost($internal_reservations),
+                                               
$this->format_kommfakt($internal_reservations, $account_codes, 
$number_generator)
+                                               );
+                        }
                                }
                        }
                        return $this->build_export_result($export_format, 0, 
0.0);
@@ -397,6 +445,7 @@
                        $combined_data = array();
                        $export_format = null;
                        $combine_method = null;
+
                        foreach($export_results as &$export_result) {
                                if (!isset($export_result['export_format']) || 
!is_string($export_result['export_format'])) {
                                        throw new 
InvalidArgumentException('export_format must be specified');
@@ -435,7 +484,7 @@
                                $combined_data[] = substr($export['data'], 
strpos($export['data'], "\n")+1); //Remove first line (i.e don't to repeat 
headers in file)
                        }
                }
-               
+
                public function format_csv(array &$reservations, array 
$account_codes, $sequential_number_generator) {
                        $export_info = array();
                        $output = array();
@@ -710,7 +759,7 @@
                                        $header['line_no'] = '0000'; //Nothing 
here according to example file but spec. says so
                                
                                        //Topptekst til faktura, knyttet mot 
fagavdeling
-                                       $header['long_info1'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1",$account_codes['invoice_instruction']),
 0, 120), 120, ' ');
+                                       $header['long_info1'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1//TRANSLIT",$account_codes['invoice_instruction']),
 0, 120), 120, ' ');
 
                                        //Ordrenr. UNIKT, løpenr. genereres i 
booking ut fra gitt serie, eks. 38000000
                                        $header['order_id'] = 
str_pad($order_id, 9, 0, STR_PAD_LEFT);
@@ -741,7 +790,7 @@
                                        /* Data hentes fra booking, tidspunkt 
legges i eget felt som kommer på 
                                         * linjen under: 78_short_info. <navn 
på bygg>,  <navn på ressurs>
                                         */
-                                       $item['art_descr'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1",$reservation['article_description']), 
0, 35), 35, ' '); //35 chars long
+                                       $item['art_descr'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1//TRANSLIT",$reservation['article_description']),
 0, 35), 35, ' '); //35 chars long
                                
                                        //Artikkel opprettes i Agresso (4 
siffer), en for kultur og en for idrett, inneholder konteringsinfo.
                                        $item['article'] = 
str_pad(substr(strtoupper($account_codes['article']), 0, 15), 15, ' ');
@@ -797,7 +846,7 @@
                                        $text['batch_id'] = $header['batch_id'];
                                        $text['client'] = $header['client'];
                                        $text['line_no'] = $item['line_no']; 
-                                       $text['short_info'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1",$reservation['description']), 0, 60), 
60, ' ');
+                                       $text['short_info'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1//TRANSLIT",$reservation['description']),
 0, 60), 60, ' ');
                                        $text['trans_type'] = 
$header['trans_type'];
                                        $text['voucher_type'] = 
$header['voucher_type'];
                                
@@ -855,7 +904,7 @@
                                        /* Data hentes fra booking, tidspunkt 
legges i eget felt som kommer på 
                                         * linjen under: 78_short_info. <navn 
på bygg>,  <navn på ressurs>
                                         */
-                                       $item['art_descr'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1",$reservation['article_description']), 
0, 35), 35, ' '); //35 chars long
+                                       $item['art_descr'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1//TRANSLIT",$reservation['article_description']),
 0, 35), 35, ' '); //35 chars long
                                
                                        //Artikkel opprettes i Agresso (4 
siffer), en for kultur og en for idrett, inneholder konteringsinfo.
                                        $item['article'] = 
str_pad(substr(strtoupper($account_codes['article']), 0, 15), 15, ' ');
@@ -911,7 +960,7 @@
                                        $text['batch_id'] = 
$stored_header['batch_id'];
                                        $text['client'] = 
$stored_header['client'];
                                        $text['line_no'] = $item['line_no']; 
-                                       $text['short_info'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1",$reservation['description']), 0, 60), 
60, ' ');
+                                       $text['short_info'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1//TRANSLIT",$reservation['description']),
 0, 60), 60, ' ');
                                        $text['trans_type'] = 
$stored_header['trans_type'];
                                        $text['voucher_type'] = 
$stored_header['voucher_type'];
                                
@@ -933,8 +982,14 @@
                        if (count($export_info) == 0) {
                                return null;
                        }
+
+            if ($config->config_data['external_format_linebreak'] == 
'Windows') {
+                $file_format_linebreak = "\r\n";
+            } else {
+                $file_format_linebreak = "\n";
+            }    
                
-                       return array('data' => implode("\n", $output), 
'data_log' => implode("\n", $log), 'info' => $export_info, 'header_count' => 
$header_count);
+                       return array('data' => implode($file_format_linebreak, 
$output), 'data_log' => implode("\n", $log), 'info' => $export_info, 
'header_count' => $header_count);
                }
                
                protected function get_agresso_row_template() {
@@ -944,4 +999,207 @@
                        $row_template = array('accept_flag' => str_repeat(' ', 
1), 'account' => str_repeat(' ', 8), 'accountable' => str_repeat(' ', 20), 
'address' => str_repeat(' ', 160), 'allocation_key' => str_repeat(' ', 2), 
'amount' => str_repeat(' ', 17), 'amount_set' => str_repeat(' ', 1), 'apar_id' 
=> str_repeat(' ', 8), 'apar_name' => str_repeat(' ', 30), 'art_descr' => 
str_repeat(' ', 35), 'article' => str_repeat(' ', 15), 'att_1_id' => 
str_repeat(' ', 2), 'att_2_id' => str_repeat(' ', 2), 'att_3_id' => 
str_repeat(' ', 2), 'att_4_id' => str_repeat(' ', 2), 'att_5_id' => 
str_repeat(' ', 2), 'att_6_id' => str_repeat(' ', 2), 'att_7_id' => 
str_repeat(' ', 2), 'bank_account' => str_repeat(' ', 35), 'batch_id' => 
str_repeat(' ', 12), 'client' => str_repeat(' ', 2), 'client_ref' => 
str_repeat(' ', 2), 'confirm_date' => str_repeat(' ', 17), 'control' => 
str_repeat(' ', 1), 'cur_amount' => str_repeat(' ', 17), 'currency' => 
str_repeat(' ', 3), 'del_met_descr' => str_repeat(' ', 60), 'del_term_descr' => 
str_repeat(' ', 60), 'deliv_addr' => str_repeat(' ', 255), 'deliv_attention' => 
str_repeat(' ', 50), 'deliv_countr' => str_repeat(' ', 3), 'deliv_date' => 
str_repeat(' ', 17), 'deliv_method' => str_repeat(' ', 8), 'deliv_terms' => 
str_repeat(' ', 8), 'dim_1' => str_repeat(' ', 8), 'dim_2' => str_repeat(' ', 
8), 'dim_3' => str_repeat(' ', 8), 'dim_4' => str_repeat(' ', 8), 'dim_5' => 
str_repeat(' ', 12), 'dim_6' => str_repeat(' ', 4), 'dim_7' => str_repeat(' ', 
4), 'dim_value_1' => str_repeat(' ', 12), 'dim_value_2' => str_repeat(' ', 12), 
'dim_value_3' => str_repeat(' ', 12), 'dim_value_4' => str_repeat(' ', 12), 
'dim_value_5' => str_repeat(' ', 12), 'dim_value_6' => str_repeat(' ', 12), 
'dim_value_7' => str_repeat(' ', 12), 'disc_percent' => str_repeat(' ', 17), 
'exch_rate' => str_repeat(' ', 17), 'ext_ord_ref' => str_repeat(' ', 15), 
'intrule_id' => str_repeat(' ', 6), 'line_no' => str_repeat(' ', 4), 'location' 
=> str_repeat(' ', 4), 'long_info1' => str_repeat(' ', 120), 'long_info2' => 
str_repeat(' ', 120), 'lot' => str_repeat(' ', 10), 'main_apar_id' => 
str_repeat(' ', 8), 'mark_attention' => str_repeat(' ', 50), 'mark_ctry_cd' => 
str_repeat(' ', 3), 'markings' => str_repeat(' ', 120), 'obs_date' => 
str_repeat(' ', 17), 'order_date' => str_repeat(' ', 17), 'order_id' => 
str_repeat(' ', 9), 'order_type' => str_repeat(' ', 2), 'pay_method' => 
str_repeat(' ', 2), 'period' => str_repeat(' ', 8), 'place' => str_repeat(' ', 
30), 'province' => str_repeat(' ', 40), 'rel_value' => str_repeat(' ', 12), 
'responsible' => str_repeat(' ', 8), 'responsible2' => str_repeat(' ', 8), 
'sequence_no' => str_repeat(' ', 8), 'sequence_ref' => str_repeat(' ', 8), 
'serial_no' => str_repeat(' ', 20), 'short_info' => str_repeat(' ', 60), 
'status' => str_repeat(' ', 1), 'tax_code' => str_repeat(' ', 2), 'tax_system' 
=> str_repeat(' ', 2), 'template_id' => str_repeat(' ', 8), 'terms_id' => 
str_repeat(' ', 2), 'tekx1' => str_repeat(' ', 12), 'tekst2' => str_repeat(' ', 
12), 'tekst3' => str_repeat(' ', 12), 'text4' => str_repeat(' ', 12), 
'trans_type' => str_repeat(' ', 2), 'unit_code' => str_repeat(' ', 3), 
'unit_descr' => str_repeat(' ', 50), 'value_1' => str_repeat(' ', 17), 
'voucher_ref' => str_repeat(' ', 9), 'voucher_type' => str_repeat(' ', 2), 
'warehouse' => str_repeat(' ', 4), 'zip_code' => str_repeat(' ', 15));
                        return $row_template;
                }
+
+               protected function combine_kommfakt_export_data(array 
&$combined_data, $export) {
+                       if (count($combined_data) == 0) {
+                               $combined_data[] = $export['data'];
+                       } else {
+                               $combined_data[] = "\n";
+                               $combined_data[] = $export['data'];
+                       }
+               }
+
+               public function format_kommfakt(array &$reservations, array 
$account_codes, $sequential_number_generator) {
+                       $export_info = array();
+                       $output = array();
+                       
+                       $log = array();
+
+                       $date = str_pad(date('Ymd'), 17, ' ', STR_PAD_LEFT);
+
+                       $config = CreateObject('phpgwapi.config','booking');
+                       $config->read();
+                       
+                       
+
+                       $stored_header = array();                       
+                       $line_no = 0;
+            $header_count = 0;
+                       $log_order_id = '';
+                       $log_customer_name = '';
+                       $log_customer_nr = '';
+                       $log_buidling = '';
+                       
+                       $internal = false;
+
+                       $ant_post = 0;
+                       $linjenr = 1;   
+                       $lopenr = 1;    
+
+                       foreach($reservations as &$reservation) {
+
+                               if ($this->get_cost_value($reservation['cost']) 
<= 0) {
+                                       continue; //Don't export costless rows
+                               }
+
+                               if(!empty($reservation['organization_id'])) {
+                                       $org = 
$this->organization_bo->read_single($reservation['organization_id']);           
                 
+                                       $reservation['organization_name'] = 
$org['name'];
+                               } else {
+                                       $data = 
$this->event_so->get_org($reservation['customer_organization_number']);
+                                       if(!empty($data['id'])) {
+                                               
$reservation['organization_name'] = $data['name'];
+                                       } else {
+                                               
if($reservation['reservation_type'] == 'event') {
+                                                       $data = 
$this->event_bo->read_single($reservation['reservation_id']);
+                                                       
$reservation['organization_name'] = $data['contact_name'];
+#                                              } elseif 
($reservation['reservation_type'] == 'booking') {
+#                                                      $data = 
$this->booking_bo->read_single($reservation['reservation_id']);
+#                                                      
error_log('b'.$data['id']." ".$data['group_id']);
+#                                              } else {
+#                                                      $data = 
$this->allocation_bo->read_single($reservation['reservation_id']);
+#                                                      
error_log('a'.$data['id']." ".$data['organization_id']);
+                                               }
+                                       }
+                               }
+
+                               $type = $reservation['customer_type'];
+
+                               $order_id = 
$sequential_number_generator->increment()->get_current();
+                               $export_info[] = 
$this->create_export_item_info($reservation, $order_id);
+                               $header_count += 1;
+                               $stored_header['kundenr'] = $kundenr;
+
+                               $kundenr = 
str_pad(substr($this->get_customer_identifier_value_for($reservation), 0, 11), 
11, '0',STR_PAD_LEFT);
+
+
+                               if 
(strlen($this->get_customer_identifier_value_for($reservation)) > 9) {
+                                       $name = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$reservation['organization_name']),
 30, ' ');
+                               } else {
+                                       $name = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$reservation['organization_name']),
 30, ' ');
+                               }               
+
+                               //Startpost ST
+                               $startpost = 
$this->get_kommfakt_ST_row_template();
+                               $startpost['posttype'] = 'ST';
+                               $startpost['referanse'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1//TRANSLIT",$reservation['article_description']),
 0, 60), 60, ' ');
+#                              $startpost['referanse'] = 
str_pad(substr(iconv("utf-8","ISO-8859-1//TRANSLIT",$account_codes['invoice_instruction']),
 0, 60), 60, ' ');
+
+                               //Fakturalinje FL
+                               $fakturalinje = 
$this->get_kommfakt_FL_row_template();
+                               $fakturalinje['posttype'] = 'FL';
+                               $fakturalinje['kundenr'] = $kundenr;
+                               $fakturalinje['navn'] = $name;
+#                              $fakturalinje['adresse1'] = ;
+#                              $fakturalinje['adresse2'] = ;
+#                              $fakturalinje['postnr'] = ;
+                               $fakturalinje['betform'] = 'BG';
+                               $fakturalinje['oppdrgnr'] = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$account_codes['object_number']), 
3, '0', STR_PAD_LEFT);
+                               $fakturalinje['varenr'] = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$account_codes['responsible_code']),
 4, '0', STR_PAD_LEFT);
+                               $fakturalinje['lopenr'] = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$lopenr), 2, '0', STR_PAD_LEFT);
+                               $fakturalinje['pris'] = 
str_pad($reservation['cost']*100,8,'0',STR_PAD_LEFT).' ';
+                               $fakturalinje['grunnlag'] = '000000001';
+                               $fakturalinje['belop'] = 
str_pad($reservation['cost']*100,8,'0',STR_PAD_LEFT).' ';
+#                              $fakturalinje['saksnr'] = ;
+
+                               //Linjetekst LT
+                               $linjetekst = 
$this->get_kommfakt_LT_row_template();
+                               $linjetekst['posttype'] = 'LT';
+                               $linjetekst['kundenr'] = $kundenr;
+                               $linjetekst['oppdrgnr'] = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$account_codes['object_number']), 
3, '0', STR_PAD_LEFT);
+                               $linjetekst['varenr'] = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$account_codes['responsible_code']),
 4, '0', STR_PAD_LEFT) ;
+                               $linjetekst['lopenr'] = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$lopenr), 2, '0', STR_PAD_LEFT);
+                               $linjetekst['linjenr'] = $linjenr;
+                               $linjetekst['tekst'] = 
str_pad(iconv("utf-8","ISO-8859-1//TRANSLIT",$reservation['description']), 50, 
' ');
+                               $ant_post += 3;
+
+                                       //Sluttpost SL
+                               $sluttpost = 
$this->get_kommfakt_SL_row_template();
+                               $sluttpost['posttype'] = 'SL';
+                               $sluttpost['antpost'] = 
str_pad(intval($ant_post)+1, 8, '0', STR_PAD_LEFT);
+                               $ant_post = 0;
+
+
+                               $log_order_id = $order_id;
+
+                               if(!empty($reservation['organization_id'])) {
+                                       $org = 
$this->organization_bo->read_single($reservation['organization_id']);           
                 
+                                       $log_customer_name = $org['name'];
+                               } else {
+                                       $data = 
$this->event_so->get_org($reservation['customer_organization_number']);
+                                       if(!empty($data['id'])) {
+                                               $log_customer_name = 
$data['name'];
+                                       } else {
+                                               
if($reservation['reservation_type'] == 'event') {
+                                                       $data = 
$this->event_bo->read_single($reservation['reservation_id']);
+                                                       $log_customer_name = 
$data['contact_name'];
+#                                              } elseif 
($reservation['reservation_type'] == 'booking') {
+#                                                      $data = 
$this->booking_bo->read_single($reservation['reservation_id']);
+#                                                      
error_log('b'.$data['id']." ".$data['group_id']);
+#                                              } else {
+#                                                      $data = 
$this->allocation_bo->read_single($reservation['reservation_id']);
+#                                                      
error_log('a'.$data['id']." ".$data['organization_id']);
+                                               }
+                                       }
+                               }
+
+                       $log_customer_nr = 
$this->get_customer_identifier_value_for($reservation);
+                               $log_buidling = $reservation['building_name'];
+                               $log_cost = $reservation['cost'];
+                               $log_varelinjer_med_dato = 
$reservation['article_description'].' - '.$reservation['description'];
+
+                               $log[] = $log_order_id.';'.$log_customer_name.' 
- 
'.$log_customer_nr.';'.$log_varelinjer_med_dato.';'.$log_buidling.';'.$log_cost;
+
+                               $output[] = implode('', str_replace(array("\n", 
"\r"), '', $startpost));
+                               $output[] = implode('', str_replace(array("\n", 
"\r"), '', $fakturalinje));
+                               $output[] = implode('', str_replace(array("\n", 
"\r"), '', $linjetekst));
+                               $output[] = implode('', str_replace(array("\n", 
"\r"), '', $sluttpost));
+
+                       }                       
+
+                       if (count($export_info) == 0) {
+                               return null;
+                       }
+            if ($config->config_data['external_format_linebreak'] == 
'Windows') {
+                $file_format_linebreak = "\r\n";
+            } else {
+                $file_format_linebreak = "\n";
+            }    
+
+                       return array('data' => implode($file_format_linebreak, 
$output), 'data_log' => implode("\n", $log), 'info' => $export_info, 
'header_count' => $header_count);
+
+               }               
+
+               protected function get_kommfakt_ST_row_template() {
+                       static $row_template = false;
+                       if ($row_template) { return $row_template; }
+       
+                       $row_template = array('posttype' => str_repeat(' ', 2), 
'referanse' => str_repeat(' ', 60));
+                       return $row_template;
+               }
+
+               protected function get_kommfakt_FL_row_template() {
+                       static $row_template = false;
+                       if ($row_template) { return $row_template; }
+
+                       $row_template = array('posttype' => str_repeat(' ', 2), 
'kundenr' => str_repeat(' ', 11), 'navn' => str_repeat(' ', 30), 'adresse1' => 
str_repeat(' ', 30), 'adresse2' => str_repeat(' ', 30), 'postnr' => 
str_repeat(' ', 4), 'betform' => str_repeat(' ', 2), 'oppdrgnr' => str_repeat(' 
', 3), 'varenr' => str_repeat(' ', 4), 'lopenr' => str_repeat(' ', 2), 'pris' 
=> str_repeat(' ', 9), 'grunnlag' => str_repeat(' ', 9), 'belop' => 
str_repeat(' ', 11), 'saksnr' => str_repeat(' ', 16));
+                       return $row_template;
+       
+               }
+
+               protected function get_kommfakt_LT_row_template() {
+                       static $row_template = false;
+                       if ($row_template) { return $row_template; }
+       
+                       $row_template = array('posttype' => str_repeat(' ', 2), 
'kundenr' => str_repeat(' ', 11), 'oppdrgnr' => str_repeat(' ', 3), 'varenr' => 
str_repeat(' ', 4), 'lopenr' => str_repeat(' ', 2), 'linjenr' => str_repeat(' 
', 2), 'tekst' => str_repeat(' ', 50));
+                       return $row_template;
+               }
+
+               protected function get_kommfakt_SL_row_template() {
+                       static $row_template = false;
+                       if ($row_template) { return $row_template; }
+       
+                       $row_template = array('posttype' => str_repeat(' ', 2), 
'antpost' => str_repeat(' ', 8));
+                       return $row_template;
+               }
        }

Modified: 
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export_file.inc.php
===================================================================
--- 
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export_file.inc.php
       2015-04-09 11:54:43 UTC (rev 12974)
+++ 
branches/dev-syncromind/booking/inc/class.socompleted_reservation_export_file.inc.php
       2015-04-09 13:36:49 UTC (rev 12975)
@@ -43,12 +43,27 @@
                 {
                     return 'csv';
                 }
-                elseif ($config->config_data['internal_format'] == 'AGGRESSO')
+                elseif ($config->config_data['internal_format'] == 'AGRESSO')
                 {
                            return 'txt';
                 }
+                elseif ($config->config_data['internal_format'] == 'KOMMFAKT')
+                {
+                           return 'txt';
+                }
             } elseif ($export_type === 'external'){
-                return 'txt';    
+                if ($config->config_data['external_format'] == 'CSV')
+                {
+                    return 'csv';
+                }
+                elseif ($config->config_data['external_format'] == 'AGRESSO')
+                {
+                           return 'txt';
+                }
+                elseif ($config->config_data['external_format'] == 'KOMMFAKT')
+                {
+                           return 'txt';
+                }
             } else {
                 return 'txt';    
             }
@@ -110,7 +125,7 @@
                        $entity_export_files = array();
                        $export_files = array();
                        $export_conf_updates = array();
-                       
+            
                        try {                           

@@ Diff output truncated at 153600 characters. @@



reply via email to

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