fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [14548] controller: formatting code


From: Sigurd Nes
Subject: [Fmsystem-commits] [14548] controller: formatting code
Date: Wed, 09 Dec 2015 19:19:59 +0000

Revision: 14548
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14548
Author:   sigurdne
Date:     2015-12-09 19:19:58 +0000 (Wed, 09 Dec 2015)
Log Message:
-----------
controller: formatting code

Modified Paths:
--------------
    branches/dev-syncromind/controller/inc/class.cat_hooks.inc.php
    branches/dev-syncromind/controller/inc/class.hook_helper.inc.php
    branches/dev-syncromind/controller/inc/class.menu.inc.php
    branches/dev-syncromind/controller/inc/class.socase.inc.php
    branches/dev-syncromind/controller/inc/class.socheck_item.inc.php
    branches/dev-syncromind/controller/inc/class.socheck_list.inc.php
    branches/dev-syncromind/controller/inc/class.socommon.inc.php
    branches/dev-syncromind/controller/inc/class.socontrol.inc.php
    branches/dev-syncromind/controller/inc/class.socontrol_group.inc.php
    branches/dev-syncromind/controller/inc/class.socontrol_group_list.inc.php
    branches/dev-syncromind/controller/inc/class.socontrol_item.inc.php
    branches/dev-syncromind/controller/inc/class.socontrol_item_list.inc.php
    branches/dev-syncromind/controller/inc/class.socontrol_item_option.inc.php
    branches/dev-syncromind/controller/inc/class.sodocument.inc.php
    branches/dev-syncromind/controller/inc/class.soprocedure.inc.php
    branches/dev-syncromind/controller/inc/class.uicalendar.inc.php
    branches/dev-syncromind/controller/inc/class.uicase.inc.php
    branches/dev-syncromind/controller/inc/class.uicheck_list.inc.php
    
branches/dev-syncromind/controller/inc/class.uicheck_list_for_component.inc.php
    branches/dev-syncromind/controller/inc/class.uicomponent.inc.php
    branches/dev-syncromind/controller/inc/class.uicontrol.inc.php
    branches/dev-syncromind/controller/inc/class.uicontrol_group.inc.php
    
branches/dev-syncromind/controller/inc/class.uicontrol_group_component.inc.php
    branches/dev-syncromind/controller/inc/class.uicontrol_item.inc.php
    
branches/dev-syncromind/controller/inc/class.uicontrol_register_to_component.inc.php
    
branches/dev-syncromind/controller/inc/class.uicontrol_register_to_location.inc.php
    branches/dev-syncromind/controller/inc/class.uidocument.inc.php
    branches/dev-syncromind/controller/inc/class.uilookup.inc.php
    branches/dev-syncromind/controller/inc/class.uiprocedure.inc.php
    
branches/dev-syncromind/controller/inc/component/class.check_list_status_info.inc.php
    
branches/dev-syncromind/controller/inc/component/class.check_list_status_manager.inc.php
    
branches/dev-syncromind/controller/inc/component/class.date_generator.inc.php
    
branches/dev-syncromind/controller/inc/component/class.month_calendar.inc.php
    
branches/dev-syncromind/controller/inc/component/class.status_agg_month_info.inc.php
    branches/dev-syncromind/controller/inc/component/class.year_calendar.inc.php
    
branches/dev-syncromind/controller/inc/component/class.year_calendar_agg.inc.php
    branches/dev-syncromind/controller/inc/helper/class.date_converter.inc.php
    branches/dev-syncromind/controller/inc/helper/class.location_finder.inc.php
    branches/dev-syncromind/controller/inc/hook_config.inc.php
    branches/dev-syncromind/controller/inc/hook_settings.inc.php
    branches/dev-syncromind/controller/inc/model/class.check_item.inc.php
    branches/dev-syncromind/controller/inc/model/class.check_item_case.inc.php
    branches/dev-syncromind/controller/inc/model/class.check_list.inc.php
    branches/dev-syncromind/controller/inc/model/class.component.inc.php
    branches/dev-syncromind/controller/inc/model/class.control.inc.php
    branches/dev-syncromind/controller/inc/model/class.control_group.inc.php
    
branches/dev-syncromind/controller/inc/model/class.control_group_list.inc.php
    branches/dev-syncromind/controller/inc/model/class.control_item.inc.php
    branches/dev-syncromind/controller/inc/model/class.control_item_list.inc.php
    
branches/dev-syncromind/controller/inc/model/class.control_item_option.inc.php
    branches/dev-syncromind/controller/inc/model/class.control_location.inc.php
    branches/dev-syncromind/controller/inc/model/class.document.inc.php
    branches/dev-syncromind/controller/inc/model/class.model.inc.php
    branches/dev-syncromind/controller/inc/model/class.procedure.inc.php
    branches/dev-syncromind/controller/js/controller/ajax.js
    
branches/dev-syncromind/controller/js/controller/ajax_control_to_component.js
    branches/dev-syncromind/controller/js/controller/ajax_control_to_location.js
    branches/dev-syncromind/controller/js/controller/case.js
    branches/dev-syncromind/controller/js/controller/check_list.js
    branches/dev-syncromind/controller/js/controller/check_list_update_status.js
    
branches/dev-syncromind/controller/js/controller/control_group_to_component.js
    branches/dev-syncromind/controller/js/controller/custom_drag_drop.js
    branches/dev-syncromind/controller/js/controller/custom_ui.js

Modified: branches/dev-syncromind/controller/inc/class.cat_hooks.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.cat_hooks.inc.php      
2015-12-09 18:15:59 UTC (rev 14547)
+++ branches/dev-syncromind/controller/inc/class.cat_hooks.inc.php      
2015-12-09 19:19:58 UTC (rev 14548)
@@ -1,53 +1,55 @@
 <?php
        /**
-       * phpGroupWare - controller: a part of a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2011,2012 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/bbb_/ekstern/
-       * @package controller
-       * @subpackage entity
-       * @version $Id$
-       */
+        * phpGroupWare - controller: a part of a Facilities Management System.
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2011,2012 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/bbb_/ekstern/
+        * @package controller
+        * @subpackage entity
+        * @version $Id$
+        */
 
        /**
-       * hook management for categories
-       * @package controller
-       */
+        * hook management for categories
+        * @package controller
+        */
        class controller_cat_hooks
        {
+
                protected $soresponsible;
                protected $_db;
 
                function __construct()
                {
-                       $this->_db                              =& 
$GLOBALS['phpgw']->db;
-                       $this->soresponsible    = 
CreateObject('property.soresponsible');
-                       $this->soresponsible->appname = 'controller';
-               }               
+                       $this->_db                                              
 = & $GLOBALS['phpgw']->db;
+                       $this->soresponsible                     = 
CreateObject('property.soresponsible');
+                       $this->soresponsible->appname    = 'controller';
+               }
+
                /**
                 * Handle a new category being added, create location to hold 
ACL-data
                 */
                function cat_add($data)
                {
-                       if ( isset($data['cat_owner']) && $data['cat_owner'] != 
-1 )
+                       if(isset($data['cat_owner']) && $data['cat_owner'] != 
-1)
                        {
                                return false; //nothing needed to be done, we 
only care about global cats
                        }
@@ -55,22 +57,22 @@
                        $location = '';
                        if($data['location_id'])
                        {
-                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($data['location_id']);
-                               $location = $location_info['location'];
+                               $location_info   = 
$GLOBALS['phpgw']->locations->get_name($data['location_id']);
+                               $location                = 
$location_info['location'];
                        }
                        
$GLOBALS['phpgw']->locations->add("{$location}.category.{$data['cat_id']}", 
$data['cat_name'], 'controller');
-                       
-/*
-                       $this->soresponsible->add_type(array
-                               (
-                                       'name'  => $data['cat_name'],
-                                       'descr' => $data['cat_name'],
-                                       'location'      => 
"{$location}.category.{$data['cat_id']}",
-                                       'cat_id'        => $data['cat_id'],
-                                       'active'        => true
-                               )
-                       );
-*/
+
+                       /*
+                         $this->soresponsible->add_type(array
+                         (
+                         'name'        => $data['cat_name'],
+                         'descr'       => $data['cat_name'],
+                         'location'    => 
"{$location}.category.{$data['cat_id']}",
+                         'cat_id'      => $data['cat_id'],
+                         'active'      => true
+                         )
+                         );
+                        */
                }
 
                /**
@@ -78,14 +80,14 @@
                 */
                function cat_delete($data)
                {
-                       if ( isset($data['cat_owner']) && $data['cat_owner'] != 
-1 )
+                       if(isset($data['cat_owner']) && $data['cat_owner'] != 
-1)
                        {
                                return false; //nothing needed to be done, we 
only care about global cats
                        }
                        if($data['location_id'])
                        {
-                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($data['location_id']);
-                               $location = 
"{$location_info['location']}.category.{$data['cat_id']}";
+                               $location_info   = 
$GLOBALS['phpgw']->locations->get_name($data['location_id']);
+                               $location                = 
"{$location_info['location']}.category.{$data['cat_id']}";
                                
$GLOBALS['phpgw']->locations->delete('controller', $location, false);
 //                             $this->_db->query("DELETE FROM 
fm_responsibility WHERE cat_id = " . (int) $data['cat_id'], __LINE__, __FILE__);
                        }
@@ -96,24 +98,24 @@
                 */
                function cat_edit($data)
                {
-                       if ( isset($data['cat_owner']) && $data['cat_owner'] != 
-1 )
+                       if(isset($data['cat_owner']) && $data['cat_owner'] != 
-1)
                        {
                                return false; //nothing needed to be done, we 
only care about global cats
                        }
 
                        if($data['location_id'])
                        {
-                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($data['location_id']);
-                               $location = 
"{$location_info['location']}.category.{$data['cat_id']}";
+                               $location_info   = 
$GLOBALS['phpgw']->locations->get_name($data['location_id']);
+                               $location                = 
"{$location_info['location']}.category.{$data['cat_id']}";
                                
$GLOBALS['phpgw']->locations->update_description($location, $data['cat_name'], 
'controller');
 
-/*
-                               $value_set['name']              = 
$this->_db->db_addslashes($data['cat_name']);
-                               $value_set['descr']             = 
$value_set['name'];
+                               /*
+                                 $value_set['name']            = 
$this->_db->db_addslashes($data['cat_name']);
+                                 $value_set['descr']           = 
$value_set['name'];
 
-                               $value_set      = 
$this->_db->validate_update($value_set);
-                               $this->_db->query("UPDATE fm_responsibility SET 
$value_set WHERE cat_id = " . (int) $data['cat_id'], __LINE__, __FILE__);
-*/
+                                 $value_set    = 
$this->_db->validate_update($value_set);
+                                 $this->_db->query("UPDATE fm_responsibility 
SET $value_set WHERE cat_id = " . (int) $data['cat_id'], __LINE__, __FILE__);
+                                */
                        }
                }
-       }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/controller/inc/class.hook_helper.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.hook_helper.inc.php    
2015-12-09 18:15:59 UTC (rev 14547)
+++ branches/dev-syncromind/controller/inc/class.hook_helper.inc.php    
2015-12-09 19:19:58 UTC (rev 14548)
@@ -10,20 +10,19 @@
         * @package controller
         * @version $Id$
         */
-
        /*
-          This program 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.
+         This program 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.
 
-          This program 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.
+         This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+         You should have received a copy of the GNU General Public License
+         along with this program.  If not, see <http://www.gnu.org/licenses/>.
         */
 
        include_class('controller', 'check_list', 'inc/model/');
@@ -39,15 +38,15 @@
         */
        class controller_hook_helper
        {
+
                private $home_alternative;
                private $skip_portalbox_controls;
 
-
                public function __construct()
                {
-                       $config  = CreateObject('phpgwapi.config', 
'controller');
+                       $config                                  = 
CreateObject('phpgwapi.config', 'controller');
                        $config->read();
-                       $this->home_alternative = 
isset($config->config_data['home_alternative']) && 
$config->config_data['home_alternative'] == 1 ? true : false;
+                       $this->home_alternative  = 
isset($config->config_data['home_alternative']) && 
$config->config_data['home_alternative'] == 1 ? true : false;
                }
 
                /**
@@ -66,6 +65,7 @@
                                $this->home();
                        }
                }
+
                /**
                 * Show info for homepage - called from mobilefrontend
                 *
@@ -87,49 +87,48 @@
                private function status_componants()
                {
 
-                               $portalbox = CreateObject('phpgwapi.listbox', 
array
+                       $portalbox = CreateObject('phpgwapi.listbox', array
                                (
-                                       'title'         => lang('controller'),
-                                       'primary'       => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
-                                       'secondary'     => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
-                                       'tertiary'      => 
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
-                                       'width' => '100%',
-                                       'outerborderwidth'      => '0',
-                                       'header_background_image'       => 
$GLOBALS['phpgw']->common->image('phpgwapi','bg_filler', '.png', False)
-                               ));
+                               'title'                                         
 => lang('controller'),
+                               'primary'                                       
 => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+                               'secondary'                                     
 => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+                               'tertiary'                                      
 => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+                               'width'                                         
 => '100%',
+                               'outerborderwidth'                       => '0',
+                               'header_background_image'        => 
$GLOBALS['phpgw']->common->image('phpgwapi', 'bg_filler', '.png', False)
+                       ));
 
-                               $app_id = 
$GLOBALS['phpgw']->applications->name2id('controller');
-                               if( !isset($GLOBALS['portal_order']) 
||!in_array($app_id, $GLOBALS['portal_order']) )
-                               {
-                                       $GLOBALS['portal_order'][] = $app_id;
-                               }
+                       $app_id = 
$GLOBALS['phpgw']->applications->name2id('controller');
+                       if(!isset($GLOBALS['portal_order']) || 
!in_array($app_id, $GLOBALS['portal_order']))
+                       {
+                               $GLOBALS['portal_order'][] = $app_id;
+                       }
 
-                               $var = $this->get_controls($app_id);
+                       $var = $this->get_controls($app_id);
 
-                               foreach ( $var as $key => $value )
-                               {
-                                       $portalbox->set_controls($key,$value);
-                               }
-/*
-                               $url_component  = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicomponent.index', 'noframework' => true));
+                       foreach($var as $key => $value)
+                       {
+                               $portalbox->set_controls($key, $value);
+                       }
+                       /*
+                         $url_component        = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicomponent.index', 'noframework' => true));
 
-                               $extra_data = <<<HTML
-                                <iframe src="{$url_component}" width="100%" 
height="400" style="border:none"></iframe>
-HTML;
-*/
-                               $lang_status_components =  
$GLOBALS['phpgw']->translation->translate('status components', array(), false, 
'controller');
-                               $url_component  = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicomponent.index'));
-                                
-                                $extra_data = <<<HTML
+                         $extra_data = <<<HTML
+                         <iframe src="{$url_component}" width="100%" 
height="400" style="border:none"></iframe>
+                         HTML;
+                        */
+                       $lang_status_components  = 
$GLOBALS['phpgw']->translation->translate('status components', array(), false, 
'controller');
+                       $url_component                   = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicomponent.index'));
+
+                       $extra_data = <<<HTML
                                 <a 
href="{$url_component}">{$lang_status_components}</a>
 HTML;
 
-                                $portalbox->data = array();
+                       $portalbox->data = array();
 
-                               echo "\n".'<!-- BEGIN ticket info -->'."\n<div 
class='property_tickets' style='padding-left: 
10px;'>".$portalbox->draw($extra_data)."</div>\n".'<!-- END ticket info 
-->'."\n";
+                       echo "\n" . '<!-- BEGIN ticket info -->' . "\n<div 
class='property_tickets' style='padding-left: 10px;'>" . 
$portalbox->draw($extra_data) . "</div>\n" . '<!-- END ticket info -->' . "\n";
 
-                               unset($portalbox);
-                       
+                       unset($portalbox);
                }
 
                private function get_controls($app_id)
@@ -139,9 +138,9 @@
                                return array();
                        }
                        $var = array
-                       (
-                               'up'    => array('url'  => '/set_box.php', 
'app'        => $app_id),
-                               'down'  => array('url'  => '/set_box.php', 
'app'        => $app_id),
+                               (
+                               'up'     => array('url' => '/set_box.php', 
'app' => $app_id),
+                               'down'   => array('url' => '/set_box.php', 
'app' => $app_id),
 //                             'close' => array('url'  => '/set_box.php', 
'app'        => $app_id),
 //                             'question'      => array('url'  => 
'/set_box.php', 'app'        => $app_id),
 //                             'edit'  => array('url'  => '/set_box.php', 
