fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15217] Syncromind: merge 15164:15215 from trunk


From: sigurdne
Subject: [Fmsystem-commits] [15217] Syncromind: merge 15164:15215 from trunk
Date: Mon, 30 May 2016 08:04:44 +0000 (UTC)

Revision: 15217
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15217
Author:   sigurdne
Date:     2016-05-30 08:04:44 +0000 (Mon, 30 May 2016)
Log Message:
-----------
Syncromind: merge 15164:15215 from trunk

Modified Paths:
--------------
    branches/dev-syncromind-2/admin/inc/class.uiaccounts.inc.php
    branches/dev-syncromind-2/booking/inc/class.uiallocation.inc.php
    branches/dev-syncromind-2/booking/inc/class.uibooking.inc.php
    branches/dev-syncromind-2/booking/inc/class.uievent.inc.php
    branches/dev-syncromind-2/booking/setup/phpgw_no.lang
    branches/dev-syncromind-2/booking/templates/base/allocation.xsl
    branches/dev-syncromind-2/controller/inc/class.menu.inc.php
    branches/dev-syncromind-2/controller/setup/phpgw_no.lang
    branches/dev-syncromind-2/controller/templates/base/config.tpl
    branches/dev-syncromind-2/demo/inc/class.sodemo.inc.php
    branches/dev-syncromind-2/helpdesk/inc/class.sotts.inc.php
    branches/dev-syncromind-2/hrm/inc/class.bocommon.inc.php
    branches/dev-syncromind-2/hrm/inc/class.souser.inc.php
    branches/dev-syncromind-2/hrm/inc/class.uiuser.inc.php
    branches/dev-syncromind-2/notes/inc/class.sonotes.inc.php
    branches/dev-syncromind-2/notes/inc/class.uinotes.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/class.acl.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/class.jqcal.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/class.phpgw.inc.php
    branches/dev-syncromind-2/phpgwapi/js/jquery/common.js
    branches/dev-syncromind-2/phpgwapi/setup/phpgw_en.lang
    branches/dev-syncromind-2/phpgwapi/templates/base/datatable_jquery.xsl
    branches/dev-syncromind-2/preferences/changepassword.php
    branches/dev-syncromind-2/property/inc/class.boadmin_entity.inc.php
    branches/dev-syncromind-2/property/inc/class.boadmin_location.inc.php
    branches/dev-syncromind-2/property/inc/class.boagreement.inc.php
    branches/dev-syncromind-2/property/inc/class.boasync.inc.php
    branches/dev-syncromind-2/property/inc/class.bobudget.inc.php
    branches/dev-syncromind-2/property/inc/class.bocommon.inc.php
    branches/dev-syncromind-2/property/inc/class.bocustom.inc.php
    branches/dev-syncromind-2/property/inc/class.bodocument.inc.php
    branches/dev-syncromind-2/property/inc/class.boentity.inc.php
    branches/dev-syncromind-2/property/inc/class.bogab.inc.php
    branches/dev-syncromind-2/property/inc/class.boifc.inc.php
    branches/dev-syncromind-2/property/inc/class.boinvestment.inc.php
    branches/dev-syncromind-2/property/inc/class.bolocation.inc.php
    branches/dev-syncromind-2/property/inc/class.bopricebook.inc.php
    branches/dev-syncromind-2/property/inc/class.boproject.inc.php
    branches/dev-syncromind-2/property/inc/class.borequest.inc.php
    branches/dev-syncromind-2/property/inc/class.bos_agreement.inc.php
    branches/dev-syncromind-2/property/inc/class.botemplate.inc.php
    branches/dev-syncromind-2/property/inc/class.botenant_claim.inc.php
    branches/dev-syncromind-2/property/inc/class.bowo_hour.inc.php
    branches/dev-syncromind-2/property/inc/class.boworkorder.inc.php
    branches/dev-syncromind-2/property/inc/class.soagreement.inc.php
    branches/dev-syncromind-2/property/inc/class.socustom.inc.php
    branches/dev-syncromind-2/property/inc/class.soentity.inc.php
    branches/dev-syncromind-2/property/inc/class.sojasper.inc.php
    branches/dev-syncromind-2/property/inc/class.soproject.inc.php
    branches/dev-syncromind-2/property/inc/class.sos_agreement.inc.php
    branches/dev-syncromind-2/property/inc/class.sotts.inc.php
    branches/dev-syncromind-2/property/inc/class.soworkorder.inc.php
    branches/dev-syncromind-2/property/inc/class.uiadmin_entity.inc.php
    branches/dev-syncromind-2/property/inc/class.uiagreement.inc.php
    branches/dev-syncromind-2/property/inc/class.uigeneric.inc.php
    branches/dev-syncromind-2/property/inc/class.uijasper.inc.php
    branches/dev-syncromind-2/property/inc/class.uiproject.inc.php
    branches/dev-syncromind-2/property/inc/class.uiresponsible.inc.php
    branches/dev-syncromind-2/property/inc/class.uiwo_hour.inc.php
    branches/dev-syncromind-2/property/inc/class.uiworkorder.inc.php
    branches/dev-syncromind-2/property/js/portico/admin_entity.edit_category.js
    branches/dev-syncromind-2/property/templates/base/agreement.xsl
    branches/dev-syncromind-2/property/templates/base/invoice2.xsl
    branches/dev-syncromind-2/registration/inc/class.boreg.inc.php
    branches/dev-syncromind-2/rental/inc/class.menu.inc.php
    branches/dev-syncromind-2/rental/inc/class.sobilling.inc.php
    branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
    branches/dev-syncromind-2/rental/inc/class.socontract.inc.php
    branches/dev-syncromind-2/rental/inc/class.socontract_price_item.inc.php
    branches/dev-syncromind-2/rental/inc/class.soinvoice_price_item.inc.php
    branches/dev-syncromind-2/rental/inc/class.uibilling.inc.php
    branches/dev-syncromind-2/rental/inc/class.uicontract.inc.php
    branches/dev-syncromind-2/rental/inc/class.uiprice_item.inc.php
    branches/dev-syncromind-2/rental/inc/model/class.agresso_gl07.inc.php
    branches/dev-syncromind-2/rental/inc/model/class.agresso_lg04.inc.php
    branches/dev-syncromind-2/rental/inc/model/class.contract.inc.php
    branches/dev-syncromind-2/rental/inc/model/class.invoice.inc.php
    branches/dev-syncromind-2/rental/inc/model/class.invoice_price_item.inc.php
    branches/dev-syncromind-2/rental/setup/phpgw_no.lang
    branches/dev-syncromind-2/rental/setup/setup.inc.php
    branches/dev-syncromind-2/rental/setup/tables_current.inc.php
    branches/dev-syncromind-2/rental/setup/tables_update.inc.php
    branches/dev-syncromind-2/rental/templates/base/billing.xsl
    branches/dev-syncromind-2/rental/templates/base/contract.xsl
    branches/dev-syncromind-2/rental/templates/base/css/base.css
    branches/dev-syncromind-2/sms/inc/class.soautoreply.inc.php
    branches/dev-syncromind-2/sms/inc/class.socommand.inc.php
    branches/dev-syncromind-2/sms/inc/class.sopoll.inc.php
    branches/dev-syncromind-2/sms/inc/class.sosms.inc.php
    branches/dev-syncromind-2/todo/inc/class.botodo.inc.php
    branches/dev-syncromind-2/todo/inc/class.sotodo.inc.php
    branches/dev-syncromind-2/todo/inc/class.uitodo.inc.php

Added Paths:
-----------
    branches/dev-syncromind-2/rental/inc/class.soapplication.inc.php
    branches/dev-syncromind-2/rental/inc/class.uiapplication.inc.php
    branches/dev-syncromind-2/rental/inc/model/class.application.inc.php
    branches/dev-syncromind-2/rental/js/rental/application.index.js
    branches/dev-syncromind-2/rental/templates/base/application.xsl

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


Property changes on: branches/dev-syncromind-2
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
/trunk:14934-14935
   + /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
/trunk:14934-14935,15165-15215

Modified: branches/dev-syncromind-2/admin/inc/class.uiaccounts.inc.php
===================================================================
--- branches/dev-syncromind-2/admin/inc/class.uiaccounts.inc.php        
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/admin/inc/class.uiaccounts.inc.php        
2016-05-30 08:04:44 UTC (rev 15217)
@@ -859,6 +859,12 @@
                public function _user_save()
                {
                        $values                                                 
                = phpgw::get_var('values', 'string', 'POST');
+                       if(isset($values['passwd']))
+                       {
+                               // remove entities to stop mangling
+                               $values['passwd'] = 
html_entity_decode($values['passwd']);
+                               $values['passwd_2'] = 
html_entity_decode($values['passwd_2']);
+                       }
                        $values['account_groups']                               
= (array) phpgw::get_var('account_groups', 'int', 'POST');
                        $account_permissions                                    
= phpgw::get_var('account_permissions', 'int', 'POST');
                        $account_permissions_admin                              
= phpgw::get_var('account_permissions_admin', 'int', 'POST');


Property changes on: branches/dev-syncromind-2/booking
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:14937-15027
   + /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:14937-15027,15165-15215

Modified: branches/dev-syncromind-2/booking/inc/class.uiallocation.inc.php
===================================================================
--- branches/dev-syncromind-2/booking/inc/class.uiallocation.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/booking/inc/class.uiallocation.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -109,6 +109,15 @@
                                                        'label' => lang('To')
                                                ),
                                                array(
+                                                       'key' => 'cost',
+                                                       'label' => lang('cost')
+                                               ),
+                                               array(
+                                                       'key' => 'cost_history',
+                                                       'label' => lang('cost 
history'),
+                                                       'sortable' => false,
+                                               ),
+                                               array(
                                                        'key' => 'link',
                                                        'hidden' => true
                                                )
@@ -188,6 +197,7 @@
                        {
                                $allocation['from_'] = 
pretty_timestamp($allocation['from_']);
                                $allocation['to_'] = 
pretty_timestamp($allocation['to_']);
+                               $allocation['cost_history'] = 
count($this->bo->so->get_ordered_costs($allocation['id']));
                        }
 
                        return $this->jquery_results($allocations);

Modified: branches/dev-syncromind-2/booking/inc/class.uibooking.inc.php
===================================================================
--- branches/dev-syncromind-2/booking/inc/class.uibooking.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/booking/inc/class.uibooking.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -120,6 +120,11 @@
                                                        'label' => lang('Cost')
                                                ),
                                                array(
+                                                       'key' => 'cost_history',
+                                                       'label' => lang('cost 
history'),
+                                                       'sortable' => false,
+                                               ),
+                                               array(
                                                        'key' => 'link',
                                                        'hidden' => true
                                                )
@@ -199,6 +204,7 @@
                                $booking['building_name'] = $building['name'];
                                $booking['from_'] = 
pretty_timestamp($booking['from_']);
                                $booking['to_'] = 
pretty_timestamp($booking['to_']);
+                               $booking['cost_history'] = 
count($this->bo->so->get_ordered_costs($booking['id']));
                        }
 
                        array_walk($bookings["results"], array($this, 
"_add_links"), "booking.uibooking.show");

Modified: branches/dev-syncromind-2/booking/inc/class.uievent.inc.php
===================================================================
--- branches/dev-syncromind-2/booking/inc/class.uievent.inc.php 2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/booking/inc/class.uievent.inc.php 2016-05-30 
08:04:44 UTC (rev 15217)
@@ -111,6 +111,15 @@
                                                        'label' => 
lang('Active')
                                                ),
                                                array(
+                                                       'key' => 'cost',
+                                                       'label' => lang('Cost')
+                                               ),
+                                               array(
+                                                       'key' => 'cost_history',
+                                                       'label' => lang('cost 
history'),
+                                                       'sortable' => false,
+                                               ),
+                                               array(
                                                        'key' => 'link',
                                                        'hidden' => true
                                                )
@@ -172,6 +181,7 @@
                        {
                                $event['from_'] = 
pretty_timestamp($event['from_']);
                                $event['to_'] = pretty_timestamp($event['to_']);
+                               $event['cost_history'] = 
count($this->bo->so->get_ordered_costs($event['id']));
                        }
 
                        array_walk($events["results"], array($this, 
"_add_links"), "booking.uievent.edit");

Modified: branches/dev-syncromind-2/booking/setup/phpgw_no.lang
===================================================================
--- branches/dev-syncromind-2/booking/setup/phpgw_no.lang       2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/booking/setup/phpgw_no.lang       2016-05-30 
08:04:44 UTC (rev 15217)
@@ -681,4 +681,5 @@
 Subject caseofficer    booking no      Emne Saksbehandler
 Mail text for comment added    booking no      Ekstra epost tekst for kommentar
 organzations_ids_description   booking no      Her kan du legge inn en komma 
separert liste med organisasjons IDer som vil få epost viss noen avbestiller 
denne ressursen.
-organzations_ids       booking no      Organisasjons IDer
\ No newline at end of file
+organzations_ids       booking no      Organisasjons IDer
+cost history   booking no      Prishistorikk
\ No newline at end of file

Modified: branches/dev-syncromind-2/booking/templates/base/allocation.xsl
===================================================================
--- branches/dev-syncromind-2/booking/templates/base/allocation.xsl     
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/booking/templates/base/allocation.xsl     
2016-05-30 08:04:44 UTC (rev 15217)
@@ -21,6 +21,12 @@
                                        <xsl:value-of 
select="php:function('pretty_timestamp', allocation/to_)"/>
                                </div>
                                <div class="pure-control-group">
+                                       <label for="field_cost">
+                                               <xsl:value-of 
select="php:function('lang', 'Cost')" />
+                                       </label>
+                                       <xsl:value-of select="allocation/cost"/>
+                               </div>
+                               <div class="pure-control-group">
                                        <label>
                                                <xsl:value-of 
select="php:function('lang', 'Season')" />
                                        </label>

Modified: branches/dev-syncromind-2/controller/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind-2/controller/inc/class.menu.inc.php 2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/controller/inc/class.menu.inc.php 2016-05-30 
08:04:44 UTC (rev 15217)
@@ -42,79 +42,67 @@
                                'controller' => array
                                        (
                                        'text' => lang('Controller'),
-                                       'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.control_list')),
+                       //              'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.control_list')),
+                                       'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicomponent.index')),
                                        'image' => array('property', 
'location'),
                                        'order' => 10,
                                        'group' => 'office'
                                )
                        );
 
+                       $menus['navigation'] = array();
                        if 
($GLOBALS['phpgw']->acl->check('.usertype.superuser', PHPGW_ACL_ADD, 
'controller'))
                        {
-                               $menus['navigation'] = array
-                                       (
-                                       'control' => array
-                                               (
-                                               'text' => lang('Control'),
+                               $menus['navigation']['control'] =  array(
+                                               'text' => lang('Control types'),
                                                'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.control_list')),
-                                               'image' => array('property', 
'location_1'),
-                                               'children' => array(
+                                               'image' => array('property', 
'location_1'));
+
+                               
+                               $config = CreateObject('phpgwapi.config', 
'controller');
+                               $config->read();
+
+
+                               if 
(!isset($config->config_data['home_alternative']) || 
!$config->config_data['home_alternative'])
+                               {
+                                                               
+                                       
$menus['navigation']['control']['children'] = array(
                                                        
'location_for_check_list' => array
                                                                (
                                                                'text' => 
lang('location_connections'),
                                                                'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_register_to_location.index')),
                                                                'image' => 
array('property', 'location_1')
-                                                       ),
-                                                       
'component_for_check_list' => array
-                                                               (
-                                                               'text' => 
lang('component'),
-                                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_register_to_component.index')),
-                                                               'image' => 
array('property', 'entity_1')
                                                        )
-                                               )
-                                       ),
-                                       'control_item' => array
-                                               (
-                                               'text' => lang('Control_item'),
-                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_item.index')),
-                                               'image' => array('property', 
'location_1')
-                                       ),
-                                       'control_group' => array
-                                               (
-                                               'text' => lang('Control_group'),
-                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_group.index')),
-                                               'image' => array('property', 
'location_1'),
-                                       /*
-                                         'children' => array(
-                                         'component_for_control_group' => array
-                                         (
-                                         'text'        => lang('component'),
-                                         'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicontrol_group_component.index') ),
-                                         'image'       => array('property', 
'entity_1')
-                                         )
-                                         )
-                                        */
-                                       ),
-                                       'procedure' => array
-                                               (
-                                               'text' => lang('Procedure'),
-                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uiprocedure.index')),
-                                               'image' => array('property', 
'location_1'),
-                                       ),
-                                       'calendar_overview' => array
-                                               (
-                                               'text' => 
lang('Calendar_overview'),
-                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicalendar.view_calendar_for_year')),
-                                               'image' => array('property', 
'location_1'),
-                                       ),
-                                       'status_components' => array
-                                               (
-                                               'text' => lang('status 
components'),
-                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicomponent.index')),
-                                               'image' => array('property', 
'location_1'),
-                                       ),
+                                               );
+                               }
+
+                               $menus['navigation']['control_item'] = array(
+                                       'text' => lang('Control_item'),
+                                       'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_item.index')),
+                                       'image' => array('property', 
'location_1')
                                );
+                               $menus['navigation']['control_group'] = array(
+                                       'text' => lang('Control_group'),
+                                       'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_group.index')),
+                                       'image' => array('property', 
'location_1')
+                                       );
+
+                               $menus['navigation']['procedure'] = array(
+                                       'text' => lang('Procedure'),
+                                       'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uiprocedure.index')),
+                                       'image' => array('property', 
'location_1'),
+                               );
                        }
