fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11905] property: more on org_unit


From: Sigurd Nes
Subject: [Fmsystem-commits] [11905] property: more on org_unit
Date: Fri, 11 Apr 2014 14:16:18 +0000

Revision: 11905
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11905
Author:   sigurdne
Date:     2014-04-11 14:16:17 +0000 (Fri, 11 Apr 2014)
Log Message:
-----------
property: more on org_unit

Modified Paths:
--------------
    trunk/frontend/inc/class.uientity.inc.php
    trunk/property/inc/class.boentity.inc.php
    trunk/property/inc/class.soentity.inc.php

Modified: trunk/frontend/inc/class.uientity.inc.php
===================================================================
--- trunk/frontend/inc/class.uientity.inc.php   2014-04-11 10:44:09 UTC (rev 
11904)
+++ trunk/frontend/inc/class.uientity.inc.php   2014-04-11 14:16:17 UTC (rev 
11905)
@@ -109,7 +109,7 @@
                                foreach ($this->header_state['org_unit'] as 
$org_unit)
                                {
                                        $_org_unit_id = 
(int)$org_unit['ORG_UNIT_ID'];
-                                       $_subs = 
execMethod('property.sogeneric.read_tree',array('node_id' => $_org_unit_id, 
'type' => 'department'));
+                                       $_subs = 
execMethod('property.sogeneric.read_tree',array('node_id' => $_org_unit_id, 
'type' => 'org_unit'));
                                        $_org_units[$_org_unit_id] = true;
                                        foreach($_subs as $entry)
                                        {
@@ -118,11 +118,9 @@
                                }
                        }
                        $org_units = array_keys($_org_units);
-                       _debug_array($this->header_state['org_unit']);
-                       _debug_array($org_units);
-                       
-                       die();
 
+                       $this->bo->org_units = $org_units;
+
                }
 
 

Modified: trunk/property/inc/class.boentity.inc.php
===================================================================
--- trunk/property/inc/class.boentity.inc.php   2014-04-11 10:44:09 UTC (rev 
11904)
+++ trunk/property/inc/class.boentity.inc.php   2014-04-11 14:16:17 UTC (rev 
11905)
@@ -45,6 +45,7 @@
                var $location_code;
                var $results;
                var $acl_location;
