fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9297] property: custom functions


From: Sigurd Nes
Subject: [Fmsystem-commits] [9297] property: custom functions
Date: Mon, 07 May 2012 17:33:51 +0000

Revision: 9297
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9297
Author:   sigurdne
Date:     2012-05-07 17:33:50 +0000 (Mon, 07 May 2012)
Log Message:
-----------
property: custom functions

Modified Paths:
--------------
    trunk/phpgwapi/inc/class.custom_fields.inc.php
    trunk/property/inc/class.botts.inc.php
    trunk/property/inc/class.custom_fields.inc.php
    trunk/property/inc/class.sotts.inc.php
    trunk/property/inc/class.uitts.inc.php

Modified: trunk/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.custom_fields.inc.php      2012-05-07 14:00:35 UTC 
(rev 9296)
+++ trunk/phpgwapi/inc/class.custom_fields.inc.php      2012-05-07 17:33:50 UTC 
(rev 9297)
@@ -468,7 +468,7 @@
                                                break;
 
                                        case 'D':
-                                               $ts = 
phpgwapi_datetime::date_to_timestamp($attrib['value']);
+                                               $ts = 
phpgwapi_datetime::date_to_timestamp($attrib['value']) - 
phpgwapi_datetime::user_timezone();
                                                $attrib['value'] = 
date($this->_dateformat, $ts);
                                                break;
 
@@ -476,7 +476,7 @@
                                                if($attrib['value']['date'])
                                                {
                                                        $date_array     = 
phpgwapi_datetime::date_array($attrib['value']['date']);
-                                                       $ts = mktime 
((int)$attrib['value']['hour'], (int)$attrib['value']['min'], 0, 
$date_array['month'], $date_array['day'], $date_array['year']);
+                                                       $ts = mktime 
((int)$attrib['value']['hour'], (int)$attrib['value']['min'], 0, 
$date_array['month'], $date_array['day'], $date_array['year']) - 
phpgwapi_datetime::user_timezone();
                                                        $attrib['value'] = 
date($this->_datetimeformat, $ts);
                                                }
                                                else

Modified: trunk/property/inc/class.botts.inc.php
===================================================================
--- trunk/property/inc/class.botts.inc.php      2012-05-07 14:00:35 UTC (rev 
9296)
+++ trunk/property/inc/class.botts.inc.php      2012-05-07 17:33:50 UTC (rev 
9297)
@@ -231,6 +231,25 @@
                                        'name'=> lang('assignedto')
                                );
 