'app'        => $app_id)
@@ -157,26 +156,26 @@
                public function home()
                {
                        $app_id = 
$GLOBALS['phpgw']->applications->name2id('controller');
-                       if( !isset($GLOBALS['portal_order']) 
||!in_array($app_id, $GLOBALS['portal_order']) )
+                       if(!isset($GLOBALS['portal_order']) || 
!in_array($app_id, $GLOBALS['portal_order']))
                        {
                                $GLOBALS['portal_order'][] = $app_id;
                        }
 
-                       $location_array = array();
-                       $component_short_desc = array();
-                       $component_short_desc[0][0] = '';
+                       $location_array                          = array();
+                       $component_short_desc            = array();
+                       $component_short_desc[0][0]      = '';
 
-                       $so_check_list = 
CreateObject('controller.socheck_list');
-                       $so_control = CreateObject('controller.socontrol');
+                       $so_check_list   = 
CreateObject('controller.socheck_list');
+                       $so_control              = 
CreateObject('controller.socontrol');
 
-                       $config = CreateObject('phpgwapi.config','controller');
+                       $config                                  = 
CreateObject('phpgwapi.config', 'controller');
                        $config->read();
-                       $limit_no_of_planned = 
isset($GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_planned_controls'])?
 
$GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_planned_controls']
 : (isset($config->config_data['no_of_planned_controls']) && 
$config->config_data['no_of_planned_controls'] > 0 ? 
$config->config_data['no_of_planned_controls']:5);
-                       $limit_no_of_assigned = 
isset($GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_assigned_controls'])?
 
$GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_assigned_controls']
 : (isset($config->config_data['no_of_assigned_controls']) && 
$config->config_data['no_of_assigned_controls'] > 0 ? 
$config->config_data['no_of_assigned_controls']:10);
+                       $limit_no_of_planned     = 
isset($GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_planned_controls'])
 ? 
$GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_planned_controls']
 : (isset($config->config_data['no_of_planned_controls']) && 
$config->config_data['no_of_planned_controls'] > 0 ? 
$config->config_data['no_of_planned_controls'] : 5);
+                       $limit_no_of_assigned    = 
isset($GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_assigned_controls'])
 ? 
$GLOBALS['phpgw_info']['user']['preferences']['controller']['no_of_assigned_controls']
 : (isset($config->config_data['no_of_assigned_controls']) && 
$config->config_data['no_of_assigned_controls'] > 0 ? 
$config->config_data['no_of_assigned_controls'] : 10);
 
                        $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
 
-                       $styling  = "\n".'<!-- BEGIN checklist info -->'."\n ";
+                       $styling = "\n" . '<!-- BEGIN checklist info -->' . "\n 
";
                        $styling .= "<style>";
                        $styling .= " .home-box { background: none repeat 
scroll 0 0 #EDF5FF; border-color: #DBE5EF; border-radius: 4px; margin: 5px 20px 
20px;}";
                        $styling .= " .home-box .home_portal { margin: 
0;border: 1px solid #EBF3FC;}";
@@ -209,7 +208,7 @@
                        $styling .= " .expand_list li{ 
clear:both;overflow:hidden;margin:5px 0; }";
 
                        $styling .= "</style>";
-                       $styling .= "\n".'<!-- END checklist info -->'."\n";
+                       $styling .= "\n" . '<!-- END checklist info -->' . "\n";
                        echo $styling;
 
                        //Loaded from home.php
@@ -231,34 +230,34 @@
 
                        // Fetches my properties
                        $criteria = array
-                       (
-                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'],
-                               'type_id' => 1, // Nivå i bygningsregisteret 
1:eiendom
-                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
-                               'allrows' => false
+                               (
+                               'user_id'        => 
$GLOBALS['phpgw_info']['user']['account_id'],
+                               'type_id'        => 1, // Nivå i 
bygningsregisteret 1:eiendom
+                               'role_id'        => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
+                               'allrows'        => false
                        );
 
                        $location_finder = new location_finder();
-                       $my_properties = 
$location_finder->get_responsibilities( $criteria );
+                       $my_properties   = 
$location_finder->get_responsibilities($criteria);
 
                        // Fetches my buildings
                        $criteria = array
-                       (
-                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'],
-                               'type_id' => 2, // Nivå i bygningsregisteret 
1:eiendom
-                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
-                               'allrows' => false
+                               (
+                               'user_id'        => 
$GLOBALS['phpgw_info']['user']['account_id'],
+                               'type_id'        => 2, // Nivå i 
bygningsregisteret 1:eiendom
+                               'role_id'        => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
+                               'allrows'        => false
                        );
 
                        $location_finder = new location_finder();
-                       $my_buildings = $location_finder->get_responsibilities( 
$criteria );
+                       $my_buildings    = 
$location_finder->get_responsibilities($criteria);
 
                        $my_locations = array_merge($my_properties, 
$my_buildings);
 
 
-               /* =======================================  PLANNED CONTROLS 
FOR CURRENT USER  ================================= */
+                       /* =======================================  PLANNED 
CONTROLS FOR CURRENT USER  ================================= */
 
-                       $my_planned_controls_HTML = <<<HTML
+                       $my_planned_controls_HTML        = <<<HTML
                                <div class='home_portal'>
                                        <table>
                                        <tr>
@@ -270,70 +269,69 @@
                                        </tr>
 HTML;
                        // Todays date
-                       $from_date_ts =  mktime(0, 0, 0, date("n"), date("j"), 
date("Y") );
+                       $from_date_ts                            = mktime(0, 0, 
0, date("n"), date("j"), date("Y"));
                        // One month ahead in time
-                       $to_date_ts = mktime(0, 0, 0, date("n")+1, date("j"), 
date("Y") );
+                       $to_date_ts                                      = 
mktime(0, 0, 0, date("n") + 1, date("j"), date("Y"));
 
-               // fetch all repeat types
+                       // fetch all repeat types
                        $repeat_type = null;
 
-               // Fetches controls current user is responsible for 1 month 
ahead
+                       // Fetches controls current user is responsible for 1 
month ahead
                        $my_controls = array();
 //                     $my_controls = $this->get_my_controls($my_locations, 
$from_date_ts, $to_date_ts, $repeat_type);
 
                        $my_check_lists = 
$this->get_my_assigned_check_list($from_date_ts, $to_date_ts, $repeat_type);
 
                        $_assigned_list = array();
-                       foreach ($my_check_lists as $_key => $my_check_list)
+                       foreach($my_check_lists as $_key => $my_check_list)
                        {
                                
$_assigned_list[$my_check_list['location_code']][$_key] = $my_check_list;
                        }
 
-                       foreach ($_assigned_list as $location_code => 
$controls_at_location)
+                       foreach($_assigned_list as $location_code => 
$controls_at_location)
                        {
-                               $my_controls[] = array( $location_code, 
'assigned', $controls_at_location );
-                       } 
+                               $my_controls[] = array($location_code, 
'assigned', $controls_at_location);
+                       }
 
                        $my_planned_controls = array();
                        // Generates an array with planned controls
                        foreach($my_controls as $container_arr)
                        {
-                               $location_code = $container_arr[0];
-                               $control_type = $container_arr[1];
-                               $controls = $container_arr[2];
+                               $location_code   = $container_arr[0];
+                               $control_type    = $container_arr[1];
+                               $controls                = $container_arr[2];
 
                                foreach($controls as $my_control)
                                {
                                        if($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_DAY)
                                        {
                                                // Daily control: To_date 
assigned to one week ahead in time if repeat type is daily
-                                               $to_date_ts =  mktime(0, 0, 0, 
date("n"), date("j")+7, date("Y") );
+                                               $to_date_ts = mktime(0, 0, 0, 
date("n"), date("j") + 7, date("Y"));
                                        }
-                                       else if(($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_WEEK)
-                                                               | 
($my_control["repeat_type"] == controller_control::REPEAT_TYPE_MONTH)
-                                                               | 
($my_control["repeat_type"] == controller_control::REPEAT_TYPE_YEAR))
+                                       else if(($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_WEEK) | ($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_MONTH) | ($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_YEAR))
                                        {
                                                // Daily, monthly yearly 
control: to_date in one month
-                                               $to_date_ts =  mktime(0, 0, 0, 
date("n")+1, date("j"), date("Y") );
+                                               $to_date_ts = mktime(0, 0, 0, 
date("n") + 1, date("j"), date("Y"));
                                        }
 
                                        if($control_type == "location")
                                        {
-                                               $check_list_array = 
$so_check_list->get_check_lists_for_control_and_location( $my_control['id'], 
$location_code, $from_date_ts, $to_date_ts, $repeat_type = null, 
$filter_assigned_to = true);
+                                               $check_list_array        = 
$so_check_list->get_check_lists_for_control_and_location($my_control['id'], 
$location_code, $from_date_ts, $to_date_ts, $repeat_type          = null, 
$filter_assigned_to     = true);
                                                foreach($check_list_array as 
$check_list)
                                                {
                                                        
$planned_date_for_check_list = $check_list->get_planned_date();
 
                                                        
if($planned_date_for_check_list > 0)
                                                        {
-                                                               
$my_planned_controls[$planned_date_for_check_list][] = array( 
$check_list->get_deadline(), $my_control, $check_list->get_id(), "location", 
$location_code );
+                                                               
$my_planned_controls[$planned_date_for_check_list][] = 
array($check_list->get_deadline(),
+                                                                       
$my_control, $check_list->get_id(), "location", $location_code);
                                                        }
                                                }
                                        }
                                        else if($control_type == "component")
                                        {
-                                               $component = $container_arr[3];
-                                               
$check_lists_for_control_and_component = 
$so_check_list->get_check_lists_for_control_and_component( $my_control['id'], 
$component['location_id'], $component['id'], $from_date_ts, $to_date_ts, 
$repeat_type = null );
+                                               $component                      
                                         = $container_arr[3];
+                                               
$check_lists_for_control_and_component   = 
$so_check_list->get_check_lists_for_control_and_component($my_control['id'], 
$component['location_id'], $component['id'], $from_date_ts, $to_date_ts, 
$repeat_type                                                    = null);
 
                                                
foreach($check_lists_for_control_and_component['check_lists_array'] as 
$check_list)
                                                {
@@ -341,7 +339,9 @@
 
                                                        
if($planned_date_for_check_list > 0)
                                                        {
-                                                               
$my_planned_controls[$planned_date_for_check_list][] = 
array($check_list->get_deadline(), $my_control, $check_list->get_id(), 
"component", $component['location_id'], $component['id'] );
+                                                               
$my_planned_controls[$planned_date_for_check_list][] = 
array($check_list->get_deadline(),
+                                                                       
$my_control, $check_list->get_id(), "component", $component['location_id'],
+                                                                       
$component['id']);
                                                        }
                                                }
                                        }
@@ -354,7 +354,8 @@
 
                                                        
if($planned_date_for_check_list > 0)
                                                        {
-                                                               
$my_planned_controls[$planned_date_for_check_list][] = array( 
$check_list['deadline'], $my_control, $check_list['id'], "location", 
$location_code );
+                                                               
$my_planned_controls[$planned_date_for_check_list][] = 
array($check_list['deadline'],
+                                                                       
$my_control, $check_list['id'], "location", $location_code);
                                                        }
                                                }
                                        }
@@ -369,45 +370,46 @@
                                foreach($planned_controls_on_date as 
$my_planned_control)
                                {
 
-                                       switch ($_row_class)
+                                       switch($_row_class)
                                        {
                                                case 'on':
-                                                       $_row_class = 'off';
+                                                       $_row_class      = 
'off';
                                                        break;
                                                case 'off':
-                                                       $_row_class = 'on';
+                                                       $_row_class      = 'on';
                                                        break;
                                                default:
-                                                       $_row_class = 'on';     
                                        
+                                                       $_row_class      = 'on';
                                        }
 
                                        $my_planned_controls_HTML .= "<tr class 
= '{$_row_class}'>";
 
                                        $deadline_ts = $my_planned_control[0];
-                                       $my_control = $my_planned_control[1];
-                                       
-                                       $location_id = 
isset($my_control['location_id']) && $my_control['location_id'] ? 
$my_control['location_id'] : 0;
-                                       $component_id = 
isset($my_control['component_id']) && $my_control['component_id'] ? 
$my_control['component_id'] : 0;
+                                       $my_control      = 
$my_planned_control[1];
 
-                                       $control_area_name = 
$this->get_control_area_name( $my_control["control_area_id"] );
+                                       $location_id     = 
isset($my_control['location_id']) && $my_control['location_id'] ? 
$my_control['location_id'] : 0;
+                                       $component_id    = 
isset($my_control['component_id']) && $my_control['component_id'] ? 
$my_control['component_id'] : 0;
 
-                                       $deadline_formatted = date($dateformat, 
$deadline_ts);
-                                       $planned_formatted = date($dateformat, 
$planned_date_ts);
+                                       $control_area_name = 
$this->get_control_area_name($my_control["control_area_id"]);
 
-                                       $check_list_id = $my_planned_control[2];
-                                       $location_code = $my_planned_control[4];
+                                       $deadline_formatted      = 
date($dateformat, $deadline_ts);
+                                       $planned_formatted       = 
date($dateformat, $planned_date_ts);
 
+                                       $check_list_id   = 
$my_planned_control[2];
+                                       $location_code   = 
$my_planned_control[4];
+
                                        $location_name = 
$this->get_location_name($location_code);
-                                       
+
                                        if($component_id)
                                        {
                                                $short_descr = 
$this->get_short_description($location_id, $component_id);
                                                $location_name .= 
"::{$short_descr}";
                                        }
 
-                                       $link = "";
-                               //      $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
-                                       $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicase.add_case', 'check_list_id' => $check_list_id));
+                                       $link    = "";
+                                       //      $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
+                                       $link    = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicase.add_case',
+                                               'check_list_id' => 
$check_list_id));
 //                                     $my_planned_controls_HTML .= "<li><a 
href='$link'><div class='date'>{$planned_formatted}</div><div 
class='date'>{$deadline_formatted}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
                                        $my_planned_controls_HTML .= "<td><a 
href='$link'><div class='date'>{$planned_formatted}</div></a></td>";
                                        $my_planned_controls_HTML .= "<td><a 
href='$link'><div class='date'>{$deadline_formatted}</div></a></td>";
@@ -418,118 +420,118 @@
                                }
                        }
 
-                       if(count( $planned_controls_on_date ) > 1 )
+                       if(count($planned_controls_on_date) > 1)
                        {
 //                             $my_planned_controls_HTML .= "</li></ul>";
                        }
 
                        $my_planned_controls_HTML .= "</table></div>"; // 
home_portal
 
-                       echo "\n".'<!-- BEGIN checklist info -->'."\n <h2 
class='heading'>Mine planlagte kontroller</h2><div class='home-box'>" . 
$my_planned_controls_HTML . "</div>\n".'<!-- END checklist info -->'."\n";
+                       echo "\n" . '<!-- BEGIN checklist info -->' . "\n <h2 
class='heading'>Mine planlagte kontroller</h2><div class='home-box'>" . 
$my_planned_controls_HTML . "</div>\n" . '<!-- END checklist info -->' . "\n";
+                       {
+                               /* =======================================  
UNDONE ASSIGNED CONTROLS FOR CURRENT USER  ================================= */
 
+                               // from date is set to 3 months back in time
+                               $from_date_ts    = mktime(0, 0, 0, date("n") - 
3, date("j"), date("Y"));
+                               $to_date_ts              = mktime(0, 0, 0, 
date("n"), date("j"), date("Y"));
 
-             {
-                       /* =======================================  UNDONE 
ASSIGNED CONTROLS FOR CURRENT USER  ================================= */
+                               // fetch all repeat types
+                               $repeat_type = null;
 
-               // from date is set to 3 months back in time
-                       $from_date_ts =  mktime(0, 0, 0, date("n")-3, 
date("j"), date("Y") );
-                       $to_date_ts =  mktime(0, 0, 0, date("n"), date("j"), 
date("Y") );
+                               // Fetches controls current user is responsible 
for 3 months back in time
+                               $my_controls             = 
$this->get_my_controls($my_locations, $from_date_ts, $to_date_ts, $repeat_type);
+                               $my_undone_controls      = array();
 
-               // fetch all repeat types
-                       $repeat_type = null;
-
-               // Fetches controls current user is responsible for 3 months 
back in time
-                       $my_controls = $this->get_my_controls($my_locations, 
$from_date_ts, $to_date_ts, $repeat_type);
-                       $my_undone_controls = array();
-
-                       // Generates an array containing undone controls
-                       foreach($my_controls as $container_arr)
-                       {
-                               $location_code = $container_arr[0];
-                               $control_type = $container_arr[1];
-                               $controls = $container_arr[2];
-
-                               foreach($controls as $my_control)
+                               // Generates an array containing undone controls
+                               foreach($my_controls as $container_arr)
                                {
-                                       if($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_DAY)
-                                       {
-                                               // DAILY CONTROLS: Fetch undone 
controls one week back in time
-                                               $from_date_ts =  mktime(0, 0, 
0, date("n"), date("j")-7, date("Y") );
-                                       }
-                                       else if($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_WEEK)
-                                       {
-                                               // WEEKLY CONTROLS: Fetch 
undone controls one month back in time
-                                               $from_date_ts =  mktime(0, 0, 
0, date("n")-1, date("j"), date("Y") );
-                                       }
-                                       else if($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_MONTH)
-                                       {
-                                               // MONTHLY CONTROLS: Fetch 
undone controls three months back in time
-                                               $from_date_ts =  mktime(0, 0, 
0, date("n")-3, date("j"), date("Y") );
-                                       }
-                                       else if($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_YEAR)
-                                       {
-                                               // YEARLY CONTROLS: Fetch 
undone controls one year back in time
-                                               $from_date_ts =  mktime(0, 0, 
0, date("n"), date("j"), date("Y")-1 );
-                                       }
+                                       $location_code   = $container_arr[0];
+                                       $control_type    = $container_arr[1];
+                                       $controls                = 
$container_arr[2];
 
-                                       $date_generator = new 
date_generator($my_control["start_date"], $my_control["end_date"], 
$from_date_ts, $to_date_ts, $my_control["repeat_type"], 
$my_control["repeat_interval"]);
-                                       $deadline_dates_for_control = 
$date_generator->get_dates();
-
-                                       $check_list_array = array();
-                                       foreach($deadline_dates_for_control as 
$deadline_ts)
+                                       foreach($controls as $my_control)
                                        {
-                                               $check_list = null;
-
-                                               if($control_type == "location")
+                                               if($my_control["repeat_type"] 
== controller_control::REPEAT_TYPE_DAY)
                                                {
-                                                       $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, $location_code, null, null, "location"  );
+                                                       // DAILY CONTROLS: 
Fetch undone controls one week back in time
+                                                       $from_date_ts = 
mktime(0, 0, 0, date("n"), date("j") - 7, date("Y"));
                                                }
-                                               else if($control_type == 
"component")
+                                               else 
if($my_control["repeat_type"] == controller_control::REPEAT_TYPE_WEEK)
                                                {
-                                                       $component = 
$container_arr[3];
-
-                                                       $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, null, $component['location_id'], $component['id'], 
"component"  );
+                                                       // WEEKLY CONTROLS: 
Fetch undone controls one month back in time
+                                                       $from_date_ts = 
mktime(0, 0, 0, date("n") - 1, date("j"), date("Y"));
                                                }
-                                               $control_id = $my_control['id'];
-
-                                               if($check_list == null & 
$control_type == "location")
+                                               else 
if($my_control["repeat_type"] == controller_control::REPEAT_TYPE_MONTH)
                                                {
-                                                       
$my_undone_controls[$deadline_ts][] = array("add", $deadline_ts, $my_control, 
"location", $location_code );
+                                                       // MONTHLY CONTROLS: 
Fetch undone controls three months back in time
+                                                       $from_date_ts = 
mktime(0, 0, 0, date("n") - 3, date("j"), date("Y"));
                                                }
-                                               else if($check_list == null & 
$control_type == "component")
+                                               else 
if($my_control["repeat_type"] == controller_control::REPEAT_TYPE_YEAR)
                                                {
-                                                       $component = 
$container_arr[3];
-                                                       
$my_undone_controls[$deadline_ts][]= array("add", $deadline_ts, $my_control, 
"component", $component['location_id'], $component['id'] );
+                                                       // YEARLY CONTROLS: 
Fetch undone controls one year back in time
+                                                       $from_date_ts = 
mktime(0, 0, 0, date("n"), date("j"), date("Y") - 1);
                                                }
-                                               else if( 
($check_list->get_status() == controller_check_list::STATUS_NOT_DONE) || 
($check_list->get_status() == controller_check_list::STATUS_CANCELED) )
+
+                                               $date_generator                 
         = new date_generator($my_control["start_date"], 
$my_control["end_date"], $from_date_ts, $to_date_ts, 
$my_control["repeat_type"], $my_control["repeat_interval"]);
+                                               $deadline_dates_for_control     
 = $date_generator->get_dates();
+
+                                               $check_list_array = array();
+                                               
foreach($deadline_dates_for_control as $deadline_ts)
                                                {
-                                                       
$my_undone_controls[$deadline_ts][] = array("edit", $deadline_ts, $my_control, 
$check_list->get_id(), $location_code );
+                                                       $check_list = null;
+
+                                                       if($control_type == 
"location")
+                                                       {
+                                                               $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, $location_code, null, null, "location");
+                                                       }
+                                                       else if($control_type 
== "component")
+                                                       {
+                                                               $component = 
$container_arr[3];
+
+                                                               $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, null, $component['location_id'], $component['id'], 
"component");
+                                                       }
+                                                       $control_id = 
$my_control['id'];
+
+                                                       if($check_list == null 
& $control_type == "location")
+                                                       {
+                                                               
$my_undone_controls[$deadline_ts][] = array("add", $deadline_ts, $my_control,
+                                                                       
"location", $location_code);
+                                                       }
+                                                       else if($check_list == 
null & $control_type == "component")
+                                                       {
+                                                               $component      
                                                 = $container_arr[3];
+                                                               
$my_undone_controls[$deadline_ts][]      = array("add", $deadline_ts, 
$my_control,
+                                                                       
"component", $component['location_id'], $component['id']);
+                                                       }
+                                                       else 
if(($check_list->get_status() == controller_check_list::STATUS_NOT_DONE) || 
($check_list->get_status() == controller_check_list::STATUS_CANCELED))
+                                                       {
+                                                               
$my_undone_controls[$deadline_ts][] = array("edit", $deadline_ts, $my_control,
+                                                                       
$check_list->get_id(), $location_code);
+                                                       }
                                                }
                                        }
