fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12353] change custom function


From: Nelson Guerra
Subject: [Fmsystem-commits] [12353] change custom function
Date: Thu, 20 Nov 2014 23:11:27 +0000

Revision: 12353
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12353
Author:   nelson224
Date:     2014-11-20 23:11:27 +0000 (Thu, 20 Nov 2014)
Log Message:
-----------
change custom function

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

Modified: branches/dev-syncromind/property/inc/class.uilookup.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.uilookup.inc.php 2014-11-20 
23:10:51 UTC (rev 12352)
+++ branches/dev-syncromind/property/inc/class.uilookup.inc.php 2014-11-20 
23:11:27 UTC (rev 12353)
@@ -31,9 +31,10 @@
         * Description
         * @package property
         */
-       phpgw::import_class('phpgwapi.yui');
+       phpgw::import_class('phpgwapi.uicommon_jquery');
+       phpgw::import_class('phpgwapi.jquery');
 
-       class property_uilookup
+       class property_uilookup extends phpgwapi_uicommon_jquery
        {
                var $grants;
                var $cat_id;
@@ -68,6 +69,8 @@
 
                function __construct()
                {
+                       parent::__construct();
+                       
                        $GLOBALS['phpgw_info']['flags']['noframework'] = true;
                        $GLOBALS['phpgw_info']['flags']['headonly']=true;
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
@@ -106,6 +109,10 @@
 
                }
 
+               public function query()
+               {
+               }
+               
                function save_sessiondata()
                {
                        $data = array
@@ -3451,225 +3458,92 @@
 
                function custom()
                {
-                       $type           = phpgw::get_var('type');
-               //      $get_list_function_input        = 
urlencode(phpgw::get_var('get_list_function_input'));
-                       $column                                 = 
phpgw::get_var('column');
+                       $type   = phpgw::get_var('type');
+                       $column = phpgw::get_var('column');
 
-                       if( phpgw::get_var('phpgw_return_as') != 'json' )
+                       if( phpgw::get_var('phpgw_return_as') == 'json' )
                        {
-                               $datatable['config']['base_url']        = 
$GLOBALS['phpgw']->link('/index.php', array
-                               (
-                                       'menuaction'                    => 
'property.uilookup.custom',
-                                       'cat_id'                                
=> $this->cat_id,
-                                       'query'                                 
=> $this->query,
-                                       'filter'                                
=> $this->filter,
-                                       'type'                                  
=> $type,
-//                                     'get_list_function_input' => 
$get_list_function_input
-                               ));
-                               $datatable['config']['allow_allrows'] = true;
+                               $search = phpgw::get_var('search');
+                               $order = phpgw::get_var('order');
+                               $draw = phpgw::get_var('draw', 'int');
+                               $columns = phpgw::get_var('columns');
 
-                               $datatable['config']['base_java_url'] = 
"menuaction:'property.uilookup.custom',"
-                                       ."cat_id:'{$this->cat_id}',"
-                                       ."query:'{$this->query}',"
-                                       ."filter:'{$this->filter}',"
-                                       ."type:'{$type}'";
-//                                     
."get_list_function_input:'{$get_list_function_input}'";
-               
-                               $datatable['actions']['form'] = array
-                                       (
-                                               array
-                                               (
-                                                       'action'        => 
$GLOBALS['phpgw']->link('/index.php',
-                                                       array
-                                                       (
-                                                               'menuaction'    
        => 'property.uilookup.custom',
-                                                               'cat_id'        
                => $this->cat_id,
-                                                               'query'         
                => $this->query,
-                                                               'filter'        
                => $this->filter,
-                                                               'type'  => 
$type,
-//                                                             
'get_list_function_input' => $get_list_function_input
-                                                       )
-                                               ),
-                                               'fields'        => array
-                                               (
-                                                       'field' => array
-                                                       (
-                                                               array
-                                                               ( //boton  
SEARCH
-                                                                       'id' => 
'btn_search',
-                                                                       'name' 
=> 'search',
-                                                                       'value' 
   => lang('search'),
-                                                                       'type' 
=> 'button',
-                                                                       
'tab_index' => 2
-                                                               ),
-                                                               array
-                                                               ( // TEXT IMPUT
-                                                                       'name'  
   => 'query',
-                                                                       'id'    
 => 'txt_query',
-                                                                       'value' 
   => '',//'',//$query,
-                                                                       'type' 
=> 'text',
-                                                                       'size'  
  => 28,
-                                                                       
'onkeypress' => 'return pulsar(event)',
-                                                                       
'tab_index' => 1
-                                                               )
-                                                       ),
-                                                       'hidden_value' => array
-                                                       (
-                                                               )
-                                                       )
-                                               )
-                                       );
+                               $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'],
+                                       'dir' => $order[0]['dir'],
+                                       'cat_id' => phpgw::get_var('cat_id', 
'int', 'REQUEST', 0),
+                                       'allrows' => phpgw::get_var('length', 
'int') == -1
+                               );
+
+                               $bogeneric = CreateObject('property.bogeneric');
+                               
$bogeneric->get_location_info(phpgw::get_var('type','string'));
+                               $values = $bogeneric->read($params);
+
+                               $result_data = array('results' => $values);
+
+                               $result_data['total_records'] = 
$bogeneric->total_records;
+                               $result_data['draw'] = $draw;
+
+                               return $this->jquery_results($result_data);
                        }
 
+                       self::add_javascript('phpgwapi', 'jquery', 
'editable/jquery.jeditable.js');
+                       self::add_javascript('phpgwapi', 'jquery', 
'editable/jquery.dataTables.editable.js');
+                       
+                       $data = array(
+                               'left_click_action'     => 'parent.buscar',
+                               'datatable_name'        => $appname,
+                               'form' => array(
+                                       'toolbar' => array(
+                                               'item' => array()
+                                       )
+                               ),
+                               'datatable' => array(
+                                       'source' => self::link(array(
+                                                       'menuaction'    => 
'property.uilookup.custom',
+                                                       'cat_id'                
=> $this->cat_id,
+                                                       'filter'                
=> $this->filter,
+                                                       'type'                  
=> $type,
+                                                       'phpgw_return_as' => 
'json'
+                                       )),
+                                       'allrows'       => true,
+                                       'editor_action' => '',
+                                       'field' => array(),
+                                       'actions' => ''
+                               )
+                       );
+                                                               
                        $bogeneric = CreateObject('property.bogeneric');
                        
$bogeneric->get_location_info(phpgw::get_var('type','string'));
                        $values = $bogeneric->read();
 
                        $uicols = $bogeneric->uicols;
-                       
-//_debug_array($values);die();
-                       $content = array();
-                       $j=0;
-                       if (is_array($values))
-                       {
-                               foreach($values as $entry)
-                               {
-                                       for 
($i=0;$i<count($uicols['name']);$i++)
-                                       {
-                                               
$datatable['rows']['row'][$j]['column'][$i]['value']    = 
$entry[$uicols['name'][$i]];
-                                               
$datatable['rows']['row'][$j]['column'][$i]['name']     = $uicols['name'][$i];
-                                       }
-                                       $j++;
-                               }
-                       }
 
-                       $uicols_count   = count($uicols['name']);
-                       $datatable['rowactions']['action'] = array();
-                       for ($i=0;$i<$uicols_count;$i++)
-                       {
-                               //all colums should be have formatter
-                               
$datatable['headers']['header'][$i]['formatter'] = 
($uicols['formatter'][$i]==''?  '""' : $uicols['formatter'][$i]);
-
-                               $datatable['headers']['header'][$i]['name']     
                = $uicols['name'][$i];
-                               $datatable['headers']['header'][$i]['text']     
                = $uicols['descr'][$i];
-                               $datatable['headers']['header'][$i]['visible']  
                = true;
-                               $datatable['headers']['header'][$i]['sortable'] 
                = true;
-                               
$datatable['headers']['header'][$i]['sort_field']               = 
$uicols['name'][$i];
+                       $count_uicols_name = count($uicols['name']);
+       
+                       for($k=0;$k<$count_uicols_name;$k++)
+                       {                                               
+                               $params = array(
+                                                               'key' => 
$uicols['name'][$k],
+                                                               'label' => 
$uicols['descr'][$k],
+                                                               'sortable' => 
false,
+                                                               'hidden' => 
false
+                                                       );
+                               
+                               array_push ($data['datatable']['field'], 
$params);
                        }
 
-                       $custom_id              = "{$column}_id";
-                       $custom_name    = "{$column}_name";
-//     _debug_array($datatable);die();
-                       $function_exchange_values = '';
-
-                       $function_exchange_values .= 
'opener.document.getElementsByName("'.$custom_id.'")[0].value = "";' ."\r\n";
-                       $function_exchange_values .= 
"opener.document.getElementById('txt_{$column}').innerHTML = '';\r\n";
-
-                       $function_exchange_values .= 
'opener.document.getElementsByName("'.$custom_id.'")[0].value = 
data.getData("id");' ."\r\n";
-                       $function_exchange_values .= 
"opener.document.getElementById('txt_{$column}').innerHTML = 
data.getData('name');\r\n";
-
-                       $function_exchange_values .= 'window.close()';
-
-                       $datatable['exchange_values'] = 
$function_exchange_values;
-                       $datatable['valida'] = '';
-
-                       // 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->start;
-                       $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-                       $datatable['pagination']['records_returned']= 
count($values);
-                       $datatable['pagination']['records_total']       = 
$bogeneric->total_records;
-
-                       if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
-                       {
-                               $datatable['sorting']['order']                  
= 'id'; // name key Column in myColumnDef
-                               $datatable['sorting']['sort']                   
= 'ASC'; // ASC / DESC
-                       }
-                       else
-                       {
-                               $datatable['sorting']['order']                  
= phpgw::get_var('order', 'string'); // name of column of Database
-                               $datatable['sorting']['sort']                   
= phpgw::get_var('sort', 'string'); // ASC / DESC
-                       }
-
                        $appname                                                
= lang('template');
                        $function_msg                                   = 
lang('list order template');
 
-
-                       //-- 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']."' target='_blank'>" 
.$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;
-                       }
-//     _debug_array($json);die();
-                       $datatable['json_data'] = json_encode($json);
-                       //-------------------- JSON CODE ----------------------
-
-                       // Prepare template variables and process XSLT
-                       $template_vars = array();
-                       $template_vars['datatable'] = $datatable;
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
-                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
$template_vars);
-
-
-                       //Title of Page
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+                       
+                       self::render_template_xsl('datatable_jquery', $data);
 
-                       // Prepare YUI Library
-                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'lookup.generic.index', 'property' );
-
-                       $this->save_sessiondata();
                }
 
        }




reply via email to

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