+                       if( $GLOBALS['phpgw']->acl->check('.ticket.order', 
PHPGW_ACL_ADD, 'property') )
+                       {
+                               $columns['order_id'] = array
+                                       (
+                                               'id' => 'order_id',
+                                               'name'=> lang('order id')
+                                       );
+                               $columns['estimate'] = array
+                                       (
+                                               'id' => 'estimate',
+                                               'name'=> lang('estimate')
+                                       );
+                               $columns['actual_cost'] = array
+                                       (
+                                               'id' => 'actual_cost',
+                                               'name'=> lang('actual cost')
+                                       );
+                       }
+
                        $columns['vendor'] = array
                                (
                                        'id' => 'vendor',

Modified: trunk/property/inc/class.custom_fields.inc.php
===================================================================
--- trunk/property/inc/class.custom_fields.inc.php      2012-05-07 14:00:35 UTC 
(rev 9296)
+++ trunk/property/inc/class.custom_fields.inc.php      2012-05-07 17:33:50 UTC 
(rev 9297)
@@ -51,6 +51,7 @@
                public function __construct($appname = null)
                {
                        parent::__construct($appname);
+                       $this->_db2 = clone($this->_db);                        
                }
 
                /**
@@ -133,8 +134,8 @@
                                                        $timestamp= 
strtotime($attributes['value']);
                                                        $attributes['value'] = 
array();
                                                        
$attributes['value']['date'] = 
$GLOBALS['phpgw']->common->show_date($timestamp,$dateformat);
-                                                       
$attributes['value']['hour'] = date('H', $timestamp);
-                                                       
$attributes['value']['min'] = date('i', $timestamp);
+                                                       
$attributes['value']['hour'] = date('H', $timestamp + 
phpgwapi_datetime::user_timezone());
+                                                       
$attributes['value']['min'] = date('i', $timestamp + 
phpgwapi_datetime::user_timezone());
 
                                                }
                                                else
@@ -417,7 +418,7 @@
                                        {
                                                if($entry['datatype'] == 'C' || 
$entry['datatype'] == 'T' || $entry['datatype'] == 'V' || $entry['datatype'] == 
'link')
                                                {
-                                                       $entry['value'] = 
$this->_db->db_addslashes($entry['value']);
+                                                       $entry['value'] = 
$this->_db2->db_addslashes($entry['value']);
                                                }
 
                                                if($entry['datatype'] == 'pwd' 
&& $entry['value'] && $entry['value2'])
@@ -444,9 +445,9 @@
                                        {
                                                if($id)
                                                {
-                                                       
$this->_db->query("SELECT {$entry['name']} FROM $table WHERE id = 
{$id}",__LINE__,__FILE__);
-                                                       
$this->_db->next_record();
-                                                       $old_value = 
$this->_db->f($entry['name']);
+                                                       
$this->_db2->query("SELECT {$entry['name']} FROM $table WHERE id = 
{$id}",__LINE__,__FILE__);
+                                                       
$this->_db2->next_record();
+                                                       $old_value = 
$this->_db2->f($entry['name']);
                                                        if($entry['value'] != 
$old_value)
                                                        {
                                                                
$data['history_set'][$entry['attrib_id']] = array
@@ -466,6 +467,89 @@
                        return $data;
                }
 
+               public function get_translated_value($data, $location_id)
+               {
+                       if(!$data['value'])
+                       {
+                               return $data['value'];
+                       }
+
+                       $ret = '';
+                       switch($data['datatype'])
+                       {
+                               case 'R':
+                               case 'LB':
+                                       if($data['attrib_id'])
+                                       {
+                                               $sql="SELECT value FROM 
$choice_table WHERE $attribute_filter AND attrib_id=" .(int)$data['attrib_id']. 
"  AND id=" . (int)$data['value'];
+                                               $this->_db2->query($sql);
+                                               $this->_db2->next_record();
+                                               $ret =  $this->_db2->f('value');
+                                       }
+                                       break;
+                               case 'AB':
+                                       $contact_data   = 
$contacts->read_single_entry($data['value'],array('fn'));
+                                       $ret =  $contact_data[0]['fn'];
+                                       break;
+                               case 'ABO':
+                                       $contact_data   = 
$contacts->get_principal_organizations_data($data['value']);
+                                       $ret = $contact_data[0]['org_name'];
+                                       break;
+                               case 'VENDOR':
+                                       $sql="SELECT org_name FROM fm_vendor 
where id=" . (int)$data['value'];
+                                       $this->_db2->query($sql);
+                                       $this->_db2->next_record();
+                                       $ret =  $this->_db2->f('org_name',true);
+                                       break;
+                               case 'CH':
+                                       $ch = explode(',', trim($data['value'], 
','));
+                                       if (isset($ch) AND is_array($ch))
+                                       {
+                                               for ($k=0;$k<count($ch);$k++)
+                                               {
+                                                       $sql="SELECT value FROM 
$choice_table WHERE $attribute_filter AND attrib_id= " . 
(int)$data['attrib_id'] . ' AND id = ' . (int)$ch[$k];
+                                                       
$this->_db2->query($sql);
+                                                       while 
($this->_db2->next_record())
+                                                       {
+                                                               
$ch_value[]=$this->_db2->f('value');
+                                                       }
+                                               }
+                                               $ret =  @implode(",", 
$ch_value);
+                                               unset($ch_value);
+                                       }
+                                       break;
+                               case 'D':
+                                       $ret =  
$GLOBALS['phpgw']->common->show_date(strtotime($data['value']), 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                       break;
+                               case 'DT':
+                                       $ret =  
$GLOBALS['phpgw']->common->show_date(strtotime($data['value']));
+                                       break;
+                               case 'timestamp':
+               //                      $ret =  
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$data['value']);
+                                       $ret =  
$GLOBALS['phpgw']->common->show_date($data['value']);
+                                       break;
+                               case 'link':
+                                       $ret =  
phpgw::safe_redirect($data['value']);
+                                       break;
+                               case 'user':
+                                       $ret =   
$GLOBALS['phpgw']->accounts->get($data['value'])->__toString();
+                                       break;
+                               case 'pwd':
+                                       $ret =   lang('yes');
+                                       break;
+                               default:
+                                       if(is_array($data['value']))
+                                       {
+                                               $ret =  $data['value'];         
                                                
+                                       }
+                                       else
+                                       {
+                                               $ret =  
stripslashes($data['value']);
+                                       }
+                       }
+                       return $ret;
+               }
+
                function translate_value($values, $location_id, $location_count 
= 0)
                {
                        $choice_table = 'phpgw_cust_choice';
@@ -485,78 +569,7 @@
                                                $location = 
explode('-',$data['value']);
                                        }
 
-                                       $ret[$j][$field] = '';
-                                       if($data['value'])
-                                       {
-                                               switch($data['datatype'])
-                                               {
-                                                       case 'R':
-                                                       case 'LB':
-                                                               
if($data['attrib_id'])
-                                                               {
-                                                                       
$sql="SELECT value FROM $choice_table WHERE $attribute_filter AND attrib_id=" 
.(int)$data['attrib_id']. "  AND id=" . (int)$data['value'];
-                                                                       
$this->_db->query($sql);
-                                                                       
$this->_db->next_record();
-                                                                       
$ret[$j][$field] =  $this->_db->f('value');
-                                                               }
-                                                               break;
-                                                       case 'AB':
-                                                               $contact_data   
= $contacts->read_single_entry($data['value'],array('fn'));
-                                                               
$ret[$j][$field] =  $contact_data[0]['fn'];
-                                                               break;
-                                                       case 'ABO':
-                                                               $contact_data   
= $contacts->get_principal_organizations_data($data['value']);
-                                                               
$ret[$j][$field] = $contact_data[0]['org_name'];
-                                                               break;
-                                                       case 'VENDOR':
-                                                               $sql="SELECT 
org_name FROM fm_vendor where id=" . (int)$data['value'];
-                                                               
$this->_db->query($sql);
-                                                               
$this->_db->next_record();
-                                                               
$ret[$j][$field] =  $this->_db->f('org_name',true);
-                                                               break;
-                                                       case 'CH':
-                                                               $ch = 
explode(',', trim($data['value'], ','));
-                                                               if (isset($ch) 
AND is_array($ch))
-                                                               {
-                                                                       for 
($k=0;$k<count($ch);$k++)
-                                                                       {
-                                                                               
$sql="SELECT value FROM $choice_table WHERE $attribute_filter AND attrib_id= " 
. (int)$data['attrib_id'] . ' AND id = ' . (int)$ch[$k];
-                                                                               
$this->_db->query($sql);
-                                                                               
while ($this->_db->next_record())
-                                                                               
{
-                                                                               
        $ch_value[]=$this->_db->f('value');
-                                                                               
}
-                                                                       }
-                                                                       
$ret[$j][$field] =  @implode(",", $ch_value);
-                                                                       
unset($ch_value);
-                                                               }
-                                                               break;
-                                                       case 'D':
-                                                               
$ret[$j][$field] =  
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($data['value']));
-                                                               break;
-                                                       case 'timestamp':
-                                                               
$ret[$j][$field] =  
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$data['value']);
-                                                               break;
-                                                       case 'link':
-                                                               
$ret[$j][$field] =  phpgw::safe_redirect($data['value']);
-                                                               break;
-                                                       case 'user':
-                                                               
$ret[$j][$field] =   
$GLOBALS['phpgw']->accounts->get($data['value'])->__toString();
-                                                               break;
-                                                       case 'pwd':
-                                                               
$ret[$j][$field] =   lang('yes');
-                                                               break;
-                                                       default:
-                                                               
if(is_array($data['value']))
-                                                               {
-                                                                       
$ret[$j][$field] =  $data['value'];                                             
                
-                                                               }
-                                                               else
-                                                               {
-                                                                       
$ret[$j][$field] =  stripslashes($data['value']);
-                                                               }
-                                               }
-                                       }
+                                       $ret[$j][$field] = 
$this->get_translated_value($data, $location_id);
 
                                        if($location)
                                        {

Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php      2012-05-07 14:00:35 UTC (rev 
9296)
+++ trunk/property/inc/class.sotts.inc.php      2012-05-07 17:33:50 UTC (rev 
9297)
@@ -493,6 +493,8 @@
                        $this->sum_budget               = 
$cache_info['sum_budget'];
                        $this->sum_actual_cost  = 
$cache_info['sum_actual_cost'];
 
+                       $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', '.ticket');
+
                        $tickets = array();
                        if(!$dry_run)
                        {
@@ -547,17 +549,7 @@
                                        {
                                                if($custom_value = 
$this->db->f($custom_col['column_name'],true))
                                                {
-                                                       
switch($custom_col['datatype'])
-                                                       {
-                                                               case 'DT':
-                                                                       
$custom_value = $GLOBALS['phpgw']->common->show_date(strtotime($custom_value) - 
phpgwapi_datetime::user_timezone());
-                                                                       break;
-                                                               case 'D':
-                                                                       
$custom_value = $GLOBALS['phpgw']->common->show_date(strtotime($custom_value) - 
phpgwapi_datetime::user_timezone(),$this->dateformat);
-                                                                       break;
-                                                               default:
-                                                               // nothing
-                                                       }
+                                                       $custom_value = 
$this->custom->get_translated_value(array('value' =>$custom_value, 'attrib_id' 
=> $custom_col['attrib_id'], 'datatype' => $custom_col['datatype'] ), 
$location_id);
                                                }
                                                
$tickets[$i][$custom_col['column_name']] = $custom_value;
                                        }

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2012-05-07 14:00:35 UTC (rev 
9296)
+++ trunk/property/inc/class.uitts.inc.php      2012-05-07 17:33:50 UTC (rev 
9297)
@@ -940,31 +940,6 @@
                        }
 
 
-                       if( $order_read )
-                       {
-                               $uicols['name'][] = 'order_id';
-                               $uicols['descr'][]      = lang('order id');
-//                             $uicols['name'][] = 'vendor';
-//                             $uicols['descr'][]      = lang('vendor');
-                       }
-
-                       if( $this->acl->check('.ticket.order', PHPGW_ACL_ADD, 
'property') )
-                       {
-                               $uicols['name'][] = 'estimate';
-                               $uicols['descr'][]      = lang('estimate');
-                               $uicols['name'][] = 'actual_cost';
-                               $uicols['descr'][]      = lang('actual cost');
-                       }
-
-/*
-                       if( $this->show_finnish_date )
-                       {
-                               $uicols['name'][] = 'finnish_date';
-                               $uicols['descr'][]      = lang('finnish date');
-                               $uicols['name'][] = 'delay';
-                               $uicols['descr'][]      = lang('delay');
-                       }
-*/
                        $uicols['name'][] = 'child_date';
                        $uicols['descr'][]      = lang('child date');
                        $uicols['name'][] = 'link_view';




reply via email to

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