-
                                }
 
-                       }
+                               //Add assigned
+                               $my_check_lists = 
$this->get_my_assigned_check_list($from_date_ts, $to_date_ts, $repeat_type, 
true);
 
-                       //Add assigned
-                       $my_check_lists = 
$this->get_my_assigned_check_list($from_date_ts, $to_date_ts, $repeat_type, 
true);
-
-/*??
-                       $_assigned_list = array();
-                       foreach ($my_check_lists as $_key => $my_check_list)
-                       {
-                               
$_assigned_list[$my_check_list['location_code']][$_key] = $my_check_list;
-                       }
-*/
-                       foreach ($my_check_lists as $_key => $my_check_list)
-                       {
-                               
$my_undone_controls[$my_check_list['deadline']][] = array("edit", 
$my_check_list['deadline'], $my_check_list, $_key, 
$my_check_list['location_code'] );
-                       }
+                               /* ??
+                                 $_assigned_list = array();
+                                 foreach ($my_check_lists as $_key => 
$my_check_list)
+                                 {
+                                 
$_assigned_list[$my_check_list['location_code']][$_key] = $my_check_list;
+                                 }
+                                */
+                               foreach($my_check_lists as $_key => 
$my_check_list)
+                               {
+                                       
$my_undone_controls[$my_check_list['deadline']][] = array("edit", 
$my_check_list['deadline'],
+                                               $my_check_list, $_key, 
$my_check_list['location_code']);
+                               }
 //_debug_array($my_undone_controls);
-       
-                       ksort($my_undone_controls);
 
-                       $my_undone_controls_HTML = <<<HTML
+                               ksort($my_undone_controls);
+
+                               $my_undone_controls_HTML = <<<HTML
                         <div class='home_portal'>
                                <h2>
                                        <div class='date 
heading'>Fristdato</div>
@@ -538,135 +540,144 @@
                                        <div class='control-area 
heading'>Kontrollområde</div>
                                </h2>
 HTML;
-                       // Sorts my_undone_controls by deadline date
-                       ksort($my_undone_controls);
+                               // Sorts my_undone_controls by deadline date
+                               ksort($my_undone_controls);
 
-                       $my_undone_controls_HTML .= "<ul>";
-                       
-                       $lang_planned_date = lang('planned date');
-                       foreach($my_undone_controls as $date_ts => 
$controls_on_date)
-                       {
-                               // If number of controls on a date exceeds 1 it 
will be put in expand list
-                               if(count( $controls_on_date) > 1 )
-                               {
-                                       $my_undone_controls_HTML .= "<li>";
-                                       $my_undone_controls_HTML .= "<a 
href='#'><h4 class='expand_trigger'><img height='12' 
src='controller/images/arrow_right.png' /><span class='deadline'>"  . 
date($dateformat, $date_ts) .  "</span><span class='num_check_lists'>(" .  
count($controls_on_date) . " kontroller)</span></h4></a>";
-                                       $my_undone_controls_HTML .= "<ul 
class='expand_list'>";
-                               }
+                               $my_undone_controls_HTML .= "<ul>";
 
-                               foreach($controls_on_date as $my_undone_control)
+                               $lang_planned_date = lang('planned date');
+                               foreach($my_undone_controls as $date_ts => 
$controls_on_date)
                                {
-                                       $check_list_status = 
$my_undone_control[0];
-                                       $deadline_ts = $my_undone_control[1];
-                                       $my_control = $my_undone_control[2];
-                                       $control_area_name = 
$this->get_control_area_name( $my_control["control_area_id"] );
-
-                                       $date_str = date($dateformat, 
$deadline_ts);
-                                       if($my_control['planned_date'])
+                                       // If number of controls on a date 
exceeds 1 it will be put in expand list
+                                       if(count($controls_on_date) > 1)
                                        {
-                                               $date_str_planned =  
$lang_planned_date . ': ' . date($dateformat, $my_control['planned_date']);
+                                               $my_undone_controls_HTML .= 
"<li>";
+                                               $my_undone_controls_HTML .= "<a 
href='#'><h4 class='expand_trigger'><img height='12' 
src='controller/images/arrow_right.png' /><span class='deadline'>" . 
date($dateformat, $date_ts) . "</span><span class='num_check_lists'>(" . 
count($controls_on_date) . " kontroller)</span></h4></a>";
+                                               $my_undone_controls_HTML .= 
"<ul class='expand_list'>";
                                        }
 
-                                       if($check_list_status == "add")
+                                       foreach($controls_on_date as 
$my_undone_control)
                                        {
-                                               $check_list_type = 
$my_undone_control[3];
-                                               if($check_list_type == 
"location")
+                                               $check_list_status       = 
$my_undone_control[0];
+                                               $deadline_ts             = 
$my_undone_control[1];
+                                               $my_control                     
 = $my_undone_control[2];
+                                               $control_area_name       = 
$this->get_control_area_name($my_control["control_area_id"]);
+
+                                               $date_str = date($dateformat, 
$deadline_ts);
+                                               if($my_control['planned_date'])
                                                {
-                                                       $location_code = 
$my_undone_control[4];
+                                                       $date_str_planned = 
$lang_planned_date . ': ' . date($dateformat, $my_control['planned_date']);
+                                               }
 
-                                                       $location_name = 
$this->get_location_name($location_code);
-
-                                                       if(count( 
$controls_on_date) > 1 )
+                                               if($check_list_status == "add")
+                                               {
+                                                       $check_list_type = 
$my_undone_control[3];
+                                                       if($check_list_type == 
"location")
                                                        {
-                                                               $link = "";
-                                                               $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list', 'type' => "location", 'control_id' => 
$my_control['id'], 'location_code' => $location_code, 'deadline_ts' => 
$deadline_ts));
+                                                               $location_code 
= $my_undone_control[4];
 
-                                                               
$my_undone_controls_HTML .= "<li><a href='{$link}' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
-                                                       }
-                                                       else
-                                                       {
-                                                               $link = "";
-                                                               $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list', 'type' => "location", 'control_id' => 
$my_control['id'], 'location_code' => $location_code, 'deadline_ts' => 
$deadline_ts));
+                                                               $location_name 
= $this->get_location_name($location_code);
 
-                                                               
$my_undone_controls_HTML .= "<a href='{$link} title = 
'{$date_str_planned}''><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a>";
-                                                       }
+                                                               
if(count($controls_on_date) > 1)
+                                                               {
+                                                                       $link   
 = "";
+                                                                       $link   
 = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list',
+                                                                               
'type' => "location", 'control_id' => $my_control['id'], 'location_code' => 
$location_code,
+                                                                               
'deadline_ts' => $deadline_ts));
 
-                                               }
-                                               else if($check_list_type == 
"component")
-                                               {
-                                                       $location_id = 
$my_undone_control[4];
-                                                       $component_id = 
$my_undone_control[5];
+                                                                       
$my_undone_controls_HTML .= "<li><a href='{$link}' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                               }
+                                                               else
+                                                               {
+                                                                       $link   
 = "";
+                                                                       $link   
 = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list',
+                                                                               
'type' => "location", 'control_id' => $my_control['id'], 'location_code' => 
$location_code,
+                                                                               
'deadline_ts' => $deadline_ts));
 
-                                                       $short_descr = 
$this->get_short_description($location_id, $component_id);
-                                                       if(count( 
$controls_on_date) > 1 )
-                                                       {
-                                                               $link = "";
-                                                               $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list', 'type' => "component", 'control_id' 
=> $my_control['id'], 'location_id' => $location_id, 'component_id' => 
$component_id, 'deadline_ts' => $deadline_ts));
-
-                                                               
$my_undone_controls_HTML .= "<li><a href='{$link}' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$short_descr}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                                       
$my_undone_controls_HTML .= "<a href='{$link} title = 
'{$date_str_planned}''><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a>";
+                                                               }
                                                        }
-                                                       else
+                                                       else 
if($check_list_type == "component")
                                                        {
-                                                               $link = "";
-                                                               $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list', 'type' => "component", 'control_id' 
=> $my_control['id'], 'location_id' => $location_id, 'component_id' => 
$component_id, 'deadline_ts' => $deadline_ts));
+                                                               $location_id    
 = $my_undone_control[4];
+                                                               $component_id   
 = $my_undone_control[5];
 
-                                                               
$my_undone_controls_HTML .= "<a href='{$link}' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$short_descr}</div><div 
class='control-area'>{$control_area_name}</div></a>";
+                                                               $short_descr = 
$this->get_short_description($location_id, $component_id);
+                                                               
if(count($controls_on_date) > 1)
+                                                               {
+                                                                       $link   
 = "";
+                                                                       $link   
 = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list',
+                                                                               
'type' => "component", 'control_id' => $my_control['id'], 'location_id' => 
$location_id,
+                                                                               
'component_id' => $component_id, 'deadline_ts' => $deadline_ts));
+
+                                                                       
$my_undone_controls_HTML .= "<li><a href='{$link}' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$short_descr}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                               }
+                                                               else
+                                                               {
+                                                                       $link   
 = "";
+                                                                       $link   
 = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list',
+                                                                               
'type' => "component", 'control_id' => $my_control['id'], 'location_id' => 
$location_id,
+                                                                               
'component_id' => $component_id, 'deadline_ts' => $deadline_ts));
+
+                                                                       
$my_undone_controls_HTML .= "<a href='{$link}' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$short_descr}</div><div 
class='control-area'>{$control_area_name}</div></a>";
+                                                               }
                                                        }
                                                }
-                                       }
-                                       else if($check_list_status == "edit")
-                                       {
+                                               else if($check_list_status == 
"edit")
+                                               {
 
-                                               $location_id = 
isset($my_control['location_id']) && $my_control['location_id'] ? 
$my_control['location_id'] : 0;
-                                               $component_id = 
isset($my_control['component_id']) && $my_control['component_id'] ? 
$my_control['component_id'] : 0;
+                                                       $location_id     = 
isset($my_control['location_id']) && $my_control['location_id'] ? 
$my_control['location_id'] : 0;
+                                                       $component_id    = 
isset($my_control['component_id']) && $my_control['component_id'] ? 
$my_control['component_id'] : 0;
 
 
-                                               $check_list_id = 
$my_undone_control[3];
-                                               $location_code = 
$my_undone_control[4];
+                                                       $check_list_id   = 
$my_undone_control[3];
+                                                       $location_code   = 
$my_undone_control[4];
 
-                                               $location_name = 
$this->get_location_name($location_code);
+                                                       $location_name = 
$this->get_location_name($location_code);
 
-                                               if($component_id)
-                                               {
-                                                       $short_descr = 
$this->get_short_description($location_id, $component_id);
+                                                       if($component_id)
+                                                       {
+                                                               $short_descr = 
$this->get_short_description($location_id, $component_id);
 
-                                                       $location_name .= 
"::{$short_descr}";
-                                               }
+                                                               $location_name 
.= "::{$short_descr}";
+                                                       }
 
-                                               if(count( $controls_on_date) > 
1 )
-                                               {
-                                                       $link = "";
-                                                       $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
+                                                       
if(count($controls_on_date) > 1)
+                                                       {
+                                                               $link    = "";
+                                                               $link    = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list',
+                                                                       
'check_list_id' => $check_list_id));
 
-                                                       
$my_undone_controls_HTML .= "<li><a href='{$link}' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
-                                               }
-                                               else
-                                               {
-                                                       $link = "";
-                                                       $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
+                                                               
$my_undone_controls_HTML .= "<li><a href='{$link}' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                       }
+                                                       else
+                                                       {
+                                                               $link    = "";
+                                                               $link    = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list',
+                                                                       
'check_list_id' => $check_list_id));
 
-                                                       
$my_undone_controls_HTML .= "<li><a href='$link' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                               
$my_undone_controls_HTML .= "<li><a href='$link' title = 
'{$date_str_planned}'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                       }
                                                }
                                        }
-                               }
 
-                               if(count( $controls_on_date ) > 1 )
-                               {
-                                       $my_undone_controls_HTML .= "</ul>";
-                                       $my_undone_controls_HTML .= "</li>";
+                                       if(count($controls_on_date) > 1)
+                                       {
+                                               $my_undone_controls_HTML .= 
"</ul>";
+                                               $my_undone_controls_HTML .= 
"</li>";
+                                       }
                                }
-                       }
 
-                       $my_undone_controls_HTML .= "</ul>";
+                               $my_undone_controls_HTML .= "</ul>";
 
-                       $my_undone_controls_HTML .= "</div>"; // home_portal
+                               $my_undone_controls_HTML .= "</div>"; // 
home_portal
 
-                       echo "\n".'<!-- BEGIN checklist info -->'."\n <h2 
class='heading'>Mine ugjorte kontroller</h2><div 
class='home-box'>".$my_undone_controls_HTML."</div>\n".'<!-- END checklist info 
-->'."\n";
+                               echo "\n" . '<!-- BEGIN checklist info -->' . 
"\n <h2 class='heading'>Mine ugjorte kontroller</h2><div class='home-box'>" . 
$my_undone_controls_HTML . "</div>\n" . '<!-- END checklist info -->' . "\n";
 
 
-                       /* ================================  CONTROLS ASSIGNED 
TO CURRENT USER  ================================= */
+                               /* ================================  CONTROLS 
ASSIGNED TO CURRENT USER  ================================= */
 
-                       $my_assigned_controls_HTML = <<<HTML
+                               $my_assigned_controls_HTML = <<<HTML
                                <div class='home_portal'>
                                        <h2>
                                                <div class='date 
heading'>Fristdato</div>
@@ -676,196 +687,201 @@
                                        </h2>
 HTML;
 
-                       $from_date_ts =  strtotime("now");
-                       $to_date_ts = mktime(0, 0, 0, date("n")+1, date("j"), 
date("Y") );
+                               $from_date_ts    = strtotime("now");
+                               $to_date_ts              = mktime(0, 0, 0, 
date("n") + 1, date("j"), date("Y"));
 
-                       // fetch all repeat types
-                       $repeat_type = null;
+                               // fetch all repeat types
+                               $repeat_type = null;
 
-                       // Fetches controls current user is responsible for 1 
month ahead in time
-                       $my_controls = array();
-                       $my_controls = $this->get_my_controls($my_locations, 
$from_date_ts, $to_date_ts, $repeat_type);
+                               // Fetches controls current user is responsible 
for 1 month ahead in time
+                               $my_controls = array();
+                               $my_controls = 
$this->get_my_controls($my_locations, $from_date_ts, $to_date_ts, $repeat_type);
 
-                       $my_assigned_controls = array();
+                               $my_assigned_controls = array();
 
-                       $from_date_ts =  mktime(0, 0, 0, date("n"), date("j"), 
date("Y") );
+                               $from_date_ts = mktime(0, 0, 0, date("n"), 
date("j"), date("Y"));
 
