fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [17273] more on controller


From: sigurdne
Subject: [Fmsystem-commits] [17273] more on controller
Date: Sun, 5 Nov 2017 17:46:17 -0500 (EST)

Revision: 17273
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17273
Author:   sigurdne
Date:     2017-11-05 17:46:16 -0500 (Sun, 05 Nov 2017)
Log Message:
-----------
more on controller

Modified Paths:
--------------
    trunk/controller/inc/class.menu.inc.php
    trunk/controller/inc/class.socheck_list.inc.php
    trunk/controller/inc/class.uicheck_list.inc.php
    trunk/controller/inc/class.uicomponent.inc.php
    trunk/controller/templates/base/case/create_case_message.xsl
    trunk/controller/templates/base/case/view_case_message.xsl
    
trunk/controller/templates/base/check_list/fragments/check_list_top_section.xsl
    trunk/controller/templates/base/check_list/fragments/nav_control_plan.xsl
    trunk/property/inc/class.bolocation.inc.php
    trunk/property/inc/class.controller_helper.inc.php
    trunk/property/inc/class.custom_fields.inc.php
    trunk/property/inc/class.solocation.inc.php

Modified: trunk/controller/inc/class.menu.inc.php
===================================================================
--- trunk/controller/inc/class.menu.inc.php     2017-11-05 12:56:00 UTC (rev 
17272)
+++ trunk/controller/inc/class.menu.inc.php     2017-11-05 22:46:16 UTC (rev 
17273)
@@ -110,6 +110,11 @@
                                'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'controller.uicomponent.index')),
                                'image' => array('property', 'location_1'),
                        );
+                       $menus['navigation']['status_locations'] = array(
+                               'text' => lang('status locations'),
+                               'url' => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'controller.uicomponent.index', 'get_locations' => true)),
+                               'image' => array('property', 'location_1'),
+                       );
 
                        if ($GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin') || $GLOBALS['phpgw']->acl->check('admin', 
phpgwapi_acl::ADD, 'controller'))
                        {

Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php     2017-11-05 12:56:00 UTC 
(rev 17272)
+++ trunk/controller/inc/class.socheck_list.inc.php     2017-11-05 22:46:16 UTC 
(rev 17273)
@@ -686,7 +686,7 @@
 
                        if ($repeat_type != null)
                        {
-                               $sql .= "AND c.repeat_type = $repeat_type ";
+                               $sql .= "AND cs.repeat_type = $repeat_type ";
                        }
 
 //             if($user_id)

Modified: trunk/controller/inc/class.uicheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list.inc.php     2017-11-05 12:56:00 UTC 
(rev 17272)
+++ trunk/controller/inc/class.uicheck_list.inc.php     2017-11-05 22:46:16 UTC 
(rev 17273)
@@ -110,8 +110,8 @@
                }
 
                /**
-                * Public function for displaying checklists  
-                * 
+                * Public function for displaying checklists
+                *
                 * @param HTTP:: phpgw_return_as
                 * @return data array
                 */
@@ -208,7 +208,7 @@
 
                /**
                 * Public function for displaying the add check list form
-                * 
+                *
                 * @param HTTP:: location code, control id, date
                 * @return data array
                 */
@@ -268,6 +268,7 @@
                                $level = 
$this->location_finder->get_location_level($location_code);
                        }
 
+                       $get_locations = false;
 
                        if ($type == "component")
                        {
@@ -279,28 +280,47 @@
                                        
$check_list->set_component_id($component_id);
                                }
 
-                               $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id,
-                                       'id' => $component_id));
 
-                               $location_code = 
$component_arr['location_code'];
+                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($location_id);
 
-                               $check_list->set_location_code($location_code);
-                               $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$check_list->get_location_code()));
-                               $level = 
$this->location_finder->get_location_level($location_code);
+                               if (substr($location_info['location'], 1, 8) == 
'location')
+                               {
+                                       $get_locations = true;
 
-                               $location_name = 
execMethod('property.bolocation.get_location_name', 
$component_arr['location_code']);
+                                       $type_info = explode('.', 
$location_info['location']);
+                                       $level = $type_info[2];
+                                       $item_arr = 
createObject('property.solocation')->read_single('', array('location_id' => 
$location_id,
+                                               'id' => $component_id), true);
+                                       $location_code = 
$item_arr['location_code'];
+                                       
$check_list->set_location_code($location_code);
+                                       $location_name = 
execMethod('property.bolocation.get_location_name', $location_code);
+                                       $short_desc = $location_name;
+                               }
+                               else
+                               {
+                                       $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id,
+                                               'id' => $component_id));
 
-                               $short_desc = $location_name . '::' . 
execMethod('property.soentity.get_short_description', array(
-                                               'location_id' => $location_id, 
'id' => $component_id));
+                                       $location_code = 
$component_arr['location_code'];
+                                       
$check_list->set_location_code($location_code);
+                                       $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$check_list->get_location_code()));
+                                       $level = 
$this->location_finder->get_location_level($location_code);
 
+                                       $location_name = 
execMethod('property.bolocation.get_location_name', 
$component_arr['location_code']);
+
+                                       $short_desc = $location_name . '::' . 
execMethod('property.soentity.get_short_description', array(
+                                                       'location_id' => 
$location_id, 'id' => $component_id));
+
+                               }
+
                                $component = new controller_component();
                                $component->set_id($component_id);
                                $component->set_location_id($location_id);
-                               
$component->set_location_code($component_arr['location_code']);
+                               $component->set_location_code($location_code);
                                $component->set_xml_short_desc($short_desc);
 
                                $component_array = $component->toArray();
-                               $building_location_code = 
$this->location_finder->get_building_location_code($component_arr['location_code']);
+                               $building_location_code = 
$this->location_finder->get_building_location_code($location_code);
 
                                $type = "component";
                        }
@@ -372,6 +392,7 @@
                                'user_list' => array('options' => 
$user_list_options),
                                'location_array' => $location_array,
                                'component_array' => $component_array,
+                               'get_locations' => $get_locations,
                                'control' => $control,
                                'check_list' => $check_list,
                                'buildings_on_property' => 
$buildings_on_property,
@@ -400,8 +421,8 @@
                }
 
                /**
-                * Public function for displaying the edit check list form  
-                * 
+                * Public function for displaying the edit check list form
+                *
                 * @param HTTP:: check list id
                 * @return data array
                 */
@@ -435,6 +456,7 @@
                        }
 
                        $component_id = $check_list->get_component_id();
+                       $get_locations = false;
 
                        if ($component_id > 0)
                        {
@@ -441,13 +463,33 @@
                                $location_id = $check_list->get_location_id();
                                $component_id = $check_list->get_component_id();
 
-                               $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id,
-                                       'id' => $component_id));
-                               $location_name = 
execMethod('property.bolocation.get_location_name', 
$component_arr['location_code']);
 
-                               $short_desc = $location_name . '::' . 
execMethod('property.soentity.get_short_description', array(
-                                               'location_id' => $location_id, 
'id' => $component_id));
+                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($location_id);
 
+                               if (substr($location_info['location'], 1, 8) == 
'location')
+                               {
+                                       $get_locations = true;
+                                       $type_info = explode('.', 
$location_info['location']);
+                                       $level = $type_info[2];
+                                       $item_arr = 
createObject('property.solocation')->read_single('', array('location_id' => 
$location_id,
+                                               'id' => $component_id), true);
+                                       $location_code = 
$item_arr['location_code'];
+                                       
$check_list->set_location_code($location_code);
+                                       $location_name = 
execMethod('property.bolocation.get_location_name', $location_code);
+                                       $short_desc = $location_name;
+                               }
+                               else
+                               {
+                                       $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$location_id,
+                                               'id' => $component_id));
+                                       $location_code = 
$component_arr['location_code'];
+                                       $location_name = 
execMethod('property.bolocation.get_location_name', $location_code);
+
+                                       $short_desc = $location_name . '::' . 
execMethod('property.soentity.get_short_description', array(
+                                                       'location_id' => 
$location_id, 'id' => $component_id));
+
+                               }
+
                                $component = new controller_component();
                                $component->set_id($component_id);
                                $component->set_location_id($location_id);