+                       $menus['navigation']['calendar_overview'] = array(
+                               'text' => lang('Calendar_overview'),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'controller.uicalendar.view_calendar_for_year')),
+                               'image' => array('property', 'location_1'),
+                       );
+                       $menus['navigation']['status_components'] = array(
+                               'text' => lang('status components'),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'controller.uicomponent.index')),
+                               'image' => array('property', 'location_1'),
+                       );
 
                        if ($GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin') || $GLOBALS['phpgw']->acl->check('admin', 
phpgwapi_acl::ADD, 'controller'))
                        {

Modified: branches/dev-syncromind-2/controller/setup/phpgw_no.lang
===================================================================
--- branches/dev-syncromind-2/controller/setup/phpgw_no.lang    2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/controller/setup/phpgw_no.lang    2016-05-30 
08:04:44 UTC (rev 15217)
@@ -390,4 +390,5 @@
 summary        common  no      Sammendrag
 components     controller      no      Komponenter
 report type    controller      no      RapportType
-lang_control_mandatory_location        controller      no      Påkrevd 
lokasjonsvalg
\ No newline at end of file
+lang_control_mandatory_location        controller      no      Påkrevd 
lokasjonsvalg
+Control types  controller      no      Kontrolltyper
\ No newline at end of file

Modified: branches/dev-syncromind-2/controller/templates/base/config.tpl
===================================================================
--- branches/dev-syncromind-2/controller/templates/base/config.tpl      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/controller/templates/base/config.tpl      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -1,90 +1,90 @@
 <!-- $Id$ -->
-<!-- BEGIN header -->
-<form method="POST" action="{action_url}">
+<!-- BEGIN header -->
+<form method="POST" action="{action_url}">
        <table class="pure-table pure-table-bordered">
-               <tr class="th">
-                       <td colspan="2"><font 
color="{th_text}">&nbsp;<b>{title}</b></font></td>
-               </tr>
-               <!-- END header -->
-               <!-- BEGIN body -->
-               <tr class="row_on">
-                       <td colspan="2">&nbsp;</td>
-               </tr>
-               <tr class="row_off">
-                       <td colspan="2">&nbsp;<b>{lang_controller} 
{lang_settings}</b></td>
-               </tr>
-               <tr class="row_on">
-                       <td>{lang_Use_ACL_for_control_areas}.</td>
-                       <td>
-                               <select name="newsettings[acl_at_control_area]">
-                                       <option value="2" 
{selected_acl_at_control_area_2}>{lang_no}</option>
-                                       <option value="1" 
{selected_acl_at_control_area_1}>{lang_yes}</option>
-                               </select>
-                       </td>
-               </tr>
-               <tr class="row_off">
-                       <td>{lang_required_actual_hours}.</td>
-                       <td>
-                               <select 
name="newsettings[required_actual_hours]">
-                                       <option value="" 
{selected_required_actual_hours_}>{lang_no}</option>
-                                       <option value="1" 
{selected_required_actual_hours_1}>{lang_yes}</option>
-                               </select>
-                       </td>
-               </tr>
-               <tr class="row_on">
-                       <td>Antall planlagte kontroller som skal vises.</td>
-                       <td>
-                               <input type="text" 
name="newsettings[no_of_planned_controls]" 
value="{value_no_of_planned_controls}"/>
-                       </td>
-               </tr>
-               <tr class="row_off">
-                       <td>Antall tildelte kontroller som skal vises</td>
-                       <td>
-                               <input type="text" 
name="newsettings[no_of_assigned_controls]" 
value="{value_no_of_assigned_controls}"/>
-                       </td>
-               </tr>
-               <tr class="row_on">
-                       <td>{lang_home_alternative}</td>
-                       <td>
-                               <select name="newsettings[home_alternative]">
-                                       <option value="" 
{selected_home_alternative_}>{lang_no}</option>
-                                       <option value="1" 
{selected_home_alternative_1}>{lang_yes}</option>
-                               </select>
-                       </td>
-               </tr>
-                <tr class="row_off">
-                       <td>{lang_control_mandatory_location}</td>
-                       <td>
-                               <select 
name="newsettings[control_mandatory_location]">
-                                       <option value="" 
{selected_control_mandatory_location_}>{lang_no}</option>
-                                       <option value="1" 
{selected_control_mandatory_location_1}>{lang_yes}</option>
-                               </select>
-                       </td>
-               </tr>
-               <tr class="row_on">
-                       <td>{lang_document_category}:</td>
-                       <td>
-               <!--to be able to blank the setting - need an empty value-->
-               <input type = 'hidden' name="newsettings[document_cat][]" 
value="">
-                    <table>
+               <tr class="th">
+                       <td colspan="2"><font 
color="{th_text}">&nbsp;<b>{title}</b></font></td>
+               </tr>
+               <!-- END header -->
+               <!-- BEGIN body -->
+               <tr class="row_on">
+                       <td colspan="2">&nbsp;</td>
+               </tr>
+               <tr class="row_off">
+                       <td colspan="2">&nbsp;<b>{lang_controller} 
{lang_settings}</b></td>
+               </tr>
+               <tr class="row_on">
+                       <td>{lang_Use_ACL_for_control_areas}.</td>
+                       <td>
+                               <select name="newsettings[acl_at_control_area]">
+                                       <option value="2" 
{selected_acl_at_control_area_2}>{lang_no}</option>
+                                       <option value="1" 
{selected_acl_at_control_area_1}>{lang_yes}</option>
+                               </select>
+                       </td>
+               </tr>
+               <tr class="row_off">
+                       <td>{lang_required_actual_hours}.</td>
+                       <td>
+                               <select 
name="newsettings[required_actual_hours]">
+                                       <option value="" 
{selected_required_actual_hours_}>{lang_no}</option>
+                                       <option value="1" 
{selected_required_actual_hours_1}>{lang_yes}</option>
+                               </select>
+                       </td>
+               </tr>
+               <tr class="row_on">
+                       <td>Antall planlagte kontroller som skal vises.</td>
+                       <td>
+                               <input type="text" 
name="newsettings[no_of_planned_controls]" 
value="{value_no_of_planned_controls}"/>
+                       </td>
+               </tr>
+               <tr class="row_off">
+                       <td>Antall tildelte kontroller som skal vises</td>
+                       <td>
+                               <input type="text" 
name="newsettings[no_of_assigned_controls]" 
value="{value_no_of_assigned_controls}"/>
+                       </td>
+               </tr>
+               <tr class="row_on">
+                       <td>{lang_home_alternative}</td>
+                       <td>
+                               <select name="newsettings[home_alternative]">
+                                       <option value="" 
{selected_home_alternative_}>{lang_no}</option>
+                                       <option value="1" 
{selected_home_alternative_1}>{lang_yes}</option>
+                               </select>
+                       </td>
+               </tr>
+               <tr class="row_off">
+                       <td>{lang_control_mandatory_location}</td>
+                       <td>
+                               <select 
name="newsettings[control_mandatory_location]">
+                                       <option value="" 
{selected_control_mandatory_location_}>{lang_no}</option>
+                                       <option value="1" 
{selected_control_mandatory_location_1}>{lang_yes}</option>
+                               </select>
+                       </td>
+               </tr>
+               <tr class="row_on">
+                       <td>{lang_document_category}:</td>
+                       <td>
+                               <!--to be able to blank the setting - need an 
empty value-->
+                               <input type = 'hidden' 
name="newsettings[document_cat][]" value="">
+                               <table>
                                        {hook_document_cat}
-                        </table>
-                       </td>
-               </tr>
-
-               <!-- END body -->
-               <!-- BEGIN footer -->
-               <tr class="th">
-                       <td colspan="2">
-                               &nbsp;
-                       </td>
-               </tr>
-               <tr>
-                       <td colspan="2" align="center">
-                               <input type="submit" name="submit" 
value="{lang_submit}">
-                               <input type="submit" name="cancel" 
value="{lang_cancel}">
-                       </td>
-               </tr>
-       </table>
-</form>
-<!-- END footer -->
+                               </table>
+                       </td>
+               </tr>
+
+               <!-- END body -->
+               <!-- BEGIN footer -->
+               <tr class="th">
+                       <td colspan="2">
+                               &nbsp;
+                       </td>
+               </tr>
+               <tr>
+                       <td colspan="2" align="center">
+                               <input type="submit" name="submit" 
value="{lang_submit}">
+                               <input type="submit" name="cancel" 
value="{lang_cancel}">
+                       </td>
+               </tr>
+       </table>
+</form>
+<!-- END footer -->

Modified: branches/dev-syncromind-2/demo/inc/class.sodemo.inc.php
===================================================================
--- branches/dev-syncromind-2/demo/inc/class.sodemo.inc.php     2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/demo/inc/class.sodemo.inc.php     2016-05-30 
08:04:44 UTC (rev 15217)
@@ -60,7 +60,7 @@
                        $this->custom = createObject('property.custom_fields');
 
                        $GLOBALS['phpgw']->acl->set_account_id($this->account);
-                       $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('demo', $this->acl_location);
+                       $this->grants = 
$GLOBALS['phpgw']->acl->get_grants2('demo', $this->acl_location);
                }
 
                function read( $data )
@@ -83,15 +83,36 @@
 
                        if (!$filter)
                        {
-                               if (is_array($this->grants))
+                               $public_user_list = array();
+                               if (is_array($this->grants['accounts']) && 
$this->grants['accounts'])
                                {
-                                       while (list($user) = 
each($this->grants))
+                                       foreach($this->grants['accounts'] as 
$user => $_right)
                                        {
                                                $public_user_list[] = $user;
                                        }
+                                       unset($user);
                                        reset($public_user_list);
-                                       $filtermethod .= " $where ( 
$table.user_id IN(" . implode(',', $public_user_list) . "))";
+                                       $filtermethod .= " $where 
(({$table}.user_id IN(" . implode(',', $public_user_list) . ")";
+                                       $where = 'AND';
                                }
+
+                               $public_group_list = array();
+                               if (is_array($this->grants['groups']) && 
$this->grants['groups'])
+                               {
+                                       foreach($this->grants['groups'] as 
$user => $_right)
+                                       {
+                                               $public_group_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_group_list);
+                                       $where = $public_user_list ? 'OR' : 
$where;
+                                       $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
+                                       $where = 'AND';
+                               }
+                               if($public_user_list && !$public_group_list)
+                               {
+                                       $filtermethod .=')';
+                               }
                        }
                        else if ($filter == 'yours')
                        {
@@ -126,13 +147,19 @@
                                $querymethod = " $where name $this->like 
'%$query%'";
                        }
 
-                       $sql = "SELECT COUNT(phpgw_demo_table.id) as cnt FROM 
$table $filtermethod $querymethod";
+                       $sql = "SELECT COUNT(phpgw_demo_table.id) as cnt FROM 
$table"
+                               . " {$this->join} phpgw_accounts ON ( 
{$table}.user_id = phpgw_accounts.account_id)"
+                               . " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)"
+                               . " $filtermethod $querymethod";
 
                        $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
                        $this->total_records = $this->db->f('cnt');
 
-                       $sql = "SELECT * FROM $table $filtermethod $querymethod 
$ordermethod";
+                       $sql = "SELECT DISTINCT {$table}.* FROM {$table}"
+                               . " {$this->join} phpgw_accounts ON ( 
{$table}.user_id = phpgw_accounts.account_id)"
+                               . " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)"
+                               . " $filtermethod $querymethod $ordermethod";
 
                        if ($allrows)
                        {
@@ -151,7 +178,6 @@
                                        'id' => $this->db->f('id'),
                                        'name' => $this->db->f('name', true),
                                        'entry_date' => 
$this->db->f('entry_date'),
-                                       'grants' => 
(int)$this->grants[$this->db->f('user_id')]
                                );
                        }
 
@@ -184,15 +210,36 @@
 
                        if (!$filter)
                        {
-                               if (is_array($this->grants))
+                               $public_user_list = array();
+                               if (is_array($this->grants['accounts']) && 
$this->grants['accounts'])
                                {
-                                       while (list($user) = 
each($this->grants))
+                                       foreach($this->grants['accounts'] as 
$user => $_right)
                                        {
                                                $public_user_list[] = $user;
                                        }
+                                       unset($user);
                                        reset($public_user_list);
-                                       $filtermethod .= " $where ( 
$table.user_id IN(" . implode(',', $public_user_list) . "))";
+                                       $filtermethod .= " $where 
(({$table}.user_id IN(" . implode(',', $public_user_list) . ")";
+                                       $where = 'AND';
                                }
+
+                               $public_group_list = array();
+                               if (is_array($this->grants['groups']) && 
$this->grants['groups'])
+                               {
+                                       foreach($this->grants['groups'] as 
$user => $_right)
+                                       {
+                                               $public_group_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_group_list);
+                                       $where = $public_user_list ? 'OR' : 
$where;
+                                       $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
+                                       $where = 'AND';
+                               }
+                               if($public_user_list && !$public_group_list)
+                               {
+                                       $filtermethod .=')';
+                               }
                        }
                        else if ($filter == 'yours')
                        {
@@ -317,7 +364,10 @@
 
                        $this->uicols = $uicols;
 
-                       $sql = "SELECT COUNT(phpgw_demo_table.id) as cnt FROM 
$table $filtermethod $querymethod";
+                       $sql = "SELECT COUNT(phpgw_demo_table.id) as cnt FROM"
+                               . " {$this->join} phpgw_accounts ON ( 
{$table}.user_id = phpgw_accounts.account_id)"
+                               . " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)"
+                               . " $table $filtermethod $querymethod";
                        $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
                        $this->total_records = $this->db->f('cnt');
@@ -327,7 +377,10 @@
                                return array();
                        }
 
-                       $sql = "SELECT * FROM $table $filtermethod $querymethod 
$ordermethod";
+                       $sql = "SELECT DISTINCT {$table}.* FROM {$table}"
+                               . " {$this->join} phpgw_accounts ON ( 
{$table}.user_id = phpgw_accounts.account_id)"
+                               . " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)"
+                               . " $filtermethod $querymethod $ordermethod";
                        if ($allrows)
                        {
                                $this->db->query($sql, __LINE__, __FILE__);
@@ -382,7 +435,6 @@
                                $values['user_id'] = $this->db->f('user_id');
                                $values['cat_id'] = $this->db->f('category');
                                $values['access'] = $this->db->f('access');
-                               $values['grants'] = 
(int)$this->grants[$this->db->f('user_id')];
 
                                if (isset($values['attributes']) && 
is_array($values['attributes']))
                                {

Modified: branches/dev-syncromind-2/helpdesk/inc/class.sotts.inc.php
===================================================================
--- branches/dev-syncromind-2/helpdesk/inc/class.sotts.inc.php  2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/helpdesk/inc/class.sotts.inc.php  2016-05-30 
08:04:44 UTC (rev 15217)
@@ -121,28 +121,23 @@
                        $location_code  = isset($data['location_code']) ? 
$data['location_code'] : '';
                        $p_num                  = isset($data['p_num']) ? 
$data['p_num'] : '';
 
-                       $this->grants   = 
$GLOBALS['phpgw']->session->appsession('grants_ticket','helpdesk');
+                       $GLOBALS['phpgw']->acl->set_account_id($this->account);
+                       $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants2('helpdesk','.ticket');
 
-                       if(!$this->grants)
-                       {
-                               
$GLOBALS['phpgw']->acl->set_account_id($this->account);
-                               $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants('helpdesk','.ticket');
-                               
$GLOBALS['phpgw']->session->appsession('grants_ticket','helpdesk',$this->grants);
-                       }
+                       $order_join = "{$this->join} phpgw_accounts ON 
phpgw_helpdesk_tickets.user_id=phpgw_accounts.account_id";
 
                        $result_order_field = '';
                        if ($order)
                        {
                                if( $order == 'assignedto' )
                                {
-                                       $result_order_field = 
',account_lastname';
-                                       $order_join = "LEFT OUTER JOIN 
phpgw_accounts ON phpgw_helpdesk_tickets.assignedto=phpgw_accounts.account_id";
-                                       $order = 'account_lastname';
+//                                     $result_order_field = 
',account_lastname';
+//                                     $order_join = "LEFT OUTER JOIN 
phpgw_accounts ON phpgw_helpdesk_tickets.assignedto=phpgw_accounts.account_id";
+//                                     $order = 'account_lastname';
                                }
                                else if( $order == 'user' )
                                {
                                        $result_order_field = 
',account_lastname';
-                                       $order_join = "LEFT OUTER JOIN 
phpgw_accounts ON phpgw_helpdesk_tickets.user_id=phpgw_accounts.account_id";
                                        $order = 'account_lastname';
                                }
                                else
@@ -157,6 +152,8 @@
                                $ordermethod = ' ORDER BY 
phpgw_helpdesk_tickets.id DESC';
                        }
 
+                       $order_join .= " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)";
+
                        $filtermethod = '';
 
                        $categories = 
$GLOBALS['phpgw']->locations->get_subs('helpdesk', '.ticket.category');
@@ -195,14 +192,36 @@
 
                        if (is_array($this->grants))
                        {
-                               $grants = & $this->grants;
-                               foreach($grants as $user => $right)
+                               $public_user_list = array();
+                               if (is_array($this->grants['accounts']) && 
$this->grants['accounts'])
                                {
-                                       $public_user_list[] = $user;
+                                       foreach($this->grants['accounts'] as 
$user => $_right)
+                                       {
+                                               $public_user_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_user_list);
+                                       $filtermethod .= " $where 
((phpgw_helpdesk_tickets.user_id IN(" . implode(',', $public_user_list) . ")";
+                                       $where = 'AND';
                                }
-                               reset($public_user_list);
-                               $filtermethod .= " $where ( 
phpgw_helpdesk_tickets.user_id IN(" . implode(',',$public_user_list) . "))";
-                               $where= 'AND';
+
+                               $public_group_list = array();
+                               if (is_array($this->grants['groups']) && 
$this->grants['groups'])
+                               {
+                                       foreach($this->grants['groups'] as 
$user => $_right)
+                                       {
+                                               $public_group_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_group_list);
+                                       $where = $public_user_list ? 'OR' : 
$where;
+                                       $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
+                                       $where = 'AND';
+                               }
+                               if($public_user_list && !$public_group_list)
+                               {
+                                       $filtermethod .=')';
+                               }
                        }
 
                        if($tenant_id = 
$GLOBALS['phpgw']->session->appsession('tenant_id','helpdesk'))

Modified: branches/dev-syncromind-2/hrm/inc/class.bocommon.inc.php
===================================================================
--- branches/dev-syncromind-2/hrm/inc/class.bocommon.inc.php    2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/hrm/inc/class.bocommon.inc.php    2016-05-30 
08:04:44 UTC (rev 15217)
@@ -71,6 +71,32 @@
                        return ($rights & $required);
                }
 
+               /**
+                *
+                * @param integer $owner_id
+                * @param array $grants
+                * @param integer $required
+                * @return bool
+                */
+               function check_perms2( $owner_id, $grants,  $required )
+               {
+                       if(isset($grants['accounts'][$owner_id]) && 
($grants['accounts'][$owner_id] & $required))
+                       {
+                               return true;
+                       }
+
+                       $equalto = 
$GLOBALS['phpgw']->accounts->membership($owner_id);
+                       foreach($grants['groups'] as $group => $_right)
+                       {
+                               if(isset($equalto[$group]) && ($_right & 
$required))
+                               {
+                                       return true;
+                               }
+                       }
+
+                       return false;
+               }
+
                function create_preferences($app='',$user_id='')
                {
                        return 
$this->socommon->create_preferences($app,$user_id);

Modified: branches/dev-syncromind-2/hrm/inc/class.souser.inc.php
===================================================================
--- branches/dev-syncromind-2/hrm/inc/class.souser.inc.php      2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/hrm/inc/class.souser.inc.php      2016-05-30 
08:04:44 UTC (rev 15217)
@@ -30,7 +30,7 @@
                        $this->join             = & $this->db->join;
                        $this->left_join        = & $this->db->left_join;
                        $GLOBALS['phpgw']->acl->set_account_id($this->account);
-                       $this->grants           = 
$GLOBALS['phpgw']->acl->get_grants('hrm','.user');
+                       $this->grants           = 
$GLOBALS['phpgw']->acl->get_grants2('hrm','.user');
                }
 
                function read($data)
@@ -54,7 +54,6 @@
                        {
                                $account_info[] = array
                                (
-                                       'grants'                        => 
isset($this->grants[$entry->id]) ? $this->grants[$entry->id] : 0,
                                        'account_firstname'     => 
$entry->firstname,
                                        'account_lastname'      => 
$entry->lastname,
                                        'account_id'            => $entry->id

Modified: branches/dev-syncromind-2/hrm/inc/class.uiuser.inc.php
===================================================================
--- branches/dev-syncromind-2/hrm/inc/class.uiuser.inc.php      2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/hrm/inc/class.uiuser.inc.php      2016-05-30 
08:04:44 UTC (rev 15217)
@@ -76,7 +76,7 @@
                        $content = array();
                        foreach ( $account_info as $entry )
                        {
-                               if($entry['grants'])
+                               
if($this->bocommon->check_perms2($entry['account_id'], $this->grants, 
PHPGW_ACL_READ))
                                {
                                        $link_training                          
= $GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'hrm.uiuser.training', 'user_id'=> $entry['account_id']));
                                        $text_training                          
= lang('training');
@@ -182,9 +182,9 @@
                {
                        $user_id        = phpgw::get_var('user_id', 'int');
 
-                       if (!$this->grants[$user_id])
+                       if (!$this->bocommon->check_perms2($user_id, 
$this->grants, PHPGW_ACL_READ))
                        {
-                               $this->bocommon->no_access($links);
+                               phpgw::no_access();
                                return;
                        }
 
@@ -216,13 +216,13 @@
                                        $entry['end_date']      = 
$GLOBALS['phpgw']->common->show_date($entry['end_date'],$dateformat);
                                }
 
-                               
if($this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_EDIT))
+                               if($this->bocommon->check_perms2($user_id, 
$this->grants, PHPGW_ACL_EDIT))
                                {
                                        $link_edit      = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 'hrm.uiuser.edit', 
'user_id'=> $user_id, 'training_id'=> $entry['training_id']));
                                        $text_edit      = lang('edit');
                                        $lang_edit_text = lang('edit training 
item');
                                }
-                               
if($this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_DELETE))
+                               
if($this->bocommon->check_perms2($user_id,$this->grants, PHPGW_ACL_DELETE))
                                {
                                        $link_delete            = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 'hrm.uiuser.delete', 
'user_id'=> $user_id, 'training_id'=> $entry['training_id']));
                                        $text_delete            = 
lang('delete');
@@ -320,7 +320,7 @@
                                'user_id'       => $user_id
                        );
 
-                       
if($this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_ADD))
+                       if($this->bocommon->check_perms2($user_id, 
$this->grants, PHPGW_ACL_ADD))
                        {
                                $add_action     = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 'hrm.uiuser.edit', 
'user_id'=> $user_id));
                                $lang_add       = lang('add');
@@ -388,17 +388,17 @@
 
                        if(!$training_id)
                        {
-                               
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_ADD))
+                               if(!$this->bocommon->check_perms2($user_id, 
$this->grants, PHPGW_ACL_ADD))
                                {
-                                       $this->bocommon->no_access($links);
+                                       phpgw::no_access();
                                        return;
                                }
                        }
                        else
                        {
-                               
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_EDIT))
+                               if(!$this->bocommon->check_perms2($user_id, 
$this->grants, PHPGW_ACL_EDIT))
                                {
-                                       $this->bocommon->no_access($links);
+                                       phpgw::no_access();
                                        return;
                                }
                        }
@@ -605,9 +605,9 @@
                        $training_id            = phpgw::get_var('training_id', 
'int');
                        $user_id        = phpgw::get_var('user_id', 'int');
 
-                       
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_READ))
+                       if(!$this->bocommon->check_perms2($user_id, 
$this->grants, PHPGW_ACL_READ))
                        {
-                               $this->bocommon->no_access($links);
+                               phpgw::no_access();
                                return;
                        }
                        $GLOBALS['phpgw']->xslttpl->add_file(array('user'));