-                       // Generates an array with undone controls
-                       foreach($my_controls as $container_arr)
-                       {
-                               $location_code = $container_arr[0];
-                               $control_type = $container_arr[1];
-                               $controls = $container_arr[2];
-
-                               foreach($controls as $my_control)
+                               // Generates an array with undone controls
+                               foreach($my_controls as $container_arr)
                                {
-                                       if($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_DAY)
-                                       {
-                                               // Daily control: Todate in one 
week
-                                               $to_date_ts =  mktime(0, 0, 0, 
date("n"), date("j")+7, date("Y") );
-                                       }
-                                       else if(($my_control["repeat_type"] == 
controller_control::REPEAT_TYPE_WEEK)
-                                                               | 
($my_control["repeat_type"] == controller_control::REPEAT_TYPE_MONTH)
-                                                               | 
($my_control["repeat_type"] == controller_control::REPEAT_TYPE_YEAR))
-                                       {
-                                               // Daily, monthly yearly 
control: to_date in one month
-                                               $to_date_ts =  mktime(0, 0, 0, 
date("n")+1, date("j"), date("Y") );
-                                       }
+                                       $location_code   = $container_arr[0];
+                                       $control_type    = $container_arr[1];
+                                       $controls                = 
$container_arr[2];
 
-                                       $date_generator = new 
date_generator($my_control["start_date"], $my_control["end_date"], 
$from_date_ts, $to_date_ts, $my_control["repeat_type"], 
$my_control["repeat_interval"]);
-                                       $deadline_dates_for_control = 
$date_generator->get_dates();
-
-                                       $check_list_array = array();
-                                       foreach($deadline_dates_for_control as 
$deadline_ts)
+                                       foreach($controls as $my_control)
                                        {
-                                               $check_list = null;
-
-                                               if($control_type == "location")
+                                               if($my_control["repeat_type"] 
== controller_control::REPEAT_TYPE_DAY)
                                                {
-                                                       // Gets checklist for 
control with current date as deadline if there exists one
-                                                       $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, $location_code, null, null, "location"  );
+                                                       // Daily control: 
Todate in one week
+                                                       $to_date_ts = mktime(0, 
0, 0, date("n"), date("j") + 7, date("Y"));
                                                }
-                                               else if($control_type == 
"component")
+                                               else 
if(($my_control["repeat_type"] == controller_control::REPEAT_TYPE_WEEK) | 
($my_control["repeat_type"] == controller_control::REPEAT_TYPE_MONTH) | 
($my_control["repeat_type"] == controller_control::REPEAT_TYPE_YEAR))
                                                {
-                                                       $component = 
$container_arr[3];
-
-                                                       // Gets checklist for 
control with current date as deadline if there exists one
-                                                       $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, null, $component['location_id'], $component['id'], 
"component"  );
+                                                       // Daily, monthly 
yearly control: to_date in one month
+                                                       $to_date_ts = mktime(0, 
0, 0, date("n") + 1, date("j"), date("Y"));
                                                }
 
-                                                       // Check if there is a 
checklist on the deadline
-                                               if($check_list == null)
+                                               $date_generator                 
         = new date_generator($my_control["start_date"], 
$my_control["end_date"], $from_date_ts, $to_date_ts, 
$my_control["repeat_type"], $my_control["repeat_interval"]);
+                                               $deadline_dates_for_control     
 = $date_generator->get_dates();
+
+                                               $check_list_array = array();
+                                               
foreach($deadline_dates_for_control as $deadline_ts)
                                                {
+                                                       $check_list = null;
+
                                                        if($control_type == 
"location")
                                                        {
-                                                               
$my_assigned_controls[$deadline_ts][] = array("add", $deadline_ts, $my_control, 
"location", $location_code );
+                                                               // Gets 
checklist for control with current date as deadline if there exists one
+                                                               $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, $location_code, null, null, "location");
                                                        }
                                                        else if($control_type 
== "component")
                                                        {
                                                                $component = 
$container_arr[3];
-                                                               
$my_assigned_controls[$deadline_ts][] =  array("add", $deadline_ts, 
$my_control, "component", $component['location_id'], $component['id'] );
+
+                                                               // Gets 
checklist for control with current date as deadline if there exists one
+                                                               $check_list = 
$so_check_list->get_check_list_for_control_by_date($my_control['id'], 
$deadline_ts, null, null, $component['location_id'], $component['id'], 
"component");
                                                        }
+
+                                                       // Check if there is a 
checklist on the deadline
+                                                       if($check_list == null)
+                                                       {
+                                                               
if($control_type == "location")
+                                                               {
+                                                                       
$my_assigned_controls[$deadline_ts][] = array("add", $deadline_ts, $my_control,
+                                                                               
"location", $location_code);
+                                                               }
+                                                               else 
if($control_type == "component")
+                                                               {
+                                                                       
$component                                                               = 
$container_arr[3];
+                                                                       
$my_assigned_controls[$deadline_ts][]    = array("add", $deadline_ts, 
$my_control,
+                                                                               
"component", $component['location_id'], $component['id']);
+                                                               }
+                                                       }
+                                                       // Do not put checklist 
with status planned in list
+                                                       else 
if(($check_list->get_planned_date() == '' || $check_list->get_planned_date() == 
0 ) && ( $check_list->get_status() == controller_check_list::STATUS_NOT_DONE || 
($check_list->get_status() == controller_check_list::STATUS_CANCELED)))
+                                                       {
+                                                               
$my_assigned_controls[$deadline_ts][] = array("edit", $deadline_ts, $my_control,
+                                                                       
$check_list->get_id(), $location_code);
+                                                       }
                                                }
-                                               // Do not put checklist with 
status planned in list
-                                               else if( 
($check_list->get_planned_date() == '' || $check_list->get_planned_date() == 0 
) && ( $check_list->get_status() == controller_check_list::STATUS_NOT_DONE || 
($check_list->get_status() == controller_check_list::STATUS_CANCELED)) )
-                                               {
-                                                       
$my_assigned_controls[$deadline_ts][] = array("edit", $deadline_ts, 
$my_control, $check_list->get_id(), $location_code );
-                                               }
                                        }
                                }
-                       }
 
-                       // Sorts my_undone_controls by deadline date
-                       $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
-                       $cats->supress_info     = true;
-                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => '','globals' 
=> true,'use_acl' => $this->_category_acl));
+                               // Sorts my_undone_controls by deadline date
+                               $cats                            = 
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+                               $cats->supress_info      = true;
+                               $control_areas           = 
$cats->formatted_xslt_list(array('format' => 'filter', 'selected' => '',
+                                       'globals' => true, 'use_acl' => 
$this->_category_acl));
 
-                       $my_assigned_controls_HTML .= "<ul>";
+                               $my_assigned_controls_HTML .= "<ul>";
 
-                       foreach($my_assigned_controls as $date_ts => 
$assigned_controls_on_date)
-                       {
-                               if(count( $assigned_controls_on_date) > 1 )
+                               foreach($my_assigned_controls as $date_ts => 
$assigned_controls_on_date)
                                {
-                                       $my_assigned_controls_HTML .= "<li>";
-                                       $my_assigned_controls_HTML .= "<a 
href='#'><h4 class='expand_trigger'><img height='12' 
src='controller/images/arrow_right.png' /><span class='deadline'>"  . 
date($dateformat, $date_ts) .  "</span><span class='num_controls'>(" .  
count($assigned_controls_on_date) . " kontroller)</span></h4></a>";
-                                       $my_assigned_controls_HTML .= "<ul 
class='expand_list'>";
-                               }
+                                       if(count($assigned_controls_on_date) > 
1)
+                                       {
+                                               $my_assigned_controls_HTML .= 
"<li>";
+                                               $my_assigned_controls_HTML .= 
"<a href='#'><h4 class='expand_trigger'><img height='12' 
src='controller/images/arrow_right.png' /><span class='deadline'>" . 
date($dateformat, $date_ts) . "</span><span class='num_controls'>(" . 
count($assigned_controls_on_date) . " kontroller)</span></h4></a>";
+                                               $my_assigned_controls_HTML .= 
"<ul class='expand_list'>";
+                                       }
 
-                               foreach($assigned_controls_on_date as 
$my_assigned_control)
-                               {
-                                       $check_list_status = 
$my_assigned_control[0];
-                                       $deadline_ts = $my_assigned_control[1];
-                                       $my_control = $my_assigned_control[2];
+                                       foreach($assigned_controls_on_date as 
$my_assigned_control)
+                                       {
+                                               $check_list_status       = 
$my_assigned_control[0];
+                                               $deadline_ts             = 
$my_assigned_control[1];
+                                               $my_control                     
 = $my_assigned_control[2];
 
-                                       reset($control_areas['cat_list']);
+                                               
reset($control_areas['cat_list']);
 
-                                       foreach($control_areas['cat_list'] as 
$area)
-                                       {
-                                               if($area['cat_id'] == 
$my_control["control_area_id"])
+                                               
foreach($control_areas['cat_list'] as $area)
                                                {
-                                                       $control_area_name = 
$area['name'];
+                                                       if($area['cat_id'] == 
$my_control["control_area_id"])
+                                                       {
+                                                               
$control_area_name = $area['name'];
+                                                       }
                                                }
-                                       }
 
-                                       $date_str = date($dateformat, 
$deadline_ts);
+                                               $date_str = date($dateformat, 
$deadline_ts);
 
-                                       if($check_list_status == "add")
-                                       {
-                                               $check_list_type = 
$my_assigned_control[3];
-
-                                               if($check_list_type == 
"location")
+                                               if($check_list_status == "add")
                                                {
-                                                       $location_code = 
$my_assigned_control[4];
+                                                       $check_list_type = 
$my_assigned_control[3];
 
-                                                       $location_name = 
$this->get_location_name($location_code);
+                                                       if($check_list_type == 
"location")
+                                                       {
+                                                               $location_code 
= $my_assigned_control[4];
 
-                                                       $link = "";
-                                                       $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list', 'type' => "location", 'control_id' => 
$my_control['id'], 'location_code' => $location_code, 'deadline_ts' => 
$deadline_ts));
+                                                               $location_name 
= $this->get_location_name($location_code);
 
-                                                       
$my_assigned_controls_HTML .= "<li><a href='$link'><div 
class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                               $link    = "";
+                                                               $link    = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list',
+                                                                       'type' 
=> "location", 'control_id' => $my_control['id'], 'location_code' => 
$location_code,
+                                                                       
'deadline_ts' => $deadline_ts));
+
+                                                               
$my_assigned_controls_HTML .= "<li><a href='$link'><div 
class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                       }
+                                                       else 
if($check_list_type == "component")
+                                                       {
+                                                               $location_id    
 = $my_assigned_control[4];
+                                                               $component_id   
 = $my_assigned_control[5];
+
+                                                               $short_descr = 
$this->get_short_description($location_id, $component_id);
+
+                                                               $link    = "";
+                                                               $link    = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list',
+                                                                       'type' 
=> "component", 'control_id' => $my_control['id'], 'location_id' => 
$location_id,
+                                                                       
'component_id' => $component_id, 'deadline_ts' => $deadline_ts));
+
+                                                               
$my_assigned_controls_HTML .= "<li><a href='$link'><div 
class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$short_descr}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                       }
                                                }
-                                               else if($check_list_type == 
"component")
+                                               else if($check_list_status == 
"edit")
                                                {
-                                                       $location_id = 
$my_assigned_control[4];
-                                                       $component_id = 
$my_assigned_control[5];
-                                                       
-                                                       $short_descr = 
$this->get_short_description($location_id, $component_id);
+                                                       $check_list_id   = 
$my_assigned_control[3];
+                                                       $location_code   = 
$my_assigned_control[4];
 
-                                                       $link = "";
-                                                       $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.add_check_list', 'type' => "component", 'control_id' 
=> $my_control['id'], 'location_id' => $location_id, 'component_id' => 
$component_id, 'deadline_ts' => $deadline_ts));
+                                                       $location_name = 
$this->get_location_name($location_code);
 
-                                                       
$my_assigned_controls_HTML .= "<li><a href='$link'><div 
class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$short_descr}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                                       $link    = "";
+                                                       $link    = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list',
+                                                               'check_list_id' 
=> $check_list_id));
+
+                                                       
$my_assigned_controls_HTML .= "<li><a href='$link'><div 
class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
                                                }
                                        }
-                                       else if($check_list_status == "edit")
+
+                                       if(count($assigned_controls_on_date) > 
1)
                                        {
-                                               $check_list_id = 
$my_assigned_control[3];
-                                               $location_code = 
$my_assigned_control[4];
-
-                                               $location_name = 
$this->get_location_name($location_code);
-
-                                               $link = "";
-                                               $link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list.edit_check_list', 'check_list_id' => $check_list_id));
-
-                                               $my_assigned_controls_HTML .= 
"<li><a href='$link'><div class='date'>{$date_str}</div><div 
class='control'>{$my_control['title']}</div><div 
class='title'>{$location_name}</div><div 
class='control-area'>{$control_area_name}</div></a></li>";
+                                               $my_assigned_controls_HTML .= 
"</li>";
+                                               $my_assigned_controls_HTML .= 
"</ul>";
                                        }
                                }
 
-                               if(count( $assigned_controls_on_date ) > 1 )
-                               {
-                                       $my_assigned_controls_HTML .= "</li>";
-                                       $my_assigned_controls_HTML .= "</ul>";
-                               }
+                               $my_assigned_controls_HTML .= "</ul>";
+                               $my_assigned_controls_HTML .= "</div>"; // 
home_portal
 
+                               echo "\n" . '<!-- BEGIN checklist info -->' . 
"\n <h2 class='heading'>Mine tildelte kontroller</h2><div class='home-box'>" . 
$my_assigned_controls_HTML . "</div>\n" . '<!-- END checklist info -->' . "\n";
                        }
-
-                       $my_assigned_controls_HTML .= "</ul>";
-                       $my_assigned_controls_HTML .= "</div>"; // home_portal
-
-                       echo "\n".'<!-- BEGIN checklist info -->'."\n <h2 
class='heading'>Mine tildelte kontroller</h2><div class='home-box'>" . 
$my_assigned_controls_HTML . "</div>\n".'<!-- END checklist info -->'."\n";
-               }
                }
                /* ================================  FUNCTIONS  
======================================== */
 
-
                function get_my_assigned_check_list($from_date_ts, $to_date_ts, 
$repeat_type, $completed = null)
                {
                        $check_list_array = array();
 
                        $so_control = CreateObject('controller.socontrol');
 
-                       $user_id = $GLOBALS['phpgw_info']['user']['account_id'];
-                       $assigned_check_list_at_location = 
$so_control->get_assigned_check_list_at_location( $from_date_ts, $to_date_ts, 
$repeat_type, $user_id,$completed, 'return_array');
+                       $user_id                                                
 = $GLOBALS['phpgw_info']['user']['account_id'];
+                       $assigned_check_list_at_location = 
$so_control->get_assigned_check_list_at_location($from_date_ts, $to_date_ts, 
$repeat_type, $user_id, $completed, 'return_array');
 
-                       foreach ($assigned_check_list_at_location as 
$assigned_check_list)
+                       foreach($assigned_check_list_at_location as 
$assigned_check_list)
                        {
                                $check_list_array[$assigned_check_list['id']] = 
$assigned_check_list;
                        }
                        unset($assigned_check_list);
 
-                       $assigned_check_list_at_component = 
$so_control->get_assigned_check_list_by_component( $from_date_ts, $to_date_ts, 
$repeat_type, $user_id, $completed, 'return_array');
+                       $assigned_check_list_at_component = 
$so_control->get_assigned_check_list_by_component($from_date_ts, $to_date_ts, 
$repeat_type, $user_id, $completed, 'return_array');
 
-                       foreach ($assigned_check_list_at_component as 
$assigned_check_list)
+                       foreach($assigned_check_list_at_component as 
$assigned_check_list)
                        {
                                $check_list_array[$assigned_check_list['id']] = 
$assigned_check_list;
                        }
@@ -873,7 +889,6 @@
                        return $check_list_array;
                }
 
-
                function get_my_controls($my_locations, $from_date_ts, 
$to_date_ts, $repeat_type)
                {
                        $so_control = CreateObject('controller.socontrol');
@@ -882,39 +897,40 @@
 
                        foreach($my_locations as $location)
                        {
-                               $components_with_controls_array = array();
-                               $controls_at_location = array();
-                               $location_code = $location["location_code"];
+                               $components_with_controls_array  = array();
+                               $controls_at_location                    = 
array();
+                               $location_code                                  
 = $location["location_code"];
 
-                               $controls_at_location = 
$so_control->get_controls_by_location( $location_code, $from_date_ts, 
$to_date_ts, $repeat_type, "return_array", $location["role_id"] );
+                               $controls_at_location = 
$so_control->get_controls_by_location($location_code, $from_date_ts, 
$to_date_ts, $repeat_type, "return_array", $location["role_id"]);
 
                                $level = count(explode('-', $location_code));
 
                                if($level == 1)
                                {
                                        // Fetches all controls for the 
components for a location within time period
-                                       $filter = "bim_item.location_code = 
'$location_code' ";
-                                       $components_with_controls_array = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);
+                                       $filter                                 
                 = "bim_item.location_code = '$location_code' ";
+                                       $components_with_controls_array  = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);
                                }
                                else
                                {
                                        // Fetches all controls for the 
components for a location within time period
-                                       $filter = "bim_item.location_code LIKE 
'$location_code%' ";
-                                       $components_with_controls_array = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);
+                                       $filter                                 
                 = "bim_item.location_code LIKE '$location_code%' ";
+                                       $components_with_controls_array  = 
$so_control->get_controls_by_component($from_date_ts, $to_date_ts, 
$repeat_type, "return_array", $location["role_id"], $filter);
                                }
 
-                               if( $controls_at_location )
+                               if($controls_at_location)
                                {
                                        // Saves location code, location type 
and an array containing controls at locations
-                                       $my_controls[] = array( $location_code, 
'location', $controls_at_location );
+                                       $my_controls[] = array($location_code, 
'location', $controls_at_location);
                                }
 
-                               if( $components_with_controls_array )
+                               if($components_with_controls_array)
                                {
                                        foreach($components_with_controls_array 
as $component)
                                        {
-                                       // Saves location code, location type, 
an array containing controls at locations and component object
-                                               $my_controls[] = array( 
$location_code, 'component', $component['controls_array'], $component );
+                                               // Saves location code, 
location type, an array containing controls at locations and component object
+                                               $my_controls[] = 
array($location_code, 'component', $component['controls_array'],
+                                                       $component);
                                        }
                                }
                        }
