fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [13089] class.uicustom.inc.php


From: Saul
Subject: [Fmsystem-commits] [13089] class.uicustom.inc.php
Date: Fri, 24 Apr 2015 23:08:25 +0000

Revision: 13089
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13089
Author:   psaul
Date:     2015-04-24 23:08:24 +0000 (Fri, 24 Apr 2015)
Log Message:
-----------
class.uicustom.inc.php

Modified Paths:
--------------
    branches/dev-syncromind/property/inc/class.uicustom.inc.php

Modified: branches/dev-syncromind/property/inc/class.uicustom.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.uicustom.inc.php 2015-04-24 
23:07:42 UTC (rev 13088)
+++ branches/dev-syncromind/property/inc/class.uicustom.inc.php 2015-04-24 
23:08:24 UTC (rev 13089)
@@ -53,7 +53,8 @@
                                'edit'          => true,
                                'download'      => true,
                                'delete'        => true,
-                'save'      => true
+                'save'      => true,
+                'query_view' => true,
                        );
 
                function __construct()
@@ -504,238 +505,333 @@
                function view()
                {
                        $custom_id      = phpgw::get_var('custom_id', 
'int','GET');
-
-                       $datatable = array();
-
-                       if( phpgw::get_var('phpgw_return_as') != 'json' )
-                       {
-                               $datatable['menu']      = 
$this->bocommon->get_menu();
-
-                               $datatable['config']['base_url'] = 
$GLOBALS['phpgw']->link('/index.php', array
-                                       (
-                                               'menuaction'    => 
'property.uicustom.view',
-                                               'sort'          => $this->sort,
-                                               'order'         => $this->order,
+                        
+//                     $datatable = array();
+            
+            
self::add_javascript('phpgwapi','jquery','editable/jquery.jeditable.js');
+            
self::add_javascript('phpgwapi','jquery','editable/jquery.dataTables.editable.js');
+            
+            $appname                                   = lang('documents');
+                       $function_msg                           = lang('list 
documents');
+            
+            $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . 
' - ' . $appname . ': ' . $function_msg;
+            
+            if( phpgw::get_var('phpgw_return_as') == 'json' )
+            {
+                return $this->query_view($custom_id);
+            }
+            
+            $data = array(
+                'datatable_name' => $appname,
+                'form' => array(
+                   'toolbar' => array(
+                       'item' => array(
+   
+                       )
+                   )
+                ),
+                'datatable' => array(
+                    'source' => self::link(array(
+                        'menuaction'   => 'property.uicustom.view',
                                                'custom_id'     => $custom_id,
                                                'filter'        => 
$this->filter,
-                                               'query'         => $this->query
-                                       ));
-
-                               $datatable['config']['base_java_url'] = 
"menuaction:'property.uicustom.view',"
-                                       ."sort:'{$this->sort}',"
-                                       ."order:'{$this->order}',"
-                                       ."custom_id:'{$custom_id}',"
-                                       ."filter:'{$this->filter}',"
-                                       ."query:'{$this->query}'";
-
-                               $link_data = array
-                                       (
-                                               'menuaction'    => 
'property.uicustom.view',
-                                               'sort'          => $this->sort,
-                                               'order'         => $this->order,
-                                               'custom_id'     => $custom_id,
-                                               'filter'        => 
$this->filter,
-                                               'query'         => $this->query
-                                       );
-
-                               $datatable['config']['allow_allrows'] = true;
-
-                               $datatable['actions']['form'] = array
-                                       (
-                                               array
-                                               (
-                                                       'action'        => 
$GLOBALS['phpgw']->link('/index.php',
-                                                       array
-                                                       (
-                                                               'menuaction'    
=> 'property.uicustom.view',
-                                                               'sort'          
=> $this->sort,
-                                                               'order'         
=> $this->order,
-                                                               'custom_id'     
=> $custom_id,
-                                                               'filter'        
=> $this->filter,
-                                                               'query'         
=> $this->query
-                                                       )
-                                               ),
-                                               'fields'        => array
-                                               (
-                                                       'field' => array
-                                                       (
-                                                               'type'  => 
'button',
-                                                               'id'    => 
'btn_export',
-                                                               'value' => 
lang('download'),
-                                                               'tab_index' => 1
-                                                       )
-                                               )
-                                       )
-                               );
-                       }
+                        'phpgw_return_as'   => 'json'
+                    )),
+                    'download' => self::link(array(
+                               'menuaction'    => 'property.uicustom.download',
+                            'filter'   => $this->filter,
+                            'custom_id'        => $custom_id,
+                            'export'           => true,
+                                                       'skip_origin'   => true,
+                                                       'allrows'               
=> true
+                    )),
+                    'allrows' => true,
+                    'editor_action' => '',
+                    'field' => array()
+                )
+            );
+            
+//                     if( phpgw::get_var('phpgw_return_as') != 'json' )
+//                     {
+//                             $datatable['menu']      = 
$this->bocommon->get_menu();
+//
+//                             $datatable['config']['base_url'] = 
$GLOBALS['phpgw']->link('/index.php', array
+//                                     (
+//                                             'menuaction'    => 
'property.uicustom.view',
+//                                             'sort'          => $this->sort,
+//                                             'order'         => $this->order,
+//                                             'custom_id'     => $custom_id,
+//                                             'filter'        => 
$this->filter,
+//                                             'query'         => $this->query
+//                                     ));
+//
+//                             $datatable['config']['base_java_url'] = 
"menuaction:'property.uicustom.view',"
+//                                     ."sort:'{$this->sort}',"
+//                                     ."order:'{$this->order}',"
+//                                     ."custom_id:'{$custom_id}',"
+//                                     ."filter:'{$this->filter}',"
+//                                     ."query:'{$this->query}'";
+//
+//                             $link_data = array
+//                                     (
+//                                             'menuaction'    => 
'property.uicustom.view',
+//                                             'sort'          => $this->sort,
+//                                             'order'         => $this->order,
+//                                             'custom_id'     => $custom_id,
+//                                             'filter'        => 
$this->filter,
+//                                             'query'         => $this->query
+//                                     );
+//
+//                             $datatable['config']['allow_allrows'] = true;
+//
+//                             $datatable['actions']['form'] = array
+//                                     (
+//                                             array
+//                                             (
+//                                                     'action'        => 
$GLOBALS['phpgw']->link('/index.php',
+//                                                     array
+//                                                     (
+//                                                             'menuaction'    
=> 'property.uicustom.view',
+//                                                             'sort'          
=> $this->sort,
+//                                                             'order'         
=> $this->order,
+//                                                             'custom_id'     
=> $custom_id,
+//                                                             'filter'        
=> $this->filter,
+//                                                             'query'         
=> $this->query
+//                                                     )
+//                                             ),
+//                                             'fields'        => array
+//                                             (
+//                                                     'field' => array
+//                                                     (
+//                                                             'type'  => 
'button',
+//                                                             'id'    => 
'btn_export',
+//                                                             'value' => 
lang('download'),
+//                                                             'tab_index' => 1
+//                                                     )
+//                                             )
+//                                     )
+//                             );
+//                     }
                        //_debug_array($custom_id);die;
-                       $list = $this->bo->read_custom($custom_id);
+           
+                       $list = $this->bo->read_custom(array('custom_id' => 
$custom_id));
                        $uicols = $this->bo->uicols;
-                       $j = 0;
+            
                        $count_uicols_name = count($uicols);
 
-                       if (isset($list) AND is_array($list))
-                       {
-                               foreach($list as $list_entry)
-                               {
-                                       for ($k=0;$k<$count_uicols_name;$k++)
-                                       {
-                                               
$datatable['rows']['row'][$j]['column'][$k]['name']                     = 
$uicols[$k]['name'];
-                                               
$datatable['rows']['row'][$j]['column'][$k]['value']                    = 
$list_entry[$uicols[$k]['name']];
-                                       }
-                                       $j++;
-                               }
-
-                               $datatable['rowactions']['action'] = array();
-
-                       }
+//                     if (isset($list) AND is_array($list))
+//                     {
+//                             foreach($list as $list_entry)
+//                             {
+//                                     for ($k=0;$k<$count_uicols_name;$k++)
+//                                     {
+//                                             
$datatable['rows']['row'][$j]['column'][$k]['name']                     = 
$uicols[$k]['name'];
+//                                             
$datatable['rows']['row'][$j]['column'][$k]['value']                    = 
$list_entry[$uicols[$k]['name']];
+//                                     }
+//                                     $j++;
+//                             }
+//
+//                             $datatable['rowactions']['action'] = array();
+//
+//                     }
                        //_debug_array($datatable);die;
 
-                       for ($i=0;$i<$count_uicols_name;$i++)
-                       {
-                               if($uicols['input_type'][$i]!='hidden')
-                               {
-                                       
$datatable['headers']['header'][$i]['formatter']                = 
($uicols[$i]['formatter']==''?  '""' : $uicols[$i]['formatter']);
-                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols[$i]['name'];
-                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols[$i]['descr'];
-                                       
$datatable['headers']['header'][$i]['visible']                  = true;
-                                       
$datatable['headers']['header'][$i]['sortable']                 = false;
-                               }
+                       for ($i = 0; $i < $count_uicols_name; $i++)
+                       {   
+                
+                $params = array
+                            (
+                                'key'       =>  $uicols[$i]['name'],
+                                'label'     =>  $uicols[$i]['descr'],
+                                'sortable'  =>  
($uicols[$i]['sortable'])?true:false,
+                                'hidden'    =>  ($uicols[$i]['input_type'] == 
'hidden')?true:false
+                            );
+                
+//                             if($uicols['input_type'][$i]!='hidden')
+//                             {
+//                                     
$datatable['headers']['header'][$i]['formatter']                = 
($uicols[$i]['formatter']==''?  '""' : $uicols[$i]['formatter']);
+//                                     
$datatable['headers']['header'][$i]['name']                     = 
$uicols[$i]['name'];
+//                                     
$datatable['headers']['header'][$i]['text']                     = 
$uicols[$i]['descr'];
+//                                     
$datatable['headers']['header'][$i]['visible']                  = true;
+//                                     
$datatable['headers']['header'][$i]['sortable']                 = false;
+//                             }
+                array_push($data['datatable']['field'], $params);
                        }
+            
+            $data['datatable']['actions'][] = array();
+//                     $link_download = array
+//                             (
+//                                     'menuaction'    => 
'property.uicustom.download',
+//                                     'sort'          => $this->sort,
+//                                     'order'         => $this->order,
+//                                     'filter'        => $this->filter,
+//                                     'query'         => $this->query,
+//                                     'custom_id'     => $custom_id,
+//                                     'allrows'       => $this->allrows
+//                             );
 
-                       $link_download = array
-                               (
-                                       'menuaction'    => 
'property.uicustom.download',
-                                       'sort'          => $this->sort,
-                                       'order'         => $this->order,
-                                       'filter'        => $this->filter,
-                                       'query'         => $this->query,
-                                       'custom_id'     => $custom_id,
-                                       'allrows'       => $this->allrows
-                               );
-
-                       //path for property.js
-                       $property_js = "/property/js/yahoo/property.js";
-
-                       if 
(!isset($GLOBALS['phpgw_info']['server']['no_jscombine']) || 
!$GLOBALS['phpgw_info']['server']['no_jscombine'])
-                       {
-                               $cachedir = 
urlencode($GLOBALS['phpgw_info']['server']['temp_dir']);
-                               $property_js = 
"/phpgwapi/inc/combine.php?cachedir={$cachedir}&type=javascript&files=" . 
str_replace('/', '--', ltrim($property_js,'/'));
-                       }
-
-                       $datatable['property_js'] = 
$GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js;
-
-                       // Pagination and sort values
-                       $datatable['pagination']['records_start']       = 
(int)$this->bo->start;
-                       $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-                       $datatable['pagination']['records_returned']= 
count($list);
-                       $datatable['pagination']['records_total']       = 
$this->bo->total_records;
-
-                       $appname                                        = 
lang('documents');
-                       $function_msg                           = lang('list 
documents');
-
-                       //_debug_array($datatable['headers']['header']);die;
-
-                       if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
-                       {
-                               $datatable['sorting']['order']                  
= $datatable['headers']['header'][0]['name']; // name key Column in myColumnDef
-                               $datatable['sorting']['sort']                   
= 'asc'; // ASC / DESC
-                       }
-                       else
-                       {
-                               $datatable['sorting']['order']                  
= null; // name of column of Database
-                               $datatable['sorting']['sort']                   
= null; // ASC / DESC
-                       }
-
-                       phpgwapi_yui::load_widget('dragdrop');
-                       phpgwapi_yui::load_widget('datatable');
-                       phpgwapi_yui::load_widget('menu');
-                       phpgwapi_yui::load_widget('connection');
-                       phpgwapi_yui::load_widget('loader');
-                       phpgwapi_yui::load_widget('tabview');
-                       phpgwapi_yui::load_widget('paginator');
-                       phpgwapi_yui::load_widget('animation');
-
-
-                       //-- BEGIN----------------------------- JSON CODE 
------------------------------
-                       //values for Pagination
-                       $json = array
-                               (
-                                       'recordsReturned'       => 
$datatable['pagination']['records_returned'],
-                                       'totalRecords'          => 
(int)$datatable['pagination']['records_total'],
-                                       'startIndex'            => 
$datatable['pagination']['records_start'],
-                                       'sort'                          => 
$datatable['sorting']['order'],
-                                       'dir'                           => 
$datatable['sorting']['sort'],
-                                       'records'                       => 
array()
-                               );
-
-                       // values for datatable
-                       if(isset($datatable['rows']['row']) && 
is_array($datatable['rows']['row'])){
-                               foreach( $datatable['rows']['row'] as $row )
-                               {
-                                       $json_row = array();
-                                       foreach( $row['column'] as $column)
-                                       {
-                                               if(isset($column['format']) && 
$column['format']== "link" && $column['java_link']==true)
-                                               {
-                                                       
$json_row[$column['name']] = "<a href='#' id='".$column['link']."' 
onclick='javascript:filter_data(this.id);'>" .$column['value']."</a>";
-                                               }
-                                               else 
if(isset($column['format']) && $column['format']== "link")
-                                               {
-                                                       
$json_row[$column['name']] = "<a href='".$column['link']."'>" 
.$column['value']."</a>";
-                                               }
-                                               else
-                                               {
-                                                       
$json_row[$column['name']] = $column['value'];
-                                               }
-                                       }
-                                       $json['records'][] = $json_row;
-                               }
-                       }
-
-                       // right in datatable
-                       if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
-                       {
-                               $json ['rights'] = 
$datatable['rowactions']['action'];
-                       }
-
-                       if( phpgw::get_var('phpgw_return_as') == 'json' )
-                       {
-                               return $json;
-                       }
-
-
-                       $datatable['json_data'] = json_encode($json);
-                       //-------------------- JSON CODE ----------------------
-
-                       $template_vars = array();
-                       $template_vars['datatable'] = $datatable;
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
-                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
$template_vars);
-
-                       if ( !isset($GLOBALS['phpgw']->css) || 
!is_object($GLOBALS['phpgw']->css) )
-                       {
-                               $GLOBALS['phpgw']->css = 
createObject('phpgwapi.css');
-                       }
-
-                       $GLOBALS['phpgw']->css->validate_file('datatable');
-                       $GLOBALS['phpgw']->css->validate_file('property');
-                       
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-
-                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'custom.view', 'property' );
+            
+//            
+//                     //path for property.js
+//                     $property_js = "/property/js/yahoo/property.js";
+//
+//                     if 
(!isset($GLOBALS['phpgw_info']['server']['no_jscombine']) || 
!$GLOBALS['phpgw_info']['server']['no_jscombine'])
+//                     {
+//                             $cachedir = 
urlencode($GLOBALS['phpgw_info']['server']['temp_dir']);
+//                             $property_js = 
"/phpgwapi/inc/combine.php?cachedir={$cachedir}&type=javascript&files=" . 
str_replace('/', '--', ltrim($property_js,'/'));
+//                     }
+//
+//                     $datatable['property_js'] = 
$GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js;
+//
+//                     // Pagination and sort values
+//                     $datatable['pagination']['records_start']       = 
(int)$this->bo->start;
+//                     $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+//                     $datatable['pagination']['records_returned']= 
count($list);
+//                     $datatable['pagination']['records_total']       = 
$this->bo->total_records;
+//
+//                     $appname                                        = 
lang('documents');
+//                     $function_msg                           = lang('list 
documents');
+//
+//                     //_debug_array($datatable['headers']['header']);die;
+//
+//                     if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
+//                     {
+//                             $datatable['sorting']['order']                  
= $datatable['headers']['header'][0]['name']; // name key Column in myColumnDef
+//                             $datatable['sorting']['sort']                   
= 'asc'; // ASC / DESC
+//                     }
+//                     else
+//                     {
+//                             $datatable['sorting']['order']                  
= null; // name of column of Database
+//                             $datatable['sorting']['sort']                   
= null; // ASC / DESC
+//                     }
+//
+//                     phpgwapi_yui::load_widget('dragdrop');
+//                     phpgwapi_yui::load_widget('datatable');
+//                     phpgwapi_yui::load_widget('menu');
+//                     phpgwapi_yui::load_widget('connection');
+//                     phpgwapi_yui::load_widget('loader');
+//                     phpgwapi_yui::load_widget('tabview');
+//                     phpgwapi_yui::load_widget('paginator');
+//                     phpgwapi_yui::load_widget('animation');
+//
+//
+//                     //-- BEGIN----------------------------- JSON CODE 
------------------------------
+//                     //values for Pagination
+//                     $json = array
+//                             (
+//                                     'recordsReturned'       => 
$datatable['pagination']['records_returned'],
+//                                     'totalRecords'          => 
(int)$datatable['pagination']['records_total'],
+//                                     'startIndex'            => 
$datatable['pagination']['records_start'],
+//                                     'sort'                          => 
$datatable['sorting']['order'],
+//                                     'dir'                           => 
$datatable['sorting']['sort'],
+//                                     'records'                       => 
array()
+//                             );
+//
+//                     // values for datatable
+//                     if(isset($datatable['rows']['row']) && 
is_array($datatable['rows']['row'])){
+//                             foreach( $datatable['rows']['row'] as $row )
+//                             {
+//                                     $json_row = array();
+//                                     foreach( $row['column'] as $column)
+//                                     {
+//                                             if(isset($column['format']) && 
$column['format']== "link" && $column['java_link']==true)
+//                                             {
+//                                                     
$json_row[$column['name']] = "<a href='#' id='".$column['link']."' 
onclick='javascript:filter_data(this.id);'>" .$column['value']."</a>";
+//                                             }
+//                                             else 
if(isset($column['format']) && $column['format']== "link")
+//                                             {
+//                                                     
$json_row[$column['name']] = "<a href='".$column['link']."'>" 
.$column['value']."</a>";
+//                                             }
+//                                             else
+//                                             {
+//                                                     
$json_row[$column['name']] = $column['value'];
+//                                             }
+//                                     }
+//                                     $json['records'][] = $json_row;
+//                             }
+//                     }
+//
+//                     // right in datatable
+//                     if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
+//                     {
+//                             $json ['rights'] = 
$datatable['rowactions']['action'];
+//                     }
+//
+//                     if( phpgw::get_var('phpgw_return_as') == 'json' )
+//                     {
+//                             return $json;
+//                     }
+//
+//
+//                     $datatable['json_data'] = json_encode($json);
+//                     //-------------------- JSON CODE ----------------------
+//
+//                     $template_vars = array();
+//                     $template_vars['datatable'] = $datatable;
+//                     
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
+//                     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
$template_vars);
+//
+//                     if ( !isset($GLOBALS['phpgw']->css) || 
!is_object($GLOBALS['phpgw']->css) )
+//                     {
+//                             $GLOBALS['phpgw']->css = 
createObject('phpgwapi.css');
+//                     }
+//
+//                     $GLOBALS['phpgw']->css->validate_file('datatable');
+//                     $GLOBALS['phpgw']->css->validate_file('property');
+//                     
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
+//                     
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+//                     
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+//                     
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+//
+//                     $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+//
+//                     $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'custom.view', 'property' );
                        //$this->save_sessiondata();
-
+            self::render_template_xsl('datatable_jquery',$data);
                }
 
