fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [6582] Property: Responsibility roles


From: Sigurd Nes
Subject: [Fmsystem-commits] [6582] Property: Responsibility roles
Date: Thu, 11 Nov 2010 22:23:04 +0000

Revision: 6582
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6582
Author:   sigurdne
Date:     2010-11-11 22:23:04 +0000 (Thu, 11 Nov 2010)
Log Message:
-----------
Property: Responsibility roles

Modified Paths:
--------------
    trunk/property/inc/class.bolocation.inc.php
    trunk/property/inc/class.solocation.inc.php
    trunk/property/inc/class.uilocation.inc.php
    trunk/property/js/yahoo/location.responsiblility_role.js

Modified: trunk/property/inc/class.bolocation.inc.php
===================================================================
--- trunk/property/inc/class.bolocation.inc.php 2010-11-11 14:51:20 UTC (rev 
6581)
+++ trunk/property/inc/class.bolocation.inc.php 2010-11-11 22:23:04 UTC (rev 
6582)
@@ -652,7 +652,7 @@
                                                                                
        'lookup_tenant'=>$data['lookup_tenant'],'lookup'=>$data['lookup'],
                                                                                
        'district_id'=>$this->district_id,'allrows'=>$data['allrows'],
                                                                                
        
'status'=>$this->status,'part_of_town_id'=>$this->part_of_town_id,'dry_run'=>$data['dry_run'],
-                                                                               
        'location_code' => $this->location_code));
+                                                                               
        'location_code' => $this->location_code, 'filter_role_on_contact' => 
$data['filter_role_on_contact'], 'role_id' => $data['role_id']));
 
                        $this->total_records = $this->so->total_records;
                        $this->uicols = $this->so->uicols;
@@ -664,7 +664,15 @@
                {
                        $soresponsible          = 
CreateObject('property.soresponsible');
                        $contacts = createObject('phpgwapi.contacts');
+                       
+                       if($data['user_id'] < 0 && $data['role_id'])
+                       {
+                               $account = 
$GLOBALS['phpgw']->accounts->get(abs($data['user_id']));
+                               $contact_id = $account->person_id;
 
+                               $data['filter_role_on_contact'] = $contact_id;
+                       }
+
                        $locations = $this->read($data);
                        foreach ($locations as & $location)
                        {

Modified: trunk/property/inc/class.solocation.inc.php
===================================================================
--- trunk/property/inc/class.solocation.inc.php 2010-11-11 14:51:20 UTC (rev 
6581)
+++ trunk/property/inc/class.solocation.inc.php 2010-11-11 22:23:04 UTC (rev 
6582)
@@ -246,24 +246,23 @@
 
                function read($data)
                {
-                       if(is_array($data))
-                       {
-                               $start                          = 
isset($data['start']) && $data['start'] ? $data['start'] : 0;
-                               $filter                         = 
isset($data['filter']) && $data['filter'] ? $data['filter'] : 0;
-                               $query                          = 
isset($data['query']) ? $data['query'] : '';
-                               $sort                           = 
isset($data['sort']) && $data['sort'] ? $data['sort'] : 'DESC';
-                               $order                          = 
isset($data['order']) ? $data['order'] : '';
-                               $cat_id                         = 
isset($data['cat_id']) && $data['cat_id'] ? $data['cat_id']:'';
-                               $type_id                        = 
isset($data['type_id']) ? $data['type_id'] : '';
-                               $lookup_tenant          = 
isset($data['lookup_tenant']) ? $data['lookup_tenant'] : '';
-                               $district_id            = 
isset($data['district_id']) ? $data['district_id'] : '';
-                               $allrows                        = 
isset($data['allrows']) ? $data['allrows'] : '';
-                               $lookup                         = 
isset($data['lookup']) ? $data['lookup'] : '';
-                               $status                         = 
isset($data['status']) ? $data['status'] : '';
-                               $part_of_town_id        = 
isset($data['part_of_town_id']) ? $data['part_of_town_id'] : '';
-                               $dry_run                        = 
isset($data['dry_run']) ? $data['dry_run'] : '';
-                               $location_code          = 
isset($data['location_code']) ? $data['location_code'] : '';
-                       }
+                       $start                                  = 
isset($data['start']) && $data['start'] ? $data['start'] : 0;
+                       $filter                                 = 
isset($data['filter']) && $data['filter'] ? $data['filter'] : 0;
+                       $query                                  = 
isset($data['query']) ? $data['query'] : '';
+                       $sort                                   = 
isset($data['sort']) && $data['sort'] ? $data['sort'] : 'DESC';
+                       $order                                  = 
isset($data['order']) ? $data['order'] : '';
+                       $cat_id                                 = 
isset($data['cat_id']) && $data['cat_id'] ? $data['cat_id']:'';
+                       $type_id                                = 
isset($data['type_id']) ? $data['type_id'] : '';
+                       $lookup_tenant                  = 
isset($data['lookup_tenant']) ? $data['lookup_tenant'] : '';
+                       $district_id                    = 
isset($data['district_id']) ? $data['district_id'] : '';
+                       $allrows                                = 
isset($data['allrows']) ? $data['allrows'] : '';
+                       $lookup                                 = 
isset($data['lookup']) ? $data['lookup'] : '';
+                       $status                                 = 
isset($data['status']) ? $data['status'] : '';
+                       $part_of_town_id                = 
isset($data['part_of_town_id']) ? $data['part_of_town_id'] : '';
+                       $dry_run                                = 
isset($data['dry_run']) ? $data['dry_run'] : '';
+                       $location_code                  = 
isset($data['location_code']) ? $data['location_code'] : '';
+                       $filter_role_on_contact = 
$data['filter_role_on_contact'] ? (int)$data['filter_role_on_contact'] : 0;
+                       $role_id                                = 
$data['role_id'] ? (int)$data['role_id'] : 0;
 
                        if (!$type_id)
                        {
@@ -287,7 +286,7 @@
                        }
 
 
-                       $sql = $this->socommon->fm_cache('sql_'. $type_id . '_' 
. $lookup_tenant . '_' . $lookup);
+                       $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}");
 
 //                     $choice_table = 'phpgw_cust_choice';
@@ -512,11 +511,21 @@
                                $joinmethod .= " {$this->left_join} 
fm_location{$type_id}_category ON ( fm_location{$type_id}.category = 
fm_location{$type_id}_category.id))";
                                $paranthesis .='(';
 
+                               if($filter_role_on_contact)
+                               {
+                                       $joinmethod .= " {$this->join} 
fm_responsibility_contact ON ( fm_location{$type_id}.location_code = 
fm_responsibility_contact.location_code))";
+                                       $paranthesis .='(';
+                                       $joinmethod .= " {$this->join} 
fm_responsibility ON ( fm_responsibility_contact.responsibility_id = 
fm_responsibility.id))";
+                                       $paranthesis .='(';
+                                       $joinmethod .= " {$this->join} 
fm_responsibility_role ON ( fm_responsibility.id = 
fm_responsibility_role.responsibility_id))";
+                                       $paranthesis .='(';
+                               }
+
                                $from = " FROM {$paranthesis} 