@@ -456,7 +498,7 @@
                                $component_array = $component->toArray();
 
                                $type = 'component';
-                               $building_location_code = 
$this->location_finder->get_building_location_code($component_arr['location_code']);
+                               $building_location_code = 
$this->location_finder->get_building_location_code($location_code);
                        }
                        else
                        {
@@ -500,7 +542,8 @@
                                'user_list' => array('options' => 
$user_list_options),
                                'control' => $control,
                                'check_list' => $check_list,
-                               '$buildings_on_property' => 
$buildings_on_property,
+                               'buildings_on_property' => 
$buildings_on_property,
+                               'get_locations' => $get_locations,
                                'location_array' => $location_array,
                                'component_array' => $component_array,
                                'type' => $type,
@@ -661,8 +704,8 @@
 
                /**
                 * Public function for saving a check list
-                * 
-                * @param HTTP:: location code, control id, status etc.. (check 
list details) 
+                *
+                * @param HTTP:: location code, control id, status etc.. (check 
list details)
                 * @return data array
                 */
                function save_check_list()
@@ -813,12 +856,29 @@
 
                                        if ($check_list->get_component_id() > 0)
                                        {
-                                               $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$check_list->get_location_id(),
-                                                       'id' => 
$check_list->get_component_id()));
-                                               $location_name = 
execMethod('property.bolocation.get_location_name', 
$component_arr['location_code']);
-                                               $short_desc = $location_name . 
'::' . execMethod('property.soentity.get_short_description', array(
+                                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($check_list->get_location_id());
+
+                                               if 
(substr($location_info['location'], 1, 8) == 'location')
+                                               {
+                                                       $type_info = 
explode('.', $location_info['location']);
+                                                       $level = $type_info[2];
+                                                       $item_arr = 
createObject('property.solocation')->read_single('', array('location_id' => 
$check_list->get_location_id(),
+                                                               'id' => 
$component_id), true);
+                                                       $location_code = 
$item_arr['location_code'];
+                                                       $location_name = 
execMethod('property.bolocation.get_location_name', $location_code);
+                                                       $short_desc = 
$location_name;
+                                               }
+                                               else
+                                               {
+                                                       $component_arr = 
execMethod('property.soentity.read_single_eav', array('location_id' => 
$check_list->get_location_id(),
+                                                               'id' => 
$check_list->get_component_id()));
+
+                                                       $location_name = 
execMethod('property.bolocation.get_location_name', 
$component_arr['location_code']);
+
+                                                       $short_desc = 
$location_name . '::' . execMethod('property.soentity.get_short_description', 
array(
                                                                'location_id' 
=> $check_list->get_location_id(), 'id' => $check_list->get_component_id()));
-                                               $location = $location_name;
+                                               }
+
                                        }
 
                                        $repeat_type_array = array
@@ -959,10 +1019,10 @@
                                        'document_date' => 
$GLOBALS['phpgw']->common->show_date($entry['document_date'], 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
                                );
                        }
-               
+
                        $generic_document = 
CreateObject('property.sogeneric_document');
                        $params['location_id'] = $location_id;
-                       $params['order'] = 'name';              
+                       $params['order'] = 'name';
                        $params['allrows'] = true;
                        $generic_document_list = array();
                        foreach ($doc_types as $doc_type)
@@ -973,7 +1033,7 @@
                                        $generic_document_list = 
array_merge($generic_document_list, $generic_document->read($params));
                                }
                        }
-                       
+
                        foreach ($generic_document_list as $entry)
                        {
                                $link_file_data = array
@@ -989,8 +1049,8 @@
                                        'file_name' => '<a href="' . 
$GLOBALS['phpgw']->link('/index.php', $link_file_data) . "\" target='_blank' 
title='{$lang_view}'>{$entry['name']}</a>"
                                );
                        }
-                               
-                       
+
+
                        return $values;
                }
 
@@ -1210,7 +1270,7 @@
                                        'control_items' => $saved_control_items
                                        );
                        }
-       
+
                        $data = array
                                (
                                'saved_groups_with_items_array' => 
$saved_groups_with_items_array,
@@ -1232,7 +1292,7 @@
                        return json_encode($check_list);
                }
 