@@ -691,9 +691,9 @@
                        $training_id            = phpgw::get_var('training_id', 
'int');
                        $user_id        = phpgw::get_var('user_id', 'int');
 
-                       
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_DELETE))
+                       if(!$this->bocommon->check_perms2($user_id, 
$this->grants, PHPGW_ACL_DELETE))
                        {
-                               $this->bocommon->no_access($links);
+                               phpgw::no_access();
                                return;
                        }
                        $confirm = phpgw::get_var('confirm', 'bool', 'POST');
@@ -734,9 +734,9 @@
                {
                        $user_id        = phpgw::get_var('user_id', 'int');
 
-                       
if(!$this->bocommon->check_perms($this->grants[$user_id], PHPGW_ACL_READ))
+                       if(!$this->bocommon->check_perms2($user_id, 
$this->grants, PHPGW_ACL_READ))
                        {
-                               $this->bocommon->no_access($links);
+                               phpgw::no_access();
                                return;
                        }
 

Modified: branches/dev-syncromind-2/notes/inc/class.sonotes.inc.php
===================================================================
--- branches/dev-syncromind-2/notes/inc/class.sonotes.inc.php   2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/notes/inc/class.sonotes.inc.php   2016-05-30 
08:04:44 UTC (rev 15217)
@@ -41,7 +41,7 @@
                        $this->db               = &$GLOBALS['phpgw']->db;
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $GLOBALS['phpgw']->acl->set_account_id($this->account);
-                       $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants('notes');
+                       $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants2('notes');
                }
 
                function read($data)
@@ -72,20 +72,33 @@
                        if ($filter == 'none')
                        {
                                $filtermethod = ' ( note_owner = ' . 
$this->account;
-                               if (is_array($this->grants))
+                               $public_user_list = array();
+                               $grants = & $this->grants;
+                               if (is_array($grants['accounts']) && 
$grants['accounts'])
                                {
-                                       $grants = $this->grants;
-                                       while (list($user) = each($grants))
+                                       foreach($grants['accounts'] as $user => 
$_right)
                                        {
                                                $public_user_list[] = $user;
                                        }
                                        reset($public_user_list);
-                                       $filtermethod .= " OR 
(note_access='public' AND note_owner IN(" . implode(',',$public_user_list) . 
")))";
+                                       $filtermethod .= " OR 
(note_access='public' AND {$table}.note_owner IN(" . implode(',', 
$public_user_list) . "))";
                                }
-                               else
+                               $public_group_list = array();
+                               if (is_array($grants['groups']) && 
$grants['groups'])
                                {
-                                       $filtermethod .= ' )';
+                                       foreach($grants['groups'] as $user => 
$_right)
+                                       {
+                                               $public_group_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_group_list);
+                                       $filtermethod .= " OR 
note_access='public' AND phpgw_group_map.group_id IN(" . implode(',', 
$public_group_list) . "))";
+                                       $where = 'AND';
                                }
+                               if($public_user_list && !$public_group_list)
+                               {
+                                       $filtermethod .=')';
+                               }
                        }
                        elseif ($filter == 'yours')
                        {
@@ -117,11 +130,20 @@
                                $filtermethod .= " AND note_lastmod > $lastmod 
";
                        }
 
-                       $sql = "SELECT * FROM phpgw_notes WHERE $filtermethod 
$querymethod";
+                               $this->db->query("SELECT count(*) as cnt FROM 
phpgw_notes"
+                               . " {$this->join} phpgw_accounts ON ( 
{$table}.note_owner = phpgw_accounts.account_id)"
+                               . " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)"
+                               . " {$app_filter} {$filtermethod} 
{$querymethod}", __LINE__, __FILE__);
 
-                       $this->db->query($sql,__LINE__,__FILE__);
-                       $this->total_records = $this->db->num_rows();
+                               $this->db->next_record();
+                               $this->total_records = $this->db->f('cnt');
 
+
+                       $sql = "SELECT DISTINCT phpgw_notes.* FROM phpgw_notes"
+                               . " {$this->join} phpgw_accounts ON ( 
{$table}.note_owner = phpgw_accounts.account_id)"
+                               . " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)"
+                               . " WHERE $filtermethod $querymethod";
+
                        if($start)
                        {
                                $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
@@ -130,7 +152,6 @@
                        $notes = array();
                        while ($this->db->next_record())
                        {
-                               $ngrants = 
$this->grants[$this->db->f('note_owner')];
                                $id = $this->db->f('note_id');
                                $notes[$id] = array
                                (
@@ -141,7 +162,6 @@
                                        'date'          => 
$GLOBALS['phpgw']->common->show_date($this->db->f('note_date')),
                                        'cat_id'        => 
$this->db->f('note_category'),
                                        'content'       => 
$this->db->f('note_content', true),
-                                       'grants'        => $ngrants
                                );
                        }
                        return $notes;

Modified: branches/dev-syncromind-2/notes/inc/class.uinotes.inc.php
===================================================================
--- branches/dev-syncromind-2/notes/inc/class.uinotes.inc.php   2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/notes/inc/class.uinotes.inc.php   2016-05-30 
08:04:44 UTC (rev 15217)
@@ -67,8 +67,8 @@
                        $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
 
                        $GLOBALS['phpgw']->acl->set_account_id($this->account);
-                       $this->grants           = 
$GLOBALS['phpgw']->acl->get_grants('notes');
-                       $this->grants[$this->account] = PHPGW_ACL_READ + 
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
+//                     $this->grants           = 
$GLOBALS['phpgw']->acl->get_grants2('notes');
+//                     $this->grants['accounts'][$this->account] = 
PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
                        $this->bonotes          = 
CreateObject('notes.bonotes',true);
 
                        $this->start            = $this->bonotes->start;

Modified: branches/dev-syncromind-2/phpgwapi/inc/class.acl.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/class.acl.inc.php    2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/phpgwapi/inc/class.acl.inc.php    2016-05-30 
08:04:44 UTC (rev 15217)
@@ -1347,6 +1347,56 @@
                        return $grant_rights;
                }
                /**
+               * Get a list of users that have grants rights to their records 
at a location within an app
+               *
+               * @param string $app      Application name
+               *                               if emptry string, value of 
$GLOBALS['phpgw_info']['flags']['currentapp'] is used
+               * @param string $location location within application
+               *
+               * @return array Array with account ids and corresponding rights
+               */
+               public function get_grants2($app = '', $location = '')
+               {
+                       $grant_rights = phpgwapi_cache::session_get('phpgwapi', 
"get_grants2_{$app}_{$location}");
+                       if ( !is_null($grant_rights) )
+                       {
+                               return $grant_rights; // nothing more to do
+                       }
+
+                       $grant_rights   = $this->get_grants_type2($app, 
$location, 0);
+                       $grant_mask             = $this->get_grants_type2($app, 
$location, 1);
+                       if ( is_array($grant_mask['accounts']) )
+                       {
+                               foreach ( $grant_mask['accounts'] as $user_id 
=> $mask )
+                               {
+                                       if ( 
$grant_rights['accounts'][$user_id] )
+                                       {
+                                               
$grant_rights['accounts'][$user_id] &= (~ $mask);
+                                               if ( 
$grant_rights['accounts'][$user_id] <= 0 )
+                                               {
+                                                       
unset($grant_rights['accounts'][$user_id]);
+                                               }
+                                       }
+                               }
+                       }
+                       if ( is_array($grant_mask['groups']) )
+                       {
+                               foreach ( $grant_mask['groups'] as $user_id => 
$mask )
+                               {
+                                       if ( $grant_rights['groups'][$user_id] )
+                                       {
+                                               
$grant_rights['groups'][$user_id] &= (~ $mask);
+                                               if ( 
$grant_rights['groups'][$user_id] <= 0 )
+                                               {
+                                                       
unset($grant_rights['groups'][$user_id]);
+                                               }
+                                       }
+                               }
+                       }
+                       phpgwapi_cache::session_set('phpgwapi', 
"get_grants2_{$app}_{$location}", $grant_rights);
+                       return $grant_rights;
+               }
+               /**
                * Get application specific account based granted rights list
                *
                * @param string  $app      Application name
@@ -1358,6 +1408,143 @@
                *
                * @internal FIXME this should be simplified - if it is actually 
used
                */
+               public function get_grants_type2($app = '', $location = '', 
$mask = 0)
+               {
+                       $accounts = array();
+                       $groups = array();
+                       $grants =array(
+                               'accounts' => $accounts,
+                               'groups' => $groups
+                       );
+                       if(!$this->_account_id)
+                       {
+                               return array(
+                                               'accounts' => $accounts,
+                                               'groups' => $groups
+                                       );
+                       }
+
+                       if ( !$app )
+                       {
+                               $app = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       }
+
+                       $at_location = '';
+                       if ( $location )
+                       {
+                               $location = 
$this->_db->db_addslashes($location);
+                               $at_location = " AND phpgw_locations.name = 
'$location'";
+                       }
+
+                       $accts =& $GLOBALS['phpgw']->accounts;
+                       $acct_ids = 
array_keys($accts->membership($this->_account_id));
+                       $acct_ids[] = $this->_account_id;
+
+                       $rights = 0;
+
+                       $ids = implode(',', $acct_ids);
+                       $sql = 'SELECT acl_account, acl_grantor, acl_rights'
+                               . ' FROM phpgw_acl'
+                               . " {$this->_join} phpgw_locations ON 
phpgw_acl.location_id = phpgw_locations.location_id"
+                               . " {$this->_join} phpgw_applications ON 
phpgw_applications.app_id = phpgw_locations.app_id"
+                               . " WHERE phpgw_applications.app_name = '$app' 
$at_location"
+                                       . " AND acl_grantor > 0 AND acl_type = 
$mask"
+                                       . " AND acl_account IN ($ids)";
+
+                       $this->_db->query($sql, __LINE__, __FILE__);
+                       if ( $this->_db->num_rows() == 0 && $mask == 0  && 
isset($GLOBALS['phpgw_info']['user']['account_id']))
+                       {
+                               //return 
array($GLOBALS['phpgw_info']['user']['account_id'] => 31);
+                               return array(
+                                       'accounts' => 
array($GLOBALS['phpgw_info']['user']['account_id'] => 31),
+                                       'groups' => $groups
+                               );
+                       }
+
+                       $records = array();
+                       while ($this->_db->next_record())
+                       {
+                               $records[] = array
+                               (
+                                       'account'       => 
$this->_db->f('acl_account'),
+                                       'grantor'       => 
$this->_db->f('acl_grantor'),
+                                       'rights'        => 
$this->_db->f('acl_rights')
+                               );
+                       }
+
+                       foreach ($records as $record )
+                       {
+                               $grantor = $record['grantor'];
+                               $rights = $record['rights'];
+
+                               if( $grantor > 0 )
+                               {
+                                       if (!isset($accounts[$grantor]))
+                                       {
+                                               $is_group[$grantor] = 
$accts->get_type($grantor) == phpgwapi_account::TYPE_GROUP;
+                                               if ( !$is_group[$grantor] )
+                                               {
+                                                       $accounts[$grantor] = 
array($grantor);
+                                               }
+                                               else
+                                               {
+                                                       $groups[$grantor] = 
array($grantor);//$GLOBALS['phpgw']->accounts->get_members($grantor);
+                                               }
+                                       }
+
+                                       if ( $is_group[$grantor] )
+                                       {
+                                               // Don't allow to override 
private!
+                                               $rights &= (~ 
PHPGW_ACL_PRIVATE);
+                                               if ( 
!isset($grants['groups'][$grantor]) )
+                                               {
+                                                       
$grants['groups'][$grantor] = 0;
+                                               }
+
+                                               $grants['groups'][$grantor] |= 
$rights;
+                                               if ( !!($rights & self::READ) )
+                                               {
+                                                       
$grants['groups'][$grantor] |= self::READ;
+                                               }
+                                       }
+
+                                       foreach ( $accounts[$grantor] as 
$grantors )
+                                       {
+                                               if ( 
!isset($grants['accounts'][$grantors]) )
+                                               {
+                                                       
$grants['accounts'][$grantors] = 0;
+                                               }
+                                               $grants['accounts'][$grantors] 
|= $rights;
+                                       }
+                               }
+                       }
+
+                       if ( $mask == 0 && 
isset($GLOBALS['phpgw_info']['user']['account_id']))
+                       {
+                               
$grants['accounts'][$GLOBALS['phpgw_info']['user']['account_id']] = 31;
+                       }
+                       else
+                       {
+                               if ( 
isset($GLOBALS['phpgw_info']['user']['account_id']) && 
isset($grants['accounts'][$GLOBALS['phpgw_info']['user']['account_id']]) )
+                               {
+                                       unset 
($grants['accounts'][$GLOBALS['phpgw_info']['user']['account_id']]);
+                               }
+                       }
+
+                       return $grants;
+               }
+               /**
+               * Get application specific account based granted rights list
+               *
+               * @param string  $app      Application name
+               *                               if emptry string, value of 
$GLOBALS['phpgw_info']['flags']['currentapp'] is used
+               * @param string  $location location within application
+               * @param integer $mask     mask or right (1 means mask , 0 
means right) to check against
+               *
+               * @return array Associative array with granted access rights 
for accounts
+               *
+               * @internal FIXME this should be simplified - if it is actually 
used
+               */
                public function get_grants_type($app = '', $location = '', 
$mask = 0)
                {
                        $grants = array();

Modified: branches/dev-syncromind-2/phpgwapi/inc/class.jqcal.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/class.jqcal.inc.php  2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/phpgwapi/inc/class.jqcal.inc.php  2016-05-30 
08:04:44 UTC (rev 15217)
@@ -80,6 +80,10 @@
                                        buttonImage: "{$this->img_cal}",
                                        buttonText: "{$this->lang_select_date}",
                                        buttonImageOnly: true
+                               }).keyup(function(e) {
+                                       if(e.keyCode == 8 || e.keyCode == 46) {
+                                               $.datepicker._clearDate(this);
+                                       }
                                });
                            $('#ui-datepicker-div').draggable();
                        });

Modified: branches/dev-syncromind-2/phpgwapi/inc/class.phpgw.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/class.phpgw.inc.php  2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/phpgwapi/inc/class.phpgw.inc.php  2016-05-30 
08:04:44 UTC (rev 15217)
@@ -604,12 +604,19 @@
                         */
                        public static function no_access($appname = '', 
$message = '')
                        {
-                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
false;
                                $message = $message ? $message : lang('no 
access');
-                               $appname = $appname ? $appname : 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                               phpgwapi_cache::message_set($message, 'error');
-                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($appname) . '::' . lang('No access');
-                               $GLOBALS['phpgw']->common->phpgw_header(true);
+                               if (phpgw::get_var('phpgw_return_as') == 'json')
+                               {
+                                       echo $message;
+                               }
+                               else
+                               {
+                                       phpgwapi_cache::message_set($message, 
'error');
+                                       $appname = $appname ? $appname : 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                                       
$GLOBALS['phpgw_info']['flags']['app_header'] = lang($appname) . '::' . 
lang('No access');
+                                       
$GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+                                       
$GLOBALS['phpgw']->common->phpgw_header(true);
+                               }
                                $GLOBALS['phpgw']->common->phpgw_exit();
                        }
                }