@@ -922,16 +938,17 @@
                        return $my_controls;
                }
 
-               function get_control_area_name( $control_area_id )
+               function get_control_area_name($control_area_id)
                {
-                       $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
-                       $cats->supress_info     = true;
+                       $cats                            = 
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
+                       $cats->supress_info      = true;
 
-                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => '','globals' 
=> true,'use_acl' => 0));
+                       $control_areas = 
$cats->formatted_xslt_list(array('format' => 'filter', 'selected' => '',
+                               'globals' => true, 'use_acl' => 0));
 
                        foreach($control_areas['cat_list'] as $area)
                        {
-                               if( $area['cat_id'] == $control_area_id )
+                               if($area['cat_id'] == $control_area_id)
                                {
                                        $control_area_name = $area['name'];
                                }
@@ -939,7 +956,7 @@
 
                        return $control_area_name;
                }
-               
+
                function get_location_name($location_code)
                {
                        static $location_array = array();
@@ -947,32 +964,33 @@
                        {
                                $_location_info = 
execMethod('property.bolocation.read_single', array
                                        (
-                                               'location_code' => 
$location_code,
-                                               'extra'                 => 
array('noattrib' => true)
-                                       )
+                                       'location_code'  => $location_code,
+                                       'extra'                  => 
array('noattrib' => true)
+                               )
                                );
 
                                $_loc_name_arr = array();
-                               for ($i=1; $i < count(explode('-', 
$location_code)) +1;$i++)
+                               for($i = 1; $i < count(explode('-', 
$location_code)) + 1; $i++)
                                {
                                        $_loc_name_arr[] = 
$_location_info["loc{$i}_name"];
                                }
 
-                               $location_array[$location_code] = implode(' | 
',$_loc_name_arr);
+                               $location_array[$location_code] = implode(' | 
', $_loc_name_arr);
                        }
 
                        return $location_array[$location_code];
                }
-               
+
                function get_short_description($location_id, $component_id)
                {
                        static $component_short_desc = array();
 
                        
if(!isset($component_short_desc[$location_id][$component_id]))
                        {
-                               
$component_short_desc[$location_id][$component_id] = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$location_id, 'id' => $component_id));
+                               
$component_short_desc[$location_id][$component_id] = 
execMethod('property.soentity.get_short_description', array(
+                                       'location_id' => $location_id, 'id' => 
$component_id));
                        }
 
-                       return  
$component_short_desc[$location_id][$component_id];
+                       return 
$component_short_desc[$location_id][$component_id];
                }
-       }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/controller/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.menu.inc.php   2015-12-09 
18:15:59 UTC (rev 14547)
+++ branches/dev-syncromind/controller/inc/class.menu.inc.php   2015-12-09 
19:19:58 UTC (rev 14548)
@@ -1,175 +1,183 @@
 <?php
+
        /**
-       * phpGroupWare - controller: a part of a Facilities Management System.
-       *
-       * @author Erik Holm-Larsen <address@hidden>
-       * @author Torstein Vadla <address@hidden>
-       * @copyright Copyright (C) 2011,2012 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/
-       * @package property
-       * @subpackage controller
-       * @version $Id$
-       */
-
+        * phpGroupWare - controller: a part of a Facilities Management System.
+        *
+        * @author Erik Holm-Larsen <address@hidden>
+        * @author Torstein Vadla <address@hidden>
+        * @copyright Copyright (C) 2011,2012 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/
+        * @package property
+        * @subpackage controller
+        * @version $Id$
+        */
        class controller_menu
        {
+
                function get_menu()
                {
-                       $incoming_app = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $GLOBALS['phpgw_info']['flags']['currentapp'] = 
'controller';
-                       $menus = array();
+                       $incoming_app                                           
                         = $GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $GLOBALS['phpgw_info']['flags']['currentapp']    = 
'controller';
+                       $menus                                                  
                                 = array();
 
                        $menus['navbar'] = array
-                       (
+                               (
                                'controller' => array
-                               (
-                                       'text'  => lang('Controller'),
-                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicontrol.control_list') ),
-                                       'image' => array('property', 
'location'),
-                                       'order' => 10,
-                                       'group' => 'office'
+                                       (
+                                       'text'   => lang('Controller'),
+                                       'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.control_list')),
+                                       'image'  => array('property', 
'location'),
+                                       'order'  => 10,
+                                       'group'  => 'office'
                                )
                        );
 
-                       
if($GLOBALS['phpgw']->acl->check('.usertype.superuser',PHPGW_ACL_ADD,'controller'))
+                       if($GLOBALS['phpgw']->acl->check('.usertype.superuser', 
PHPGW_ACL_ADD, 'controller'))
                        {
-                               $menus['navigation'] =  array
-                               (
-                                       'control' => array
+                               $menus['navigation'] = array
                                        (
-                                               'text'  => lang('Control'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicontrol.control_list') ),
-                                               'image' => array('property', 
'location_1'),
-                                               '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'                        => 
array
+                                               (
+                                               'text'           => 
lang('Control'),
+                                               'url'            => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.control_list')),
+                                               'image'          => 
array('property', 'location_1'),
+                                               '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_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')
-                                                                               
        )
-                                                                               
)
-                                               */
+                                       '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'),
+                                       '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'),
+                                       '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'),
+                                       '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'))
+
+                       if($GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin') || $GLOBALS['phpgw']->acl->check('admin', 
phpgwapi_acl::ADD, 'controller'))
                        {
                                $menus['admin'] = array
-                               (
-                                       'index' => array
                                        (
-                                               'text'  => 
lang('Configuration'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index', 'appname' => 'controller') )
+                                       'index'                                 
         => array
+                                               (
+                                               'text'   => 
lang('Configuration'),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index',
+                                                       'appname' => 
'controller'))
                                        ),
-                                       'acl'   => array
-                                       (
-                                               'text'  => lang('Configure 
Access Permissions'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'preferences.uiadmin_acl.list_acl', 'acl_app' => 'controller') )
+                                       'acl'                                   
         => array
+                                               (
+                                               'text'   => lang('Configure 
Access Permissions'),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'preferences.uiadmin_acl.list_acl',
+                                                       'acl_app' => 
'controller'))
                                        ),
-                                       'check_item_status'     => array
-                                       (
-                                               'text'  => lang('check item 
status'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uigeneric.index', 'type' => 'controller_check_item_status') )
+                                       'check_item_status'                     
 => array
+                                               (
+                                               'text'   => lang('check item 
status'),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uigeneric.index',
+                                                       'type' => 
'controller_check_item_status'))
                                        ),
-                                       'control_cats'  => array
-                                       (
-                                               'text'  => lang('Control area'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uicategories.index', 'appname' => 'controller', 'location' => 
'.control', 'global_cats' => 'true', 'menu_selection' => 
'admin::controller::control_cats') )
+                                       'control_cats'                          
 => array
+                                               (
+                                               'text'   => lang('Control 
area'),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uicategories.index',
+                                                       'appname' => 
'controller', 'location' => '.control', 'global_cats' => 'true',
+                                                       'menu_selection' => 
'admin::controller::control_cats'))
                                        ),
-                                       'role_at_location'      => array
-                                       (
-                                               'url'   =>      
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uilocation.responsiblility_role', 'menu_selection' => 
'admin::controller::role_at_location') ),
-                                               'text'  =>      lang('role at 
location'),
-                                               'image' => array('property', 
'responsibility_role')
+                                       'role_at_location'                      
 => array
+                                               (
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uilocation.responsiblility_role',
+                                                       'menu_selection' => 
'admin::controller::role_at_location')),
+                                               'text'   => lang('role at 
location'),
+                                               'image'  => array('property', 
'responsibility_role')
                                        ),
-                                       'controller_document_types'     => array
-                                       (
-                                               'url'   =>      
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'controller.uidocument.document_types', 'menu_selection' => 
'admin::controller::controller_document_types') ),
-                                               'text'  =>      lang('Document 
types')
+                                       'controller_document_types'      => 
array
+                                               (
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uidocument.document_types',
+                                                       'menu_selection' => 
'admin::controller::controller_document_types')),
+                                               'text'   => lang('Document 
types')
                                        )
                                );
                        }
 
-                       if ( 
isset($GLOBALS['phpgw_info']['user']['apps']['preferences']) )
+                       
if(isset($GLOBALS['phpgw_info']['user']['apps']['preferences']))
                        {
                                $menus['preferences'] = array
-                               (
+                                       (
                                        // in case of userprefs - need a hook 
for 'settings'
 
                                        array
-                                       (
-                                               'text'  => 
$GLOBALS['phpgw']->translation->translate('Preferences', array(), true),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' => 
'controller', 'type'=> 'user') )
+                                               (
+                                               'text'   => 
$GLOBALS['phpgw']->translation->translate('Preferences', array(), true),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' => 
'controller',
+                                                       'type' => 'user'))
                                        ),
-
                                        array
-                                       (
-                                               'text'  => 
$GLOBALS['phpgw']->translation->translate('Grant Access', array(), true),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'preferences.uiadmin_acl.aclprefs', 'acl_app'=> 'controller') )
+                                               (
+                                               'text'   => 
$GLOBALS['phpgw']->translation->translate('Grant Access', array(), true),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'preferences.uiadmin_acl.aclprefs',
+                                                       'acl_app' => 
'controller'))
                                        )
                                );
                        }
@@ -181,4 +189,4 @@
 
                        return $menus;
                }
-       }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/controller/inc/class.socase.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.socase.inc.php 2015-12-09 
18:15:59 UTC (rev 14547)
+++ branches/dev-syncromind/controller/inc/class.socase.inc.php 2015-12-09 
19:19:58 UTC (rev 14548)
@@ -1,39 +1,39 @@
 <?php
        /**
-       * phpGroupWare - controller: a part of a Facilities Management System.
-       *
-       * @author Erink Holm-Larsen <address@hidden>
-       * @author Torstein Vadla <address@hidden>
-       * @copyright Copyright (C) 2011,2012 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/
-       * @package property
-       * @subpackage controller
-       * @version $Id$
-       */
-
+        * phpGroupWare - controller: a part of a Facilities Management System.
+        *
+        * @author Erink Holm-Larsen <address@hidden>
+        * @author Torstein Vadla <address@hidden>
+        * @copyright Copyright (C) 2011,2012 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/
+        * @package property
+        * @subpackage controller
+        * @version $Id$
+        */
        phpgw::import_class('controller.socommon');
 
        include_class('controller', 'check_item_case', 'inc/model/');
 
        class controller_socase extends controller_socommon
        {
+
                protected static $so;
                protected $global_lock = false;
 
@@ -44,31 +44,37 @@
                 */
                public static function get_instance()
                {
-                       if (self::$so == null)
+                       if(self::$so == null)
                        {
                                self::$so = CreateObject('controller.socase');
                        }
                        return self::$so;
                }
 
-               function get_query(string $sort_field, boolean $ascending, 
string $search_for, string $search_type, array $filters, boolean 
$return_count){}
+               function get_query(string $sort_field, boolean $ascending, 
string $search_for, string $search_type, array $filters, boolean $return_count)
+               {
 
-               function populate(int $object_id, &$object){}
+               }
 
+               function populate(int $object_id, &$object)
+               {
+
+               }
+
                /**
-                * Get single case object from database  
-                * 
+                * Get single case object from database
+                *
                 * @param       $case id id of case to be returned
                 * @return case object
-               */
+                */
                public function get_single($case_id)
                {
-                       $case_id = (int) $case_id;
-                       
-                       $sql = "SELECT * FROM controller_check_item_case "; 
+                       $case_id = (int)$case_id;
+
+                       $sql = "SELECT * FROM controller_check_item_case ";
                        $sql .= "WHERE id = {$case_id}";
-                       
 
+
                        $this->db->query($sql, __LINE__, __FILE__);
 
                        if($this->db->next_record())
@@ -79,7 +85,7 @@
                                
$case->set_location_id($this->unmarshal($this->db->f('location_id'), 'int'));
                                
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id'), 
'int'));
                                
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
-                               
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));   
+                               
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));
                                
$case->set_entry_date($this->unmarshal($this->db->f('entry_date'), 'int'));
                                
$case->set_modified_date($this->unmarshal($this->db->f('modified_date'), 
'int'));
                                
$case->set_modified_by($this->unmarshal($this->db->f('modified_by'), 'int'));
@@ -87,7 +93,7 @@
                                
$case->set_location_code($this->unmarshal($this->db->f('location_code'), 
'string'));
                                
$case->set_component_location_id($this->unmarshal($this->db->f('component_location_id'),
 'int'));
                                
$case->set_component_id($this->unmarshal($this->db->f('component_id'), 'int'));
-                                       
+
                                return $case;
                        }
                        else
@@ -95,27 +101,27 @@
                                return null;
                        }
                }
-               
+
                /**
-                * Get cases for message  
-                * 
+                * Get cases for message
+                *
                 * @param       $location_id location id
                 * @param       $location_item_id location item id
                 * @return array of case object represented as objects or arrays
-               */
+                */
                public function get_cases_by_message($location_id, 
$location_item_id)
                {
-                       $location_id            = (int) $location_id;
-                       $location_item_id       = (int) $location_item_id;
+                       $location_id             = (int)$location_id;
+                       $location_item_id        = (int)$location_item_id;
 
-                       $sql = "SELECT * FROM controller_check_item_case "; 
+                       $sql = "SELECT * FROM controller_check_item_case ";
                        $sql .= "WHERE location_id = {$location_id} AND 
location_item_id = {$location_item_id}";
 
                        $this->db->query($sql);
 
                        $cases_array = array();
 
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $case = new 
controller_check_item_case($this->unmarshal($this->db->f('id'), 'int'));
                                
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'), 
'int'));
@@ -123,14 +129,14 @@
                                
$case->set_location_id($this->unmarshal($this->db->f('location_id'), 'int'));
                                
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id'), 
'int'));
                                
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
-                               
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));   
+                               
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));
                                
$case->set_entry_date($this->unmarshal($this->db->f('entry_date'), 'int'));
                                
$case->set_modified_date($this->unmarshal($this->db->f('modified_date'), 
'int'));
                                
$case->set_modified_by($this->unmarshal($this->db->f('modified_by'), 'int'));
                                
$case->set_measurement($this->unmarshal($this->db->f('measurement'), 'string'));
                                
$case->set_location_code($this->unmarshal($this->db->f('location_code'), 
'string'));
                                
$case->set_component_location_id($this->unmarshal($this->db->f('component_location_id'),
 'int'));
-                               
$case->set_component_id($this->unmarshal($this->db->f('component_id'), 'int')); 
                        
+                               
$case->set_component_id($this->unmarshal($this->db->f('component_id'), 'int'));
 
                                $cases_array[] = $case;
                        }
@@ -138,22 +144,21 @@
                        return $cases_array;
                }
 
-
                /**
-                * Get cases for component  
-                * 
+                * Get cases for component
+                *
                 * @param       $location_id location id
                 * @param       $location_item_id location item id
                 * @return array of case object represented as objects or arrays
-               */
+                */
                public function get_cases_by_component($component_location_id, 
$component_id, $control_item_id = 0, $check_list_id = 0)
                {
-                       $component_location_id  = (int) $component_location_id;
-                       $component_id                   = (int) $component_id;
-                       $control_item_id                = (int) 
$control_item_id;
-                       $check_list_id                  = (int) $check_list_id;
+                       $component_location_id   = (int)$component_location_id;
+                       $component_id                    = (int)$component_id;
+                       $control_item_id                 = 
(int)$control_item_id;
+                       $check_list_id                   = (int)$check_list_id;
 
-                       $sql = "SELECT controller_check_item_case.*, 
check_list_id FROM controller_check_item_case " 
+                       $sql = "SELECT controller_check_item_case.*, 
check_list_id FROM controller_check_item_case "
                        . " {$this->join} controller_check_item ON 
controller_check_item_case.check_item_id = controller_check_item.id"
                        . " WHERE 
controller_check_item_case.component_location_id = {$component_location_id} AND 
controller_check_item_case.component_id = {$component_id}";
 
@@ -170,49 +175,47 @@
                        $this->db->query($sql);
 
                        $values = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $values[] = array
-                               (
-                                       'id'                    => 
$this->db->f('id'),
-                                       'check_list_id' => 
$this->db->f('check_list_id'),
-                                       'descr'                 => 
$this->db->f('descr', true),
-                                       'measurement'   => 
$this->db->f('measurement', true),
-                                       'user_id'               => 
$this->db->f('user_id'),
-                                       'status'                => 
$this->db->f('status'),
-                                       'modified_date' => 
$this->db->f('modified_date')
+                                       (
+                                       'id'                     => 
$this->db->f('id'),
+                                       'check_list_id'  => 
$this->db->f('check_list_id'),
+                                       'descr'                  => 
$this->db->f('descr', true),
+                                       'measurement'    => 
$this->db->f('measurement', true),
+                                       'user_id'                => 
$this->db->f('user_id'),
+                                       'status'                 => 
$this->db->f('status'),
+                                       'modified_date'  => 
$this->db->f('modified_date')
                                );
                        }
 
                        return $values;
                }
 