+               public $org_units = array();
                protected $xsl_rootdir;
 
                /**
@@ -342,6 +343,9 @@
 
                function read($data= array())
                {
+                       static $location_data = array();
+                       static $org_units = array();
+
                        if(isset($this->allrows) && $this->allrows)
                        {
                                $data['allrows'] = true;
@@ -388,15 +392,34 @@
                                }
                        }
 
-                       $entity = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                               'filter' => $this->filter,'cat_id' => 
$this->cat_id,'district_id' => $this->district_id, 'part_of_town_id' => 
$this->part_of_town_id,
-                               
'lookup'=>isset($data['lookup'])?$data['lookup']:'','allrows'=>isset($data['allrows'])?$data['allrows']:'',
 'results' => $this->results,
-                               
'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'status'=>$this->status,
-                               
'start_date'=>$this->bocommon->date_to_timestamp($data['start_date']),
-                               
'end_date'=>$this->bocommon->date_to_timestamp($data['end_date']),
-                               'dry_run'=>$data['dry_run'], 
'type'=>$data['type'], 'location_code' => $this->location_code,
-                               'criteria_id' => $this->criteria_id, 
'attrib_filter' => $attrib_filter, 'p_num' => $this->p_num,
-                               
'control_registered'=>isset($data['control_registered'])?$data['control_registered']:'','control_id'=>isset($data['control_id'])?$data['control_id']:''));
+                       $entity = $this->so->read(array
+                               (
+                                       'start' => $this->start,
+                                       'query' => $this->query,
+                                       'sort' => $this->sort,
+                                       'order' => $this->order,
+                                       'filter' => $this->filter,
+                                       'cat_id' => $this->cat_id,
+                                       'district_id' => $this->district_id,
+                                       'part_of_town_id' => 
$this->part_of_town_id,
+                                       
'lookup'=>isset($data['lookup'])?$data['lookup']:'',
+                                       
'allrows'=>isset($data['allrows'])?$data['allrows']:'',
+                                       'results' => $this->results,
+                                       'entity_id'=>$this->entity_id,
+                                       'status'=>$this->status,
+                                       
'start_date'=>$this->bocommon->date_to_timestamp($data['start_date']),
+                                       
'end_date'=>$this->bocommon->date_to_timestamp($data['end_date']),
+                                       'dry_run'=>$data['dry_run'],
+                                       'type'=>$data['type'],
+                                       'location_code' => $this->location_code,
+                                       'criteria_id' => $this->criteria_id,
+                                       'attrib_filter' => $attrib_filter,
+                                       'p_num' => $this->p_num,
+                                       
'control_registered'=>isset($data['control_registered']) ? 
$data['control_registered'] : '',
+                                       
'control_id'=>isset($data['control_id']) ? $data['control_id'] : '',
+                                       'org_units' => $this->org_units
+                               )
+                       );
 
                        $this->total_records = $this->so->total_records;
                        $this->uicols   = $this->so->uicols;
@@ -429,58 +452,42 @@
                                }
                        }
 
-//_debug_array($cols_extra);
-//_debug_array($this->uicols);die();
-/*
-                       $location_relation_data =       
$this->location_relation_data;
-                       
-                       if ($location_relation_data && 
is_array($location_relation_data))
-                       {
-                               foreach ($location_relation_data as $entry)
-                               {
-                                       $this->uicols['input_type'][]   = 
'text';
-                                       $this->uicols['name'][]                 
= $entry['name'];
-                                       $this->uicols['descr'][]                
= $entry['descr'];
-                                       $this->uicols['statustext'][]   = 
$entry['descr'];
-                                       $this->uicols['exchange'][]             
= false;
-                                       $this->uicols['align'][]                
= '';
-                                       $this->uicols['datatype'][]             
= '';
-                                       $this->uicols['formatter'][]    = '';
-                                       $this->uicols['classname'][]    = '';
-                                       $this->uicols['sortable'][]             
= false;
+                       $sogeneric      = CreateObject('property.sogeneric');
+                       $sogeneric->get_location_info('org_unit');
 
-                                       $cols_extra[]                           
= $entry['name'];
-
-                               }
-                       }
-                       
-                       unset($entry);
-*/
-
-                       //_debug_array($entity);
-//                     _debug_array($cols_extra);
-                       //_debug_array($cols_return_lookup);
-
-//                     if(isset($data['lookup']) && $data['lookup'])
+                       foreach ($entity as &$entry)
                        {
-                               foreach ($entity as &$entry)
+//_debug_array($entry);die();
+                               if(isset($entry['location_code']))
                                {
-                                       $location_data = 
$this->solocation->read_single($entry['location_code']);
+                                       
if(!isset($location_data[$entry['location_code']]))
+                                       {
+                                               
$location_data[$entry['location_code']] = 
$this->solocation->read_single($entry['location_code']);
+                                       }
                                        for ($j=0;$j<count($cols_extra);$j++)
                                        {
-                                               $entry[$cols_extra[$j]] = 
$location_data[$cols_extra[$j]];
+                                               $entry[$cols_extra[$j]] = 
$location_data[$entry['location_code']][$cols_extra[$j]];
                                        }
 
                                        if($cols_return_lookup)
                                        {
                                                for 
($k=0;$k<count($cols_return_lookup);$k++)
                                                {
-                                                       
$entry[$cols_return_lookup[$k]] = $location_data[$cols_return_lookup[$k]];
+                                                       
$entry[$cols_return_lookup[$k]] = 
$location_data[$entry['location_code']][$cols_return_lookup[$k]];
                                                }
                                        }
                                }
+                               if(isset($entry['org_unit_id']))
+                               {
+                                       
if(!isset($org_units[$entry['org_unit_id']]))
+                                       {
+                                               $org_unit = 
$sogeneric->read_single(array('id' => $entry['org_unit_id']));
+                                               
$org_units[$entry['org_unit_id']]['name'] = $org_unit['name'];
+                                       }
+                                       $entry['org_unit'] = 
$org_units[$entry['org_unit_id']]['name'];
+                               }
                        }
-
+//_debug_array($entity);die();
                        return $entity;
                }
 

Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php   2014-04-11 10:44:09 UTC (rev 
11904)
+++ trunk/property/inc/class.soentity.inc.php   2014-04-11 14:16:17 UTC (rev 
11905)
@@ -442,6 +442,7 @@
                        $custom_condition= isset($data['custom_condition']) ? 
$data['custom_condition'] : '';
                        $control_registered= isset($data['control_registered']) 
? $data['control_registered'] : '';
                        $control_id             = isset($data['control_id']) && 
$data['control_id'] ? $data['control_id'] : 0;
+                       $org_units              = isset($data['org_units']) && 
is_array($data['org_units']) ? $data['org_units'] : array();
 
                        if(!$entity_id || !$cat_id)
                        {
@@ -484,6 +485,18 @@
                        $filtermethod = "WHERE fm_bim_type.location_id = 
{$location_id}";
                        $where= 'AND';
 
+                       if( $category['org_unit'])
+                       {
+                               if($org_units)
+                               {
+                                       $filtermethod .= " $where ( 
$entity_table.org_unit_id IN(" . implode(',',$org_units) . "))";
+                               }
+                               else
+                               {
+                                       return array();
+                               }
+                       }
+
                        $_config        = 