Modified: branches/dev-syncromind-2/phpgwapi/js/jquery/common.js
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/common.js      2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/common.js      2016-05-30 
08:04:44 UTC (rev 15217)
@@ -347,9 +347,9 @@
 
        if (buttons_def)
        {
-               var sDom_def = 'B<"clear">lfrtip';
-//             var sDom_def = 'Bfrtlip';
-               var sDom_def = '<lfB<t>ip>'
+//             var sDom_def = 'B<"clear">lfrtip';
+               var sDom_def = 'Bfrtlip';
+//             var sDom_def = '<lfB<t>ip>'
                if (singleSelect == true)
                {
                        select = true;
@@ -370,7 +370,7 @@
        var oTable = $("#" + container).dataTable({
                paginate: disablePagination ? false : true,
                filter: disableFilter ? false : true,
-               info: disableFilter ? false : true,
+               info: disablePagination ? false : true,
                order: order,
                processing: true,
                serverSide: serverSide_def,
@@ -599,11 +599,25 @@
 };
 
 
-JqueryPortico.autocompleteHelper = function (baseUrl, field, hidden, 
container, label_attr)
+JqueryPortico.autocompleteHelper = function (baseUrl, field, hidden, 
container, label_attr, show_id, requestGenerator)
 {
+       show_id = show_id ? true : false;
+       requestGenerator = requestGenerator || false;
        label_attr = (label_attr) ? label_attr : 'name';
        $(document).ready(function ()
        {
+               if(requestGenerator)
+               {
+                       try
+                       {
+                               baseUrl = window[requestGenerator](baseUrl);
+                       }
+                       catch(err)
+                       {
+
+                       }
+               }
+
                $("#" + field).autocomplete({
                        source: function (request, response)
                        {
@@ -629,8 +643,17 @@
                                                }
                                                response($.map(data_t, function 
(item)
                                                {
+                                                       if(show_id)
+                                                       {
+                                                               label = item.id 
+ ' ' + item[label_attr];                                       
+                                                       }
+                                                       else
+                                                       {
+                                                               label = 
item[label_attr];
+                                                       }
+
                                                        return {
-                                                               label: 
item[label_attr],
+                                                               label: label,
                                                                value: item.id
                                                        };
                                                }));

Modified: branches/dev-syncromind-2/phpgwapi/setup/phpgw_en.lang
===================================================================
--- branches/dev-syncromind-2/phpgwapi/setup/phpgw_en.lang      2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/phpgwapi/setup/phpgw_en.lang      2016-05-30 
08:04:44 UTC (rev 15217)
@@ -550,4 +550,12 @@
 zambia common  en      ZAMBIA
 zimbabwe       common  en      ZIMBABWE
 browser not supported  common  en      The browser seems to not support HTML5
-no access      common  en      No Access
\ No newline at end of file
+no access      common  en      No Access
+No data available in table     common  en      No data available in table
+Showing _START_ to _END_ of _TOTAL_ entries    common  en      Showing _START_ 
to _END_ of _TOTAL_ entries
+Showing 0 to 0 of 0 entries    common  en      Showing 0 to 0 of 0 entries
+filtered from _MAX_ total entries      common  en      filtered from _MAX_ 
total entries
+Show _MENU_ entries    common  en      Show _MENU_ entries
+Loading...     common  en      Loading...
+Processing...  common  en      Processing...
+No matching records found      common  en      No matching records found

Modified: branches/dev-syncromind-2/phpgwapi/templates/base/datatable_jquery.xsl
===================================================================
--- branches/dev-syncromind-2/phpgwapi/templates/base/datatable_jquery.xsl      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/phpgwapi/templates/base/datatable_jquery.xsl      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -154,8 +154,20 @@
                                                                                
<script type="text/javascript">
                                                                                
        $(document).ready(function() {
                                                                                
        var app = "<xsl:value-of select="app"/>";
+                                                                               
        app = app || 'booking';
+                                                                               
        var label_attr = "<xsl:value-of select="label_attr"/>";
+                                                                               
        label_attr = label_attr || 'name';
+                                                                               
        var show_id =  false;
+                                                                               
        <xsl:if test="show_id = 1">
+                                                                               
                show_id = true;
+                                                                               
        </xsl:if>
+
                                                                                
        var name = "<xsl:value-of select="name"/>";
                                                                                
        var ui = "<xsl:value-of select="ui"/>";
+                                                                               
        var requestGenerator = false;
+                                                                               
        <xsl:if test="requestGenerator">
+                                                                               
                requestGenerator = '<xsl:value-of select="requestGenerator"/>';
+                                                                               
        </xsl:if>
                                                                                
        var depends = false;
                                                                                
        var filter_depends = "";
                                                                                
        var filter_selected = "";
@@ -168,8 +180,8 @@
                                                                                
                if (filter_select != filter_selected){
                                                                                
                if (filter_depends) {
                                                                                
                        <![CDATA[
-                                                                               
                                        
JqueryPortico.autocompleteHelper('index.php?menuaction=booking.ui'+ui+'.index&phpgw_return_as=json&filter_'+depends+'_id='+filter_depends+'&',
-                                                                               
                                                                                
                                        'filter_'+name+'_name', 
'filter_'+name+'_id', 'filter_'+name+'_container');
+                                                                               
                                        
JqueryPortico.autocompleteHelper('index.php?menuaction=' + app + 
'.ui'+ui+'.index&filter_'+depends+'_id='+filter_depends+'&',
+                                                                               
                                                                                
                                        'filter_'+name+'_name', 
'filter_'+name+'_id', 'filter_'+name+'_container', label_attr, show_id, 
requestGenerator);
                                                                                
                        ]]>
                                                                                
                }
                                                                                
                
oTable.dataTableSettings[0]['ajax']['data']['filter_'+name+'_id'] = "";
@@ -183,8 +195,8 @@
                                                                                
                filter_depends = false;
                                                                                
                if (!filter_depends) {
                                                                                
                                        <![CDATA[
-                                                                               
                                                
JqueryPortico.autocompleteHelper('index.php?menuaction=booking.ui'+ui+'.index&phpgw_return_as=json&',
-                                                                               
                                                                                
                                        'filter_'+name+'_name', 
'filter_'+name+'_id', 'filter_'+name+'_container');
+                                                                               
                                                
JqueryPortico.autocompleteHelper('index.php?menuaction=' + app + 
'.ui'+ui+'.index&',
+                                                                               
                                                                                
                                        'filter_'+name+'_name', 
'filter_'+name+'_id', 'filter_'+name+'_container', label_attr, show_id, 
requestGenerator);
                                                                                
                                        ]]>
                                                                                
                }
                                                                                
                filter_selected = "";
@@ -196,13 +208,13 @@
                                                                                
        </xsl:if>
                                                                                
        if (filter_depends) {
                                                                                
                        <![CDATA[
-                                                                               
                                
JqueryPortico.autocompleteHelper('index.php?menuaction=booking.ui'+ui+'.index&phpgw_return_as=json&filter_'+depends+'_id='+filter_depends+'&',
-                                                                               
                                                                                
                        'filter_'+name+'_name', 'filter_'+name+'_id', 
'filter_'+name+'_container');
+                                                                               
                                
JqueryPortico.autocompleteHelper('index.php?menuaction=' + app + 
'.ui'+ui+'.index&filter_'+depends+'_id='+filter_depends+'&',
+                                                                               
                                                                                
                        'filter_'+name+'_name', 'filter_'+name+'_id', 
'filter_'+name+'_container', label_attr, show_id, requestGenerator);
                                                                                
                        ]]>
                                                                                
        }else{
                                                                                
                        <![CDATA[
-                                                                               
                                
JqueryPortico.autocompleteHelper('index.php?menuaction=booking.ui'+ui+'.index&phpgw_return_as=json&',
-                                                                               
                                                                                
                        'filter_'+name+'_name', 'filter_'+name+'_id', 
'filter_'+name+'_container');
+                                                                               
                                
JqueryPortico.autocompleteHelper('index.php?menuaction=' + app + 
'.ui'+ui+'.index&',
+                                                                               
                                                                                
                        'filter_'+name+'_name', 'filter_'+name+'_id', 
'filter_'+name+'_container', label_attr, show_id, requestGenerator);
                                                                                
                        ]]>
                                                                                
        }
                                                                                
        });

Modified: branches/dev-syncromind-2/preferences/changepassword.php
===================================================================
--- branches/dev-syncromind-2/preferences/changepassword.php    2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/preferences/changepassword.php    2016-05-30 
08:04:44 UTC (rev 15217)
@@ -20,8 +20,8 @@
         */
        include('../header.inc.php');
 
-       $n_passwd   = isset($_POST['n_passwd']) && $_POST['n_passwd'] ? 
$_POST['n_passwd'] : '';
-       $n_passwd_2 = isset($_POST['n_passwd_2']) && $_POST['n_passwd_2'] ? 
$_POST['n_passwd_2'] : '';
+       $n_passwd   = isset($_POST['n_passwd']) && $_POST['n_passwd'] ? 
html_entity_decode(phpgw::get_var('n_passwd', 'string', 'POST')) : '';
+       $n_passwd_2 = isset($_POST['n_passwd_2']) && $_POST['n_passwd_2'] ? 
html_entity_decode(phpgw::get_var('n_passwd_2', 'string', 'POST')) : '';
 
        if (! $GLOBALS['phpgw']->acl->check('changepassword', 1, 'preferences') 
|| (isset($_POST['cancel']) && $_POST['cancel']))
        {

Modified: branches/dev-syncromind-2/property/inc/class.boadmin_entity.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boadmin_entity.inc.php 
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boadmin_entity.inc.php 
2016-05-30 08:04:44 UTC (rev 15217)
@@ -84,7 +84,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true,
                        'get_category_list' => true,
                        'get_attrib_list' => true
                );

Modified: branches/dev-syncromind-2/property/inc/class.boadmin_location.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boadmin_location.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boadmin_location.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -50,7 +50,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.boagreement.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boagreement.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boagreement.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -53,7 +53,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )
@@ -128,10 +127,6 @@
                        $this->status_id = $data['status_id'];
                }
 
-               function check_perms( $has, $needed )
-               {
-                       return (!!($has & $needed) == true);
-               }
 
                function select_vendor_list( $format = '', $selected = '' )
                {

Modified: branches/dev-syncromind-2/property/inc/class.boasync.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boasync.inc.php        
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boasync.inc.php        
2016-05-30 08:04:44 UTC (rev 15217)
@@ -47,7 +47,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.bobudget.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bobudget.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bobudget.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -58,7 +58,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )
@@ -145,11 +144,6 @@
                        $this->direction = isset($data['direction']) ? 
$data['direction'] : '';
                }
 
-               function check_perms( $has, $needed )
-               {
-                       return (!!($has & $needed) == true);
-               }
-
                function read( $data = array() )
                {
                        /* $budget = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,

Modified: branches/dev-syncromind-2/property/inc/class.bocommon.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bocommon.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bocommon.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -76,6 +76,32 @@
                        return ($rights & $required);
                }
 
+               /**
+                *
+                * @param integer $owner_id
+                * @param array $grants
+                * @param integer $required
+                * @return bool
+                */
+               function check_perms2( $owner_id, $grants,  $required )
+               {
+                       if(isset($grants['accounts'][$owner_id]) && 
($grants['accounts'][$owner_id] & $required))
+                       {
+                               return true;
+                       }
+
+                       $equalto = 
$GLOBALS['phpgw']->accounts->membership($owner_id);
+                       foreach($grants['groups'] as $group => $_right)
+                       {
+                               if(isset($equalto[$group]) && ($_right & 
$required))
+                               {
+                                       return true;
+                               }
+                       }
+
+                       return false;
+               }
+
                function create_preferences( $app = '', $user_id = '' )
                {
                        return $this->socommon->create_preferences($app, 
$user_id);

Modified: branches/dev-syncromind-2/property/inc/class.bocustom.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bocustom.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bocustom.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -46,7 +46,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )
@@ -126,11 +125,6 @@
                        $this->cat_id = $data['cat_id'];
                }
 
-               function check_perms( $has, $needed )
-               {
-                       return (!!($has & $needed) == true);
-               }
-
                function read( $data = array() )
                {
                        /* $custom = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,

Modified: branches/dev-syncromind-2/property/inc/class.bodocument.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bodocument.inc.php     
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bodocument.inc.php     
2016-05-30 08:04:44 UTC (rev 15217)
@@ -52,7 +52,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.boentity.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boentity.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boentity.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -64,7 +64,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true,
                        'add_control' => true,
                        'update_control_serie' => true
                );

Modified: branches/dev-syncromind-2/property/inc/class.bogab.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bogab.inc.php  2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bogab.inc.php  2016-05-30 
08:04:44 UTC (rev 15217)
@@ -47,7 +47,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.boifc.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boifc.inc.php  2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boifc.inc.php  2016-05-30 
08:04:44 UTC (rev 15217)
@@ -53,7 +53,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )
@@ -152,11 +151,6 @@
                        $this->cat_id = (isset($data['cat_id']) ? 
$data['cat_id'] : '');
                }
 
-               function check_perms( $rights, $required )
-               {
-                       return ($rights & $required);
-               }
-
                function import( $values = '', $ifcfile = '' )
                {
                        _debug_array($ifcfile);

Modified: branches/dev-syncromind-2/property/inc/class.boinvestment.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boinvestment.inc.php   
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boinvestment.inc.php   
2016-05-30 08:04:44 UTC (rev 15217)
@@ -49,7 +49,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.bolocation.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bolocation.inc.php     
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bolocation.inc.php     
2016-05-30 08:04:44 UTC (rev 15217)
@@ -56,7 +56,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true,
                        'get_locations_by_name' => true
                );
 

Modified: branches/dev-syncromind-2/property/inc/class.bopricebook.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bopricebook.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bopricebook.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -47,7 +47,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.boproject.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boproject.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boproject.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -51,7 +51,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )
@@ -386,10 +385,10 @@
                        $criteria[1] = array
                                (
                                'field' => 'external_project_id',
-                               'type' => 'int',
+                               'type' => 'varchar',
                                'matchtype' => 'exact',
-                               'front' => '',
-                               'back' => ''
+                               'front' => "'",
+                               'back' => "'"
                        );
                        $criteria[2] = array
                                (

Modified: branches/dev-syncromind-2/property/inc/class.borequest.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.borequest.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.borequest.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -53,7 +53,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.bos_agreement.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bos_agreement.inc.php  
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bos_agreement.inc.php  
2016-05-30 08:04:44 UTC (rev 15217)
@@ -55,7 +55,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )
@@ -128,11 +127,6 @@
                        $this->status_id = $data['status_id'];
                }
 
-               function check_perms( $has, $needed )
-               {
-                       return (!!($has & $needed) == true);
-               }
-
                function select_vendor_list( $format = '', $selected = '' )
                {
                        switch ($format)

Modified: branches/dev-syncromind-2/property/inc/class.botemplate.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.botemplate.inc.php     
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.botemplate.inc.php     
2016-05-30 08:04:44 UTC (rev 15217)
@@ -46,7 +46,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.botenant_claim.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.botenant_claim.inc.php 
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.botenant_claim.inc.php 
2016-05-30 08:04:44 UTC (rev 15217)
@@ -132,11 +132,6 @@
                        $this->district_id = isset($data['district_id']) ? 
$data['district_id'] : '';
                }
 
-               function check_perms( $has, $needed )
-               {
-                       return (!!($has & $needed) == true);
-               }
-
                function get_status_list( $data = 0 )
                {
                        if (is_array($data))

Modified: branches/dev-syncromind-2/property/inc/class.bowo_hour.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.bowo_hour.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.bowo_hour.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -46,7 +46,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true
                );
 
                function __construct( $session = false )

Modified: branches/dev-syncromind-2/property/inc/class.boworkorder.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.boworkorder.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.boworkorder.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -49,7 +49,6 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'check_perms' => true,
                        'get_category' => true
                );
 
@@ -337,10 +336,10 @@
                        $criteria[1] = array
                                (
                                'field' => 'external_project_id',
-                               'type' => 'int',
+                               'type' => 'varchar',
                                'matchtype' => 'exact',
-                               'front' => '',
-                               'back' => ''
+                               'front' => "'",
+                               'back' => "'"
                        );
                        $criteria[2] = array
                                (

Modified: branches/dev-syncromind-2/property/inc/class.soagreement.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.soagreement.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.soagreement.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -212,28 +212,6 @@
 
                        $where = 'WHERE';
 
-                       /*                      if ($filter=='all')
-                         {
-                         if (is_array($grants))
-                         {
-                         while (list($user) = each($grants))
-                         {
-                         $public_user_list[] = $user;
-                         }
-                         reset($public_user_list);
-                         $filtermethod .= " $where ( $entity_table.user_id 
IN(" . implode(',',$public_user_list) . "))";
-
-                         $where= 'AND';
-                         }
-
-                         }
-                         else
-                         {
-                         $filtermethod = " $where 
$entity_table.user_id=$filter ";
-                         $where= 'AND';
-                         }
-                        */
-
                        if ($agreement_id)
                        {
                                $filtermethod .= " $where 
$entity_table.agreement_id=$agreement_id";
@@ -319,7 +297,6 @@
                                for ($i = 0; $i < $n; $i++)
                                {
                                        $agreement_list[$j][$cols_return[$i]] = 
$this->db->f($cols_return[$i]);
-                                       $agreement_list[$j]['grants'] = 
(int)isset($grants[$this->db->f('user_id')]) ? $grants[$this->db->f('user_id')] 
: '';
                                }
 
                                if (isset($cols_return_extra) && 
is_array($cols_return_extra))

Modified: branches/dev-syncromind-2/property/inc/class.socustom.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.socustom.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.socustom.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -322,7 +322,6 @@
                                for ($i = 0; $i < $n; $i++)
                                {
                                        $custom[$j][$uicols[$i]['name']] = 
$this->db->f($uicols[$i]['name']);
-                                       $custom[$j]['grants'] = 
(int)$grants[$this->db->f('user_id')];
                                }
                                $j++;
                        }

Modified: branches/dev-syncromind-2/property/inc/class.soentity.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.soentity.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.soentity.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -126,16 +126,10 @@
                        {
                                return;
                        }
+               
+                       $acl = & $GLOBALS['phpgw']->acl;
+                       $grants = 
$acl->get_grants2($this->type_app[$this->type], 
".{$this->type}.{$entity_id}.{$cat_id}");
 
-                       $grants = 
$GLOBALS['phpgw']->session->appsession('grants_entity_' . $entity_id . '_' . 
$cat_id, $this->type_app[$this->type]);
-
-                       if (!$grants)
-                       {
-                               $this->acl = & $GLOBALS['phpgw']->acl;
-                               $grants = 
$this->acl->get_grants($this->type_app[$this->type], 
".{$this->type}.{$entity_id}.{$cat_id}");
-                               
$GLOBALS['phpgw']->session->appsession('grants_entity_' . $entity_id . '_' . 
$cat_id, $this->type_app[$this->type], $grants);
-                       }
-
                        $admin_entity = CreateObject('property.soadmin_entity');
                        $admin_entity->type = $this->type;
 
@@ -179,17 +173,38 @@
 
                        if ($filter == 'all')
                        {
-                               if (is_array($grants))
+                               $public_user_list = array();
+                               if (is_array($grants['accounts']) && 
$grants['accounts'])
                                {
-                                       foreach ($grants as $user => $right)
+                                       foreach ($grants['accounts'] as $user 
=> $right)
                                        {
                                                $public_user_list[] = $user;
                                        }
+                                       unset($user);
+
                                        reset($public_user_list);
-                                       $filtermethod .= " $where ( 
$entity_table.user_id IN(" . implode(',', $public_user_list) . "))";
+                                       $filtermethod .= " $where ( 
$entity_table.user_id IN(" . implode(',', $public_user_list) . ")";
 
                                        $where = 'AND';
                                }
+
+                               $public_group_list = array();
+                               if (is_array($grants['groups']) && 
$grants['groups'])
+                               {
+                                       foreach($grants['groups'] as $user => 
$_right)
+                                       {
+                                               $public_group_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_group_list);
+                                       $where = $public_user_list ? 'OR' : 
$where;
+                                       $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
+                                       $where = 'AND';
+                               }
+                               if($public_user_list && !$public_group_list)
+                               {
+                                       $filtermethod .=')';
+                               }
                        }
                        else
                        {
@@ -198,7 +213,10 @@
                        }
                        $values = array();
                        $name = 'title';
-                       $sql = "SELECT id, {$name} as name FROM {$entity_table} 
{$filtermethod}";
+                       $sql = "SELECT id, {$name} as name FROM {$entity_table}"
+                               . " {$this->join} phpgw_accounts ON 
$entity_table.user_id = phpgw_accounts.account_id"
+                               . " {$this->join} phpgw_group_map ON 
phpgw_accounts.account_id = phpgw_group_map.account_id"
+                               . " {$filtermethod}";
 
                        $this->db->query($sql, __LINE__, __FILE__);
                        while ($this->db->next_record())
@@ -465,17 +483,11 @@
                        {
                                $location_id = 
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], 
".{$this->type}.{$entity_id}.{$cat_id}");
                        }
+               
+                       $acl = & $GLOBALS['phpgw']->acl;
+                       $acl->set_account_id($this->account);
+                       $grants = 
$acl->get_grants2($this->type_app[$this->type], 
".{$this->type}.{$entity_id}.{$cat_id}");
 
-                       $grants = 
$GLOBALS['phpgw']->session->appsession("grants_entity_{$entity_id}_{$cat_id}", 
$this->type_app[$this->type]);
-
-                       if (!$grants)
-                       {
-                               $this->acl = & $GLOBALS['phpgw']->acl;
-                               $this->acl->set_account_id($this->account);
-                               $grants = 
$this->acl->get_grants($this->type_app[$this->type], 
".{$this->type}.{$entity_id}.{$cat_id}");
-                               
$GLOBALS['phpgw']->session->appsession("grants_entity_{$entity_id}_{$cat_id}", 
$this->type_app[$this->type], $grants);
-                       }
-
                        $admin_entity = CreateObject('property.soadmin_entity');
                        $admin_entity->type = $this->type;
 
@@ -529,17 +541,38 @@
 
                        if ($filter == 'all')
                        {
-                               if (is_array($grants) && !$bypass_acl_at_entity)
+                               $public_user_list = array();
+                               if (!$bypass_acl_at_entity && 
is_array($grants['accounts']) && $grants['accounts'])
                                {
-                                       foreach ($grants as $user => $right)
+                                       foreach ($grants['accounts'] as $user 
=> $right)
                                        {
                                                $public_user_list[] = $user;
                                        }
+                                       unset($user);
+
                                        reset($public_user_list);
-                                       $filtermethod .= " $where ( 
$entity_table.user_id IN(" . implode(',', $public_user_list) . "))";
+                                       $filtermethod .= " $where ( 
$entity_table.user_id IN(" . implode(',', $public_user_list) . ")";
 
                                        $where = 'AND';
                                }
+
+                               $public_group_list = array();
+                               if (!$bypass_acl_at_entity && 
is_array($grants['groups']) && $grants['groups'])
+                               {
+                                       foreach($grants['groups'] as $user => 
$_right)
+                                       {
+                                               $public_group_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_group_list);
+                                       $where = $public_user_list ? 'OR' : 
$where;
+                                       $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
+                                       $where = 'AND';
+                               }
+                               if($public_user_list && !$public_group_list)
+                               {
+                                       $filtermethod .=')';
+                               }
                        }
                        else
                        {
@@ -743,7 +776,9 @@
                                }
                        }
 
-                       $sql = "SELECT fm_bim_item.* __XML-ORDER__ FROM 
fm_bim_item {$this->join} fm_bim_type ON (fm_bim_item.type = fm_bim_type.id)";
+                       $sql = "SELECT fm_bim_item.* __XML-ORDER__ FROM 
fm_bim_item {$this->join} fm_bim_type ON (fm_bim_item.type = fm_bim_type.id)"
+                               . " {$this->join} phpgw_accounts ON 
$entity_table.user_id = phpgw_accounts.account_id"
+                               . " {$this->join} phpgw_group_map ON 
phpgw_accounts.account_id = phpgw_group_map.account_id ";
                        $join_control = "controller_control_component_list ON 
(fm_bim_item.id = controller_control_component_list.component_id  AND 
controller_control_component_list.location_id = fm_bim_type.location_id)";
 
                        if ($control_registered)
@@ -1436,17 +1471,11 @@
                        {
                                return;
                        }
+               
+                       $acl = & $GLOBALS['phpgw']->acl;
+                       $acl->set_account_id($this->account);
+                       $grants = 
$acl->get_grants2($this->type_app[$this->type], 
".{$this->type}.{$entity_id}.{$cat_id}");
 
-                       $grants = 
$GLOBALS['phpgw']->session->appsession("grants_entity_{$entity_id}_{$cat_id}", 
$this->type_app[$this->type]);
-
-                       if (!$grants)
-                       {
-                               $this->acl = & $GLOBALS['phpgw']->acl;
-                               $this->acl->set_account_id($this->account);
-                               $grants = 
$this->acl->get_grants($this->type_app[$this->type], 
".{$this->type}.{$entity_id}.{$cat_id}");
-                               
$GLOBALS['phpgw']->session->appsession("grants_entity_{$entity_id}_{$cat_id}", 
$this->type_app[$this->type], $grants);
-                       }
-
                        //_debug_array($cols_return_extra);
 
                        if ($order)
@@ -1502,17 +1531,38 @@
 
                        if ($filter == 'all')
                        {
-                               if (is_array($grants) && !$bypass_acl_at_entity)
+                               $public_user_list = array();
+                               if (!$bypass_acl_at_entity && 
is_array($grants['accounts']) && $grants['accounts'])
                                {
-                                       foreach ($grants as $user => $right)
+                                       foreach ($grants['accounts'] as $user 
=> $right)
                                        {
                                                $public_user_list[] = $user;
                                        }
+                                       unset($user);
+
                                        reset($public_user_list);
-                                       $filtermethod .= " $where ( 
$entity_table.user_id IN(" . implode(',', $public_user_list) . "))";
+                                       $filtermethod .= " $where ( 
$entity_table.user_id IN(" . implode(',', $public_user_list) . ")";
 
                                        $where = 'AND';
                                }
+
+                               $public_group_list = array();
+                               if (!$bypass_acl_at_entity && 
is_array($grants['groups']) && $grants['groups'])
+                               {
+                                       foreach($grants['groups'] as $user => 
$_right)
+                                       {
+                                               $public_group_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_group_list);
+                                       $where = $public_user_list ? 'OR' : 
$where;
+                                       $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
+                                       $where = 'AND';
+                               }
+                               if($public_user_list && !$public_group_list)
+                               {
+                                       $filtermethod .=')';
+                               }
                        }
                        else
                        {
@@ -1707,9 +1757,11 @@
                        }
 
                        $_joinmethod_datatype = 
array_merge($_joinmethod_datatype, $_joinmethod_datatype_custom);
+                       $_joinmethod_datatype[] = " {$this->join} 
phpgw_accounts ON $entity_table.user_id = phpgw_accounts.account_id"
+                               . " {$this->join} phpgw_group_map ON 
phpgw_accounts.account_id = phpgw_group_map.account_id ";
                        foreach ($_joinmethod_datatype as $_joinmethod)
                        {
-                               $sql .= $_joinmethod;
+                               $sql .= " {$_joinmethod}";
                        }
 
                        $querymethod = '';

Modified: branches/dev-syncromind-2/property/inc/class.sojasper.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.sojasper.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.sojasper.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -41,7 +41,7 @@
                        $this->join = & $this->db->join;
                        $this->like = & $this->db->like;
                        $GLOBALS['phpgw']->acl->set_account_id($this->account);
-                       $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('property', '.jasper');
+                       $this->grants = 
$GLOBALS['phpgw']->acl->get_grants2('property', '.jasper');
                }
 
                public function read( $data )