-
-               
                /**
-                * Inserts a new case in database  
-                * 
+                * Inserts a new case in database
+                *
                 * @param       $case to inserted
                 * @return true or false
-               */
+                */
                function add(&$case)
                {
                        $this->db->transaction_begin();
 
                        $cols = array(
-                                       'check_item_id',
-                                       'status',
-                                       'location_id',
-                                       'location_item_id',
-                                       'descr',
-                                       'user_id',
-                                       'entry_date',
-                                       'modified_date',
-                                       'modified_by',
-                                       'measurement',
-                                       'location_code',
-                                       'component_location_id',
-                                       'component_id'
+                               'check_item_id',
+                               'status',
+                               'location_id',
+                               'location_item_id',
+                               'descr',
+                               'user_id',
+                               'entry_date',
+                               'modified_date',
+                               'modified_by',
+                               'measurement',
+                               'location_code',
+                               'component_location_id',
+                               'component_id'
                        );
 
                        $values = array(
@@ -227,19 +230,19 @@
                                $this->marshal($case->get_modified_by(), 'int'),
                                $this->marshal($case->get_measurement(), 
'string'),
                                $this->marshal($case->get_location_code(), 
'string'),
-                               
$this->marshal($case->get_component_location_id(), 'int'),                      
        
+                               
$this->marshal($case->get_component_location_id(), 'int'),
                                $this->marshal($case->get_component_id(), 
'int'),
                        );
 
-                       $sql = 'INSERT INTO controller_check_item_case (' . 
join(',', $cols) . ') VALUES (' . join(',', $values) . ')';
-                       $this->db->query( $sql, __LINE__,__FILE__);
+                       $sql     = 'INSERT INTO controller_check_item_case (' . 
join(',', $cols) . ') VALUES (' . join(',', $values) . ')';
+                       $this->db->query($sql, __LINE__, __FILE__);
                        $case_id = 
$this->db->get_last_insert_id('controller_check_item_case', 'id');
-                       
+
 //--------
 
                        
$this->update_cases_on_check_list($case->get_check_item_id());
-                       
 
+
 //------
 
                        if($this->db->transaction_commit())
@@ -252,43 +255,42 @@
                        }
                }
 
-
                function update_cases_on_check_list($check_item_id = 0)
                {
-                       $check_item_id = (int) $check_item_id;
-                       $sql = "SELECT check_list_id  FROM 
controller_check_item WHERE id = {$check_item_id}";
+                       $check_item_id   = (int)$check_item_id;
+                       $sql                     = "SELECT check_list_id  FROM 
controller_check_item WHERE id = {$check_item_id}";
 
-                       $this->db->query($sql, __LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
-                       $check_list_id = (int) $this->db->f('check_list_id');
-               
-                       $so_check_item = 
CreateObject('controller.socheck_item');
-                       $check_items = 
$so_check_item->get_check_items_with_cases($check_list_id, $control_item_type = 
null, $status = null, $messageStatus = null);
-       
-                       $num_open_cases = 0;
-                       $num_pending_cases = 0;
-                                       
+                       $check_list_id = (int)$this->db->f('check_list_id');
+
+                       $so_check_item           = 
CreateObject('controller.socheck_item');
+                       $check_items             = 
$so_check_item->get_check_items_with_cases($check_list_id, $control_item_type   
      = null, $status                                 = null, $messageStatus    
      = null);
+
+                       $num_open_cases          = 0;
+                       $num_pending_cases       = 0;
+
                        foreach($check_items as $check_item)
                        {
                                foreach($check_item->get_cases_array() as $case)
                                {
-                                       
+
                                        if($case->get_status() == 
controller_check_item_case::STATUS_OPEN)
                                        {
                                                $num_open_cases++;
                                        }
-                                       
+
                                        if($case->get_status() == 
controller_check_item_case::STATUS_PENDING)
                                        {
                                                $num_pending_cases++;
                                        }
-                               }       
+                               }
                        }
-                       
+
                        $values = array
-                       (
-                               'num_open_cases' => $num_open_cases,
-                               'num_pending_cases' => $num_pending_cases,
+                               (
+                               'num_open_cases'         => $num_open_cases,
+                               'num_pending_cases'      => $num_pending_cases,
                        );
 
 //                     if($num_open_cases > 0)
@@ -296,19 +298,19 @@
 //                             $values['status'] = 
controller_check_list::STATUS_DONE;
 //                     }
 
-                       $value_set      = $this->db->validate_update($values);
-                       return $this->db->query("UPDATE controller_check_list 
SET {$value_set} WHERE id = '{$check_list_id}'",__LINE__,__FILE__);
+                       $value_set = $this->db->validate_update($values);
+                       return $this->db->query("UPDATE controller_check_list 
SET {$value_set} WHERE id = '{$check_list_id}'", __LINE__, __FILE__);
                }
 
                /**
-                * Updates an existing case object in database  
-                * 
+                * Updates an existing case object in database
+                *
                 * @param       $case to updated
                 * @return true or false
-               */
+                */
                function update($case)
                {
-                       if ( $this->db->get_transaction() )
+                       if($this->db->get_transaction())
                        {
                                $this->global_lock = true;
                        }
@@ -317,8 +319,8 @@
                                $this->db->transaction_begin();
                        }
 
-                       $id = (int) $case->get_id();
-                       
+                       $id = (int)$case->get_id();
+
                        $values = array(
                                'check_item_id = ' . 
$this->marshal($case->get_check_item_id(), 'int'),
                                'status = ' . $case->get_status(),
@@ -333,11 +335,11 @@
                                'location_code = ' . 
$this->marshal($case->get_location_code(), 'string')
                        );
 
-                       $result = $this->db->query('UPDATE 
controller_check_item_case SET ' . join(',', $values) . " WHERE id=$id", 
__LINE__,__FILE__);
+                       $result = $this->db->query('UPDATE 
controller_check_item_case SET ' . join(',', $values) . " WHERE id=$id", 
__LINE__, __FILE__);
 
                        $ok = 
$this->update_cases_on_check_list($case->get_check_item_id());
 
-                       if ( !$this->global_lock )
+                       if(!$this->global_lock)
                        {
                                $this->db->transaction_commit();
                        }
@@ -351,18 +353,21 @@
                                return 0;
                        }
                }
-               
+
                /**
-                * Delete case in database  
-                * 
+                * Delete case in database
+                *
                 * @param       $case_id case to be deleted
                 * @return true or false
-               */
+                */
                function delete($case_id)
                {
-                       $case_id = (int) $case_id;
+                       $case_id = (int)$case_id;
                        return $this->db->query("DELETE FROM 
controller_check_item_case WHERE id = $case_id");
                }
-               
-               function get_id_field_name(){}
-       }
+
+               function get_id_field_name()
+               {
+
+               }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/controller/inc/class.socheck_item.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.socheck_item.inc.php   
2015-12-09 18:15:59 UTC (rev 14547)
+++ branches/dev-syncromind/controller/inc/class.socheck_item.inc.php   
2015-12-09 19:19:58 UTC (rev 14548)
@@ -1,33 +1,32 @@
 <?php
        /**
-       * phpGroupWare - controller: a part of a Facilities Management System.
-       *
-       * @author Erink Holm-Larsen <address@hidden>
-       * @author Torstein Vadla <address@hidden>
-       * @copyright Copyright (C) 2011,2012 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/
-       * @package property
-       * @subpackage controller
-       * @version $Id$
-       */
-
+        * phpGroupWare - controller: a part of a Facilities Management System.
+        *
+        * @author Erink Holm-Larsen <address@hidden>
+        * @author Torstein Vadla <address@hidden>
+        * @copyright Copyright (C) 2011,2012 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/
+        * @package property
+        * @subpackage controller
+        * @version $Id$
+        */
        phpgw::import_class('controller.socommon');
 
        include_class('controller', 'check_item', 'inc/model/');
@@ -35,6 +34,7 @@
 
        class controller_socheck_item extends controller_socommon
        {
+
                protected static $so;
 
                /**
@@ -44,7 +44,7 @@
                 */
                public static function get_instance()
                {
-                       if (self::$so == null)
+                       if(self::$so == null)
                        {
                                self::$so = 
CreateObject('controller.socheck_item');
                        }
@@ -53,15 +53,15 @@
 
                /**
                 * Add a new check item object to database
-                * 
+                *
                 * @param       $check_item check item oject to be added
-                * @return id of the inserted check item, 0 otherwise 
-               */
+                * @return id of the inserted check item, 0 otherwise
+                */
                function add(&$check_item)
                {
                        $cols = array(
-                                       'control_item_id',
-                                       'check_list_id'
+                               'control_item_id',
+                               'check_list_id'
                        );
 
                        $values = array(
@@ -69,17 +69,17 @@
                                
$this->marshal($check_item->get_check_list_id(), 'int')
                        );
 
-                       $result = $this->db->query('INSERT INTO 
controller_check_item (' . join(',', $cols) . ') VALUES (' . join(',', $values) 
. ')', __LINE__,__FILE__);
+                       $result = $this->db->query('INSERT INTO 
controller_check_item (' . join(',', $cols) . ') VALUES (' . join(',', $values) 
. ')', __LINE__, __FILE__);
 
                        return $result ? 
$this->db->get_last_insert_id('controller_check_item', 'id') : 0;
                }
 
                /**
-                * Update existing check item object in database  
-                * 
+                * Update existing check item object in database
+                *
                 * @param       $check_item check item oject to be updated
-                * @return  id of the inserted check item, 0 otherwise 
-               */
+                * @return  id of the inserted check item, 0 otherwise
+                */
                function update($check_item)
                {
                        $id = $check_item->get_id();
@@ -89,9 +89,9 @@
                                'check_list_id = ' . 
$this->marshal($check_item->get_check_list_id(), 'int')
                        );
 
-                       $result = $this->db->query('UPDATE 
controller_check_item SET ' . join(',', $values) . " WHERE id=$id", 
__LINE__,__FILE__);
+                       $result = $this->db->query('UPDATE 
controller_check_item SET ' . join(',', $values) . " WHERE id=$id", __LINE__, 
__FILE__);
 
-                       if( $result )
+                       if($result)
                        {
                                return $id;
                        }
@@ -102,17 +102,17 @@
                }
 
                /**
-                * Get single check item object from database including related 
control item  
-                * 
+                * Get single check item object from database including related 
control item
+                *
                 * @param       $check_item_id id to check item to be fetched 
from database
-                * @return  check item object 
-               */
+                * @return  check item object
+                */
                public function get_single($check_item_id)
                {
-                       $check_item_id = (int) $check_item_id;
+                       $check_item_id = (int)$check_item_id;
 
                        $sql = "SELECT ci.*, ci.id as c_id, coi.id as coi_id, 
coi.* ";
-                       $sql .= "FROM controller_check_item ci, 
controller_control_item coi "; 
+                       $sql .= "FROM controller_check_item ci, 
controller_control_item coi ";
                        $sql .= "WHERE ci.id = {$check_item_id} ";
                        $sql .= "AND ci.control_item_id=coi.id";
 
@@ -140,97 +140,96 @@
                                return null;
                        }
                }
-               
                /**
-                * Get single check item object from database including related 
cases and control item 
-                * 
+                * Get single check item object from database including related 
cases and control item
+                *
                 * @param       $check_item_id id to check item to be fetched 
from database
-                * @return  check item object 
-               */
-    /*
-               public function get_single_with_cases($check_item_id)
-               {
-                       $check_item_id = (int) $check_item_id;
+                * @return  check item object
+                */
+               /*
+                 public function get_single_with_cases($check_item_id)
+                 {
+                 $check_item_id = (int) $check_item_id;
 
-                       $sql  = "SELECT ci.id as ci_id, control_item_id, 
check_list_id, ";
-                       $sql .= "cic.id as cic_id, cic.status as cic_status, 
cic.*, ";
-                       $sql .= "coi.id as coi_id, coi.* ";
-                       $sql .= "FROM controller_check_item ci "; 
-                       $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
-                       $sql .= "LEFT JOIN controller_check_item_case as cic ON 
ci.id = cic.check_item_id ";
-                       $sql .= "WHERE ci.id = {$check_item_id} ";
-                                                                               
        
-                       $this->db->query($sql);
-                       
-                       $counter = 0;
-                       $check_item = null;
-                       while ($this->db->next_record())
-                       {
-                               if( $counter == 0 )
-                               {
-                                       $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
-                                       
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
 'int'));
-                                       
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'), 
'int'));
-                                       
-                                       $control_item = new 
controller_control_item($this->unmarshal($this->db->f('coi_id'), 'int'));
-                                       
$control_item->set_title($this->db->f('title', true), 'string');
-                                       
$control_item->set_required($this->db->f('required', true), 'string');
-                                       
$control_item->set_what_to_do($this->db->f('what_to_do', true), 'string');
-                                       
$control_item->set_how_to_do($this->db->f('how_to_do', true), 'string');
-                                       
$control_item->set_control_group_id($this->db->f('control_group_id'), 'int');
-                                       
$control_item->set_type($this->db->f('type', true), 'string');
-                                                                       
-                                       
$check_item->set_control_item($control_item);
-                                               
-                                       $cases_array = array();
-                               }
-                               
-                               if($this->db->f('cic_id'))
-                               {
-                                       $case = new 
controller_check_item_case($this->unmarshal($this->db->f('cic_id'), 'int'));
-                                       
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'), 
'int'));
-                                       
$case->set_status($this->unmarshal($this->db->f('cic_status'), 'int'));
-                                       
$case->set_location_id($this->unmarshal($this->db->f('location_id'), 'int'));
-                                       
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id'), 
'int'));
-                                       
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
-                                       
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));   
-                                       
$case->set_entry_date($this->unmarshal($this->db->f('entry_date'), 'int'));
-                                       
$case->set_modified_date($this->unmarshal($this->db->f('modified_date'), 
'int'));
-                                       
$case->set_modified_by($this->unmarshal($this->db->f('modified_by'), 'int'));
-                               
-          $cases_array[] = $case;
-                               }
-                               
-                               $check_item_id =  $check_item->get_id();
-                               $counter++;
-                       }
-                       
-                       if($check_item != null)
-                       {
-                               $check_item->set_cases_array($cases_array);
-                               return $check_item;
-                       }
-                       else
-                       {
-                               return null;
-                       }
-               }
-     */
-               
+                 $sql  = "SELECT ci.id as ci_id, control_item_id, 
check_list_id, ";
+                 $sql .= "cic.id as cic_id, cic.status as cic_status, cic.*, ";
+                 $sql .= "coi.id as coi_id, coi.* ";
+                 $sql .= "FROM controller_check_item ci ";
+                 $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
+                 $sql .= "LEFT JOIN controller_check_item_case as cic ON ci.id 
= cic.check_item_id ";
+                 $sql .= "WHERE ci.id = {$check_item_id} ";
+
+                 $this->db->query($sql);
+
+                 $counter = 0;
+                 $check_item = null;
+                 while ($this->db->next_record())
+                 {
+                 if( $counter == 0 )
+                 {
+                 $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
+                 
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
 'int'));
+                 
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'), 
'int'));
+
+                 $control_item = new 
controller_control_item($this->unmarshal($this->db->f('coi_id'), 'int'));
+                 $control_item->set_title($this->db->f('title', true), 
'string');
+                 $control_item->set_required($this->db->f('required', true), 
'string');
+                 $control_item->set_what_to_do($this->db->f('what_to_do', 
true), 'string');
+                 $control_item->set_how_to_do($this->db->f('how_to_do', true), 
'string');
+                 
$control_item->set_control_group_id($this->db->f('control_group_id'), 'int');
+                 $control_item->set_type($this->db->f('type', true), 'string');
+
+                 $check_item->set_control_item($control_item);
+
+                 $cases_array = array();
+                 }
+
+                 if($this->db->f('cic_id'))
+                 {
+                 $case = new 
controller_check_item_case($this->unmarshal($this->db->f('cic_id'), 'int'));
+                 
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'), 
'int'));
+                 
$case->set_status($this->unmarshal($this->db->f('cic_status'), 'int'));
+                 
$case->set_location_id($this->unmarshal($this->db->f('location_id'), 'int'));
+                 
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id'), 
'int'));
+                 $case->set_descr($this->unmarshal($this->db->f('descr', 
true), 'string'));
+                 $case->set_user_id($this->unmarshal($this->db->f('user_id'), 
'int'));
+                 
$case->set_entry_date($this->unmarshal($this->db->f('entry_date'), 'int'));
+                 
$case->set_modified_date($this->unmarshal($this->db->f('modified_date'), 
'int'));
+                 
$case->set_modified_by($this->unmarshal($this->db->f('modified_by'), 'int'));
+
+                 $cases_array[] = $case;
+                 }
+
+                 $check_item_id =  $check_item->get_id();
+                 $counter++;
+                 }
+
+                 if($check_item != null)
+                 {
+                 $check_item->set_cases_array($cases_array);
+                 return $check_item;
+                 }
+                 else
+                 {
+                 return null;
+                 }
+                 }
+                */
+
                /**
                 * Get single check item object from database including related 
control item
-                * 
+                *
                 * @param       $check_list_id check list id
                 * @param       $check_item_id control item id
-                * @return check item object 
-               */
+                * @return check item object
+                */
                public function 
get_check_item_by_check_list_and_control_item($check_list_id, $control_item_id)
                {
-                       $check_list_id = (int) $check_list_id;
-                       $control_item_id = (int) $control_item_id;
+                       $check_list_id   = (int)$check_list_id;
+                       $control_item_id = (int)$control_item_id;
 
-                       $sql  = "SELECT ci.*, ci.id as c_id, coi.id as coi_id, 
coi.* ";
-                       $sql .= "FROM controller_check_item ci, 
controller_control_item coi "; 
+                       $sql = "SELECT ci.*, ci.id as c_id, coi.id as coi_id, 
coi.* ";
+                       $sql .= "FROM controller_check_item ci, 
controller_control_item coi ";
                        $sql .= "WHERE ci.check_list_id = {$check_list_id} ";
                        $sql .= "AND ci.control_item_id = coi.id ";
                        $sql .= "AND ci.control_item_id = {$control_item_id}";
@@ -259,31 +258,31 @@
                                return null;
                        }
                }