CreateObject('phpgwapi.config',$this->type_app[$this->type]);
                        $_config->read();
                        if(isset($_config->config_data['acl_at_location'])
@@ -823,7 +836,8 @@
                        $j=0;
 
                        $uicols = $this->uicols;
-                       $cols_return = $uicols['name'];
+//                     $cols_return = $uicols['name'];
+                       $cols_return = $this->cols_return;
                        $dataset = array();
 
                        while ($this->db->next_record())
@@ -922,7 +936,7 @@
                                $entity_table = 
"fm_{$this->type}_{$entity_id}_{$cat_id}";
                        }
 
-                       $this->uicols   = 
$this->bocommon->fm_cache("uicols_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
+                       $this->uicols   = 
$this->bocommon->fm_cache("uicols_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}_{$category['org_unit']}");
 
                        $choice_table = 'phpgw_cust_choice';
                        $attribute_table = 'phpgw_cust_attribute';
@@ -1022,6 +1036,21 @@
                                        $uicols['classname'][]          = '';
                                }
 
+                               if($category['org_unit'])
+                               {
+                                       $cols_return[]                          
= 'org_unit_id';
+                                       $uicols['input_type'][]         = 
'text';
+                                       $uicols['name'][]                       
= 'org_unit';
+                                       $uicols['descr'][]                      
= lang('department');
+                                       $uicols['statustext'][]         = 
lang('department');
+                                       $uicols['align'][]                      
= '';
+                                       $uicols['datatype'][]           = '';
+                                       $uicols['sortable'][]           = true;
+                                       $uicols['exchange'][]           = false;
+                                       $uicols['formatter'][]          = '';
+                                       $uicols['classname'][]          = '';
+                               }
+
                //              $cols .= ", {$entity_table}.user_id";
                                $cols_return[]                          = 
'user_id';
 
@@ -1038,14 +1067,15 @@
                                        
$this->bocommon->fm_cache("sql_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}", 
$this->sql);
                                }
 
-                               
$this->bocommon->fm_cache("uicols_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->uicols);
-                               
$this->bocommon->fm_cache("cols_return_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->cols_return);
+                               
$this->bocommon->fm_cache("uicols_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}_{$category['org_unit']}",
 $this->bocommon->uicols);
+                               
$this->bocommon->fm_cache("cols_return_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}_{$category['org_unit']}",
 $this->bocommon->cols_return);
                                
$this->bocommon->fm_cache("cols_return_lookup_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->cols_return_lookup);
                                
$this->bocommon->fm_cache("cols_extra_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->cols_extra);
 
                                $this->uicols                           = 
$this->bocommon->uicols;
                                $this->cols_return_lookup       = 
$this->bocommon->cols_return_lookup;
                                $this->cols_extra                       = 
$this->bocommon->cols_extra;
+                               $this->cols_return                      = 
$this->bocommon->cols_return;
                        }
                        else
                        {
@@ -1057,6 +1087,8 @@
 
                                $this->cols_return_lookup       = 
$this->bocommon->fm_cache("cols_return_lookup_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
                                $this->cols_extra                       = 
$this->bocommon->fm_cache("cols_extra_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
+                               $this->cols_return                      = 
$this->bocommon->fm_cache("cols_return_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}_{$category['org_unit']}");
+
                        }
 
                        $uicols = &$this->uicols;
@@ -1106,6 +1138,7 @@
                                                        'datatype'      => 
$this->db->f('datatype'),
                                                        'attrib_id'     => 
$this->db->f('id')
                                                );
+                                       $this->cols_return[] = 
$this->db->f('column_name');
 
                                        $i++;
                                }
@@ -1155,6 +1188,7 @@
                        $attrib_filter  = $data['attrib_filter'] ? 
$data['attrib_filter'] : array();
                        $p_num                  = isset($data['p_num']) ? 
$data['p_num'] : '';
                        $custom_condition= isset($data['custom_condition']) ? 
$data['custom_condition'] : '';
+                       $org_units              = isset($data['org_units']) && 
is_array($data['org_units']) ? $data['org_units'] : array();
 
                        if(!$entity_id || !$cat_id)
                        {
@@ -1245,7 +1279,19 @@
                        }
 
                        unset($_config);
-
+                       if( $category['org_unit'])
+                       {
+                               if($org_units)
+                               {
+                                       $filtermethod .= " $where ( 
$entity_table.org_unit_id IN(" . implode(',',$org_units) . "))";
+                                       $where= 'AND';
+                               }
+                               else
+                               {
+                                       return array();
+                               }
+                       }
+                       
                        if ($filter=='all')
                        {
                                if (is_array($grants) && !$bypass_acl_at_entity)
@@ -1499,7 +1545,9 @@
 
                        $j=0;
                        $uicols = $this->uicols;
-                       $cols_return = $uicols['name'];
+//                     $cols_return = $uicols['name'];
+                       $cols_return = $this->cols_return;
+
                        $dataset = array();
                        while ($this->db->next_record())
                        {




reply via email to

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