@@ -75,20 +75,34 @@
                        }
 
 
-                       $filtermethod = "WHERE ( {$table}.user_id = 
{$this->account}";
-                       if (is_array($grants))
+                       $filtermethod = "WHERE {$table}.user_id = 
{$this->account}";
+                       $public_user_list = array();
+                       if (is_array($grants['accounts']) && 
$grants['accounts'])
                        {
-                               foreach ($grants as $user => $right)
+                               foreach($grants['accounts'] as $user => $_right)
                                {
                                        $public_user_list[] = $user;
                                }
                                reset($public_user_list);
-                               $filtermethod .= " OR (access='public' AND 
{$table}.user_id IN(" . implode(',', $public_user_list) . ")))";
+                               $filtermethod .= " OR (access='public' AND 
{$table}.user_id IN(" . implode(',', $public_user_list) . ")";
                        }
-                       else
+
+                       $public_group_list = array();
+                       if (is_array($grants['groups']) && $grants['groups'])
                        {
-                               $filtermethod .= ' )';
+                               foreach($grants['groups'] as $user => $_right)
+                               {
+                                       $public_group_list[] = $user;
+                               }
+                               unset($user);
+                               reset($public_group_list);
+                               $filtermethod .= " OR access='public' AND 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
+                               $where = 'AND';
                        }
+                       if($public_user_list && !$public_group_list)
+                       {
+                               $filtermethod .=')';
+                       }
 
                        if ($location_id)
                        {
@@ -101,11 +115,17 @@
                                $querymethod = "AND (title {$this->like} 
'%{$query}%' OR descr {$this->like} '%{$query}%')";
                        }
 
-                       $sql = "SELECT * FROM {$table} {$app_filter} 
{$filtermethod} {$querymethod}";
+                       $sql = "SELECT DISTINCT {$table}.* FROM {$table}"
+                               . " {$this->join} phpgw_accounts ON ( 
{$table}.user_id = phpgw_accounts.account_id)"
+                               . " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)"
+                               . " {$app_filter} {$filtermethod} 
{$querymethod}";
 
                        if (!$allrows)
                        {
-                               $this->db->query("SELECT count(*) as cnt FROM 
{$table} {$app_filter} {$filtermethod} {$querymethod}", __LINE__, __FILE__);
+                               $this->db->query("SELECT count(*) as cnt FROM 
{$table}"
+                               . " {$this->join} phpgw_accounts ON ( 
{$table}.user_id = phpgw_accounts.account_id)"
+                               . " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)"
+                               . " {$app_filter} {$filtermethod} 
{$querymethod}", __LINE__, __FILE__);
                                $this->db->next_record();
                                $this->total_records = $this->db->f('cnt');
                                $this->db->limit_query($sql . $ordermethod, 
$start, __LINE__, __FILE__, $results);
@@ -244,12 +264,6 @@
                        $this->db->next_record();
                        $user_id = $this->db->f('user_id');
 
-                       if (!($this->grants[$user_id] & PHPGW_ACL_EDIT))
-                       {
-                               $receipt['error'][] = array('msg' => 
lang('JasperReport %1 has not been edited', $jasper['id']));
-                               return $receipt;
-                       }
-
                        $value_set = array
                                (
                                'location_id' => 
$GLOBALS['phpgw']->locations->get_id($jasper['app'], $jasper['location']),

Modified: branches/dev-syncromind-2/property/inc/class.soproject.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.soproject.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.soproject.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -54,7 +54,7 @@
 
                        $this->acl = & $GLOBALS['phpgw']->acl;
                        $this->acl->set_account_id($this->account);
-                       $this->grants = $this->acl->get_grants('property', 
'.project');
+                       $this->grants = $this->acl->get_grants2('property', 
'.project');
                        $this->config = CreateObject('phpgwapi.config', 
'property');
                        $this->config->read();
                }
@@ -308,6 +308,8 @@
 
                                $joinmethod = " {$this->join} phpgw_accounts ON 
($entity_table.coordinator = phpgw_accounts.account_id))";
                                $paranthesis = '(';
+                               $joinmethod .= " {$this->join} phpgw_group_map 
ON (phpgw_accounts.account_id = phpgw_group_map.account_id))";
+                               $paranthesis .='(';
 
                                $joinmethod .= " {$this->join} 
fm_project_status ON ($entity_table.status = fm_project_status.id))";
                                $paranthesis .='(';
@@ -526,24 +528,36 @@
                                $where = 'AND';
                        }
 
-                       /*
-                         $group_method = ' GROUP BY 
fm_project_status.descr,loc1_name,fm_project.location_code,fm_project.id,fm_project.entry_date,fm_project.start_date,fm_project.end_date,'
-                         . 
'fm_project.name,fm_project.ecodimb,phpgw_accounts.account_lid,fm_project.user_id,fm_project.address,'
-                         . 
'fm_project.budget,fm_project.reserve,planned_cost,external_project_id';
-                        */
-
-                       if (is_array($this->grants))
+                       $public_user_list = array();
+                       if (is_array($this->grants['accounts']) && 
$this->grants['accounts'])
                        {
-                               $grants = $this->grants;
-                               while (list($user) = each($grants))
+                               foreach($this->grants['accounts'] as $user => 
$_right)
                                {
                                        $public_user_list[] = $user;
                                }
+                               unset($user);
                                reset($public_user_list);
-                               $filtermethod .= " $where (fm_project.user_id 
IN(" . implode(',', $public_user_list) . ")";
+                               $filtermethod .= " $where ( 
fm_project.coordinator IN(" . implode(',', $public_user_list) . ")";
+                               $where = 'AND';
+                       }
 
+                       $public_group_list = array();
+                       if (is_array($this->grants['groups']) && 
$this->grants['groups'])
+                       {
+                               foreach($this->grants['groups'] as $user => 
$_right)
+                               {
+                                       $public_group_list[] = $user;
+                               }
+                               unset($user);
+                               reset($public_group_list);
+                               $where = $public_user_list ? 'OR' : $where;
+                               $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
                                $where = 'AND';
                        }
+                       if($public_user_list && !$public_group_list)
+                       {
+                               $filtermethod .=')';
+                       }
 
                        if ($filter)
                        {
@@ -645,7 +659,7 @@
                                }
                        }
 
-                       $querymethod .= ')';
+//                     $querymethod .= ')';
 
                        $sql = str_replace('FROM', "{$_custom_cols} FROM", 
$sql);
 
@@ -715,7 +729,6 @@
                                        {
                                                $project[$cols_return[$i]] = 
$this->db->f($cols_return[$i]);
                                        }
-                                       $project['grants'] = 
(int)$this->grants[$this->db->f('user_id')];
 
                                        $location_code = 
$this->db->f('location_code');
                                        $location = explode('-', 
$location_code);
@@ -888,7 +901,6 @@
                                        'start_date' => 
$this->db->f('start_date'),
                                        'end_date' => $this->db->f('end_date'),
                                        'cat_id' => $this->db->f('category'),
-                                       'grants' => 
(int)$this->grants[$this->db->f('user_id')],
                                        'p_num' => $this->db->f('p_num'),
                                        'p_entity_id' => 
$this->db->f('p_entity_id'),
                                        'p_cat_id' => $this->db->f('p_cat_id'),

Modified: branches/dev-syncromind-2/property/inc/class.sos_agreement.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.sos_agreement.inc.php  
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.sos_agreement.inc.php  
2016-05-30 08:04:44 UTC (rev 15217)
@@ -532,7 +532,6 @@
                                for ($i = 0; $i < $n; $i++)
                                {
                                        $s_agreement_list[$j][$cols_return[$i]] 
= stripslashes($this->db->f($cols_return[$i]));
-                                       //      $s_agreement_list[$j]['grants'] 
= (int)$grants[$this->db->f('user_id')];
                                }
 
                                if (isset($cols_return_extra) && 
is_array($cols_return_extra))

Modified: branches/dev-syncromind-2/property/inc/class.sotts.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.sotts.inc.php  2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.sotts.inc.php  2016-05-30 
08:04:44 UTC (rev 15217)
@@ -141,24 +141,21 @@
 
 
                        $result_order_field = array();
+                       $order_join = "{$this->join} phpgw_accounts ON 
fm_tts_tickets.user_id=phpgw_accounts.account_id";
+
                        if ($order)
                        {
                                if ($order == 'assignedto')
                                {
-                                       $result_order_field = 
array('account_lastname' => 'account_lastname');
-                                       $order_join = "LEFT OUTER JOIN 
phpgw_accounts ON fm_tts_tickets.assignedto=phpgw_accounts.account_id";
-                                       $order = 'account_lastname';
+                       //              $result_order_field = 
array('account_lastname' => 'account_lastname');
+                       //              $order_join = "LEFT OUTER JOIN 
phpgw_accounts ON fm_tts_tickets.assignedto=phpgw_accounts.account_id";
+                       //              $order = 'account_lastname';
                                }
                                else if ($order == 'user')
                                {
                                        $result_order_field = 
array('account_lastname' => 'account_lastname');
-                                       $order_join = "LEFT OUTER JOIN 
phpgw_accounts ON fm_tts_tickets.user_id=phpgw_accounts.account_id";
                                        $order = 'account_lastname';
                                }
-                               else
-                               {
-                                       $order_join = '';
-                               }
 
                                $ordermethod = " ORDER BY $order $sort";
                        }
@@ -166,43 +163,44 @@
                        {
                                $ordermethod = ' ORDER BY id DESC';
                        }
-
+                       $order_join .= " {$this->join} phpgw_group_map ON 
(phpgw_accounts.account_id = phpgw_group_map.account_id)";
                        $union_select = false;
                        $filtermethod = '';
 
                        $where = 'WHERE';
 
-                       $GLOBALS['phpgw']->config->read();
+                       $config = $GLOBALS['phpgw']->config->read();
 
-                       if 
(!isset($GLOBALS['phpgw']->config->config_data['bypass_acl_at_tickets']) || 
!$GLOBALS['phpgw']->config->config_data['bypass_acl_at_tickets'])
+                       if (!isset($config['bypass_acl_at_tickets']) || 
!$config['bypass_acl_at_tickets'])
                        {
-                               $this->grants = 
$GLOBALS['phpgw']->session->appsession('grants_ticket', 'property');
+                               
$GLOBALS['phpgw']->acl->set_account_id($this->account);
+                               $grants = 
$GLOBALS['phpgw']->acl->get_grants2('property', '.ticket');
 
-                               if (!$this->grants)
-                               {
-                                       
$GLOBALS['phpgw']->acl->set_account_id($this->account);
-                                       $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('property', '.ticket');
-                                       
$GLOBALS['phpgw']->session->appsession('grants_ticket', 'property', 
$this->grants);
-                               }
-
                                $public_user_list = array();
-                               if 
(isset($GLOBALS['phpgw']->config->config_data['acl_at_tts_category']) && 
$GLOBALS['phpgw']->config->config_data['acl_at_tts_category'])
+                               if (isset($config['acl_at_tts_category']) && 
$config['acl_at_tts_category'])
                                {
                                        $categories = 
$GLOBALS['phpgw']->locations->get_subs('property', '.ticket.category');
 
                                        $category_grants = array();
                                        foreach ($categories as $location)
                                        {
-                                               $category_grants = 
array_merge($category_grants, $GLOBALS['phpgw']->acl->get_grants('property', 
$location));
+                                               $category_grants = 
$GLOBALS['phpgw']->acl->get_grants2('property', $location);
+                                               foreach 
($category_grants['accounts'] as $user => $right)
+                                               {
+                                                       
$grants['accounts'][$user] = $right;
+                                               }
+                                               unset($user);
+                                               unset($right);
+                                               foreach 
($category_grants['groups'] as $user => $right)
+                                               {
+                                                       
$grants['groups'][$user] = $right;
+                                               }
+                                               unset($user);
+                                               unset($right);
                                        }
-
-                                       foreach ($category_grants as $user => 
$right)
-                                       {
-                                               $public_user_list[] = $user;
-                                       }
                                }
 
-                               if 
(isset($GLOBALS['phpgw']->config->config_data['acl_at_location']) && 
$GLOBALS['phpgw']->config->config_data['acl_at_location'])
+                               if (isset($config['acl_at_location']) && 
$config['acl_at_location'])
                                {
                                        $access_location = 
execMethod('property.socommon.get_location_list', PHPGW_ACL_READ);
                                        if ($access_location)
@@ -212,22 +210,38 @@
                                        }
                                }
 
-                               if (is_array($this->grants))
+                               $public_user_list = array();
+                               if (is_array($grants['accounts']) && 
$grants['accounts'])
                                {
-                                       $grants = & $this->grants;
-                                       foreach ($grants as $user => $right)
+                                       foreach ($grants['accounts'] as $user 
=> $right)
                                        {
                                                $public_user_list[] = $user;
                                        }
+                                       unset($user);
+
+                                       reset($public_user_list);
+                                       $filtermethod .= " $where ( 
fm_tts_tickets.user_id IN(" . implode(',', $public_user_list) . ")";
+
+                                       $where = 'AND';
                                }
 
-                               if ($public_user_list)
+                               $public_group_list = array();
+                               if (is_array($grants['groups']) && 
$grants['groups'])
                                {
-                                       $public_user_list = 
array_unique($public_user_list);
-                                       reset($public_user_list);
-                                       $filtermethod .= " $where ( 
fm_tts_tickets.user_id IN(" . implode(',', $public_user_list) . "))";
+                                       foreach($grants['groups'] as $user => 
$_right)
+                                       {
+                                               $public_group_list[] = $user;
+                                       }
+                                       unset($user);
+                                       reset($public_group_list);
+                                       $where = $public_user_list ? 'OR' : 
$where;
+                                       $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
                                        $where = 'AND';
                                }
+                               if($public_user_list && !$public_group_list)
+                               {
+                                       $filtermethod .=')';
+                               }
                        }
 
                        if ($tenant_id = 
$GLOBALS['phpgw']->session->appsession('tenant_id', 'property'))
@@ -358,7 +372,7 @@
                                {
                                        $membership = array(-1 => 0);
                                }
-                               $filtermethod .= ' OR (assignedto IS NULL AND 
group_id IN (' . implode(',', array_keys($membership)) . ')))';
+                               $filtermethod .= ' OR (assignedto IS NULL AND 
fm_tts_tickets.group_id IN (' . implode(',', array_keys($membership)) . ')))';
                        }
 
                        if ($user_id < 0)

Modified: branches/dev-syncromind-2/property/inc/class.soworkorder.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.soworkorder.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.soworkorder.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -48,14 +48,9 @@
                        $this->join = & $this->db->join;
                        $this->left_join = & $this->db->left_join;
                        $this->interlink = CreateObject('property.interlink');
-                       //      $this->grants           = 
$GLOBALS['phpgw']->session->appsession('grants_project','property');
-                       //      if(!$this->grants)
-                       {
-                               $this->acl = & $GLOBALS['phpgw']->acl;
-                               $this->acl->set_account_id($this->account);
-                               $this->grants = 
$this->acl->get_grants('property', '.project');
-                               //              
$GLOBALS['phpgw']->session->appsession('grants_project','property',$this->grants);
-                       }
+                       $this->acl = & $GLOBALS['phpgw']->acl;
+                       $this->acl->set_account_id($this->account);
+                       $this->grants = $this->acl->get_grants2('property', 
'.project');
                }
 
                function next_id()
@@ -373,6 +368,8 @@
                                $uicols['classname'][] = 'rightClasss';
                                $uicols['sortable'][] = '';
 
+                               $joinmethod .= " {$this->join} phpgw_group_map 
ON (phpgw_accounts.account_id = phpgw_group_map.account_id))";
+                               $paranthesis .='(';
                                $joinmethod .= " {$this->left_join} fm_vendor 
ON (fm_workorder.vendor_id = fm_vendor.id))";
                                $paranthesis .='(';
                                $joinmethod .= " {$this->left_join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id))";
@@ -632,18 +629,37 @@
                                $where = 'AND';
                        }
 
-                       if (is_array($this->grants))
+                       $public_user_list = array();
+                       if (is_array($this->grants['accounts']) && 
$this->grants['accounts'])
                        {
-                               $grants = $this->grants;
-                               while (list($user) = each($grants))
+                               foreach($this->grants['accounts'] as $user => 
$_right)
                                {
                                        $public_user_list[] = $user;
                                }
+                               unset($user);
                                reset($public_user_list);
-                               $filtermethod .= " $where 
(fm_project.access='public' AND fm_project.user_id IN(" . implode(',', 
$public_user_list) . ")";
+                               $filtermethod .= " $where ((fm_project.user_id 
IN(" . implode(',', $public_user_list) . ")";
                                $where = 'AND';
                        }
 
+                       $public_group_list = array();
+                       if (is_array($this->grants['groups']) && 
$this->grants['groups'])
+                       {
+                               foreach($this->grants['groups'] as $user => 
$_right)
+                               {
+                                       $public_group_list[] = $user;
+                               }
+                               unset($user);
+                               reset($public_group_list);
+                               $where = $public_user_list ? 'OR' : $where;
+                               $filtermethod .= " $where 
phpgw_group_map.group_id IN(" . implode(',', $public_group_list) . "))";
+                               $where = 'AND';
+                       }
+                       if($public_user_list && !$public_group_list)
+                       {
+                               $filtermethod .=')';
+                       }
+
                        if ($filter)
                        {
                                $filtermethod .= " $where 
fm_workorder.user_id={$filter}";
@@ -689,7 +705,7 @@
                        if ($filter_year && $filter_year != 'all')
                        {
                                $filter_year = (int)$filter_year;
-                               $filtermethod .= " $where 
(fm_workorder_budget.year={$filter_year} OR fm_workorder_status.closed IS 
NULL)";
+                               $filtermethod .= " $where 
(fm_workorder_budget.year={$filter_year})";// OR fm_workorder_status.closed IS 
NULL)";
                                $where = 'AND';
                        }
 
@@ -765,7 +781,7 @@
                        {
                                $sql_minimized = "SELECT DISTINCT 
fm_workorder.id {$sql_base}";
                                $sql_count = "SELECT count(id) as cnt FROM 
({$sql_minimized}) as t";
-
+//                             _debug_array($sql_count);
                                $this->db->query($sql_count, __LINE__, 
__FILE__);
                                $this->db->next_record();
                                $this->total_records = $this->db->f('cnt');
@@ -844,7 +860,6 @@
                                $workorder['combined_cost'] = 0;
                                $workorder['budget'] = 0;
 //---------
-                               $workorder['grants'] = 
(int)$this->grants[$this->db->f('project_owner')];
 
                                $location_code = $this->db->f('location_code');
                                $location = explode('-', $location_code);
@@ -957,7 +972,6 @@
                                        'contact_phone' => 
$this->db->f('contact_phone'),
                                        'tenant_id' => 
$this->db->f('tenant_id'),
                                        'cat_id' => $this->db->f('category'),
-                                       'grants' => 
(int)$this->grants[$this->db->f('user_id')],
                                        'billable_hours' => 
$this->db->f('billable_hours'),
                                        'approved' => $this->db->f('approved'),
                                        'mail_recipients' => explode(',', 
trim($this->db->f('mail_recipients'), ',')),
@@ -2426,19 +2440,23 @@
                                }
 
                                $entry['deviation_period'] = $deviation;
-                               $budget_acc +=$entry['budget'];
+                               
+                               $entry['active'] = 
isset($active_period[$entry['period']]) && $active_period[$entry['period']] ? 
$active_period[$entry['period']] : 0;
+                               if ($entry['active'] != 2)
+                               {
+                                       $budget_acc +=$entry['budget'];
+                               }
 