-                               
+
                /**
-                * Get check item objects from database including control item 
and related cases 
-                * 
+                * Get check item objects from database including control item 
and related cases
+                *
                 * @param       $check_list_id check list id
-                * @param       $type control item registration type 
COMMENT/TEXTFIELD/CHECKLIST/RADIOBUTTONS 
+                * @param       $type control item registration type 
COMMENT/TEXTFIELD/CHECKLIST/RADIOBUTTONS
                 * @param       $status status for cases OPEN/CLOSED/PENDING
                 * @param       $messageStatus is there a message registered 
for the case
                 * @return check item objects
-               */
+                */
                public function get_check_items_with_cases($check_list_id, 
$type = "control_item_type_1", $status = "open", $messageStatus = null, 
$location_code = null)
                {
-                       $check_list_id = (int) $check_list_id;
-                       $sql  = "SELECT ci.id as ci_id, control_item_id, 
check_list_id, cic.component_location_id,";
+                       $check_list_id   = (int)$check_list_id;
+                       $sql                     = "SELECT ci.id as ci_id, 
control_item_id, check_list_id, cic.component_location_id,";
                        $sql .= "cic.id as cic_id, cic.status as cic_status, 
cic.*, ";
                        $sql .= "coi.id as coi_id, coi.* ";
-               //      $sql .= "FROM controller_check_item ci "; 
+                       //      $sql .= "FROM controller_check_item ci ";
 
                        $sql .= "FROM controller_control_group JOIN 
controller_control_item ON 
controller_control_item.control_group_id=controller_control_group.id ";
-                       $sql .= "JOIN controller_check_item ci ON 
ci.control_item_id = controller_control_item.id "; 
+                       $sql .= "JOIN controller_check_item ci ON 
ci.control_item_id = controller_control_item.id ";
 
                        $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
                        $sql .= "LEFT JOIN controller_check_item_case as cic ON 
ci.id = cic.check_item_id ";
                        $sql .= "WHERE ci.check_list_id = {$check_list_id} ";
-                       
+
                        if($status == 'open')
                        {
                                $sql .= "AND cic.status = 0 ";
@@ -300,49 +299,49 @@
                        {
                                $sql .= "AND (cic.status = 0 OR cic.status = 2) 
";
                        }
-                       
+
                        if($type != null)
                        {
                                $sql .= "AND coi.type = '$type' ";
                        }
-                                                                               
+
                        if($messageStatus != null & $messageStatus == 
'no_message_registered')
                        {
                                $sql .= "AND cic.location_item_id IS NULL ";
                        }
-                       else if($messageStatus != null &  $messageStatus == 
'message_registered')
+                       else if($messageStatus != null & $messageStatus == 
'message_registered')
                        {
                                $sql .= "AND cic.location_item_id > 0 ";
                        }
-      
-               if($location_code != null)
+
+                       if($location_code != null)
                        {
                                $sql .= "AND cic.location_code = 
'$location_code' ";
                        }
-                       
+
                        $sql .= "ORDER BY ci.id";
-                                                                               
        
+
                        $this->db->query($sql);
-                       
-                       $check_item_id = 0;
-                       $check_item = null;
-                       $check_items_array=array();
 
-                       while ($this->db->next_record())
+                       $check_item_id           = 0;
+                       $check_item                      = null;
+                       $check_items_array       = array();
+
+                       while($this->db->next_record())
                        {
-                               if( $this->db->f('ci_id') != $check_item_id )
-                               {       
+                               if($this->db->f('ci_id') != $check_item_id)
+                               {
                                        if($check_item_id)
                                        {
                                                
$check_item->set_cases_array($cases_array);
-                                                                               
+
                                                $check_items_array[] = 
$check_item;
                                        }
-                               
+
                                        $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
                                        
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
 'int'));
                                        
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'), 
'int'));
-                                       
+
                                        $control_item = new 
controller_control_item($this->unmarshal($this->db->f('coi_id'), 'int'));
                                        
$control_item->set_title($this->db->f('title', true), 'string');
                                        
$control_item->set_required($this->db->f('required', true), 'string');
@@ -350,82 +349,81 @@
                                        
$control_item->set_how_to_do($this->db->f('how_to_do', true), 'string');
                                        
$control_item->set_control_group_id($this->db->f('control_group_id'), 'int');
                                        
$control_item->set_type($this->db->f('type', true), 'string');
-                               
+
                                        
$check_item->set_control_item($control_item);
-                                                                               
                
+
                                        $cases_array = array();
                                }
-                               
-                               if( $this->db->f('cic_id') )
+
+                               if($this->db->f('cic_id'))
                                {
-                                       $case = new 
controller_check_item_case($this->unmarshal($this->db->f('cic_id'), 'int'));
+                                       $case                    = new 
controller_check_item_case($this->unmarshal($this->db->f('cic_id'), 'int'));
                                        
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'), 
'int'));
                                        
$case->set_status($this->unmarshal($this->db->f('cic_status'), 'int'));
                                        
$case->set_location_id($this->unmarshal($this->db->f('location_id'), 'int'));
                                        
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id'), 
'int'));
                                        
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
-                                       
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));   
+                                       
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));
                                        
$case->set_entry_date($this->unmarshal($this->db->f('entry_date'), 'int'));
                                        
$case->set_modified_date($this->unmarshal($this->db->f('modified_date'), 
'int'));
                                        
$case->set_modified_by($this->unmarshal($this->db->f('modified_by'), 'int'));
                                        
$case->set_measurement($this->unmarshal($this->db->f('measurement', true), 
'string'));
                                        
$case->set_component_location_id($this->db->f('component_location_id'), 'int');
-                                       
$case->set_component_id($this->unmarshal($this->db->f('component_id'), 'int')); 
                                                        
-                                       $cases_array[] = $case;
-                                       
+                                       
$case->set_component_id($this->unmarshal($this->db->f('component_id'), 'int'));
+                                       $cases_array[]   = $case;
                                }
-                               
+
                                $check_item_id = $check_item->get_id();
                        }
-                       
+
                        if($check_item != null)
                        {
                                $check_item->set_cases_array($cases_array);
-                                                       
+
                                $check_items_array[] = $check_item;
                        }
 
                        return $check_items_array;
                }
-               
+
                /**
                 * Get check item objects from database including related 
control item and cases
-                * 
+                *
                 * @param       $message_ticket_id get check items and cases 
for this message
-                * @return check item objects 
-               */
+                * @return check item objects
+                */
                public function 
get_check_items_with_cases_by_message($message_ticket_id)
                {
-                       $message_ticket_id = (int) $message_ticket_id;
+                       $message_ticket_id = (int)$message_ticket_id;
 
-                       $sql  = "SELECT ci.id as ci_id, control_item_id, 
cic.component_location_id,"; 
+                       $sql = "SELECT ci.id as ci_id, control_item_id, 
cic.component_location_id,";
                        $sql .= "check_list_id, cic.id as cic_id, cic.status as 
cic_status, cic.*, ";
                        $sql .= "coi.id as coi_id, coi.* ";
                        $sql .= "FROM controller_control_group JOIN 
controller_control_item ON 
controller_control_item.control_group_id=controller_control_group.id ";
-                       $sql .= "JOIN controller_check_item ci ON 
ci.control_item_id = controller_control_item.id "; 
+                       $sql .= "JOIN controller_check_item ci ON 
ci.control_item_id = controller_control_item.id ";
                        $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
                        $sql .= "LEFT JOIN controller_check_item_case as cic ON 
ci.id = cic.check_item_id ";
                        $sql .= "WHERE cic.location_item_id = 
{$message_ticket_id}";
-                                                                               
        
+
                        $this->db->query($sql);
-                       
-                       $check_item_id = 0;
-                       $check_item = null;
-                       while ($this->db->next_record())
+
+                       $check_item_id   = 0;
+                       $check_item              = null;
+                       while($this->db->next_record())
                        {
-                               if( $this->db->f('ci_id') != $check_item_id )
+                               if($this->db->f('ci_id') != $check_item_id)
                                {
                                        if($check_item_id)
                                        {
                                                
$check_item->set_cases_array($cases_array);
-                                               
+
                                                $check_items_array[] = 
$check_item;
                                        }
-                               
+
                                        $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
                                        
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
 'int'));
                                        
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'), 
'int'));
-                                       
+
                                        $control_item = new 
controller_control_item($this->unmarshal($this->db->f('coi_id'), 'int'));
                                        
$control_item->set_title($this->db->f('title', true), 'string');
                                        
$control_item->set_required($this->db->f('required', true), 'string');
@@ -434,12 +432,12 @@
                                        
$control_item->set_control_group_id($this->db->f('control_group_id'), 'int');
                                        
$control_item->set_component_location_id($this->db->f('component_location_id'), 
'int');
                                        
$control_item->set_type($this->db->f('type', true), 'string');
-                                                                       
+
                                        
$check_item->set_control_item($control_item);
-                                                                               
                                
+
                                        $cases_array = array();
                                }
-                               
+
                                if($this->db->f('cic_id'))
                                {
                                        $case = new 
controller_check_item_case($this->unmarshal($this->db->f('cic_id'), 'int'));
@@ -448,22 +446,22 @@
                                        
$case->set_location_id($this->unmarshal($this->db->f('location_id'), 'int'));
                                        
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id'), 
'int'));
                                        
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
-                                       
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));   
+                                       
$case->set_user_id($this->unmarshal($this->db->f('user_id'), 'int'));
                                        
$case->set_entry_date($this->unmarshal($this->db->f('entry_date'), 'int'));
                                        
$case->set_modified_date($this->unmarshal($this->db->f('modified_date'), 
'int'));
                                        
$case->set_modified_by($this->unmarshal($this->db->f('modified_by'), 'int'));
-                               
+
                                        $cases_array[] = $case;
                                }
-                               
-                               $check_item_id =  $check_item->get_id();
+
+                               $check_item_id = $check_item->get_id();
                        }
-                       
+
                        if($check_item != null)
                        {
                                $check_item->set_cases_array($cases_array);
                                $check_items_array[] = $check_item;
-                               
+
                                return $check_items_array;
                        }
                        else
@@ -471,36 +469,45 @@
                                return null;
                        }
                }
-                /* Later ikke til at vi bruker denne: Torstein 10.07.12
-               public function get_check_items_by_message($location_id, 
$location_item_id, $return_type = "return_array" )
+               /* Later ikke til at vi bruker denne: Torstein 10.07.12
+                 public function get_check_items_by_message($location_id, 
$location_item_id, $return_type = "return_array" )
+                 {
+                 $location_id          = (int)$location_id;
+                 $location_item_id     = (int)$location_item_id;
+                 $sql  = "SELECT ci.* ";
+                 $sql .= "FROM controller_check_item ci ";
+                 $sql .= "LEFT JOIN controller_check_item_case as cic ON ci.id 
= cic.check_item_id ";
+                 $sql .= "WHERE cic.location_id = {$location_id} AND 
cic.location_item_id = {$location_item_id} ";
+
+                 $this->db->query($sql);
+
+                 while ($this->db->next_record()) {
+                 $check_item = new 
controller_check_item($this->unmarshal($this->db->f('id', true), 'int'));
+                 
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
 true), 'int'));
+                 
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id', 
true), 'int'));
+
+                 if($return_type == "return_array")
+                 $check_items_array[] = $check_item->toArray();
+                 else
+                 $check_items_array[] = $check_item;
+                 }
+
+                 return $check_items_array;
+                 }
+                */
+
+               function get_query(string $sort_field, boolean $ascending, 
string $search_for, string $search_type, array $filters, boolean $return_count)
                {
-                       $location_id            = (int)$location_id;
-                       $location_item_id       = (int)$location_item_id;
-                       $sql  = "SELECT ci.* "; 
-                       $sql .= "FROM controller_check_item ci "; 
-                       $sql .= "LEFT JOIN controller_check_item_case as cic ON 
ci.id = cic.check_item_id ";
-                       $sql .= "WHERE cic.location_id = {$location_id} AND 
cic.location_item_id = {$location_item_id} ";
-                                                               
-                       $this->db->query($sql);
-                       
-                       while ($this->db->next_record()) {
-                               $check_item = new 
controller_check_item($this->unmarshal($this->db->f('id', true), 'int'));
-                               
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
 true), 'int'));
-                               
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id', 
true), 'int'));
-                               
-                               if($return_type == "return_array")
-                                       $check_items_array[] = 
$check_item->toArray();
-                               else
-                                       $check_items_array[] = $check_item;
-                       }
-                       
-                       return $check_items_array;
+
                }
-               */
-               
-               function get_query(string $sort_field, boolean $ascending, 
string $search_for, string $search_type, array $filters, boolean 
$return_count){}
 
-               function populate(int $object_id, &$object){}
+               function populate(int $object_id, &$object)
+               {
 
-               function get_id_field_name(){}
-       }
+               }
+
+               function get_id_field_name()
+               {
+
+               }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/controller/inc/class.socheck_list.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.socheck_list.inc.php   
2015-12-09 18:15:59 UTC (rev 14547)
+++ branches/dev-syncromind/controller/inc/class.socheck_list.inc.php   
2015-12-09 19:19:58 UTC (rev 14548)
@@ -1,786 +1,785 @@
-<?php  
+<?php
        /**
-       * phpGroupWare - controller: a part of a Facilities Management System.
-       *
-       * @author Erik Holm-Larsen <address@hidden>
-       * @author Torstein Vadla <address@hidden>
-       * @copyright Copyright (C) 2011,2012 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/
-       * @package property
-       * @subpackage controller
-       * @version $Id$
-       */
+        * phpGroupWare - controller: a part of a Facilities Management System.
+        *
+        * @author Erik Holm-Larsen <address@hidden>
+        * @author Torstein Vadla <address@hidden>
+        * @copyright Copyright (C) 2011,2012 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/
+        * @package property
+        * @subpackage controller
+        * @version $Id$
+        */
+       phpgw::import_class('controller.socommon');
 
-phpgw::import_class('controller.socommon');
+       include_class('controller', 'check_list', 'inc/model/');
+       include_class('controller', 'control_item', 'inc/model/');
+       include_class('controller', 'check_item', 'inc/model/');
 
-include_class('controller', 'check_list', 'inc/model/');
-include_class('controller', 'control_item', 'inc/model/');
-include_class('controller', 'check_item', 'inc/model/');
+       class controller_socheck_list extends controller_socommon
+       {
 
-class controller_socheck_list extends controller_socommon
-{
-       protected static $so;
+               protected static $so;
 
-       /**
-        * Get a static reference to the storage object associated with this 
model object
-        *
-        * @return controller_socheck_list the storage object
-        */
-       public static function get_instance()
-       {
-               if (self::$so == null)
+               /**
+                * Get a static reference to the storage object associated with 
this model object
+                *
+                * @return controller_socheck_list the storage object
+                */
+               public static function get_instance()
                {
-                       self::$so = CreateObject('controller.socheck_list');
+                       if(self::$so == null)
+                       {
+                               self::$so = 
CreateObject('controller.socheck_list');
+                       }
+                       return self::$so;
                }
-               return self::$so;
-       }
-       
-       /**
-        * Get a check list and related check_items and returns it as an object
-        *
-        * @param $check_list_id
-        * @return check list object
-        */
-       public function get_single($check_list_id)
-       {
-               $check_list_id = (int) $check_list_id;
-               $sql = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.control_id, cl.comment as cl_comment, deadline, planned_date,assigned_to, 
billable_hours, "; 
-               $sql .= "completed_date, location_code, component_id, 
num_open_cases, num_pending_cases, location_id, ci.id as ci_id, 
control_item_id,serie_id ";
-               $sql .= "FROM controller_check_list cl ";
-               $sql .= "LEFT JOIN controller_check_item as ci ON cl.id = 
ci.check_list_id ";
-               $sql .= "WHERE cl.id = {$check_list_id}";
-               
-               $this->db->query($sql);
-               $this->db->next_record();
-                       
-               $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
-               
$check_list->set_control_id($this->unmarshal($this->db->f('control_id'), 
'int'));
-               
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'int'));
-               
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
-               
$check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int'));
-               
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 
'int'));
-               
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));
-               
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
-               
$check_list->set_component_id($this->unmarshal($this->db->f('component_id'), 
'int'));
-               
$check_list->set_location_id($this->unmarshal($this->db->f('location_id'), 
'int'));
-               
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
 'int'));       
-               
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
 'int'));
-               
$check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'), 
'int'));
-               $check_list->set_billable_hours($this->db->f('billable_hours'));
-               $check_list->set_serie_id($this->db->f('serie_id'));
 
-                       
-               if($check_list != null)
+               /**
+                * Get a check list and related check_items and returns it as 
an object
+                *
+                * @param $check_list_id
+                * @return check list object
+                */
+               public function get_single($check_list_id)
                {
-                       return $check_list;
+                       $check_list_id   = (int)$check_list_id;
+                       $sql                     = "SELECT cl.id as cl_id, 
cl.status as cl_status, cl.control_id, cl.comment as cl_comment, deadline, 
planned_date,assigned_to, billable_hours, ";
+                       $sql .= "completed_date, location_code, component_id, 
num_open_cases, num_pending_cases, location_id, ci.id as ci_id, 
control_item_id,serie_id ";
+                       $sql .= "FROM controller_check_list cl ";
+                       $sql .= "LEFT JOIN controller_check_item as ci ON cl.id 
= ci.check_list_id ";
+                       $sql .= "WHERE cl.id = {$check_list_id}";
+
+                       $this->db->query($sql);
+                       $this->db->next_record();
+
+                       $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
+                       
$check_list->set_control_id($this->unmarshal($this->db->f('control_id'), 
'int'));
+                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'int'));
+                       
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
+                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int'));
+                       
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 
'int'));
+                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));
+                       
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
+                       
$check_list->set_component_id($this->unmarshal($this->db->f('component_id'), 
'int'));
+                       
$check_list->set_location_id($this->unmarshal($this->db->f('location_id'), 
'int'));
+                       
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
 'int'));
+                       
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
 'int'));
+                       
$check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'), 
'int'));
+                       
$check_list->set_billable_hours($this->db->f('billable_hours'));
+                       $check_list->set_serie_id($this->db->f('serie_id'));
+
+
+                       if($check_list != null)
+                       {
+                               return $check_list;
+                       }
+                       else
+                       {
+                               return null;
+                       }
                }
