fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15601] property: custom column


From: sigurdne
Subject: [Fmsystem-commits] [15601] property: custom column
Date: Wed, 7 Sep 2016 11:28:23 +0000 (UTC)

Revision: 15601
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15601
Author:   sigurdne
Date:     2016-09-07 11:28:22 +0000 (Wed, 07 Sep 2016)
Log Message:
-----------
property: custom column

Modified Paths:
--------------
    trunk/property/inc/class.bolocation.inc.php
    trunk/property/inc/class.solocation.inc.php

Modified: trunk/property/inc/class.bolocation.inc.php
===================================================================
--- trunk/property/inc/class.bolocation.inc.php 2016-09-07 00:52:42 UTC (rev 
15600)
+++ trunk/property/inc/class.bolocation.inc.php 2016-09-07 11:28:22 UTC (rev 
15601)
@@ -180,11 +180,26 @@
                                $selected = 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['location_columns_'
 . $this->type_id . !!$this->lookup]) ? 
$GLOBALS['phpgw_info']['user']['preferences']['property']["location_columns_" . 
$this->type_id . !!$this->lookup] : '';
                        }
                        $filter = array('list' => ''); // translates to "list 
IS NULL"
-                       $columns = $this->custom->find('property', '.location.' 
. $type_id, 0, '', '', '', true, false, $filter);
-                       $column_list = 
$this->bocommon->select_multi_list($selected, $columns);
-                       return $column_list;
+                       //$columns = $this->custom->find('property', 
'.location.' . $type_id, 0, '', '', '', true, false, $filter);
+
+                       $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', ".location.{$this->type_id}");
+
+                       $columns = $this->so->get_column_list($location_id);
+                       $columns = array_merge($columns, 
$this->get_column_list());
+                       return $this->bocommon->select_multi_list($selected, 
$columns);
                }
 
+               function get_column_list()
+               {
+                       $columns = array();
+//                     $columns['category_text'] = array(
+//                             'id' => 'category_text',
+//                             'name' => lang('category'),
+//                             'sortable' => false
+//                     );
+                       return $columns;
+               }
+
                function select_status_list( $format = '', $selected = '' )
                {
                        switch ($format)
@@ -751,6 +766,32 @@
                        $this->total_records = $this->so->total_records;
                        $this->uicols = $this->so->uicols;
 
+                       $custom_cols = 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['location_columns_'
 . $this->type_id . !!$this->lookup]) ? 
$GLOBALS['phpgw_info']['user']['preferences']['property']["location_columns_" . 
$this->type_id . !!$this->lookup] : '';
+
+                       $column_list = $this->get_column_list();
+                       $get_vendor_names = false;
+
+                       foreach ($custom_cols as $col_id)
+                       {
+                               if (!ctype_digit($col_id))
+                               {
+                                       $this->uicols['input_type'][] = 'text';
+                                       $this->uicols['name'][] = $col_id;
+                                       $this->uicols['descr'][] = 
$column_list[$col_id]['name'];
+                                       $this->uicols['statustext'][] = 
$column_list[$col_id]['name'];
+                                       $this->uicols['exchange'][] = false;
+                                       $this->uicols['align'][] = '';
+                                       $this->uicols['datatype'][] = false;
+                                       $this->uicols['sortable'][] = 
$column_list[$col_id]['sortable'];
+                                       $this->uicols['formatter'][] = 
$column_list[$col_id]['formatter'];
+                                       $this->uicols['classname'][] = 
$column_list[$col_id]['classname'];
+                                       if ($col_id == 'vendor_names')
+                                       {
+                                               $get_vendor_names = true;
+                                       }
+                               }
+                       }
+
                        return $locations;
                }
 

Modified: trunk/property/inc/class.solocation.inc.php
===================================================================
--- trunk/property/inc/class.solocation.inc.php 2016-09-07 00:52:42 UTC (rev 
15600)
+++ trunk/property/inc/class.solocation.inc.php 2016-09-07 11:28:22 UTC (rev 
15601)
@@ -285,6 +285,51 @@
                        return $this->db->next_record();
                }
 