+                               $entry['budget_acc'] = $budget_acc;
                                $entry['deviation_acc'] = abs($deviation) > 0 ? 
$deviation_acc : 0;
 
-
                                $entry['deviation_percent_period'] = $deviation 
/ $entry['budget'] * 100;
                                $entry['deviation_percent_acc'] = 
$entry['deviation_acc'] / $budget_acc * 100;
 
                                $entry['closed'] = 
isset($closed_period[$entry['period']]) && $closed_period[$entry['period']];
-                               $entry['active'] = 
isset($active_period[$entry['period']]) && $active_period[$entry['period']] ? 
$active_period[$entry['period']] : 0;
                                $entry['fictive'] = 
isset($fictive_period[$entry['period']]) && $fictive_period[$entry['period']];
                        }
-
+//                     _debug_array($values);die();
                        phpgwapi_cache::system_set('property', 
"budget_order_{$order_id}", $values);
 
                        return $values;

Modified: branches/dev-syncromind-2/property/inc/class.uiadmin_entity.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uiadmin_entity.inc.php 
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.uiadmin_entity.inc.php 
2016-05-30 08:04:44 UTC (rev 15217)
@@ -987,6 +987,7 @@
                                'form_action' => 
$GLOBALS['phpgw']->link('/index.php', $link_data),
                                'done_action' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uiadmin_entity.category',
                                        'entity_id' => $entity_id, 'type' => 
$this->type)),
+                               'base_java_url' => 
json_encode(array('menuaction' => "property.uiadmin_entity.edit_category")),
                                'lang_save' => lang('save'),
                                'lang_done' => lang('done'),
                                'value_id' => $id,

Modified: branches/dev-syncromind-2/property/inc/class.uiagreement.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uiagreement.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.uiagreement.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -2088,11 +2088,7 @@
                                $table_header = $list['table_header'];
                        }
 
-                       $link_data = array
-                               (
-                               'menuaction' => 'property.uiagreement.save',
-                               'id' => $agreement_id,
-                       );
+                       $link_data = array('menuaction' => 
'property.uiagreement.index');
 
                        $vendor_data = 
$this->bocommon->initiate_ui_vendorlookup(array(
                                'vendor_id' => $agreement['vendor_id'],
@@ -2149,12 +2145,6 @@
                                $record_limit = $this->bo->total_records;
                        }
 
-                       $link_data2 = array
-                               (
-                               'menuaction' => 'property.uiagreement.view',
-                               'id' => $agreement_id,
-                       );
-
                        //---datatable0 
settings---------------------------------------------------
 
                        $myColumnDefs = array
@@ -2271,7 +2261,6 @@
                                'num_records' => count($content),
                                'lang_total_records' => lang('Total'),
                                'all_records' => $this->bo->total_records,
-                               'link_url' => 
$GLOBALS['phpgw']->link('/index.php', $link_data2),
                                'img_path' => 
$GLOBALS['phpgw']->common->get_image_path('phpgwapi', 'default'),
                                'alarm_data' => $alarm_data,
                                'lang_alarm' => lang('Alarm'),
@@ -2280,7 +2269,7 @@
                                'lang_files' => lang('files'),
                                'lang_filename' => lang('Filename'),
                                'lang_view_file_statustext' => lang('click to 
view file'),
-                               'edit_url' => 
$GLOBALS['phpgw']->link('/index.php', $link_data),
+                               'cancel_url' => 
$GLOBALS['phpgw']->link('/index.php', $link_data),
                                'lang_id' => lang('ID'),
                                'value_agreement_id' => $agreement_id,
                                'lang_category' => lang('category'),

Modified: branches/dev-syncromind-2/property/inc/class.uigeneric.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uigeneric.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.uigeneric.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -470,6 +470,7 @@
                 */
                public function query()
                {
+                       $query = phpgw::get_var('query');
                        $search = phpgw::get_var('search');
                        $order = phpgw::get_var('order');
                        $draw = phpgw::get_var('draw', 'int');
@@ -479,7 +480,7 @@
                        $params = array(
                                'start' => phpgw::get_var('start', 'int', 
'REQUEST', 0),
                                'results' => phpgw::get_var('length', 'int', 
'REQUEST', 0),
-                               'query' => $search['value'],
+                               'query' => $query ? $query : $search['value'],
                                'order' => 
$columns[$order[0]['column']]['data'],
                                'sort' => $order[0]['dir'],
                                'dir' => $order[0]['dir'],

Modified: branches/dev-syncromind-2/property/inc/class.uijasper.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uijasper.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.uijasper.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -250,100 +250,7 @@
                                        )
                                )
                        );
-                       //$this->save_sessiondata();
-                       //$datatable = array();
 
-                       /* if( phpgw::get_var('phpgw_return_as') != 'json' )
-                         {
-                         $datatable['config']['base_url'] = 
$GLOBALS['phpgw']->link('/index.php', array
-                         (
-                         'menuaction'  => 'property.uijasper.index',
-                         'app'                 => $this->app
-                         ));
-
-                         $datatable['config']['base_java_url'] = 
"menuaction:'property.uijasper.index',"
-                         ."app: '{$this->app}',"
-                         ."allrows:'{$this->allrows}'";
-
-
-                         $link_data = array
-                         (
-                         'menuaction'  => 'property.uijasper.index',
-                         'app'                 => $this->app
-                         );
-
-                         $values_combo_box[0]  = $this->bo->get_apps();
-
-                         $datatable['config']['allow_allrows'] = true;
-
-                         $datatable['actions']['form'] = array
-                         (
-                         array
-                         (
-                         'action'      => $GLOBALS['phpgw']->link('/index.php',
-                         array
-                         (
-                         'menuaction'  => 'property.uijasper.index'//,
-                         )
-                         ),
-                         'fields'      => array
-                         (
-                         'field' => array
-                         (
-                         array //boton         CATEGORY
-                         (
-                         'id' => 'btn_app_id',
-                         'name' => 'app',
-                         'value'       => lang('application'),
-                         'type' => 'button',
-                         'style' => 'filter',
-                         'tab_index' => 1
-                         ),
-                         array
-                         (
-                         'type'        => 'button',
-                         'id'  => 'btn_export',
-                         'value'       => lang('download'),
-                         'tab_index' => 9
-                         ),
-                         array
-                         (
-                         'type'        => 'button',
-                         'id'  => 'btn_new',
-                         'value'       => lang('add'),
-                         'tab_index' => 8
-                         ),
-                         array //boton  SEARCH
-                         (
-                         'id' => 'btn_search',
-                         'name' => 'search',
-                         'value'       => lang('search'),
-                         'type' => 'button',
-                         'tab_index' => 7
-                         ),
-                         array // TEXT INPUT
-                         (
-                         'name'         => 'query',
-                         'id'   => 'txt_query',
-                         'value'       => '',//$query,
-                         'type' => 'text',
-                         'onkeypress' => 'return pulsar(event)',
-                         'size'        => 28,
-                         'tab_index' => 6
-                         )
-                         ),
-                         'hidden_value' => array
-                         (
-                         array //div values  combo_box_0
-                         (
-                         'id' => 'values_combo_box_0',
-                         'value'       => 
$this->bocommon->select2String($values_combo_box[0])
-                         )
-                         )
-                         )
-                         )
-                         );
-                         } */
                        $filters = $this->_get_Filters();
                        foreach ($filters as $filter)
                        {
@@ -637,12 +544,9 @@
                        {
                                $values = $this->bo->read_single($id);
                                $function_msg = lang('edit report');
-                               $this->acl->set_account_id($this->account);
-                               $grants = $this->acl->get_grants('property', 
'.jasper');
-                               if 
(!$this->bocommon->check_perms($grants[$values['user_id']], PHPGW_ACL_READ))
+                               if 
(!$this->bocommon->check_perms2($values['user_id'], $this->grants, 
PHPGW_ACL_READ))
                                {
-                                       $values = array();
-                                       $receipt['error'][] = array('msg' => 
lang('You are not granted sufficient rights for this entry'));
+                                       phpgw::no_access();
                                }
                        }
                        else
@@ -780,7 +684,7 @@
                                $values['input'] = $values_attribute;
                                $first_run = false;
                        }
-                       if 
(!$this->bocommon->check_perms($this->grants[$values['user_id']], 
PHPGW_ACL_READ))
+                       if (!$this->bocommon->check_perms2($values['user_id'], 
$this->grants, PHPGW_ACL_READ))
                        {
                                echo lang('not allowed');
                                $GLOBALS['phpgw']->common->phpgw_exit();
@@ -946,7 +850,7 @@
 
                        $id = phpgw::get_var('id'); // string
                        $values = $this->bo->read_single($id);
-                       if 
(!$this->bocommon->check_perms($this->grants[$values['user_id']], 
PHPGW_ACL_DELETE))
+                       if (!$this->bocommon->check_perms2($values['user_id'], 
$this->grants, PHPGW_ACL_DELETE))
                        {
                                return lang('not allowed');
                        }

Modified: branches/dev-syncromind-2/property/inc/class.uiproject.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uiproject.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.uiproject.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -1300,12 +1300,20 @@
                                                'project_id' => $id));
                                }
 
-                               if 
(!$this->bocommon->check_perms($values['grants'], PHPGW_ACL_EDIT))
+                               if 
(!$this->bocommon->check_perms2($values['coordinator'], $this->bo->so->grants, 
PHPGW_ACL_EDIT))
                                {
                                        $this->receipt['error'][] = array('msg' 
=> lang('You have no edit right for this project'));
-                                       
$GLOBALS['phpgw']->session->appsession('receipt', 'property', 
$this->receipt['error']);
-                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'property.uiproject.view',
-                                               'id' => $id));
+                                       
$GLOBALS['phpgw']->session->appsession('receipt', 'property', $this->receipt);
+
+                                       switch ($mode)
+                                       {
+                                               case 'edit':
+                                                       
self::redirect(array('menuaction' => 'property.uiproject.view','id' => $id));
+                                                       break;
+                                               default:
+                                                       
self::redirect(array('menuaction' => 'property.uiproject.index'));
+                                                       break;
+                                       }
                                }
                                else
                                {
@@ -2279,13 +2287,15 @@
 
                function delete()
                {
-                       if (!$this->acl_delete)
+                       $project_id = phpgw::get_var('project_id', 'int');
+
+//                     $project = $this->bo->read_single($project_id);
+
+                       if (!$this->acl_delete)// || 
!$this->bocommon->check_perms2($project['coordinator'], $this->bo->so->grants, 
PHPGW_ACL_DELETE))
                        {
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uilocation.stop',
-                                       'perm' => 8, 'acl_location' => 
$this->acl_location));
+                               phpgw::no_access();
                        }
 