-               else
+
+               /**
+                * Get check lists from database with related check items and 
control items
+                *
+                * @param $check_list_id check list id
+                * @param $status status OPEN/CLOSED
+                * @param $type control items registration type (Radiobuttons, 
Checklist, textfield, just commentfield)
+                * @return returns a check list object
+                */
+               public function get_single_with_check_items($check_list_id, 
$status, $type)
                {
-                       return null;
+                       $check_list_id   = (int)$check_list_id;
+                       $sql                     = "SELECT cl.id as cl_id, 
cl.status as cl_status, cl.control_id, cl.comment as cl_comment, deadline, 
planned_date, completed_date,assigned_to, num_open_cases, location_code, 
num_pending_cases, ";
+                       $sql .= "ci.id as ci_id, control_item_id, 
check_list_id, cl.serie_id";
+                       $sql .= "coi.title as coi_title, coi.required as 
coi_required, ";
+                       $sql .= "coi.what_to_do as coi_what_to_do, 
coi.how_to_do as coi_how_to_do, coi.control_group_id as coi_control_group_id, 
coi.type ";
+                       $sql .= "FROM controller_check_list cl ";
+                       $sql .= "LEFT JOIN controller_check_item as ci ON cl.id 
= ci.check_list_id ";
+                       $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
+                       $sql .= "WHERE cl.id = {$check_list_id} ";
+
+                       if($status == 'open')
+                       {
+                               $sql .= "AND ci.status = 0 ";
+                       }
+                       else if($status == 'handled')
+                       {
+                               $sql .= "AND ci.status = 1 ";
+                       }
+
+                       if($type != null)
+                       {
+                               $sql .= "AND coi.type = '$type'";
+                       }
+
+                       $this->db->query($sql);
+
+                       $counter         = 0;
+                       $check_list      = null;
+                       while($this->db->next_record())
+                       {
+                               if($counter == 0)
+                               {
+                                       $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
+                                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'bool'));
+                                       
$check_list->set_control_id($this->unmarshal($this->db->f('control_id'), 
'int'));
+                                       
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
+                                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int'));
+                                       
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 
'int'));
+                                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));
+                                       
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
+                                       
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
 'int'));
+                                       
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
 'int'));
+                                       
$check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'), 
'int'));
+                                       
$check_list->set_serie_id($this->db->f('serie_id'));
+                               }
+
+                               if($this->db->f('ci_id'))
+                               {
+                                       $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
+                                       
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
 'int'));
+                                       
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'), 
'int'));
+
+                                       $control_item = new 
controller_control_item($this->unmarshal($this->db->f('coi_id'), 'int'));
+                                       
$control_item->set_title($this->db->f('coi_title', true), 'string');
+                                       
$control_item->set_required($this->db->f('coi_required', true), 'string');
+                                       
$control_item->set_what_to_do($this->db->f('coi_what_to_do', true), 'string');
+                                       
$control_item->set_how_to_do($this->db->f('coi_how_to_do', true), 'string');
+                                       
$control_item->set_control_group_id($this->db->f('coi_control_group_id', true), 
'string');
+                                       
$control_item->set_type($this->db->f('type', true), 'string');
+
+                                       
$check_item->set_control_item($control_item->toArray());
+                                       $check_items_array[] = 
$check_item->toArray();
+                               }
+
+                               $counter++;
+                       }
+
+                       if($check_list != null)
+                       {
+                               
$check_list->set_check_item_array($check_items_array);
+                               return $check_list->toArray();
+                       }
+                       else
+                       {
+                               return null;
+                       }
                }
-       }
-       
-       /**
-        * Get check lists from database with related check items and control 
items
-        *
-        * @param $check_list_id check list id
-        * @param $status status OPEN/CLOSED
-        * @param $type control items registration type (Radiobuttons, 
Checklist, textfield, just commentfield)
-        * @return returns a check list object
-        */
-       public function get_single_with_check_items($check_list_id, $status, 
$type)
-       {
-               $check_list_id = (int) $check_list_id;
-               $sql  = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.control_id, cl.comment as cl_comment, deadline, planned_date, 
completed_date,assigned_to, num_open_cases, location_code, num_pending_cases, ";
-               $sql .= "ci.id as ci_id, control_item_id, check_list_id, 
cl.serie_id";
-               $sql .= "coi.title as coi_title, coi.required as coi_required, 
";
-               $sql .= "coi.what_to_do as coi_what_to_do, coi.how_to_do as 
coi_how_to_do, coi.control_group_id as coi_control_group_id, coi.type "; 
-               $sql .= "FROM controller_check_list cl "; 
-               $sql .= "LEFT JOIN controller_check_item as ci ON cl.id = 
ci.check_list_id ";
-               $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
-               $sql .= "WHERE cl.id = {$check_list_id} ";
-               
-               if($status == 'open')
+
+               /**
+                * Get check list objects for a control
+                *
+                * @param $control_id
+                * @return array with check list objects
+                */
+               function get_check_lists_for_control($control_id)
                {
-                       $sql .= "AND ci.status = 0 ";
+                       $control_id = (int)$control_id;
+
+                       $sql = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.comment as cl_comment, deadline, planned_date, assigned_to, ";
+                       $sql .= "completed_date, component_id, location_code, 
num_open_cases, num_pending_cases ";
+                       $sql .= "ci.id as ci_id, control_item_id, 
check_list_id, cl.serie_id";
+                       $sql .= "FROM controller_check_list cl, 
controller_check_item ci ";
+                       $sql .= "WHERE cl.control_id = {$control_id} ";
+                       $sql .= "AND cl.id = ci.check_list_id ";
+                       $sql .= "ORDER BY cl.id;";
+
+                       $this->db->query($sql);
+
+                       $check_list_id   = 0;
+                       $check_list              = null;
+                       while($this->db->next_record())
+                       {
+                               if($this->db->f('cl_id') != $check_list_id)
+                               {
+                                       if($check_list_id)
+                                       {
+                                               
$check_list->set_check_item_array($check_items_array);
+                                               $check_list_array[] = 
$check_list->toArray();
+                                       }
+
+                                       $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
+                                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'int'));
+                                       
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
+                                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int'));
+                                       
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 
'int'));
+                                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));
+                                       
$check_list->set_component_id($this->unmarshal($this->db->f('component_id'), 
'int'));
+                                       
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
+                                       
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
 'int'));
+                                       
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
 'int'));
+                                       
$check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'), 
'int'));
+                                       
$check_list->set_serie_id($this->db->f('serie_id'));
+
+                                       $check_items_array = array();
+                               }
+
+                               $check_item                      = new 
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
+                               
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
 'int'));
+                               
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'), 
'int'));
+                               $check_items_array[] = $check_item->toArray();
+
+                               $check_list_id = $check_list->get_id();
+                       }
+
+                       if($check_list != null)
+                       {
+                               
$check_list->set_check_item_array($check_items_array);
+                               $check_list_array[] = $check_list->toArray();
+
+                               return $check_list_array;
+                       }
+                       else
+                       {
+                               return null;
+                       }
                }
-               else if($status == 'handled')
-               {
-                       $sql .= "AND ci.status = 1 ";
-               }
-                       
-               if($type != null)
-               {
-                       $sql .= "AND coi.type = '$type'";
-               }                                       
 
-               $this->db->query($sql);
-               
-               $counter = 0;
-               $check_list = null;
-               while ($this->db->next_record())
+               function get_check_list_for_control_by_date($control_id, 
$deadline_ts, $status = null, $location_code, $location_id, $component_id, 
$type)
                {
-                       if($counter == 0)
+                       $sql = "SELECT * ";
+                       $sql .= "FROM controller_check_list ";
+                       $sql .= "WHERE control_id = {$control_id} ";
+                       $sql .= "AND deadline = {$deadline_ts} ";
+
+                       if($type == "location")
                        {
-                               $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
-                               
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'bool'));
-                               
$check_list->set_control_id($this->unmarshal($this->db->f('control_id'), 
'int'));
-                               
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
+                               $sql .= "AND location_code = '{$location_code}' 
";
+                       }
+                       else if($type == "component")
+                       {
+                               $sql .= "AND location_id = '{$location_id}' AND 
component_id = '{$component_id}' ";
+                       }
+
+                       if($status != null)
+                       {
+                               $sql .= "AND status = {$status} ";
+                       }
+
+                       $sql .= "AND assigned_to IS NOT NULL";
+
+                       $this->db->query($sql);
+
+                       $check_list = null;
+                       if($this->db->next_record())
+                       {
+                               $check_list = new 
controller_check_list($this->unmarshal($this->db->f('id'), 'int'));
+                               
$check_list->set_status($this->unmarshal($this->db->f('status'), 'int'));
+                               
$check_list->set_comment($this->unmarshal($this->db->f('comment'), 'string'));
                                
$check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int'));
                                
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 
'int'));
-                               
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));       
+                               
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));
+                               
$check_list->set_component_id($this->unmarshal($this->db->f('component_id'), 
'int'));
                                
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
-                               
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
 'int'));       
+                               
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
 'int'));
                                
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
 'int'));
                                
$check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'), 
'int'));
                                
$check_list->set_serie_id($this->db->f('serie_id'));
-                               
                        }
-                                               
-                       if($this->db->f('ci_id'))
+
+                       return $check_list;
+               }
+
+               /**
+                * Get check list objects for a control on a location with set 
planned date
+                *
+                * @param $control_id control id
+                * @param $location_code location code representing physical 
locations
+                * @param $location_id location id representing logical system 
locations
+                * @param $component_id component id: entity within logical 
location
+                * @return array with check list objects
+                */
+               function get_planned_check_lists_for_control($control_id, 
$location_code, $location_id, $component_id)
+               {
+                       $control_id = (int)$control_id;
+
+                       $component_filter = ' AND component_id IS NULL ';
+                       if($component_id)
                        {
-                               $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
-                               
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
 'int'));
-                               
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'), 
'int'));
-                               
-                               $control_item = new 
controller_control_item($this->unmarshal($this->db->f('coi_id'), 'int'));
-                               
$control_item->set_title($this->db->f('coi_title', true), 'string');
-                               
$control_item->set_required($this->db->f('coi_required', true), 'string');
-                               
$control_item->set_what_to_do($this->db->f('coi_what_to_do', true), 'string');
-                               
$control_item->set_how_to_do($this->db->f('coi_how_to_do', true), 'string');
-                               
$control_item->set_control_group_id($this->db->f('coi_control_group_id', true), 
'string');
-                               $control_item->set_type($this->db->f('type', 
true), 'string');
-                               
-                               
$check_item->set_control_item($control_item->toArray());
-                               $check_items_array[] = $check_item->toArray();
+                               $location_id             = (int)$location_id;
+                               $component_id            = (int)$component_id;
+                               $component_filter        = " AND component_id = 
{$component_id} AND location_id = {$location_id} ";
                        }
-                       
-                       $counter++;
+
+                       $sql = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.comment as cl_comment, deadline, planned_date, assigned_to,";
+                       $sql .= "completed_date, component_id, location_code, 
num_open_cases, num_pending_cases, cl.serie_id ";
+                       $sql .= "FROM controller_check_list cl ";
+                       $sql .= "WHERE cl.control_id = {$control_id} ";
+                       $sql .= "AND cl.location_code = '{$location_code}' ";
+                       $sql .= "AND NOT cl.planned_date IS NULL ";
+                       $sql .= "AND cl.completed_date IS NULL ";
+                       $sql .= $component_filter;
+                       $sql .= "ORDER BY cl.id;";
+
+                       $this->db->query($sql);
+
+                       $check_list_id   = 0;
+                       $check_list              = null;
+                       while($this->db->next_record())
+                       {
+                               if($this->db->f('cl_id') != $check_list_id)
+                               {
+                                       if($check_list_id)
+                                       {
+                                               $check_list_array[] = 
$check_list;
+                                       }
+                                       $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
+                                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'int'));
+                                       
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment'), 
'string'));
+                                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int'));
+                                       
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 
'int'));
+                                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));
+                                       
$check_list->set_component_id($this->unmarshal($this->db->f('component_id'), 
'int'));
+                                       
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
+                                       
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
 'int'));
+                                       
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
 'int'));
+                                       
$check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'), 
'int'));
+                                       
$check_list->set_serie_id($this->db->f('serie_id'));
+                               }
+                               $check_list_id = $check_list->get_id();
+                       }
+
+                       if($check_list != null)
+                       {
+                               $check_list_array[] = $check_list;
+                               return $check_list_array;
+                       }
+                       else
+                       {
+                               return null;
+                       }
                }
-               
-               if($check_list != null)
+
+               /**
+                * Get array with control id and number of open cases within 
time period
+                *
+                * @param $cl_criteria check list criteria object
+                * @param $from_date start time period
+                * @param $to_date end time period
+                * @return array with check list objects
+                */
+               function get_num_open_cases_for_control($cl_criteria, 
$from_date_ts, $to_date_ts)
                {
-                       $check_list->set_check_item_array($check_items_array);
-                       return $check_list->toArray();
+
+                       $sql = "SELECT c.id as c_id, sum(cl.num_open_cases) as 
count ";
+                       $sql .= "FROM controller_check_list cl, 
controller_control c ";
+
+                       if($cl_criteria->get_component_id() > 0 && 
$cl_criteria->get_location_id() > 0)
+                       {
+                               $sql .= "WHERE cl.component_id = 
{$cl_criteria->get_component_id()} ";
+                               $sql .= "AND cl.location_id = 
{$cl_criteria->get_location_id()} ";
+                       }
+                       else
+                       {
+                               $sql .= "WHERE cl.location_code = 
'{$cl_criteria->get_location_code()}' ";
+                       }
+
+                       $sql .= "AND c.id = {$cl_criteria->get_control_id()} ";
+                       $sql .= "AND cl.control_id = c.id ";
+                       $sql .= "AND cl.deadline >= $from_date_ts AND 
$to_date_ts > cl.deadline ";
+                       $sql .= "GROUP BY c.id";
+
+                       $this->db->query($sql);
+
+                       if($this->db->next_record() & $this->db->f('count') > 0)
+                       {
+                               $control_array = array
+                                       (
+                                       "id"     => 
$this->unmarshal($this->db->f('c_id'), 'int'),
+                                       "count"  => $this->db->f('count')
+                               );
+                       }
+
+                       return $control_array;
                }
-               else
+
+               /**
+                * Get array with check lists for a location within time period 
and for a specified repeat type
+                *
+                * @param $location_code location code
+                * @param $from_date_ts start time period
+                * @param $to_date_ts end time period
+                * @param $repeat_type_expr repeat type expression
+                * @return array with check list objects
+                */
+               function get_check_lists_for_location($location_code, 
$from_date_ts, $to_date_ts, $repeat_type_expr = null)
                {
-                       return null;
-               }
-       }
-       
-       /**
-        * Get check list objects for a control
-        *
-        * @param $control_id
-        * @return array with check list objects
-        */
-       function get_check_lists_for_control($control_id)
-       {
-               $control_id = (int) $control_id;
+                       $sql = "SELECT c.id as c_id, ";
+                       $sql .= "cl.id as cl_id, cl.status as cl_status, 
cl.comment as cl_comment, deadline, planned_date, completed_date, assigned_to, 
";
+                       $sql .= "cl.component_id as cl_component_id, 
cl.location_code as cl_location_code, num_open_cases, num_pending_cases, 
cl.serie_id ";
+                       $sql .= "FROM controller_control c ";
+                       $sql .= "LEFT JOIN controller_check_list cl on 
cl.control_id = c.id ";
+                       $sql .= "WHERE cl.location_code = '{$location_code}' ";
 
-               $sql = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.comment as cl_comment, deadline, planned_date, assigned_to, "; 
-               $sql .= "completed_date, component_id, location_code, 
num_open_cases, num_pending_cases ";
-               $sql .= "ci.id as ci_id, control_item_id, check_list_id, 
cl.serie_id";
-               $sql .= "FROM controller_check_list cl, controller_check_item 
ci ";
-               $sql .= "WHERE cl.control_id = {$control_id} ";
-               $sql .= "AND cl.id = ci.check_list_id "; 
-               $sql .= "ORDER BY cl.id;";
+                       if($repeat_type != null)
+                       {
+                               $sql .= "AND c.repeat_type $repeat_type_expr ";
+                       }
 
-               $this->db->query($sql);
-               
-               $check_list_id = 0;
-               $check_list = null;
-               while ($this->db->next_record())
-               {
-                       if( $this->db->f('cl_id') != $check_list_id )
+                       $sql .= "AND (deadline > $from_date_ts) AND (deadline < 
$to_date_ts) ";
+                       $sql .= "ORDER BY c.id;";
+
+                       $this->db->query($sql);
+
+                       $control_id              = 0;
+                       $control                 = null;
+                       $controls_array  = array();
+                       while($this->db->next_record())
                        {
-                               if( $check_list_id )
+                               if($this->db->f('c_id') != $control_id)
                                {
-                                       
$check_list->set_check_item_array($check_items_array);
-                                       $check_list_array[] = 
$check_list->toArray();
+                                       if($control_id)
+                                       {
+                                               
$control->set_check_lists_array($check_lists_array);
+                                               $controls_array[] = $control;
+                                       }
+
+                                       $control = new 
controller_control($this->unmarshal($this->db->f('c_id'), 'int'));
+
+                                       $check_lists_array = array();
                                }
-                               
+
                                $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
                                
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'int'));
                                
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
                                
$check_list->set_deadline($this->unmarshal($this->db->f('deadline'), 'int'));
                                
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date'), 
'int'));
-                               
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));       
-                               
$check_list->set_component_id($this->unmarshal($this->db->f('component_id'), 
'int'));
-                               
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
+                               
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date'),
 'int'));
+                               
$check_list->set_component_id($this->unmarshal($this->db->f('cl_component_id'), 
'int'));
+                               
$check_list->set_location_code($this->unmarshal($this->db->f('cl_location_code',
 true), 'string'));
                                
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
 'int'));
                                
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
 'int'));
                                
$check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'), 
'int'));
                                
$check_list->set_serie_id($this->db->f('serie_id'));
-                               
-                               $check_items_array = array();
+
+                               $check_lists_array[] = $check_list;
+
+                               $control_id = $control->get_id();
                        }
-                       
-                       $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
-                       
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
 'int'));
-                       
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'), 
'int'));
-                       $check_items_array[] = $check_item->toArray();
-                       
-                       $check_list_id =  $check_list->get_id();
-               }
-               

@@ Diff output truncated at 153600 characters. @@



reply via email to

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