fm_location{$type_id} ";
 
                                $sql = "SELECT $cols $from $joinmethod";
 
-                               $this->socommon->fm_cache('sql_'. $type_id . 
'_' . $lookup_tenant . '_' . $lookup ,$sql);
+                               $this->socommon->fm_cache('sql_'. $type_id . 
'_lt' . $lookup_tenant . '_l' . $lookup . '_f' . !!$filter_role_on_contact 
,$sql);
                                $this->socommon->fm_cache('uicols_'. $type_id  
. '_' . $lookup_tenant . '_' . $lookup,$uicols);
                                $this->socommon->fm_cache('cols_return_'. 
$type_id  . '_' . $lookup_tenant . '_' . $lookup,$cols_return);
 
@@ -693,10 +702,18 @@
 
                        if ($location_code)
                        {
-                               $filtermethod .= "  {$where} 
fm_location{$type_id}.location_code $this->like '{$location_code}%'";
+                               $filtermethod .= " {$where} 
fm_location{$type_id}.location_code $this->like '{$location_code}%'";
                                $where= 'AND';                  
                        }
 
+                       if($filter_role_on_contact && $role_id)
+                       {
+                               $time = time() +1;
+                               $filtermethod .= " {$where} active_from < 
{$time} AND (active_to > {$time} OR active_to = 0)"
+                               ." AND expired_on IS NULL AND 
fm_responsibility_role.id ={$role_id} AND contact_id = 
{$filter_role_on_contact}";
+                               $where= 'AND';                  
+                       }
+
                        $_querymethod = array();
                        $__querymethod = array();
                        $_joinmethod_datatype = array();
@@ -824,9 +841,9 @@
                        }
 
                        $sql .= "$filtermethod $querymethod";
-//_debug_array($sql);
+
                        $values = array();
-                       $this->db->query('SELECT count(*) AS cnt ' . 
substr($sql,strripos($sql,'from')),__LINE__,__FILE__);
+                       $this->db->query('SELECT count(*) AS cnt ' . 
substr($sql,strripos($sql,' from')),__LINE__,__FILE__);
                        $this->db->next_record();
                        $this->total_records = $this->db->f('cnt');
 