-                       $project_id = phpgw::get_var('project_id', 'int');
                        if (phpgw::get_var('phpgw_return_as') == 'json')
                        {
                                $this->bo->delete($project_id);

Modified: branches/dev-syncromind-2/property/inc/class.uiresponsible.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uiresponsible.inc.php  
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.uiresponsible.inc.php  
2016-05-30 08:04:44 UTC (rev 15217)
@@ -582,16 +582,13 @@
                        {
                                $values = $this->bo->read_single($id);
                                $function_msg = lang('edit responsible');
-                               /*
-                                 $this->acl->set_account_id($this->account);
-                                 $grants       = 
$this->acl->get_grants('property','.responsible');
-                                 
if(!$this->bocommon->check_perms($grants[$values['user_id']], PHPGW_ACL_READ))
-                                 {
-                                 $values = array();
-                                 $receipt['error'][]=array('msg'=>lang('You 
are not granted sufficient rights for this entry'));
-                                 }
-
-                                */
+                               
+//                               $this->acl->set_account_id($this->account);
+//                               $grants       = 
$this->acl->get_grants('property','.responsible');
+//                               
if(!$this->bocommon->check_perms2($values['created_by'], $grants, 
PHPGW_ACL_READ))
+//                               {
+//                                       phpgw::no_access();
+//                               }
                        }
                        else
                        {
@@ -706,8 +703,7 @@
                {
                        if (!$this->acl_add && !$this->acl_edit)
                        {
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uilocation.stop',
-                                       'perm' => 2, 'acl_location' => 
$this->acl_location));
+                               phpgw::no_access();
                        }
 
                        $id = phpgw::get_var('id', 'int');
@@ -764,16 +760,6 @@
                        {
                                $values = $this->bo->read_single_role($id);
                                $function_msg = lang('edit role');
-                               /*
-                                 $this->acl->set_account_id($this->account);
-                                 $grants       = 
$this->acl->get_grants('property','.responsible');
-                                 
if(!$this->bocommon->check_perms($grants[$values['user_id']], PHPGW_ACL_READ))
-                                 {
-                                 $values = array();
-                                 $receipt['error'][]=array('msg'=>lang('You 
are not granted sufficient rights for this entry'));
-                                 }
-
-                                */
                        }
                        else
                        {

Modified: branches/dev-syncromind-2/property/inc/class.uiwo_hour.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uiwo_hour.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.uiwo_hour.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -381,13 +381,6 @@
                {
 
                        $workorder = 
$this->boworkorder->read_single($workorder_id);
-                       /*                      if 
(!$this->bocommon->check_perms($workorder['grants'],PHPGW_ACL_EDIT))
-                         {
-                         $receipt['error'][]=array('msg'=>lang('You have no 
edit right for this project'));
-                         
$GLOBALS['phpgw']->session->appsession('receipt','property',$receipt);
-                         
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uiworkorder.view','id'=> $workorder_id));
-                         }
-                        */
                        $hour_list = $this->bo->read($workorder_id);
                        //_debug_array($hour_list);
                        $grouping_descr_old = '';

Modified: branches/dev-syncromind-2/property/inc/class.uiworkorder.inc.php
===================================================================
--- branches/dev-syncromind-2/property/inc/class.uiworkorder.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/inc/class.uiworkorder.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -1248,14 +1248,21 @@
                                }
 
                                $acl_required = $mode == 'edit' ? 
PHPGW_ACL_EDIT : PHPGW_ACL_READ;
-                               if 
(!$this->bocommon->check_perms($project['grants'], $acl_required))
+                               if 
(!$this->bocommon->check_perms2($project['coordinator'], $this->bo->so->grants, 
PHPGW_ACL_EDIT))
                                {
                                        $this->receipt['error'][] = array(
                                                'msg' => lang('You have no edit 
right for this project'));
                                        
$GLOBALS['phpgw']->session->appsession('receipt', 'property', $this->receipt);
-                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array(
-                                               'menuaction' => 
'property.uiworkorder.view',
-                                               'id' => $id));
+
+                                       switch ($mode)
+                                       {
+                                               case 'edit':
+                                                       
self::redirect(array('menuaction' => 'property.uiworkorder.view','id' => $id));
+                                                       break;
+                                               default:
+                                                       
self::redirect(array('menuaction' => 'property.uiworkorder.index'));
+                                                       break;
+                                       }
                                }
 
                                if ($project['key_fetch'] && 
!$values['key_fetch'])
@@ -1992,7 +1999,7 @@
                                array(
                                        'key' => 'year',
                                        'label' => lang('year'),
-                                       'sortable' => false,
+                                       'sortable' => true,
                                        'className' => 'center',
                                        'value_footer' => lang('Sum')),
                                array(

Modified: 
branches/dev-syncromind-2/property/js/portico/admin_entity.edit_category.js
===================================================================
--- branches/dev-syncromind-2/property/js/portico/admin_entity.edit_category.js 
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/js/portico/admin_entity.edit_category.js 
2016-05-30 08:04:44 UTC (rev 15217)
@@ -4,8 +4,15 @@
 
 $(document).ready(function ()
 {
-       var api = oTable0.api();
-       api.on('draw', add_checkall);
+       try
+       {
+               var api = oTable0.api();
+               api.on('draw', add_checkall);
+       }
+       catch(err)
+       {
+
+       }
 });
 
 function add_checkall()

Modified: branches/dev-syncromind-2/property/templates/base/agreement.xsl
===================================================================
--- branches/dev-syncromind-2/property/templates/base/agreement.xsl     
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/templates/base/agreement.xsl     
2016-05-30 08:04:44 UTC (rev 15217)
@@ -955,10 +955,10 @@
                </div>
                <div class="proplist-col">
                        <table cellpadding="2" cellspacing="2" align="left">
-                               <xsl:variable name="edit_url">
-                                       <xsl:value-of select="edit_url"/>
+                               <xsl:variable name="cancel_url">
+                                       <xsl:value-of select="cancel_url"/>
                                </xsl:variable>
-                               <form name="form" method="post" 
action="{$edit_url}">
+                               <form name="form" method="post" 
action="{$cancel_url}">
                                        <tr>
                                                <td align="left" 
valign="bottom">
                                                        <xsl:variable 
name="lang_cancel">

Modified: branches/dev-syncromind-2/property/templates/base/invoice2.xsl
===================================================================
--- branches/dev-syncromind-2/property/templates/base/invoice2.xsl      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/property/templates/base/invoice2.xsl      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -76,7 +76,7 @@
                                        </td>
                                </tr>
                                <tr>
-                                       <td valign="top">
+                                       <td valign="top" height="30">
                                                <div id = 'split_text'>
                                                </div>
                                        </td>
@@ -447,19 +447,19 @@
 <xsl:template xmlns:php="http://php.net/xsl"; name="approve">
        <xsl:apply-templates select="voucher_info/generic/approved_list"/>
        <tr class ='row_off'>
-               <td class="th_text" align="left" valign="top" 
style="white-space: nowrap;">
+               <td class="th_text" align="left" valign="top" 
style="white-space: nowrap;" height="40">
                        <input id="sign_orig" type="hidden" 
name="values[sign_orig]" value="{voucher_info/generic/sign_orig}"/>
                        <input id="my_initials" type="hidden" 
name="values[my_initials]" value="{voucher_info/generic/my_initials}"/>
                        <xsl:value-of select="php:function('lang', 'approve 
as')"/>
                </td>
-               <td class="th_text" valign="top" align="left">
+               <td class="th_text" valign="top" align="left" height="40">
                        <div id = "approve_as2"> </div>
                </td>
        </tr>
        <tr class ='row_off'>
                <td>
                </td>
-               <td>
+               <td height="50">
                        <div id = 'email_link'></div>
                </td>
        </tr>

Modified: branches/dev-syncromind-2/registration/inc/class.boreg.inc.php
===================================================================
--- branches/dev-syncromind-2/registration/inc/class.boreg.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/registration/inc/class.boreg.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -132,7 +132,8 @@
 
                        if ($this->config['password_is'] == 'http')
                        {
-                               $r_reg['passwd'] = $r_reg['passwd_confirm'] = 
$_SERVER['PHP_AUTH_PW'];
+                               // remove entities to stop mangling
+                               $r_reg['passwd'] = $r_reg['passwd_confirm'] = 
html_entity_decode(phpgw::clean_value($_SERVER['PHP_AUTH_PW']));
                        }
 
                        if (($this->config['display_tos']) && 
!$r_reg['tos_agree'])

Modified: branches/dev-syncromind-2/rental/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.menu.inc.php     2016-05-30 
07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/rental/inc/class.menu.inc.php     2016-05-30 
08:04:44 UTC (rev 15217)
@@ -118,6 +118,11 @@
 
                        $menus['navigation'] = array
                                (
+                               'application' => array(
+                                       'text' => lang('application'),
+                                       'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rental.uiapplication.index')),
+                                       'image' => array('rental', 
'text-x-generic'),
+                               ),
                                'contracts' => array
                                        (
                                        'text' => lang('contracts'),

Copied: branches/dev-syncromind-2/rental/inc/class.soapplication.inc.php (from 
rev 15215, trunk/rental/inc/class.soapplication.inc.php)
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.soapplication.inc.php            
                (rev 0)
+++ branches/dev-syncromind-2/rental/inc/class.soapplication.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -0,0 +1,299 @@
+<?php
+       /**
+        * phpGroupWare - property: a part of a Facilities Management System.
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2016 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset
+        * @package rental
+        * @subpackage application
+        * @version $Id: $
+        */
+
+       class rental_soapplication
+       {
+
+               protected $db;
+               protected $like;
+               protected $join;
+               protected $left_join;
+               protected $sort_field;
+               protected $skip_limit_query;
+               protected static $so;
+
+               public function __construct()
+               {
+                       $this->db = & $GLOBALS['phpgw']->db;
+                       $this->like = & $this->db->like;
+                       $this->join = & $this->db->join;
+                       $this->left_join = & $this->db->left_join;
+                       $this->sort_field = null;
+                       $this->skip_limit_query = null;
+               }
+
+               /**
+                * Begin transaction
+                *
+                * @return integer|bool current transaction id
+                */
+               public function transaction_begin()
+               {
+                       return $this->db->transaction_begin();
+               }
+
+               /**
+                * Complete the transaction
+                *
+                * @return bool True if sucessful, False if fails
+                */
+               public function transaction_commit()
+               {
+                       return $this->db->transaction_commit();
+               }
+
+               /**
+                * Rollback the current transaction
+                *
+                * @return bool True if sucessful, False if fails
+                */
+               public function transaction_abort()
+               {
+                       return $this->db->transaction_abort();
+               }
+
+               /**
+                * Marshal values according to type
+                * @param $value the value
+                * @param $type the type of value
+                * @return database value
+                */
+               protected function marshal( $value, $type )
+               {
+                       if ($value === null)
+                       {
+                               return 'NULL';
+                       }
+                       else if ($type == 'int')
+                       {
+                               if ($value == '')
+                               {
+                                       return 'NULL';
+                               }
+                               return intval($value);
+                       }
+                       else if ($type == 'float')
+                       {
+                               return str_replace(',', '.', $value);
+                       }
+                       else if ($type == 'field')
+                       {
+                               return $this->db->db_addslashes($value);
+                       }
+                       return "'" . $this->db->db_addslashes($value) . "'";
+               }
+
+               /**
+                * Unmarchal database values according to type
+                * @param $value the field value
+                * @param $type a string dictating value type
+                * @return the php value
+                */
+               protected function unmarshal( $value, $type )
+               {
+                       if ($type == 'bool')
+                       {
+                               return (bool)$value;
+                       }
+                       elseif ($type == 'int')
+                       {
+                               return (int)$value;
+                       }
+                       elseif ($value === null || $value == 'NULL')
+                       {
+                               return null;
+                       }
+                       elseif ($type == 'float')
+                       {
+                               return floatval($value);
+                       }
+                       return $value;
+               }
+
+               /**
+                * Get the count of the specified query. Query must return a 
signel column
+                * called count.
+                *
+                * @param $sql the sql query
+                * @return the count value
+                */
+               protected function get_query_count( $sql )
+               {
+                       $result = $this->db->query($sql);
+                       if ($result && $this->db->next_record())
+                       {
+                               return $this->unmarshal($this->db->f('count', 
true), 'int');
+                       }
+               }
+
+               /**
+                * Implementing classes must return an instance of itself.
+                *  
+                * @return the class instance.
+                */
+               public static function get_instance()
+               {
+                       if (self::$so == null)
+                       {
+                               self::$so = 
CreateObject('rental.soapplication');
+                       }
+                       return self::$so;
+                       
+               }
+
+               /**
+                * Convenience method for getting one single object. Calls 
get() with the
+                * specified id as a filter.
+                *
+                * @param $id int with id of object to return.
+                * @return object with the specified id, null if not found.
+                */
+               public function get_single( int $id )
+               {
+                       $objects = $this->get(0, 0, '', false, '', '', 
array($this->get_id_field_name() => $id));
+                       if (count($objects) > 0)
+                       {
+                               $keys = array_keys($objects);
+                               return $objects[$keys[0]];
+                       }
+                       return null;
+               }
+
+               /**
+                * Method for retrieving the db-object (security "forgotten")
+                */
+               public function get_db()
+               {
+                       return $this->db;
+               }
+
+               /**
+                * Method for retreiving objects.
+                *
+                * @param $start_index int with index of first object.
+                * @param $num_of_objects int with max number of objects to 
return.
+                * @param $sort_field string representing the object field to 
sort on.
+                * @param $ascending bool true for ascending sort on sort 
field, false
+                * for descending.
+                * @param $search_for string with free text search query.
+                * @param $search_type string with the query type.
+                * @param $filters array with key => value of filters.
+                * @return array of objects. May return an empty
+                * array, never null. The array keys are the respective index 
numbers.
+                */
+               public function get( int $start_index, int $num_of_objects, 
string $sort_field, bool $ascending, string $search_for, string $search_type, 
array $filters )
+               {
+                       $results = array();   // Array to store result objects
+
+                       return $results;
+               }
+
+               /**
+                * Returns count of matching objects.
+                *
+                * @param $search_for string with free text search query.
+                * @param $search_type string with the query type.
+                * @param $filters array with key => value of filters.
+                * @return int with object count.
+                */
+               public function get_count( string $search_for, string 
$search_type, array $filters )
+               {
+                       return $this->get_query_count($this->get_query('', 
false, $search_for, $search_type, $filters, true));
+               }
+
+               /**
+                * Implementing classes must return the name of the field used 
in the query
+                * returned from get_query().
+                * 
+                * @return string with name of id field.
+                */
+               protected function get_id_field_name()
+               {
+                       
+               }
+
+               /**
+                * Returns SQL for retrieving matching objects or object count.
+                *
+                * @param $start_index int with index of first object.
+                * @param $num_of_objects int with max number of objects to 
return.
+                * @param $sort_field string representing the object field to 
sort on.
+                * @param $ascending bool true for ascending sort on sort 
field, false
+                * for descending.
+                * @param $search_for string with free text search query.
+                * @param $search_type string with the query type.
+                * @param $filters array with key => value of filters.
+                * @param $return_count bool telling to return only the count 
of the
+                * matching objects, or the objects themself.
+                * @return string with SQL.
+                */
+               protected function get_query( string $sort_field, bool 
$ascending, string $search_for, string $search_type, array $filters, bool 
$return_count )
+               {
+
+               }
+
+               protected function populate( int $object_id, &$object )
+               {
+
+               }
+
+               protected function add( &$object )
+               {
+
+               }
+
+               protected function update( $object )
+               {
+                       
+               }
+
+               /**
+                * Store the object in the database.  If the object has no ID 
it is assumed to be new and
+                * inserted for the first time.  The object is then updated 
with the new insert id.
+                */
+               public function store( &$object )
+               {
+                       if ($object->validates())
+                       {
+                               if ($object->get_id() > 0)
+                               {
+                                       // We can assume this composite came 
from the database since it has an ID. Update the existing row
+                                       return $this->update($object);
+                               }
+                               else
+                               {
+                                       // This object does not have an ID, so 
will be saved as a new DB row
+                                       return $this->add($object);
+                               }
+                       }
+
+                       // The object did not validate
+                       return false;
+               }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind-2/rental/inc/class.sobilling.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.sobilling.inc.php        
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/rental/inc/class.sobilling.inc.php        
2016-05-30 08:04:44 UTC (rev 15217)
@@ -261,7 +261,7 @@
                        return $missing_billing_info;
                }
 
-               public function create_billing( int $decimals, int 
$contract_type, int $billing_term, int $year, int $month, $title, int 
$created_by, array $contracts_to_bill, array 
$contracts_overriding_billing_start, string $export_format, int 
$existing_billing, array $contracts_bill_only_one_time )
+               public function create_billing( int $decimals, int 
$contract_type, int $billing_term, int $year, int $month, $title, int 
$created_by, array $contracts_to_bill, array 
$contracts_overriding_billing_start, string $export_format, int 
$existing_billing, array $contracts_bill_only_one_time, bool $dry_run )
                {
                        if ($contracts_overriding_billing_start == null)
                        {
@@ -281,7 +281,10 @@
                                $billing->set_timestamp_start(time()); // Start 
of run
                                $billing->set_export_format($export_format);
                                $billing->set_title($title);
-                               $this->store($billing); // Store job as it is
+                               if(!$dry_run)
+                               {
+                                       $this->store($billing); // Store job as 
it is
+                               }
                                $billing_end_timestamp = strtotime('-1 day', 
strtotime(($month == 12 ? ($year + 1) : $year) . '-' . ($month == 12 ? '01' : 
($month + 1)) . '-01')); // Last day of billing period is the last day of the 
month we're billing
                                $counter = 0;
                                $total_sum = 0;
@@ -294,7 +297,10 @@
                        }
 
                        $billing_info = new rental_billing_info(null, 
$billing->get_id(), $contract_type, $billing_term, $year, $month);
-                       $res = 
rental_sobilling_info::get_instance()->store($billing_info);
+                       if(!$dry_run)
+                       {
+                               $res = 
rental_sobilling_info::get_instance()->store($billing_info);
+                       }
 
                        // Get the number of months in selected term for 
contract
                        $months = 
rental_socontract::get_instance()->get_months_in_term($billing_term);
@@ -303,21 +309,30 @@
                        $first_day_of_selected_month = strtotime($year . '-' . 
$month . '-01');
                        $bill_from_timestamp = strtotime('-' . ($months - 1) . 
' month', $first_day_of_selected_month);
 
+                       $invoices = array();
                        foreach ($contracts_to_bill as $contract_id) // Runs 
through all the contracts that should be billed in this run
                        {
-                               $invoice = 
rental_invoice::create_invoice($decimals, $billing->get_id(), $contract_id, 
in_array($contract_id, $contracts_overriding_billing_start) ? true : false, 
$bill_from_timestamp, $billing_end_timestamp, in_array($contract_id, 
$contracts_bill_only_one_time) ? true : false, false, $billing_term); // 
Creates an invoice of the contract
+                               $invoice = 
rental_invoice::create_invoice($decimals, $billing->get_id(), $contract_id, 
in_array($contract_id, $contracts_overriding_billing_start) ? true : false, 
$bill_from_timestamp, $billing_end_timestamp, in_array($contract_id, 
$contracts_bill_only_one_time) ? true : false, $dry_run, $billing_term); // 
Creates an invoice of the contract
                                if ($invoice != null)
                                {
                                        $total_sum += $invoice->get_total_sum();
+                                       $invoices[] = $invoice;
                                }
                        }
                        $billing->set_total_sum(round($total_sum, $decimals));
                        $billing->set_timestamp_stop(time()); //  End of run
                        $billing->set_success(true); // Billing job is a success
-                       $this->store($billing); // Store job now that we're done
+                       if(!$dry_run)
+                       {
+                               $this->store($billing); // Store job now that 
we're done
+                       }
                        // End of transaction!
                        if ($this->db->transaction_commit())
                        {
+                               if($dry_run)
+                               {
+                                       return $invoices;
+                               }
                                return $billing;
                        }
                        throw new UnexpectedValueException('Transaction 
failed.');

Modified: branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php      
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php      
2016-05-30 08:04:44 UTC (rev 15217)
@@ -209,6 +209,15 @@
                        THEN 'Ikke ledig' ELSE 'Ledig' END as status";
                        }
                        $dir = $ascending ? 'ASC' : 'DESC';
+                       if ($sort_field == 'name')
+                       {
+                               $sort_field = 'rental_composite.name';
+                       }
+                       else if ($sort_field == 'location_code')
+                       {
+                               $sort_field = 'rental_unit.location_code';
+                       }
+
                        $order = $sort_field ? "ORDER BY 
{$this->marshal($sort_field, 'field')} $dir " : '';
                        $this->sort_field = $sort_field;
 

Modified: branches/dev-syncromind-2/rental/inc/class.socontract.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.socontract.inc.php       
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/rental/inc/class.socontract.inc.php       
2016-05-30 08:04:44 UTC (rev 15217)
@@ -356,7 +356,7 @@
                        {
                                // columns to retrieve
                                $columns[] = 'contract.id AS contract_id';
-                               $columns[] = 'contract.date_start, 
contract.date_end, contract.old_contract_id, contract.executive_officer, 
contract.last_updated, contract.location_id, contract.billing_start, 
contract.billing_end, contract.service_id, contract.responsibility_id, 
contract.reference, contract.invoice_header, contract.project_id, 
billing.deleted, contract.account_in, contract.account_out, contract.term_id, 
contract.security_type, contract.security_amount, contract.comment, 
contract.due_date, 
contract.contract_type_id,contract.rented_area,contract.adjustable,contract.adjustment_interval,contract.adjustment_share,contract.adjustment_year,contract.publish_comment';
+                               $columns[] = 'contract.date_start, 
contract.date_end, contract.old_contract_id, contract.executive_officer, 
contract.last_updated, contract.location_id, contract.billing_start, 
contract.billing_end, contract.service_id, contract.responsibility_id, 
contract.reference, contract.invoice_header, contract.project_id, 
billing.deleted, contract.account_in, contract.account_out, contract.term_id, 
contract.security_type, contract.security_amount, contract.comment, 
contract.due_date, 
contract.contract_type_id,contract.rented_area,contract.adjustable,contract.adjustment_interval,contract.adjustment_share,contract.adjustment_year,override_adjustment_start,contract.publish_comment';
                                $columns[] = 'party.id AS party_id';
                                $columns[] = 'party.first_name, 
party.last_name, party.company_name, party.department, party.org_enhet_id';
                                $columns[] = 'c_t.is_payer';
@@ -384,7 +384,7 @@
                        return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}";
                }
 
-               public function get_id_field_name( $extended_info = false )
+               protected function get_id_field_name( $extended_info = false )
                {
                        if (!$extended_info)
                        {
@@ -402,7 +402,7 @@
                        return $ret;
                }
 
-               function populate( int $contract_id, &$contract )
+               protected function populate( int $contract_id, &$contract )
                {
 
                        if ($contract == null) // new contract
@@ -441,6 +441,7 @@
                                
$contract->set_adjustment_interval($this->unmarshal($this->db->f('adjustment_interval'),
 'int'));
                                
$contract->set_adjustment_share($this->unmarshal($this->db->f('adjustment_share'),
 'int'));
                                
$contract->set_adjustment_year($this->unmarshal($this->db->f('adjustment_year'),
 'int'));
+                               
$contract->set_override_adjustment_start($this->unmarshal($this->db->f('override_adjustment_start'),
 'int'));
                                
$contract->set_publish_comment($this->unmarshal($this->db->f('publish_comment'),
 'bool'));
                                
$contract->set_notify_before($this->unmarshal($this->db->f('notify_before'), 
'int'));
                                
$contract->set_notify_before_due_date($this->unmarshal($this->db->f('notify_before_due_date'),
 'int'));
@@ -592,7 +593,7 @@
                 * @param $contract the contract to be updated
                 * @return result receipt from the db operation
                 */
-               function update( $contract )
+               protected function update( $contract )
                {
                        $id = intval($contract->get_id());
 
@@ -629,6 +630,7 @@
                        $values[] = "adjustment_interval = " . 
$this->marshal($contract->get_adjustment_interval(), 'int');
                        $values[] = "adjustment_share = " . 
$this->marshal($contract->get_adjustment_share(), 'int');
                        $values[] = "publish_comment = " . 
($contract->get_publish_comment() ? "true" : "false");
+                       $values[] = "override_adjustment_start = " . 
$this->marshal($contract->get_override_adjustment_start(), 'int');
 
                        // FORM COLUMN 3
                        $values[] = "comment = " . 
$this->marshal($contract->get_comment(), 'string');
@@ -730,7 +732,7 @@
                 * @param $contract the contract to be added
                 * @return array result receipt from the db operation
                 */
-               function add( &$contract )
+               protected function add( &$contract )
                {
 
                        
$contract->set_id(self::get_new_id($contract->get_old_contract_id()));
@@ -828,6 +830,9 @@
                        $cols[] = 'adjustment_year';
                        $values[] = 
$this->marshal($contract->get_adjustment_year(), 'int');
 
+                       $cols[] = 'override_adjustment_start';
+                       $values[] = 
$this->marshal($contract->get_override_adjustment_start(), 'int');
+
                        $cols[] = 'publish_comment';
                        $values[] = ($contract->get_publish_comment() ? "true" 
: "false");
 

Modified: 
branches/dev-syncromind-2/rental/inc/class.socontract_price_item.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.socontract_price_item.inc.php    
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/rental/inc/class.socontract_price_item.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -49,35 +49,43 @@
                        }
                        if (isset($filters['contract_ids_one_time']))
                        {
-                               $billing_term_id = 
(int)$filters['billing_term_id'];
-                               $sql = "SELECT months FROM rental_billing_term 
WHERE id = {$billing_term_id}";
-                               $result = $this->db->query($sql);
-                               if (!$result)
+                               if($filters['credits'])
                                {
-                                       return;
+                                       $filter_clauses[] = "is_one_time";
+                                       $filter_clauses[] = 
"rental_contract_price_item.total_price < 0.00";    
                                }
-                               if (!$this->db->next_record())
-                               {
-                                       return;
-                               }
-                               $month = (int)$filters['month'];
-                               $year = (int)$filters['year'];
-                               $months = 
$this->unmarshal($this->db->f('months', true), 'int');
-                               $timestamp_end = 
strtotime("{$year}-{$month}-01"); // The first day in the month to bill for
-                               if ($months == 1)
-                               {
-                                       $timestamp_start = $timestamp_end; // 
The first day of the period to bill for
-                               }
                                else
                                {
-                                       $months = $months - 1;
-                                       $timestamp_start = 
strtotime("-{$months} months", $timestamp_end); // The first day of the period 
to bill for
+                                       $billing_term_id = 
(int)$filters['billing_term_id'];
+                                       $sql = "SELECT months FROM 
rental_billing_term WHERE id = {$billing_term_id}";
+                                       $result = $this->db->query($sql);
+                                       if (!$result)
+                                       {
+                                               return;
+                                       }
+                                       if (!$this->db->next_record())
+                                       {
+                                               return;
+                                       }
+                                       $month = (int)$filters['month'];
+                                       $year = (int)$filters['year'];
+                                       $months = 
$this->unmarshal($this->db->f('months', true), 'int');
+                                       $timestamp_end = 
strtotime("{$year}-{$month}-01"); // The first day in the month to bill for
+                                       if ($months == 1)
+                                       {
+                                               $timestamp_start = 
$timestamp_end; // The first day of the period to bill for
+                                       }
+                                       else
+                                       {
+                                               $months = $months - 1;
+                                               $timestamp_start = 
strtotime("-{$months} months", $timestamp_end); // The first day of the period 
to bill for
+                                       }
+                                       $timestamp_end = strtotime('+1 month', 
$timestamp_end); // The first day in the month after the one to bill for
+
+                                       $filter_clauses[] = "is_one_time";
+                                       $filter_clauses[] = "date_start < 
{$timestamp_end}";
+                                       $filter_clauses[] = "date_start >= 
{$timestamp_start}";
                                }
-                               $timestamp_end = strtotime('+1 month', 
$timestamp_end); // The first day in the month after the one to bill for
-
-                               $filter_clauses[] = "is_one_time";
-                               $filter_clauses[] = "date_start < 
{$timestamp_end}";
-                               $filter_clauses[] = "date_start >= 
{$timestamp_start}";
                        }
                        if (isset($filters['one_time']) && 
$filters['include_billed'])
                        {
@@ -342,6 +350,10 @@
                public function get_total_price_invoice( $contract_id, 
$billing_term, $month, $year )
                {
                        $billing_term_id = (int)$billing_term;
+                       if($billing_term == 5 )
+                       {
+                               return 
$this->get_total_price_invoice_credit($contract_id);
+                       }
                        $sql = "SELECT months FROM rental_billing_term WHERE id 
= {$billing_term_id}";
                        $result = $this->db->query($sql);
                        if (!$result)
@@ -378,6 +390,20 @@
                                return $total_price;
                        }
                }
+               public function get_total_price_invoice_credit( int 
$contract_id )
+               {
+                       $q_total_price = "SELECT sum(total_price::numeric) AS 
sum_total ";
+                       $q_total_price .= "FROM rental_contract_price_item ";
+                       $q_total_price .= "WHERE contract_id={$contract_id} ";
+                       $q_total_price .= "AND NOT is_billed ";
+                       $q_total_price .= "AND total_price < 0.00 ";
+                       $this->db->query($q_total_price);
+                       if ($this->db->next_record())
+                       {
+                               $total_price = $this->db->f('sum_total');
+                               return $total_price;
+                       }
+               }
 
                /**
                 * Select max area of all "active" price-items on a contract.

Modified: 
branches/dev-syncromind-2/rental/inc/class.soinvoice_price_item.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.soinvoice_price_item.inc.php     
2016-05-30 07:58:10 UTC (rev 15216)
+++ branches/dev-syncromind-2/rental/inc/class.soinvoice_price_item.inc.php     
2016-05-30 08:04:44 UTC (rev 15217)
@@ -1,104 +1,119 @@
-<?php
-       phpgw::import_class('rental.socommon');
-
-       class rental_soinvoice_price_item extends rental_socommon
-       {
-
-               protected static $so;
-
-               /**
-                * Get a static reference to the storage object associated with 
this model object
-                *
-                * @return the storage object
-                */
-               public static function get_instance()
-               {
-                       if (self::$so == null)
-                       {
-                               self::$so = 
CreateObject('rental.soinvoice_price_item');
-                       }
-                       return self::$so;
-               }
-
-               protected function get_id_field_name()
-               {
-                       return 'id';
-               }
-
-               protected function get_query( string $sort_field, bool 
$ascending, string $search_for, string $search_type, array $filters, bool 
$return_count )
-               {
-                       $clauses = array('1=1');
-                       if (isset($filters[$this->get_id_field_name()]))
-                       {
-                               $filter_clauses[] = 
"{$this->marshal($this->get_id_field_name(), 'field')} = 
{$this->marshal($filters[$this->get_id_field_name()], 'int')}";
-                       }
-                       if (isset($filters['invoice_id']))
-                       {
-                               $filter_clauses[] = "invoice_id = 
{$this->marshal($filters['invoice_id'], 'int')}";
-                       }
-                       if (isset($filters['billing_id']))
-                       {
-                               $filter_clauses[] = "billing_id = 
{$this->marshal($filters['billing_id'], 'int')}";
-                       }
-                       if (count($filter_clauses))
-                       {
-                               $clauses[] = join(' AND ', $filter_clauses);
-                       }
-                       $condition = join(' AND ', $clauses);
-
-                       $tables = "rental_invoice_price_item";
-                       $joins = "      {$this->left_join} rental_invoice ON 
(rental_invoice.id = rental_invoice_price_item.invoice_id)";
-                       if ($return_count) // We should only return a count
-                       {
-                               $cols = 
'COUNT(DISTINCT(rental_invoice_price_item.id)) AS count';
-                       }
-                       else
-                       {
-                               $cols = 'rental_invoice_price_item.id, 
invoice_id, title, area, count, agresso_id, is_area, price, total_price, 
date_start, date_end';
-                       }
-                       $dir = $ascending ? 'ASC' : 'DESC';
-                       $order = $sort_field ? "ORDER BY 
{$this->marshal($sort_field, 'field')} $dir " : ($return_count ? '' : 'ORDER BY 
rental_invoice_price_item.id ASC');
-                       return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}";
-               }
-
-               protected function populate( int $price_item_id, &$price_item )
-               {
-                       if ($price_item == null)
-                       {
-                               $price_item = new rental_invoice_price_item(0, 
$this->db->f('id', true), $this->db->f('invoice_id', true), 
$this->db->f('title', true), $this->db->f('agresso_id', true), 
$this->db->f('is_area', true), $this->db->f('price', true), 
$this->db->f('area', true), $this->db->f('count', true), 
strtotime($this->db->f('date_start', true)), strtotime($this->db->f('date_end', 
true)));
-                               
$price_item->set_total_price($this->db->f('total_price', true));
-                       }
-                       return $price_item;
-               }
-
-               public function add( &$invoice_price_item )
-               {
-                       $values = array
-                               (
-                               
$this->marshal($invoice_price_item->get_invoice_id(), 'int'),
-                               
$this->marshal($invoice_price_item->get_title(), 'string'),
-                               
$this->marshal($invoice_price_item->get_agresso_id(), 'string'),
-                               $invoice_price_item->is_area() ? 'true' : 
'false',
-                               
$this->marshal($invoice_price_item->get_price(), 'float'),
-                               $this->marshal($invoice_price_item->get_area(), 
'float'),
-                               
$this->marshal($invoice_price_item->get_count(), 'int'),
-                               
$this->marshal($invoice_price_item->get_total_price(), 'float'),
-                               $this->marshal(date('Y-m-d', 
$invoice_price_item->get_timestamp_start()), 'date'),
-                               $this->marshal(date('Y-m-d', 
$invoice_price_item->get_timestamp_end()), 'date')
-                       );
-                       $query = "INSERT INTO rental_invoice_price_item 
(invoice_id, title, agresso_id, is_area, price, area, count, total_price, 
date_start, date_end) VALUES (" . join(',', $values) . ")";
-                       $receipt = null;
-                       if ($this->db->query($query))
-                       {
-                               $receipt = array();
-                               $receipt['id'] = 
$this->db->get_last_insert_id('rental_invoice_price_item', 'id');
-                               $invoice_price_item->set_id($receipt['id']);
-                       }
-                       return $receipt;
-               }
-
-               protected function update( $object )
-               {
-                       throw new Exception("Not implemented");
-               }
-       }
\ No newline at end of file
+<?php
+       phpgw::import_class('rental.socommon');
+
+       class rental_soinvoice_price_item extends rental_socommon
+       {
+
+               protected static $so;
+
+               /**
+                * Get a static reference to the storage object associated with 
this model object
+                *
+                * @return the storage object
+                */
+               public static function get_instance()
+               {
+                       if (self::$so == null)
+                       {
+                               self::$so = 
CreateObject('rental.soinvoice_price_item');
+                       }
+                       return self::$so;
+               }
+
+               protected function get_id_field_name()
+               {
+                       return 'id';
+               }
+
+               protected function get_query( string $sort_field, bool 
$ascending, string $search_for, string $search_type, array $filters, bool 
$return_count )
+               {
+                       $clauses = array('1=1');
+                       if (isset($filters[$this->get_id_field_name()]))
+                       {
+                               $filter_clauses[] = 
"{$this->marshal($this->get_id_field_name(), 'field')} = 
{$this->marshal($filters[$this->get_id_field_name()], 'int')}";
+                       }
+                       if (isset($filters['invoice_id']))
+                       {
+                               $filter_clauses[] = "invoice_id = 
{$this->marshal($filters['invoice_id'], 'int')}";
+                       }
+                       if (isset($filters['billing_id']))
+                       {
+                               $filter_clauses[] = "billing_id = 
{$this->marshal($filters['billing_id'], 'int')}";
+                       }
+                       if (count($filter_clauses))
+                       {
+                               $clauses[] = join(' AND ', $filter_clauses);
+                       }
+                       $condition = join(' AND ', $clauses);
+
+                       $tables = "rental_invoice_price_item";
+                       $joins = "      {$this->left_join} rental_invoice ON 
(rental_invoice.id = rental_invoice_price_item.invoice_id)";
+                       if ($return_count) // We should only return a count
+                       {
+                               $cols = 
'COUNT(DISTINCT(rental_invoice_price_item.id)) AS count';
+                       }
+                       else
+                       {
+                               $cols = 'rental_invoice_price_item.id, 
invoice_id, title, area, count, agresso_id, is_area, is_one_time, price, 
total_price, date_start, date_end';
+                       }
+                       $dir = $ascending ? 'ASC' : 'DESC';
+                       $order = $sort_field ? "ORDER BY 
{$this->marshal($sort_field, 'field')} $dir " : ($return_count ? '' : 'ORDER BY 
rental_invoice_price_item.id ASC');
+                       return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}";
+               }
+
+               protected function populate( int $price_item_id, &$price_item )
+               {
+                       if ($price_item == null)
+                       {
+                               $price_item = new rental_invoice_price_item(
+                                       0,
+                                       $this->db->f('id', true),
+                                       $this->db->f('invoice_id', true),
+                                       $this->db->f('title', true),
+                                       $this->db->f('agresso_id', true),
+                                       $this->db->f('is_area', true),
+                                       $this->db->f('price', true),
+                                       $this->db->f('area', true),
+                                       $this->db->f('count', true),
+                                       strtotime($this->db->f('date_start', 
true)),
+                                       strtotime($this->db->f('date_end', 
true))
+                               );
+       
+                               
$price_item->set_total_price($this->db->f('total_price', true));
+                               
$price_item->set_is_one_time((bool)$this->db->f('is_one_time'));
+                       }
+                       return $price_item;
+               }
+
+               public function add( &$invoice_price_item )
+               {
+                       $values = array
+                               (
+                               
$this->marshal($invoice_price_item->get_invoice_id(), 'int'),
+                               
$this->marshal($invoice_price_item->get_title(), 'string'),
+                               
$this->marshal($invoice_price_item->get_agresso_id(), 'string'),
+                               $invoice_price_item->is_area() ? 'true' : 
'false',
+                               
$this->marshal($invoice_price_item->get_price(), 'float'),
+                               $this->marshal($invoice_price_item->get_area(), 
'float'),
+                               
$this->marshal($invoice_price_item->get_count(), 'int'),
+                               
$this->marshal($invoice_price_item->get_total_price(), 'float'),
+                               $this->marshal(date('Y-m-d', 
$invoice_price_item->get_timestamp_start()), 'date'),
+                               $this->marshal(date('Y-m-d', 
$invoice_price_item->get_timestamp_end()), 'date'),
+                               $invoice_price_item->is_one_time() ? 'true' : 
'false',
+                       );
+                       $query = "INSERT INTO rental_invoice_price_item 
(invoice_id, title, agresso_id, is_area, price, area, count, total_price, 
date_start, date_end,is_one_time) VALUES (" . join(',', $values) . ")";
+                       $receipt = null;
+                       if ($this->db->query($query))
+                       {
+                               $receipt = array();
+                               $receipt['id'] = 
$this->db->get_last_insert_id('rental_invoice_price_item', 'id');
+                               $invoice_price_item->set_id($receipt['id']);
+                       }
+                       return $receipt;
+               }
+
+               protected function update( $object )
+               {
+                       throw new Exception("Not implemented");
+               }
+       }

Copied: branches/dev-syncromind-2/rental/inc/class.uiapplication.inc.php (from 
rev 15215, trunk/rental/inc/class.uiapplication.inc.php)
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.uiapplication.inc.php            
                (rev 0)
+++ branches/dev-syncromind-2/rental/inc/class.uiapplication.inc.php    
2016-05-30 08:04:44 UTC (rev 15217)
@@ -0,0 +1,465 @@
+<?php
+       /**
+        * phpGroupWare - property: a part of a Facilities Management System.
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2016 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset
+        * @package rental
+        * @subpackage application
+        * @version $Id: $
+        */
+
+       phpgw::import_class('rental.uicommon');
+       phpgw::import_class('rental.soapplication');
+
+       include_class('rental', 'application', 'inc/model/');
+
+       class rental_uiapplication extends rental_uicommon
+       {
+
+               public $public_functions = array
+                       (
+                       'add' => true,
+                       'index' => true,
+                       'query' => true,
+                       'view' => true,
+                       'edit' => true,
+                       'save' => true,
+                       'set_value' => true,
+               );
+
+               public function __construct()
+               {
+                       parent::__construct();
+                       self::set_active_menu('rental::application');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('application');
+               }
+
+               public function index()
+               {
+                       if (!$this->isExecutiveOfficer())
+                       {
+                               phpgw::no_access();
+                       }
+
+                       if (phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               return $this->query();
+                       }
+
+                       phpgwapi_jquery::load_widget('autocomplete');
+
+                       $types_options = array();
+                       $types_options[] = array(
+                               'id'    => 1,
+                               'name'  => 'registrert'
+                       );
+                       $types_options[] = array(
+                               'id'    => 2,
+                               'name'  => 'under behandling'
+                       );
+                       $types_options[] = array(
+                               'id'    => 3,
+                               'name'  => 'avvist'
+                       );
+                       $types_options[] = array(
+                               'id'    => 3,
+                               'name'  => 'godkjent'
+                       );
+
+                       $function_msg = lang('application');
+
+                       $data = array(
+                               'datatable_name' => $function_msg,
+                               'form' => array(
+                                       'toolbar' => array(
+                                               'item' => array(
+                                                       array(
+                                                               'type' => 
'filter',
+                                                               'name' => 
'responsibility_id',
+                                                               'text' => 
lang('status'),
+                                                               'list' => 
$types_options
+                                                       ),
+                                                       array('type' => 
'autocomplete',
+                                                               'name' => 
'dimb',
+                                                               'app' => 
'property',
+                                                               'ui' => 
'generic',
+                                                               
'label_attr'=>'descr',
+                               //                              'show_id'=> 
true,
+                                                               'text' => 
lang('dimb') . ':',
+                                                               
'requestGenerator' => 'requestWithDimbFilter',
+                                                       ),
+                                               )
+                                       )
+                               ),
+                               'datatable' => array(
+                                       'source' => self::link(array(
+                                               'menuaction' => 
'rental.uiapplication.index',
+                                               'phpgw_return_as' => 'json'
+                                       )),
+                                       'allrows' => true,
+                                       'new_item' => 
self::link(array('menuaction' => 'rental.uiapplication.add')),
+                                       'editor_action' => '',
+                                       'field' => array(
+                                               array(
+                                                       'key' => 'title',
+                                                       'label' => lang('name'),
+                                                       'className' => '',
+                                                       'sortable' => true,
+                                                       'hidden' => false
+                                               ),
+                                               array(
+                                                       'key' => 'is_area',
+                                                       'label' => 'Avdeling',
+                                                       'className' => '',
+                                                       'sortable' => true,
+                                                       'hidden' => false
+                                               ),
+                                               array(
+                                                       'key' => 'status',
+                                                       'label' => 
lang('status'),
+                                                       'className' => '',
+                                                       'sortable' => true,
+                                                       'hidden' => false
+                                               ),
+                                               array(
+                                                       'key' => 'assignedto',
+                                                       'label' => 
'saksbehandler',
+                                                       'className' => '',
+                                                       'sortable' => true,
+                                                       'hidden' => false
+                                               ),
+                                               array(
+                                                       'key' => 'type',
+                                                       'label' => lang('type'),
+                                                       'className' => '',
+                                                       'sortable' => false,
+                                                       'hidden' => false
+                                               )
+                                       )
+                               )
+                       );
+
+                       $parameters = array(
+                               'parameter' => array(
+                                       array(
+                                               'name' => 'id',
+                                               'source' => 'id'
+                                       )
+                               )
+                       );
+
+                       $data['datatable']['actions'][] = array
+                               (
+                               'my_name' => 'view',
+                               'text' => lang('show'),
+                               'action' => 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                       'menuaction' => 
'rental.uiapplication.view'
+                               )),
+                               'parameters' => json_encode($parameters)
+                       );
+
+                       $data['datatable']['actions'][] = array
+                               (
+                               'my_name' => 'edit',
+                               'text' => lang('edit'),
+                               'action' => 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                       'menuaction' => 
'rental.uiapplication.edit'
+                               )),
+                               'parameters' => json_encode($parameters)
+                       );
+
+                       $code = <<<JS
+                               var thousandsSeparator = 
'$this->thousandsSeparator';
+                               var decimalSeparator = 
'$this->decimalSeparator';
+                               var decimalPlaces = '$this->decimalPlaces';
+                               var currency_suffix = '$this->currency_suffix';
+JS;
+
+                       $GLOBALS['phpgw']->js->add_code('', $code);
+
+                       self::add_javascript('rental', 'rental', 
'application.index.js');
+                       phpgwapi_jquery::load_widget('numberformat');
+
+                       self::render_template_xsl('datatable_jquery', $data);
+               }
+               /*
+                * View the price item with the id given in the http variable 
'id'
+                */
+
+               public function view()
+               {
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('view');
+
+                       if (!self::isExecutiveOfficer())
+                       {
+                               phpgw::no_access();
+                       }
+
+                       $this->edit(array(), 'view');
+               }
+               /*
+                * Edit the price item with the id given in the http variable 
'id'
+                */
+
+               public function edit( $values = array(), $mode = 'edit' )
+               {
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('edit');
+                       if (!self::isExecutiveOfficer())
+                       {
+                               phpgw::no_access();
+                       }
+
+                       $responsibility_id = 
phpgw::get_var('responsibility_id');
+                       $application_id = phpgw::get_var('id', 'int');
+
+                       if (!empty($values['application_id']))
+                       {
+                               $application_id = $values['application_id'];
+                       }
+
+                       if (!empty($application_id))
+                       {
+                               $application = 
rental_application::get($application_id);
+                       }
+                       else
+                       {
+                               $title = phpgw::get_var('application_title');
+
+                               $application = new rental_application();
+                               $application->set_title($title);
+//                             
$application->set_responsibility_id($responsibility_id);
+//                             $application->set_price_type_id(1); // defaults 
to year
+                       }
+
+       //              $responsibility_title = 
($application->get_responsibility_title()) ? 
$application->get_responsibility_title() : 
rental_socontract::get_instance()->get_responsibility_title($responsibility_id);
+
+                       $link_save = array(
+                               'menuaction' => 'rental.uiapplication.save'
+                       );
+
+                       $link_index = array(
+                               'menuaction' => 'rental.uiapplication.index',
+                       );
+
+                       $tabs = array();
+                       $tabs['showing'] = array('label' => 
lang('application'), 'link' => '#showing');
+                       $active_tab = 'showing';
+
+//                     $current_price_type_id = 
$application->get_price_type_id();
+                       $types_options = array();
+//                     foreach ($application->get_price_types() as 
$price_type_id => $price_type_title)
+//                     {
+//                             $selected = ($current_price_type_id == 
$price_type_id) ? 1 : 0;
+//                             $types_options[] = array('id' => 
$price_type_id, 'name' => lang($price_type_title),
+//                                     'selected' => $selected);
+//                     }
+
+                       $data = array(
+                               'form_action' => 
$GLOBALS['phpgw']->link('/index.php', $link_save),
+                               'cancel_url' => 
$GLOBALS['phpgw']->link('/index.php', $link_index),
+                               'lang_save' => lang('save'),
+                               'lang_cancel' => lang('cancel'),
+//                             'lang_current_price_type' => 
lang($application->get_price_type_title()),
+//                             'lang_adjustable_text' => 
$application->get_adjustable_text(),
+//                             'lang_standard_text' => 
$application->get_standard_text(),
+//                             'value_title' => $application->get_title(),
+//                             'value_field_of_responsibility' => 
lang($responsibility_title),
+//                             'value_agresso_id' => 
$application->get_agresso_id(),
+//                             'is_area' => ($application->is_area()) ? 1 : 0,
+//                             'list_type' => array('options' => 
$types_options),
+//                             'value_price' => $application->get_price(),
+//                             'value_price_formatted' => 
number_format($application->get_price(), $this->decimalPlaces, 
$this->decimalSeparator, $this->thousandsSeparator) . ' ' . 
$this->currency_suffix,
+//                             'has_active_contract' => 
(rental_soapplication::get_instance()->has_active_contract($application->get_id()))
 ? 1 : 0,