+        public function query_view($custom_id)
+        {
+            
+            $search                    = phpgw::get_var('search');
+                       $order                  = phpgw::get_var('order');
+                       $draw                   = phpgw::get_var('draw', 'int');
+                       $columns                = phpgw::get_var('columns');
+            
+            $params = array(
+                'start' => phpgw::get_var('start', 'int', 'REQUEST', 0),
+                               'results' => phpgw::get_var('length', 'int', 
'REQUEST', 0),
+                               'query' => $search['value'],
+                               'order' => 
$columns[$order[0]['column']]['data'],
+                               'sort' => $order[0]['dir'],
+                               'allrows' => phpgw::get_var('length', 'int') == 
-1,
+                'filter' => $this->filter,
+                'custom_id' => $custom_id
+                           );
+
+            $values = $this->bo->read_custom($params);
+            
+            if( phpgw::get_var('export','bool'))
+            {
+                return $values;
+            }
+            
+            $result_data = array('results'  => $values);
+            $result_data['total_records'] = $this->bo->total_records;
+            $result_data['draw'] = $draw;
+            
+            return $this->jquery_results($result_data);
+        }
+        
+        
                function download()
                {
                        $custom_id = phpgw::get_var('custom_id', 'int');
-                       $list= $this->bo->read_custom($custom_id,$allrows=true);
+            $params = array(
+                'custom_id' => $custom_id,
+                'allrows' => true,
+            );
+                       $list= $this->bo->read_custom($params);
                        $uicols = $this->bo->uicols;
                        foreach($uicols as $col)
                        {




reply via email to

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