-               // Returns open cases for a check list as JSON 
+               // Returns open cases for a check list as JSON
                public function get_cases_for_check_list()
                {
                        $check_list_id = phpgw::get_var('check_list_id');
@@ -1244,7 +1304,7 @@
 
                /**
                 * Public function for updateing status for a check list
-                * 
+                *
                 * @return json encoded array with status saved or not saved
                 */
                public function update_status()
@@ -1448,7 +1508,7 @@
                }
 
                /**
-                * 
+                *
                 * @param string $from_name
                 * @param string $from_address
                 * @param string $to_name

Modified: trunk/controller/inc/class.uicomponent.inc.php
===================================================================
--- trunk/controller/inc/class.uicomponent.inc.php      2017-11-05 12:56:00 UTC 
(rev 17272)
+++ trunk/controller/inc/class.uicomponent.inc.php      2017-11-05 22:46:16 UTC 
(rev 17273)
@@ -128,33 +128,56 @@
 
                        if (!$location_filter)
                        {
-                               $this->soadmin_entity = 
CreateObject('property.soadmin_entity');
-                               $entity_list = 
$this->soadmin_entity->read(array('allrows' => true));
+                               $location_filter = array();
+                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($location_id);
 
-                               $location_filter = array();
-                               foreach ($entity_list as $entry)
+                               if (substr($location_info['location'], 1, 8) == 
'location')
                                {
-                                       $categories = 
$this->soadmin_entity->read_category(array('entity_id' => $entry['id'],
-                                               'order' => 'name', 'sort' => 
'asc', 'enable_controller' => true, 'allrows' => true));
-                                       foreach ($categories as $category)
+                                       $location_types = 
CreateObject('property.soadmin_location')->read(array('allrows' => true));
+                                       foreach ($location_types as 
$location_type)
                                        {
-
-                                               if 
($category['enable_controller'])
+                                               if 
($location_type['enable_controller'])
                                                {
-                                                       if ($entity_group_id && 
$category['entity_group_id'] != $entity_group_id)
-                                                       {
-                                                               continue;
-                                                       }
-                                                       $sort_arr = explode(' 
', $category['name']);
                                                        $location_filter[] = 
array
                                                                (
-                                                               'id' => 
$category['location_id'],
-                                                               'name' => 
"{$entry['name']}::{$category['name']}",
-                                                               'sort_key' => 
trim($sort_arr[0])
+                                                               'id' => 
$GLOBALS['phpgw']->locations->get_id('property', 
".location.{$location_type['id']}"),
+                                                               'name' => 
$location_type['name'],
+                                                               'sort_key' => 
$location_type['id']
                                                        );
                                                }
                                        }
                                }
+                               else
+                               {
+                                       $this->soadmin_entity = 
CreateObject('property.soadmin_entity');
+                                       $entity_list = 
$this->soadmin_entity->read(array('allrows' => true));
+
+                                       $location_filter = array();
+                                       foreach ($entity_list as $entry)
+                                       {
+                                               $categories = 
$this->soadmin_entity->read_category(array('entity_id' => $entry['id'],
+                                                       'order' => 'name', 
'sort' => 'asc', 'enable_controller' => true, 'allrows' => true));
+                                               foreach ($categories as 
$category)
+                                               {
+
+                                                       if 
($category['enable_controller'])
+                                                       {
+                                                               if 
($entity_group_id && $category['entity_group_id'] != $entity_group_id)
+                                                               {
+                                                                       
continue;
+                                                               }
+                                                               $sort_arr = 
explode(' ', $category['name']);
+                                                               
$location_filter[] = array
+                                                                       (
+                                                                       'id' => 
$category['location_id'],
+                                                                       'name' 
=> "{$entry['name']}::{$category['name']}",
+                                                                       
'sort_key' => trim($sort_arr[0])
+                                                               );
+                                                       }
+                                               }
+                                       }
+                               }
+
                                // Obtain a list of columns
                                foreach ($location_filter as $key => $row)
                                {
@@ -164,6 +187,7 @@
                                array_multisort($id, SORT_ASC, SORT_STRING, 
$location_filter);
                                phpgwapi_cache::session_set('controller', 
"location_filter_{$entity_group_id}", $location_filter);
                        }
+
                        foreach ($location_filter as &$location)
                        {
                                $location['selected'] = $location['id'] == 
$location_id ? 1 : 0;
@@ -242,7 +266,8 @@
 
                        $year_list = array();
 
-                       $year = date('Y');
+                       $year = phpgw::get_var('year', 'int');
+                       $year = $year ? $year : date('Y');
                        for ($_year = ($year - 2); $_year < ($year + 5); 
$_year++)
                        {
                                $year_list[] = array
@@ -266,7 +291,10 @@
                        $data = array(
                                'datatable_name' => lang('status components'),
                                'form' => array(
-                                       'action' => 
self::link(array('menuaction' => 'controller.uicomponent.index')),
+                                       'action' => 
self::link(array('menuaction' => 'controller.uicomponent.index',
+                                               'get_locations' => 
phpgw::get_var('get_locations', 'bool'),
+                                               )
+                                       ),
                                        'method' => 'POST',
                                        'toolbar' => array(
                                                'item' => array(
@@ -273,7 +301,8 @@
                                                        array('type' => 
'filter',
                                                                'name' => 
'report_type',
                                                                'text' => 
lang('report type'),
-                                                               'list' => 
array(array('id' => 'components', 'name' => lang('components')),
+                                                               'list' => array(
+                                                                       
array('id' => 'components', 'name' => lang('details')),
                                                                        
array('id' => 'summary', 'name' => lang('summary'))),
                                                                'onchange' => 
'update_table();'
                                                        ),
@@ -290,7 +319,7 @@
                                                        ),
                                                        array('type' => 
'filter',
                                                                'name' => 
'location_id',
-                                                               'text' => 
lang('component'),
+                                                               'text' => 
'Register',
                                                                'list' => 
array(),
                                                                'onchange' => 
'update_table();'
                                                        ),
@@ -556,6 +585,7 @@
 
                public function query()
                {
+                       $get_locations = phpgw::get_var('get_locations', 
'bool');
                        $entity_group_id = phpgw::get_var('entity_group_id', 
'int');
                        $location_id = phpgw::get_var('location_id', 'int');
                        $location_code = phpgw::get_var('location_code', 
'string');
@@ -612,7 +642,7 @@
                                $location_type_name[$_location['id']] = 
$_location['name'];
                        }
 //                     _debug_array($location_type_name);
-                       $components = array();
+                       $items = array();
                        $keep_only_assigned_to = 0;
 
 //                     $lookup_stray_items = false;
@@ -624,20 +654,40 @@
                                $all_items = false;
 
                                $keep_only_assigned_to = $user_id;
-                               $assigned_components = 
$so_control->get_assigned_control_components($from_date_ts, $to_date_ts, 
$assigned_to = $user_id);
-                               foreach ($assigned_components as $_location_id 
=> $component_list)
+                               $assigned_items = 
$so_control->get_assigned_control_components($from_date_ts, $to_date_ts, 
$assigned_to = $user_id);
+
+                               if(empty($get_locations))
                                {
-                                       $_components = 
execMethod('property.soentity.read', array(
-                                               'filter_entity_group' => 
$entity_group_id,
-                                               'location_id' => $_location_id,
-                                               'district_id' => $district_id,
-                                               'location_code' => 
$location_code,
-                                               'allrows' => true,
-                                               'filter_item' => $component_list
-                                               )
-                                       );
-                                       $components = array_merge($components, 
$_components);
+                                       foreach ($assigned_items as 
$_location_id => $item_list)
+                                       {
+                                               $_items = 
execMethod('property.soentity.read', array(
+                                                       'filter_entity_group' 
=> $entity_group_id,
+                                                       'location_id' => 
$_location_id,
+                                                       'district_id' => 
$district_id,
+                                                       'location_code' => 
$location_code,
+                                                       'allrows' => true,
+                                                       'filter_item' => 
$item_list
+                                                       )
+                                               );
+                                               $items = array_merge($items, 
$_items);
+                                       }
                                }
+                               else
+                               {
+                                       foreach ($assigned_items as 
$_location_id => $item_list)
+                                       {
+                                               $_items = 
execMethod('property.solocation.read', array(
+                                                       'filter_entity_group' 
=> $entity_group_id,
+                                                       'location_id' => 
$_location_id,
+                                                       'district_id' => 
$district_id,
+                                                       'location_code' => 
$location_code,
+                                                       'allrows' => true,
+                                                       'filter_item' => 
$item_list
+                                                       )
+                                               );
+                                               $items = array_merge($items, 
$_items);
+                                       }
+                               }
                        }
                        else if (!$location_id)
                        {
@@ -666,26 +716,42 @@
 
                                        $location_filter_options = 
$this->_get_location_filter_options($_location_id);
 
-                                       $_components = 
execMethod('property.soentity.read', array(
-                                               'filter_entity_group' => 
$entity_group_id,
-                                               'location_id' => $_location_id,
-                                               'district_id' => $district_id,
-                                               'location_code' => 
$location_code,
-                                               'org_units' => $this->org_units,
-                                               'allrows' => true,
-                                               'control_registered' => 
!$all_items,
-                                               'check_for_control' => true,
-                                               'filter_item' => 
$filter_component ? array($filter_component) : array(),
-                                               'attrib_filter' => 
$this->_get_attrib_filter($_location_id)
-                                               )
-                                       );
-                                       $components = array_merge($components, 
$_components);
+                                       if(empty($get_locations))
+                                       {
+                                               $_items = 
execMethod('property.soentity.read', array(
+                                                       'filter_entity_group' 
=> $entity_group_id,
+                                                       'location_id' => 
$_location_id,
+                                                       'district_id' => 
$district_id,
+                                                       'location_code' => 
$location_code,
+                                                       'org_units' => 
$this->org_units,
+                                                       'allrows' => true,
+                                                       'control_registered' => 
!$all_items,
+                                                       'check_for_control' => 
true,
+                                                       'filter_item' => 
$filter_component ? array($filter_component) : array(),
+                                                       'attrib_filter' => 
$this->_get_attrib_filter($_location_id)
+                                                       )
+                                               );
+                                               $items = array_merge($items, 
$_items);
+                                       }
+                                       else
+                                       {
+                                               $_items = 
execMethod('property.solocation.read', array(
+                                                       'filter_entity_group' 
=> $entity_group_id,
+                                                       'location_id' => 
$_location_id,
+                                                       'district_id' => 
$district_id,
+                                                       'location_code' => 
$location_code,
+                                                       'allrows' => true,
+                                                       'filter_item' => 
$filter_component ? array($filter_component) : array(),
+                                                       )
+                                               );
+                                               $items = array_merge($items, 
$_items);
+                                       }
 
                                }
 
                                if ($lookup_stray_items)
                                {
-                                       $_components = 
execMethod('property.soentity.read_entity_group', array(
+                                       $_items = 
execMethod('property.soentity.read_entity_group', array(
                                                'entity_group_id' => 
$entity_group_id,
                                                'exclude_locations' => 
$exclude_locations,
                                                'location_id' => $_location_id,
@@ -697,27 +763,40 @@
                                                'check_for_control' => true
                                                )
                                        );
-                                       $components = array_merge($components, 
$_components);
+                                       $items = array_merge($items, $_items);
                                }
                        }
 
                        $all_components = array();
                        $components_with_calendar_array = array();
-//                     _debug_array($components);
-                       foreach ($components as $_component)
+//                     _debug_array($items);
+                       foreach ($items as $_item)
                        {
-                               $location_id = $_component['location_id'];
-                               $component_id = $_component['id'];
-                               
$all_components["{$location_id}_{$component_id}"] = $_component;
+                               $location_id = $_item['location_id'];
+                               $item_id = $_item['id'];
+                               $all_components["{$location_id}_{$item_id}"] = 
$_item;
 
-                               $short_description = 
$_component['short_description'];
-                               $short_description .= ' [' . 
$_component['location_name'] . ']';
+                               if(empty($get_locations))
+                               {
+                                       $short_description = 
$_item['short_description'];
+                                       $short_description .= ' [' . 
$_item['location_name'] . ']';
+                               }
+                               else
+                               {
+                                       $short_description = 
$_item['location_code'];
+                                       $short_description .= ' [' . 
$_item['loc1_name'] . ']';
 
-                               if ($all_items && !$_component['has_control'])
+                               }
+
+                               if ($all_items && !$_item['has_control'])
                                {
                                        continue;
                                }
-                               $controls_at_component = 
$so_control->get_controls_at_component2($_component);
+                               if (!$_item['id'])
+                               {
+                                       continue;
+                               }
+                               $controls_at_component = 
$so_control->get_controls_at_component2($_item);
 
                                foreach ($controls_at_component as $component)
                                {
@@ -759,7 +838,7 @@
 
                                                $year_calendar_agg = new 
year_calendar_agg($control, $year, $location_code, 
"VIEW_LOCATIONS_FOR_CONTROL");
                                                $calendar_array = 
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
-                                               
$components_with_calendar_array["{$location_id}_{$component_id}"][] = array(
+                                               
$components_with_calendar_array["{$location_id}_{$item_id}"][] = array(
                                                        "component" => 
$component->toArray(),
                                                        "calendar_array" => 
$calendar_array);
                                        }
@@ -814,12 +893,12 @@
                                                        }
                                                        if (!$found_assigned_to)
                                                        {
-                                                               
unset($all_components["{$location_id}_{$component_id}"]);
+                                                               
unset($all_components["{$location_id}_{$item_id}"]);
                                                                continue;
                                                        }
                                                }
 
-                                               
$components_with_calendar_array["{$location_id}_{$component_id}"][] = array(
+                                               
$components_with_calendar_array["{$location_id}_{$item_id}"][] = array(
                                                        "component" => 
$component->toArray(),
                                                        "calendar_array" => 
$calendar_array);
                                        }
@@ -828,9 +907,9 @@
                        $total_records = count($all_components);
 
 //                     _debug_array($components_with_calendar_array);
-                       unset($component_id);
+                       unset($item_id);
 //                     _debug_array($components_with_calendar_array[1]);
-//                     _debug_array($components);
+//                     _debug_array($items);
 //                     
_debug_array(array_keys($components_with_calendar_array));
                        $repeat_type_array = array
                                (
@@ -844,21 +923,36 @@
                        foreach ($components_with_calendar_array as $dummy => 
$entry)
                        {
                                $location_id = 
$entry[0]['component']['location_id'];
-                               $component_id = $entry[0]['component']['id'];
+                               $item_id = $entry[0]['component']['id'];
+                               $_location_code = 
$entry[0]['component']['location_code'];
 
-                               
unset($all_components["{$location_id}_{$component_id}"]);
+                               
unset($all_components["{$location_id}_{$item_id}"]);
                                $data = array();
-                               $component_link_data = array
-                                       (
-                                       'menuaction' => 
'property.uientity.edit',
-                                       'location_id' => $location_id,
-                                       'id' => $component_id,
-                                       'active_tab' => 'controller'
-                               );
 
-                               $data['component_url'] = '<a href="' . 
$GLOBALS['phpgw']->link('/index.php', $component_link_data) . "\" 
target='_blank'>{$component_id}{$entry[0]['component']['xml_short_desc']}</a>";
-                               $data['component_id'] = $component_id;
+                               if(empty($get_locations))
+                               {
+                                       $item_link_data = array
+                                               (
+                                               'menuaction' => 
'property.uientity.edit',
+                                               'location_id' => $location_id,
+                                               'id' => $item_id,
+                                               'active_tab' => 'controller'
+                                       );
+                               }
+                               else
+                               {
+                                       $item_link_data = array
+                                               (
+                                               'menuaction' => 
'property.uilocation.edit',
+                                               'location_code' => 
$_location_code,
+                                               'active_tab' => 'controller'
+                                       );
+                               }
+
+                               $data['component_url'] = '<a href="' . 
$GLOBALS['phpgw']->link('/index.php', $item_link_data) . "\" 
target='_blank'>{$item_id}{$entry[0]['component']['xml_short_desc']}</a>";
+                               $data['component_id'] = $item_id;
                                $data['location_id'] = $location_id;
+                               $data['location_code'] = $_location_code;
 
 
                                $max_interval_length = 0; //number of months
@@ -937,7 +1031,7 @@
                                $values[] = $data;
                        }
                        unset($entry);
-                       unset($component_id);
+                       unset($item_id);
                        unset($component);
 
                        if ($report_type == 'summary')
@@ -962,22 +1056,37 @@
                                {
                                        $data = array();
                                        $location_id = 
$component['location_id'];
-                                       $component_id = $component['id'];
+                                       $item_id = $component['id'];
+                                       $_location_code= 
$component['location_code'];
 
-                                       $component_link_data = array
-                                               (
-                                               'menuaction' => 
'property.uientity.edit',
-                                               'location_id' => $location_id,
-                                               'id' => $component_id,
-                                               'active_tab' => 'controller'
-                                       );
+                                       if(empty($get_locations))
+                                       {
+                                               $item_link_data = array
+                                                       (
+                                                       'menuaction' => 
'property.uientity.edit',
+                                                       'location_id' => 
$location_id,
+                                                       'id' => $item_id,
+                                                       'active_tab' => 
'controller'
+                                               );
+                                       }
+                                       else
+                                       {
+                                               $item_link_data = array
+                                                       (
+                                                       'menuaction' => 
'property.uientity.edit',
+                                                       'location_code' => 
$_location_code,
+                                                       'active_tab' => 
'controller'
+                                               );
 
+                                       }
+
                                        $short_description = 
$component['short_description'];
                                        $short_description .= "[ 
{$component['location_name']} ]";
 
-                                       $data['component_url'] = '<a href="' . 
$GLOBALS['phpgw']->link('/index.php', $component_link_data) . "\" 
target='_blank'>{$component_id} 
{$location_type_name[$location_id]}</br>{$short_description}</a>";
-                                       $data['component_id'] = $component_id;
+                                       $data['component_url'] = '<a href="' . 
$GLOBALS['phpgw']->link('/index.php', $item_link_data) . "\" 
target='_blank'>{$item_id} 
{$location_type_name[$location_id]}</br>{$short_description}</a>";
+                                       $data['component_id'] = $item_id;
                                        $data['location_id'] = $location_id;
+                                       $data['location_code'] = 
$_location_code;
                                        $data['missing_control'] = true;
                                        $values[] = $data;
                                }
@@ -1015,7 +1124,7 @@
                                $found_at_least_one = false;
                                for ($_month = 1; $_month < 13; $_month++)
                                {
-                                       $row[$_month] = 
$this->translate_calendar_info($entry[$_month], $year, $_month, $filter_status, 
$found_at_least_one, $keep_only_assigned_to);
+                                       $row[$_month] = 
$this->translate_calendar_info($entry[$_month], $year, $_month, $filter_status, 
$found_at_least_one, $keep_only_assigned_to, $entry['location_code']);
                                        if(true)// ($row[$_month] && (!$user_id 
|| $entry[$_month]['info']['assigned_to'] == $user_id))
                                        {
                                                $row_sum[$_month] = 
(float)$entry[$_month]['info']['service_time'] + 
(float)$entry[$_month]['info']['controle_time'];
@@ -1124,7 +1233,7 @@
                        );
                }
 
-               private function translate_calendar_info( $param = array(), 
$year, $month, $filter_status = '', &$found_at_least_one = false, 
$keep_only_assigned_to )
+               private function translate_calendar_info( $param = array(), 
$year, $month, $filter_status = '', &$found_at_least_one = false, 
$keep_only_assigned_to, $location_code ='' )
                {
                        if (!isset($param['repeat_type']))
                        {
@@ -1227,6 +1336,7 @@
                                        'serie_id' => 
$param['info']['serie_id'],
                                        'deadline_ts' => mktime(23, 59, 00, 
$month, date('t', strtotime($a_date)), $year),
                                        'type' => 
$param['info']['component_id'] ? 'component' : '',
+                                       'location_code' => $location_code,
                                        'assigned_to' => 
$param['info']['assigned_to']
                                );
                        }
@@ -1323,7 +1433,7 @@
                                Status
                                </th>
                                <th>
-                                       
+
                                </th>
 HTML;
 

Modified: trunk/controller/templates/base/case/create_case_message.xsl
===================================================================
--- trunk/controller/templates/base/case/create_case_message.xsl        
2017-11-05 12:56:00 UTC (rev 17272)
+++ trunk/controller/templates/base/case/create_case_message.xsl        
2017-11-05 22:46:16 UTC (rev 17273)
@@ -1,185 +1,197 @@
 <!-- $Id: edit_check_list.xsl 8374 2011-12-20 07:45:04Z vator $ -->
 <xsl:template match="data" name="view_check_list" 
xmlns:php="http://php.net/xsl";>
 
-<div id="main_content" class="medium">
-       
-       <div id="check-list-heading">
-               <div class="box-1">
-                       <h1>Kontroll: <xsl:value-of 
select="control/title"/></h1>
-                       <xsl:choose>
-                               <xsl:when test="type = 'component'">
-                                       <h2><xsl:value-of 
select="component_array/xml_short_desc"/></h2>
-                               </xsl:when>
-                               <xsl:otherwise>
-                                       <xsl:choose>
-                                               <xsl:when test="location_level 
= 1">
-                                                       <h2>Eiendom: 
<xsl:value-of select="location_array/loc1_name"/></h2>
-                                               </xsl:when>
-                                               <xsl:otherwise>
+       <div id="main_content" class="medium">
+
+               <div id="check-list-heading">
+                       <div class="box-1">
+                               <h1>Kontroll: <xsl:value-of 
select="control/title"/></h1>
+                               <xsl:choose>
+                                       <xsl:when test="type = 'component'">
+                                               <h2>
+                                                       <xsl:value-of 
select="component_array/xml_short_desc"/>
+                                               </h2>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:choose>
+                                                       <xsl:when 
test="location_level = 1">
+                                                               <h2>Eiendom: 
<xsl:value-of select="location_array/loc1_name"/></h2>
+                                                       </xsl:when>
+                                                       <xsl:otherwise>
                                                                <h2>Bygg: 
<xsl:value-of select="location_array/loc2_name"/></h2>
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                               </xsl:otherwise>
-                       </xsl:choose>
+                                                       </xsl:otherwise>
+                                               </xsl:choose>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </div>
+                       <div class="box-2 select-box">
+                               <xsl:choose>
+                                       <xsl:when test="type = 'component'">
+                                               <a>
+                                                       <xsl:attribute 
name="href">
+                                                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicomponent.index' )" />
+                                                               
<xsl:text>&amp;year=</xsl:text>
+                                                               <xsl:value-of 
select="current_year"/>
+                                                               
<xsl:text>&amp;location_id=</xsl:text>
+                                                               <xsl:value-of 
select="component_array/location_id"/>
+                                                               
<xsl:text>&amp;component_id=</xsl:text>
+                                                               <xsl:value-of 
select="component_array/id"/>
+                                                               
<xsl:text>&amp;get_locations=</xsl:text>
+                                                               <xsl:value-of 
select="get_locations"/>
+                                                       </xsl:attribute>
+                                                       Kontrollplan for 
komponent (år)
+                                               </a>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <a>
+                                                       <xsl:attribute 
name="href">
+                                                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicalendar.view_calendar_for_year' )" />
+                                                               
<xsl:text>&amp;year=</xsl:text>
+                                                               <xsl:value-of 
select="current_year"/>
+                                                               
<xsl:text>&amp;location_code=</xsl:text>
+                                                               <xsl:value-of 
select="location_array/location_code"/>
+                                                       </xsl:attribute>
+                                                       Kontrollplan for 
bygg/eiendom (år)
+                                               </a>
+
+                                               <a class="last">
+                                                       <xsl:attribute 
name="href">
+                                                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicalendar.view_calendar_for_month' )" />
+                                                               
<xsl:text>&amp;year=</xsl:text>
+                                                               <xsl:value-of 
select="current_year"/>
+                                                               
<xsl:text>&amp;month=</xsl:text>
+                                                               <xsl:value-of 
select="current_month_nr"/>
+                                                               
<xsl:text>&amp;location_code=</xsl:text>
+                                                               <xsl:value-of 
select="location_array/location_code"/>
+                                                       </xsl:attribute>
+                                                       Kontrolplan for 
bygg/eiendom (måned)
+                                               </a>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </div>
+
+                       <!-- ==================  CHECKLIST TAB MENU  
===================== -->
+                       <xsl:call-template name="check_list_menu" />
                </div>
-               <div class="box-2 select-box">
-                       <xsl:choose>
-                         <xsl:when test="type = 'component'">
-                               <a>
-                                       <xsl:attribute name="href">
-                                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicomponent.index' )" />
-                                               <xsl:text>&amp;year=</xsl:text>
-                                               <xsl:value-of 
select="current_year"/>
-                                               
<xsl:text>&amp;location_id=</xsl:text>
-                                               <xsl:value-of 
select="component_array/location_id"/>
-                                               
<xsl:text>&amp;component_id=</xsl:text>
-                                               <xsl:value-of 
select="component_array/id"/>
-                                       </xsl:attribute>
-                                       Kontrollplan for komponent (år)
-                               </a>
-                       </xsl:when>
-                       <xsl:otherwise>
-                               <a>
-                                       <xsl:attribute name="href">
-                                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicalendar.view_calendar_for_year' )" />
-                                               <xsl:text>&amp;year=</xsl:text>
-                                               <xsl:value-of 
select="current_year"/>
-                                               
<xsl:text>&amp;location_code=</xsl:text>
-                                               <xsl:value-of 
select="location_array/location_code"/>
-                                       </xsl:attribute>
-                                       Kontrollplan for bygg/eiendom (år)
-                               </a>
 
-                               <a class="last">
-                                       <xsl:attribute name="href">
-                                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicalendar.view_calendar_for_month' )" />
-                                               <xsl:text>&amp;year=</xsl:text>
-                                               <xsl:value-of 
select="current_year"/>
-                                               <xsl:text>&amp;month=</xsl:text>
-                                               <xsl:value-of 
select="current_month_nr"/>
-                                               
<xsl:text>&amp;location_code=</xsl:text>
-                                               <xsl:value-of 
select="location_array/location_code"/>
-                                       </xsl:attribute>
-                                       Kontrolplan for bygg/eiendom (måned)
-                               </a>
-                               </xsl:otherwise>
-                       </xsl:choose>
-               </div>
-               
-               <!-- ==================  CHECKLIST TAB MENU  
===================== -->
-               <xsl:call-template name="check_list_menu" />
-       </div>
-       
                <!-- =======================  INFO ABOUT MESSAGE  
========================= -->
                <h3 class="box_header ext">Registrer melding</h3>
                <div id="caseMessage" class="box ext">
                        <xsl:choose>
                                <xsl:when 
test="check_items_and_cases/child::node()">
-                               
-                               <xsl:variable name="action_url">
-                                       <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicase.send_case_message')" />
-                               </xsl:variable>
-               
-                               <form ENCTYPE="multipart/form-data" 
id="frmRegCaseMessage" action="{$action_url}" method="post">
-                                       <input>
-                                               <xsl:attribute 
name="name">check_list_id</xsl:attribute>
-                                           <xsl:attribute 
name="type">hidden</xsl:attribute>
-                                           <xsl:attribute name="value">
-                                               <xsl:value-of 
select="check_list/id"/>
-                                           </xsl:attribute>
-                                       </input>
+
+                                       <xsl:variable name="action_url">
+                                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicase.send_case_message')" />
+                                       </xsl:variable>
+
+                                       <form ENCTYPE="multipart/form-data" 
id="frmRegCaseMessage" action="{$action_url}" method="post">
                                                <input>
-                                               <xsl:attribute 
name="name">location_code</xsl:attribute>
-                                           <xsl:attribute 
name="type">hidden</xsl:attribute>
-                                           <xsl:attribute name="value">
-                                                       <xsl:choose>
-                                                         <xsl:when test="type 
= 'component'">
-                                                                 <xsl:value-of 
select="component_array/location_code"/>
-                                                               </xsl:when>
-                                                               <xsl:otherwise>
-                                                                 <xsl:value-of 
select="location_array/location_code"/>
-                                                               </xsl:otherwise>
-                                                       </xsl:choose>
-                                         </xsl:attribute>
-                                       </input>
-                                       
-                                       <!-- === TITLE === -->
-                                   <div class="row">
-                                               <label>Tittel på 
melding:</label>
-                                               <input name="message_title" 
type="text" class="required" />
-                                       </div>
-                                                                       
-                                       <!-- === CATEGORY === -->
-                                       <div class="row">
-                                               <label>Kategori:</label>
-                                                <select name="message_cat_id" 
class="required">
-                                                       <option value="0">Velg 
kategori</option>
-                                                       <xsl:for-each 
select="categories/cat_list">
-                                                               <xsl:variable 
name="cat_id"><xsl:value-of select="./cat_id"/></xsl:variable>
-                                                               <option 
value="{$cat_id}">
-                                                                       
<xsl:value-of select="./name"/>
-                                                               </option>       
                
+                                                       <xsl:attribute 
name="name">check_list_id</xsl:attribute>
+                                                       <xsl:attribute 
name="type">hidden</xsl:attribute>
+                                                       <xsl:attribute 
name="value">
+                                                               <xsl:value-of 
select="check_list/id"/>
+                                                       </xsl:attribute>
+                                               </input>
+                                               <input>
+                                                       <xsl:attribute 
name="name">location_code</xsl:attribute>
+                                                       <xsl:attribute 
name="type">hidden</xsl:attribute>
+                                                       <xsl:attribute 
name="value">
+                                                               <xsl:choose>
+                                                                       
<xsl:when test="type = 'component'">
+                                                                               
<xsl:value-of select="component_array/location_code"/>
+                                                                       
</xsl:when>
+                                                                       
<xsl:otherwise>
+                                                                               
<xsl:value-of select="location_array/location_code"/>
+                                                                       
</xsl:otherwise>
+                                                               </xsl:choose>
+                                                       </xsl:attribute>
+                                               </input>
+
+                                               <!-- === TITLE === -->
+                                               <div class="row">
+                                                       <label>Tittel på 
melding:</label>
+                                                       <input 
name="message_title" type="text" class="required" />
+                                               </div>
+
+                                               <!-- === CATEGORY === -->
+                                               <div class="row">
+                                                       <label>Kategori:</label>
+                                                       <select 
name="message_cat_id" class="required">
+                                                               <option 
value="0">Velg kategori</option>
+                                                               <xsl:for-each 
select="categories/cat_list">
+                                                                       
<xsl:variable name="cat_id">
+                                                                               
<xsl:value-of select="./cat_id"/>
+                                                                       
</xsl:variable>
+                                                                       <option 
value="{$cat_id}">
+                                                                               
<xsl:value-of select="./name"/>
+                                                                       
</option>
+                                                               </xsl:for-each>
+                                                       </select>
+                                               </div>
+                                               <!-- === UPLOAD FILE === -->
+                                               <div class="row">
+                                                       
<label>Filvedlegg:</label>
+                                                       <input type="file" 
id="file" name="file" >
+                                                               <xsl:attribute 
name="accept">image/*</xsl:attribute>
+                                                               <xsl:attribute 
name="capture">camera</xsl:attribute>
+                                                       </input>
+                                               </div>
+
+                                               <h3>Velg hvilke saker meldingen 
gjelder</h3>
+                                               <ul class="cases">
+                                                       <xsl:for-each 
select="check_items_and_cases">
+                                                               <xsl:choose>
+                                                                       
<xsl:when test="cases_array/child::node()">
+                                                                               
<li class="check_item">
+                                                                               
        <h4>
+                                                                               
                <span>
+                                                                               
                        <xsl:value-of select="control_item/control_group_name"/>
+                                                                               
                        <xsl:text>::</xsl:text>
+                                                                               
                        <xsl:value-of select="control_item/title"/>
+
+                                                                               
                </span>
+                                                                               
        </h4>
+                                                                               
        <ul>
+                                                                               
                <xsl:for-each select="cases_array">
+                                                                               
                        <xsl:variable name="cases_id">
+                                                                               
                                <xsl:value-of select="id"/>
+                                                                               
                        </xsl:variable>
+                                                                               
                        <li>
+                                                                               
                                <input type="checkbox"  name="case_ids[]" 
value="{$cases_id}" />
+                                                                               
                                <xsl:choose>
+                                                                               
                                        <xsl:when test="component_descr != ''">
+                                                                               
                                                <div class="row">
+                                                                               
                                                        <label>
+                                                                               
                                                                <xsl:value-of 
select="php:function('lang','component')" />
+                                                                               
                                                        </label>
+                                                                               
                                                </div>
+                                                                               
                                                <div class="component_descr">
+                                                                               
                                                        <xsl:value-of 
select="component_descr"/>
+                                                                               
                                                </div>
+                                                                               
                                        </xsl:when>
+                                                                               
                                </xsl:choose>
+                                                                               
                                <div class="row">
+                                                                               
                                        <label>Beskrivelse:</label>
+                                                                               
                                </div>
+                                                                               
                                <div class="case_descr">
+                                                                               
                                        <xsl:value-of select="descr"/>
+                                                                               
                                </div>
+                                                                               
                        </li>
+                                                                               
                </xsl:for-each>
+                                                                               
        </ul>
+                                                                               
</li>
+                                                                       
</xsl:when>
+                                                               </xsl:choose>
                                                        </xsl:for-each>
-                                               </select>
-                                       </div>
-                                       <!-- === UPLOAD FILE === -->
-                                       <div class="row">
-                                               <label>Filvedlegg:</label>
-                                               <input type="file" id="file" 
name="file" >
-                                                       <xsl:attribute 
name="accept">image/*</xsl:attribute>
-                                                       <xsl:attribute 
name="capture">camera</xsl:attribute>                                
-                                               </input>
-                                       </div>
-                       
-                                       <h3>Velg hvilke saker meldingen 
gjelder</h3>                                    
-                                       <ul class="cases">
-                                               <xsl:for-each 
select="check_items_and_cases">
-                                                       <xsl:choose>
-                                                               <xsl:when 
test="cases_array/child::node()">
-                                                                       <li 
class="check_item">
-                                                                               
<h4><span>
-                                                                               
<xsl:value-of select="control_item/control_group_name"/>
-                                                                               
<xsl:text>::</xsl:text>
-                                                                               
<xsl:value-of select="control_item/title"/>
-                                                                               
-                                                                               
</span></h4>
-                                                                               
<ul>            
-                                                                               
        <xsl:for-each select="cases_array">
-                                                                               
                <xsl:variable name="cases_id"><xsl:value-of 
select="id"/></xsl:variable>
-                                                                               
                <li>
-                                                                               
                        <input type="checkbox"  name="case_ids[]" 
value="{$cases_id}" />
-                                                                               
                         <xsl:choose>
-                                                                               
                                  <xsl:when test="component_descr != ''">
-                                                                               
                                          <div class="row">
-                                                                               
                                                <label>
-                                                                               
                                                        <xsl:value-of 
select="php:function('lang','component')" />
-                                                                               
                                                </label> 
-                                                                               
                                          </div>
-                                                                               
                                           <div class="component_descr">
-                                                                               
                                                <xsl:value-of 
select="component_descr"/>
-                                                                               
                                          </div>
-                                                                               
                                 </xsl:when>
-                                                                               
                        </xsl:choose>
-                                                                               
                        <div class="row">
-                                                                               
                                <label>Beskrivelse:</label> 
-                                                                               
                        </div>
-                                                                               
                        <div class="case_descr">
-                                                                               
                                <xsl:value-of select="descr"/>
-                                                                               
                        </div>
-                                                                               
                </li>
-                                                                               
        </xsl:for-each>
-                                                                               
</ul>
-                                                                       </li>
-                                                               </xsl:when>
-                                                       </xsl:choose>
-                                               </xsl:for-each>
-                                       </ul>
-                                       
-                                       <div class="form-buttons">
-                                               <xsl:variable 
name="lang_save"><xsl:value-of select="php:function('lang', 'save')" 
/></xsl:variable>
-                                               <input class="btn" 
type="submit" name="save_control" value="Send melding" title="{$lang_save}" />
-                                       </div>
-                               </form>                 
+                                               </ul>
+
+                                               <div class="form-buttons">
+                                                       <xsl:variable 
name="lang_save">
+                                                               <xsl:value-of 
select="php:function('lang', 'save')" />
+                                                       </xsl:variable>
+                                                       <input class="btn" 
type="submit" name="save_control" value="Send melding" title="{$lang_save}" />
+                                               </div>
+                                       </form>
                                </xsl:when>
                                <xsl:otherwise>
                                        Ingen registrerte saker eller det er 
blitt registrert en melding for alle registrerte saker
@@ -186,6 +198,6 @@
                                </xsl:otherwise>
                        </xsl:choose>
                </div>
-                       
-</div>
+
+       </div>
 </xsl:template>

Modified: trunk/controller/templates/base/case/view_case_message.xsl
===================================================================
--- trunk/controller/templates/base/case/view_case_message.xsl  2017-11-05 
12:56:00 UTC (rev 17272)
+++ trunk/controller/templates/base/case/view_case_message.xsl  2017-11-05 
22:46:16 UTC (rev 17273)
@@ -37,6 +37,8 @@
                                                                <xsl:value-of 
select="component_array/location_id"/>
                                                                
<xsl:text>&amp;component_id=</xsl:text>
                                                                <xsl:value-of 
select="component_array/id"/>
+                                                               
<xsl:text>&amp;get_locations=</xsl:text>
+                                                               <xsl:value-of 
select="get_locations"/>
                                                        </xsl:attribute>
                                                        Kontrollplan for 
komponent (år)
                                                </a>

Modified: 
trunk/controller/templates/base/check_list/fragments/check_list_top_section.xsl
===================================================================
--- 
trunk/controller/templates/base/check_list/fragments/check_list_top_section.xsl 
    2017-11-05 12:56:00 UTC (rev 17272)
+++ 
trunk/controller/templates/base/check_list/fragments/check_list_top_section.xsl 
    2017-11-05 22:46:16 UTC (rev 17273)
@@ -1,14 +1,19 @@
 <xsl:template name="check_list_top_section" xmlns:php="http://php.net/xsl";>
-<xsl:param name="active_tab" />
-<xsl:variable name="session_url"><xsl:text>&amp;</xsl:text><xsl:value-of 
select="php:function('get_phpgw_session_url')" /></xsl:variable>
+       <xsl:param name="active_tab" />
+       <xsl:variable name="session_url">
+               <xsl:text>&amp;</xsl:text>
+               <xsl:value-of select="php:function('get_phpgw_session_url')" />
+       </xsl:variable>
 
-<!-- ==================  CHECKLIST DETAILS INFO  ========================= -->
+       <!-- ==================  CHECKLIST DETAILS INFO  
========================= -->
        <div id="check-list-heading">
                <div class="box-1">
                        <h1>Kontroll: <xsl:value-of 
select="control/title"/></h1>
                        <xsl:choose>
                                <xsl:when test="type = 'component'">
-                                       <h2><xsl:value-of 
select="component_array/xml_short_desc"/></h2>
+                                       <h2>
+                                               <xsl:value-of 
select="component_array/xml_short_desc"/>
+                                       </h2>
                                </xsl:when>
                                <xsl:otherwise>
                                        <xsl:choose>
@@ -25,61 +30,63 @@
                
                
                
-    <!-- ==================  CHANGE STATUS FOR CHECKLIST  
===================== -->
-               <xsl:choose>
-                       <xsl:when test="check_list/id != 0">
-               <div class="box-2 select-box">
-            <xsl:call-template name="nav_control_plan" />
-                     <xsl:variable name="action_url"><xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicheck_list.update_status,phpgw_return_as:json')" 
/></xsl:variable>
-                             <form id="update-check-list-status" class="done" 
action="{$action_url}" method="post">
-                                       <input type="hidden" 
name="check_list_id" value="{check_list/id}" /> 
+               <!-- ==================  CHANGE STATUS FOR CHECKLIST  
===================== -->
+               <!--xsl:choose>
+                       <xsl:when test="check_list/id != 0"-->
+                               <div class="box-2 select-box">
+                                       <xsl:call-template 
name="nav_control_plan" />
+                                       <xsl:variable name="action_url">
+                                               <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:controller.uicheck_list.update_status,phpgw_return_as:json')" />
+                                       </xsl:variable>
+                                       <form id="update-check-list-status" 
class="done" action="{$action_url}" method="post">
+                                               <input type="hidden" 
name="check_list_id" value="{check_list/id}" />
                                                <xsl:choose>
                                                        <xsl:when 
test="check_list/status = 0">
-                                                       <input 
id='update-check-list-status-value' type="hidden" name="status" value="1" />
-                                                       <input 
id="status_submit" type="submit" class="btn">
-                                                         <xsl:attribute 
name="value">
-                                                           <xsl:value-of 
select="php:function('lang', 'Status not done')" />
-                                                         </xsl:attribute>
-                                                       </input>
+                                                               <input 
id='update-check-list-status-value' type="hidden" name="status" value="1" />
+                                                               <input 
id="status_submit" type="submit" class="btn">
+                                                                       
<xsl:attribute name="value">
+                                                                               
<xsl:value-of select="php:function('lang', 'Status not done')" />
+                                                                       
</xsl:attribute>
+                                                               </input>
                                                        </xsl:when>
                                                        <xsl:otherwise>
-                                                       <input 
id='update-check-list-status-value' type="hidden" name="status" value="0" />
-                                                       <input type="submit" 
class="btn">
-                                                         <xsl:attribute 
name="value">
-                                                           <xsl:value-of 
select="php:function('lang', 'is_executed')" />
-                                                         </xsl:attribute>
-                                                       </input>
+                                                               <input 
id='update-check-list-status-value' type="hidden" name="status" value="0" />
+                                                               <input 
type="submit" class="btn">
+                                                                       
<xsl:attribute name="value">
+                                                                               
<xsl:value-of select="php:function('lang', 'is_executed')" />
+                                                                       
</xsl:attribute>
+                                                               </input>
                                                        </xsl:otherwise>
                                                </xsl:choose>
-<!--
-                                                <div id 
='update-check-list-status-icon' class="not_done">
-                                                       <div class="icon">
-                                                               <img 
src="controller/images/red_ring.png" />
-                                                       </div>
-                                               </div>
-                                               <div id 
='update-check-list-status-icon-done' class="done">
-                                                       <div class="icon">
-                                                               <img 
src="controller/images/green_ring.png" />
-                                                       </div>
-                                               </div>
--->
-                             </form>
-                     </div>
-                               </xsl:when>
-                       </xsl:choose>
+                                               <!--
+                                               <div id 
='update-check-list-status-icon' class="not_done">
+                                                  <div class="icon">
+                                                          <img 
src="controller/images/red_ring.png" />
+                                                  </div>
+                                          </div>
+                                          <div id 
='update-check-list-status-icon-done' class="done">
+                                                  <div class="icon">
+                                                          <img 
src="controller/images/green_ring.png" />
+                                                  </div>
+                                          </div>
+                                               -->
+                                       </form>
+                               </div>
+                       <!--/xsl:when>
+               </xsl:choose-->
                <!-- ==================  CHECKLIST TAB MENU  
===================== -->
-        <xsl:choose>
-        <xsl:when test="count(check_list_type) = 0 or check_list_type != 
'add_check_list'">
-            <xsl:call-template name="check_list_menu">
-                <xsl:with-param name="active_tab">
-                       <xsl:value-of select="$active_tab" />
-                       </xsl:with-param>
-            </xsl:call-template>
-        </xsl:when>
-        <xsl:otherwise>
-            <xsl:call-template name="add_check_list_menu" />
-        </xsl:otherwise>
-        </xsl:choose>
+               <xsl:choose>
+                       <xsl:when test="count(check_list_type) = 0 or 
check_list_type != 'add_check_list'">
+                               <xsl:call-template name="check_list_menu">
+                                       <xsl:with-param name="active_tab">
+                                               <xsl:value-of 
select="$active_tab" />
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:call-template name="add_check_list_menu" />
+                       </xsl:otherwise>
+               </xsl:choose>
        </div>
                
 </xsl:template>

Modified: 
trunk/controller/templates/base/check_list/fragments/nav_control_plan.xsl
===================================================================
--- trunk/controller/templates/base/check_list/fragments/nav_control_plan.xsl   
2017-11-05 12:56:00 UTC (rev 17272)
+++ trunk/controller/templates/base/check_list/fragments/nav_control_plan.xsl   
2017-11-05 22:46:16 UTC (rev 17273)
@@ -14,6 +14,8 @@
                                        <xsl:value-of 
select="component_array/location_id"/>
                                        <xsl:text>&amp;component_id=</xsl:text>
                                        <xsl:value-of 
select="component_array/id"/>
+                                       <xsl:text>&amp;get_locations=</xsl:text>
+                                       <xsl:value-of select="get_locations"/>
                                </xsl:attribute>
                                Kontrollplan for komponent (år)
                        </a>

Modified: trunk/property/inc/class.bolocation.inc.php
===================================================================
--- trunk/property/inc/class.bolocation.inc.php 2017-11-05 12:56:00 UTC (rev 
17272)
+++ trunk/property/inc/class.bolocation.inc.php 2017-11-05 22:46:16 UTC (rev 
17273)
@@ -870,14 +870,15 @@
                                $location_code = $data;
                        }
 
-                       $location_array = explode('-', $location_code);
-                       $type_id = count($location_array);
-
-                       if (!$type_id)
+                       if (!$location_code)
                        {
                                return;
                        }
 
+                       $location_array = explode('-', $location_code);
+                       $type_id = count($location_array);
+
+
                        if (!isset($extra['noattrib']) || !$extra['noattrib'])
                        {
                                $values['attributes'] = 
$this->custom->find('property', '.location.' . $type_id, 0, '', 'ASC', 
'attrib_sort', true, true);

Modified: trunk/property/inc/class.controller_helper.inc.php
===================================================================
--- trunk/property/inc/class.controller_helper.inc.php  2017-11-05 12:56:00 UTC 
(rev 17272)
+++ trunk/property/inc/class.controller_helper.inc.php  2017-11-05 22:46:16 UTC 
(rev 17273)
@@ -523,10 +523,10 @@
 
 //                     $location_info = 
$GLOBALS['phpgw']->locations->get_name($location_id);
 //
-//                     if (substr($location_info['name'], 1, 6) == 'entity')
+//                     if (substr($location_info['location'], 1, 6) == 
'entity')
 //                     {
 //                             $type = 'entity';
-//                             $type_info = explode('.', 
$location_info['name']);
+//                             $type_info = explode('.', 
$location_info['location']);
 //                             $entity_id = $type_info[2];
 //                             $cat_id = $type_info[3];
 //                             $component_arr = 
$this->so->read_single(array('entity_id' => $entity_id, 'cat_id' => $cat_id, 
'id' => $id));

Modified: trunk/property/inc/class.custom_fields.inc.php
===================================================================
--- trunk/property/inc/class.custom_fields.inc.php      2017-11-05 12:56:00 UTC 
(rev 17272)
+++ trunk/property/inc/class.custom_fields.inc.php      2017-11-05 22:46:16 UTC 
(rev 17273)
@@ -835,6 +835,7 @@
                                                $_location_count = 0;
                                        }
                                }
+                               $ret[$j]['location_id'] = $location_id;
                                $j++;
                        }
                        return $ret;

Modified: trunk/property/inc/class.solocation.inc.php
===================================================================
--- trunk/property/inc/class.solocation.inc.php 2017-11-05 12:56:00 UTC (rev 
17272)
+++ trunk/property/inc/class.solocation.inc.php 2017-11-05 22:46:16 UTC (rev 
17273)
@@ -352,7 +352,21 @@
                        $results = $data['results'] ? (int)$data['results'] : 0;
                        $control_registered = 
isset($data['control_registered']) ? $data['control_registered'] : '';
                        $control_id = isset($data['control_id']) && 
$data['control_id'] ? $data['control_id'] : 0;
+                       $location_id = isset($data['location_id']) && 
$data['location_id'] ? (int)$data['location_id'] : 0;
+                       $filter_item = isset($data['filter_item']) && 
$data['filter_item'] ? (array)$data['filter_item'] : array();
 
+                       if($location_id && !$type_id)
+                       {
+                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($location_id);
+
+                               if (substr($location_info['location'], 1, 8) == 
'location')
+                               {
+                                       $type_info = explode('.', 
$location_info['location']);
+                                       $type_id = $type_info[2];
+                               }
+                       }
+
+
                        if (!$type_id)
                        {
                                return;
@@ -376,7 +390,10 @@
 
 
                        $sql = $this->socommon->fm_cache('sql_' . $type_id . 
'_lt' . $lookup_tenant . '_l' . $lookup . '_f' . !!$filter_role_on_contact);
-                       $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', ".location.{$type_id}");
+                       if(empty($location_id))
+                       {
+                               $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', ".location.{$type_id}");       
                 
+                       }
 
 //                     $choice_table = 'phpgw_cust_choice';
                        $attribute_table = 'phpgw_cust_attribute';
@@ -785,6 +802,11 @@
                                $where = 'AND';
                        }
 
+                       if($filter_item)
+                       {
+                               $filtermethod .= " {$where} 
fm_location{$type_id}.id IN (" . implode(', ', $filter_item) . ')';
+                               $where = 'AND';
+                       }
                        if ($filter > 0)
                        {
                                //address@hidden 16/09/08       validacion is 
added to avoid notice
@@ -1266,7 +1288,28 @@
 
                        $location_array = explode('-', $location_code);
                        $type_id = count($location_array);
+                       
+                       $location_id = !empty($values['location_id']) ? (int) 
$values['location_id'] : null;
 
+                       /**
+                        * Override
+                        */
+                       if($location_id)
+                       {
+                               $location_info = 
$GLOBALS['phpgw']->locations->get_name($location_id);
+
+                               if (substr($location_info['location'], 1, 8) == 
'location')
+                               {
+                                       $type_info = explode('.', 
$location_info['location']);
+                                       $type_id = $type_info[2];
+                               }
+                               $id = !empty($values['id']) ? (int) 
$values['id'] : null;
+                               if(!$id && !$location_code)
+                               {
+                                       $type_id = false;
+                               }
+                       }
+
                        if (!$type_id)
                        {
                                return;
@@ -1334,7 +1377,14 @@
                        //FIXME: Make sure all locations are linked to a valid 
category
                        $sql .= " {$this->left_join} 
fm_location{$type_id}_category ON (fm_location{$type_id}.category = 
fm_location{$type_id}_category.id)";
 
-                       $sql .= " WHERE 
fm_location$type_id.location_code='$location_code' ";
+                       if($location_code)
+                       {
+                               $sql .= " WHERE 
fm_location$type_id.location_code='$location_code' ";
+                       }
+                       else
+                       {
+                               $sql .= " WHERE fm_location$type_id.id=" . 
(int) $id;
+                       }
 
                        $this->db->query($sql, __LINE__, __FILE__);
 
@@ -1359,6 +1409,11 @@
                                                }
                                        }
                                }
+
+                               if(!$location_code)
+                               {
+                                       $location_code = 
$this->db->f('location_code');
+                               }
                        }
 
                        //_debug_array($cols_return);




reply via email to

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