+//                             'is_inactive' => ($application->is_inactive()) 
? 1 : 0,
+//                             'is_adjustable' => 
($application->is_adjustable()) ? 1 : 0,
+//                             'is_standard' => ($application->is_standard()) 
? 1 : 0,
+                               'application_id' => $application->get_id(),
+//                             'responsibility_id' => $responsibility_id,
+                               'mode' => $mode,
+                               'tabs' => 
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
+                               'validator' => 
phpgwapi_jquery::formvalidator_generate(array('location',
+                                       'date',
+                                       'security', 'file'))
+                       );
+
+                       self::render_template_xsl(array('application'), 
array($mode => $data));
+               }
+               /*
+                * To be removed
+                * Add a new price item to the database.  Requires only a title.
+                */
+
+               public function add()
+               {
+                       if (!self::isExecutiveOfficer())
+                       {
+                               phpgw::no_access();
+                       }
+
+                       $this->edit();
+               }
+
+               public function save()
+               {
+                       $application_id = phpgw::get_var('id', 'int');
+
+                       if (!empty($application_id))
+                       {
+                               $application = 
rental_application::get($application_id);
+                       }
+                       else
+                       {
+                               $title = phpgw::get_var('application_title');
+                               $responsibility_id = 
phpgw::get_var('responsibility_id');
+                               $application = new rental_application();
+                               $application->set_title($title);
+                               
$application->set_responsibility_id($responsibility_id);
+                               $application->set_price_type_id(1); // defaults 
to year
+                       }
+
+                       $application->set_title(phpgw::get_var('title'));
+                       
$application->set_agresso_id(phpgw::get_var('agresso_id'));
+                       $application->set_is_area(phpgw::get_var('is_area') == 
'true' ? true : false);
+                       
$application->set_is_inactive(phpgw::get_var('is_inactive') == 'on' ? true : 
false);
+                       
$application->set_is_adjustable(phpgw::get_var('is_adjustable') == 'on' ? true 
: false);
+                       $application->set_standard(phpgw::get_var('standard') 
== 'on' ? true : false);
+                       $application->set_price(phpgw::get_var('price'));
+                       
$application->set_price_type_id(phpgw::get_var('price_type_id', 'int'));
+                       if ($application->get_agresso_id() == null)
+                       {
+                               
phpgwapi_cache::message_set(lang('missing_agresso_id'), 'error');
+                       }
+                       else
+                       {
+                               if 
(rental_soapplication::get_instance()->store($application))
+                               {
+                                       
phpgwapi_cache::message_set(lang('messages_saved_form'), 'message');
+                                       $application_id = 
$application->get_id();
+                               }
+                               else
+                               {
+                                       
phpgwapi_cache::message_set(lang('messages_form_error'), 'error');
+                               }
+                       }
+                       $this->edit(array('application_id' => $application_id));
+               }
+
+               public function set_value()
+               {
+                       if (!self::isExecutiveOfficer())
+                       {
+                               return;
+                       }
+
+                       $field_name = phpgw::get_var('field_name');
+                       $value = phpgw::get_var('value');
+                       $id = phpgw::get_var('id');
+
+                       switch ($field_name)
+                       {
+                               case 'count':
+                                       $value = (int) $value;
+                                       break;
+                               case 'price':
+                                       $value = 
trim(str_replace(array($this->currency_suffix, " "), '', $value));
+                                       break;
+                               case 'date_start':
+                               case 'date_end':

@@ Diff output truncated at 153600 characters. @@



reply via email to

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