+               function get_column_list($location_id)
+               {
+                       $sql = "SELECT * FROM phpgw_cust_attribute "
+                               . " WHERE location_id = {$location_id}"
+                               . " AND custom = 1 OR column_name = 'category'";
+
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       
+                       while ($this->db->next_record())
+                       {
+                       $attribs = array();
+                               $id = $this->db->f('id');
+                               $attribs[$id] = array
+                               (
+                                       'id'                                    
=> $id,
+                                       'group_id'                              
=> (int) $this->db->f('group_id'),
+                                       'attrib_sort'                   => 
(int) $this->db->f('attrib_sort'),
+                                       'list'                                  
=> $this->db->f('list'),
+                                       'lookup_form'                   => 
$this->db->f('lookup_form'),
+                                       'entity_form'                   => 
$this->db->f('entity_form'),
+                                       'column_name'                   => 
$this->db->f('column_name'),
+                                       'name'                                  
=> $this->db->f('column_name'),
+                                       'size'                                  
=> $this->db->f('size'),
+                                       'precision'                             
=> $this->db->f('precision_'),
+                                       'statustext'                    => 
$this->db->f('statustext', true),
+                                       'input_text'                    => 
$this->db->f('input_text', true),
+                                       'type_name'                             
=> $this->db->f('type'),
+                                       'datatype'                              
=> $this->db->f('datatype'),
+                                       'search'                                
=> $this->db->f('search'),
+                                       'nullable'                              
=> ($this->db->f('nullable') == 'True'),
+                                       'history'                               
=> $this->db->f('history'),
+                                       'disabled'                              
=> $this->db->f('disabled'),
+                                       'helpmsg'                               
=> !!$this->db->f('helpmsg'),
+                                       'get_list_function'             => 
$this->db->f('get_list_function'),
+                                       'get_list_function_input' => 
$this->db->f('get_list_function_input') ? 
unserialize($this->db->f('get_list_function_input', true)) : '',
+                                       'get_single_function'           => 
$this->db->f('get_single_function'),
+                                       'get_single_function_input' => 
$this->db->f('get_single_function_input') ? 
unserialize($this->db->f('get_single_function_input', true)) : '',
+                                       'short_description'                     
=> $this->db->f('short_description'),
+                                       'javascript_action'                     
=> $this->db->f('javascript_action',true),
+                                       'default_value'                         
=> $this->db->f('default_value',true)
+                               );
+                       }
+                       return $attribs;
+               }
+
                function read( $data )
                {
                        $start = isset($data['start']) && $data['start'] ? 
$data['start'] : 0;
@@ -615,11 +660,19 @@
 
                        //---------------------start custom user cols
 
-                       $user_columns = 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['location_columns_'
 . $type_id . !!$lookup]) ? 
$GLOBALS['phpgw_info']['user']['preferences']['property']['location_columns_' . 
$type_id . !!$lookup] : '';
+                       $user_columns = 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['location_columns_'
 . $type_id . !!$lookup]) ? 
$GLOBALS['phpgw_info']['user']['preferences']['property']['location_columns_' . 
$type_id . !!$lookup] : array();
+                       $_user_columns = array();
+                       foreach ($user_columns as $user_column_id)
+                       {
+                               if (ctype_digit($user_column_id))
+                               {
+                                       $_user_columns[] = $user_column_id;
+                               }
+                       }
                        $user_column_filter = '';
-                       if (isset($user_columns) AND is_array($user_columns) 
AND $user_columns[0])
+                       if ($_user_columns)
                        {
-                               $user_column_filter = " OR ($attribute_filter 
AND id IN (" . implode(',', $user_columns) . '))';
+                               $user_column_filter = " OR ($attribute_filter 
AND id IN (" . implode(',', $_user_columns) . '))';
                        }
 
                        $this->db->query("SELECT DISTINCT * FROM 
$attribute_table WHERE (list=1 OR lookup_form=1) AND $attribute_filter 
$user_column_filter ORDER BY attrib_sort ASC");




reply via email to

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