Modified: trunk/property/inc/class.uilocation.inc.php
===================================================================
--- trunk/property/inc/class.uilocation.inc.php 2010-11-11 14:51:20 UTC (rev 
6581)
+++ trunk/property/inc/class.uilocation.inc.php 2010-11-11 22:23:04 UTC (rev 
6582)
@@ -869,6 +869,7 @@
 
 
 
+
                        }
 
                        $datatable['pagination']['records_total']       = 
$this->bo->total_records;
@@ -1041,9 +1042,11 @@
 
                        $this->save_sessiondata();
 
+                       $user_id = phpgw::get_var('user_id', 'int', 'request', 
$this->account);
+
                        if($values && $this->acl_edit)
                        {
-                               $user_id = phpgw::get_var('user_id', 'int', 
'request', $this->account);
+                               $user_id = abs($user_id);
                                $account = 
$GLOBALS['phpgw']->accounts->get($user_id);
                                $contact_id = $account->person_id;
                                if(!$role_id)
@@ -1165,6 +1168,7 @@
                                array_unshift 
($values_combo_box[4],$default_value);
 
                                $values_combo_box[5]  = 
$this->bocommon->get_user_list_right2('filter',PHPGW_ACL_READ,$this->user_id,".location.{$type_id}");
+                               array_unshift 
($values_combo_box[5],array('id'=> 
(-1*$GLOBALS['phpgw_info']['user']['account_id']),'name'=>lang('mine roles')));
                                $default_value = 
array('id'=>'','name'=>lang('no user'));
                                array_unshift 
($values_combo_box[5],$default_value);
 
@@ -1296,7 +1300,7 @@
 
                        $location_list = array();
 
-                       $location_list = 
$this->bo->get_responsible(array('role_id' =>$role_id, 
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run'
 =>$dry_run));
+                       $location_list = 
$this->bo->get_responsible(array('user_id' => $user_id, 'role_id' =>$role_id, 
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run'
 =>$dry_run));
 
                        $uicols = $this->bo->uicols;
 

Modified: trunk/property/js/yahoo/location.responsiblility_role.js
===================================================================
--- trunk/property/js/yahoo/location.responsiblility_role.js    2010-11-11 
14:51:20 UTC (rev 6581)
+++ trunk/property/js/yahoo/location.responsiblility_role.js    2010-11-11 
22:23:04 UTC (rev 6582)
@@ -2,7 +2,7 @@
 // Declaration of event.index vars
 //--------------------------------------------------------
        //define SelectButton
-    var oMenuButton_0, oMenuButton_1, oMenuButton_2, oMenuButton_3, 
oMenuButton_4, oMenuButton_5;
+    var oMenuButton_0, oMenuButton_1, oMenuButton_2, oMenuButton_3, 
oMenuButton_4;//, oMenuButton_5;
        var selectsButtons = [
     {order:0, var_URL:'type_id',               name:'btn_type_id',             
style:'typebutton',                     dependiente:[], reload:1},
     {order:1, var_URL:'cat_id',                        name:'btn_cat_id',      
        style:'categorybutton',         dependiente:[]},
@@ -22,28 +22,44 @@
        // define Text buttons
        var textImput = [
        {order:0, name:'query', id:'txt_query'}
-       ]
+       ];
 
        var toolTips =
        [
                {name:'status', title:'Status', 
description:'',ColumnDescription:'status'},
                {name:'btn_export', title:'download', description:'Download 
table to your browser',ColumnDescription:''}
-       ]
+       ];
 
        var linktoolTips =
        [
                {name:'btn_data_search', title:'Data search', 
description:'Narrow the search dates'}
-       ]
+       ];
 
        var config_values =
-       {
-               date_search : 0 //if search has link "Data search"
-       }
+       [
+               {date_search : 0} //if search has link "Data search"
+       ];
 
        var tableYUI;
        
/********************************************************************************
        *
        */
+
+       this.onChangeSelect = function()
+       {
+               var myselect=document.getElementById("sel_user_id");
+               for (var i=0; i<myselect.options.length; i++)
+               {
+                       if (myselect.options[i].selected==true)
+                       {
+                               break;
+                       }
+               }
+               eval("path_values.user_id='"+myselect.options[i].value+"'");
+               execute_ds();
+       }
+
+
        this.myParticularRenderEvent = function()
        {
                delete_content_div("message",2); //find it in property.js
@@ -189,6 +205,9 @@
                //add all control to form
                for(i=0;i<valuesForPHP.length;i++)
                {
+//alert(valuesForPHP[i].name);
+//alert(valuesForPHP[i].checked);
+
                        myclone = valuesForPHP[i].cloneNode(true);
                        mydiv.appendChild(myclone);
                }




reply via email to

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