fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12405] change functions get_related() and get_files(


From: Nelson Guerra
Subject: [Fmsystem-commits] [12405] change functions get_related() and get_files()
Date: Fri, 28 Nov 2014 23:03:38 +0000

Revision: 12405
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12405
Author:   nelson224
Date:     2014-11-28 23:03:38 +0000 (Fri, 28 Nov 2014)
Log Message:
-----------
change functions get_related() and get_files()

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

Modified: branches/dev-syncromind/property/inc/class.uientity.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.uientity.inc.php 2014-11-28 
23:02:20 UTC (rev 12404)
+++ branches/dev-syncromind/property/inc/class.uientity.inc.php 2014-11-28 
23:03:38 UTC (rev 12405)
@@ -62,6 +62,8 @@
                                'index'                         => true,
                                'addfiles'                      => true,
                                'get_files'                     => true,
+                               'get_target'            => true,
+                               'get_related'           => true,
                                'get_inventory'         => true,
                                'add_inventory'         => true,
                                'edit_inventory'        => true,
@@ -554,13 +556,69 @@
                */
                function get_related()
                {
-                       $id     = phpgw::get_var('id', 'REQUEST', 'int');
+                       $id = phpgw::get_var('id', 'REQUEST', 'int');
+                       $draw = phpgw::get_var('draw', 'int');
+                       $allrows = phpgw::get_var('length', 'int') == -1;
+               
+                       $related = 
$this->bo->read_entity_to_link(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
 
-                       if( !$this->acl_read)
+                       $values = array();
+                       if(isset($related['related']))
                        {
-                               return;
+                               foreach($related as $related_key => 
$related_data)
+                               {
+                                       foreach($related_data as $entry)
+                                       {
+                                               $values[] = array
+                                               (
+                                                       'url'           => "<a 
href=\"{$entry['entity_link']}\" > {$entry['name']}</a>",
+                                               );
+                                       }
+                               }
                        }
+
+                       $start = phpgw::get_var('startIndex', 'REQUEST', 'int', 
0);
+                       $total_records = count($values);
+
+                       $num_rows = phpgw::get_var('length', 'int', 'REQUEST', 
0);
+
+                       if($allrows)
+                       {
+                               $out = $values;
+                       }
+                       else
+                       {
+                               if ($total_records > $num_rows)
+                               {
+                                       $page = ceil( ( $start / $total_records 
) * ($total_records/ $num_rows) );
+                                       $values_part = array_chunk($values, 
$num_rows);
+                                       $out = $values_part[$page];
+                               }
+                               else 
+                               {
+                                       $out = $values;
+                               }
+                       }
+
+                       $result_data = array('results' => $out);
+
+                       $result_data['total_records'] = $total_records;
+                       $result_data['draw'] = $draw;
+                       
+                       return $this->jquery_results($result_data);
+               }
+
                
+               /**
+               * Function to get related via Ajax-call using api-version of yui
+               *
+               */
+               function get_target()
+               {
+                       $id = phpgw::get_var('id', 'REQUEST', 'int');
+                       $draw = phpgw::get_var('draw', 'int');
+                       $allrows = phpgw::get_var('length', 'int') == -1;
+               
                        $interlink      = CreateObject('property.interlink');
                        $target = $interlink->get_relation('property', 
$this->acl_location, $id, 'target');
 
@@ -584,22 +642,11 @@
                                        }
                                }
                        }
-
-/*
-                       
if(isset($GLOBALS['phpgw_info']['user']['apps']['controller']))
-                       {
-                               $location_id            = 
$GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
-                               $socase                         = 
CreateObject('controller.socase');
-                               $controller_cases       = 
$socase->get_cases_by_message($location_id, $id);
-                       }
-*/
-
-//------ Start pagination
-
-                       $start = phpgw::get_var('startIndex', 'REQUEST', 'int', 
0);
+                       
+                       $start = phpgw::get_var('start', 'int', 'REQUEST', 0);
                        $total_records = count($values);
 
-                       $num_rows = 
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int) 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;      
                
+                       $num_rows = phpgw::get_var('length', 'int', 'REQUEST', 
0);
 
                        if($allrows)
                        {
@@ -607,38 +654,33 @@
                        }
                        else
                        {
-                               $page = ceil( ( $start / $total_records ) * 
($total_records/ $num_rows) );
-                               $values_part = array_chunk($values, $num_rows);
-                               $out = $values_part[$page];
+                               if ($total_records > $num_rows)
+                               {
+                                       $page = ceil( ( $start / $total_records 
) * ($total_records/ $num_rows) );
+                                       $values_part = array_chunk($values, 
$num_rows);
+                                       $out = $values_part[$page];
+                               }
+                               else 
+                               {
+                                       $out = $values;
+                               }
                        }
 
-//------ End pagination
+                       $result_data = array('results' => $out);
 
-
-                       $data = array(
-                                'ResultSet' => array(
-                                       'totalResultsAvailable' => 
$total_records,
-                                       'startIndex' => $start,
-                                       'sortKey' => 'type', 
-                                       'sortDir' => "ASC", 
-                                       'Result' => $out,
-                                       'pageSize' => $num_rows,
-                                       'activePage' => floor($start / 
$num_rows) + 1
-                               )
-                       );
-                       return $data;
+                       $result_data['total_records'] = $total_records;
+                       $result_data['draw'] = $draw;
+                       
+                       return $this->jquery_results($result_data);
                }
-
-
+               
+               
                function get_files()
                {
-                       $id     = phpgw::get_var('id', 'int');
+                       $id = phpgw::get_var('id', 'REQUEST', 'int');
+                       $draw = phpgw::get_var('draw', 'int');
+                       $allrows = phpgw::get_var('length', 'int') == -1;
 
-                       if( !$this->acl_read)
-                       {
-                               return;
-                       }
-
                        $values = 
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
 
                        $link_file_data = array
@@ -660,7 +702,6 @@
                                }
                        }
 
-
                        $content_files = array();
                        foreach($values['files'] as $_entry )
                        {
@@ -671,19 +712,35 @@
                                        );
                        }
 
-                       if( phpgw::get_var('phpgw_return_as') == 'json' )
+                       $start = phpgw::get_var('startIndex', 'REQUEST', 'int', 
0);
+                       $total_records = count($content_files);
+
+                       $num_rows = phpgw::get_var('length', 'int', 'REQUEST', 
0);
+
+                       if($allrows)
                        {
-
-                               if(count($content_files))
+                               $out = $content_files;
+                       }
+                       else
+                       {
+                               if ($total_records > $num_rows)
                                {
-                                       return json_encode($content_files);
+                                       $page = ceil( ( $start / $total_records 
) * ($total_records/ $num_rows) );
+                                       $values_part = 
array_chunk($content_files, $num_rows);
+                                       $out = $values_part[$page];
                                }
-                               else
+                               else 
                                {
-                                       return "";
+                                       $out = $content_files;
                                }
                        }
-                       return $content_files;
+
+                       $result_data = array('results' => $out);
+
+                       $result_data['total_records'] = $total_records;
+                       $result_data['draw'] = $draw;
+                       
+                       return $this->jquery_results($result_data);
                }
 
 
@@ -1488,7 +1545,6 @@
                                {
                                        $values = 
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id),$values);
                                }
-
                        }
 
                        /* Preserve attribute values from post */
@@ -1749,22 +1805,7 @@
 
                        $custom_config  = 
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
 $this->acl_location));
                        $_config = isset($custom_config->config_data) && 
$custom_config->config_data ? $custom_config->config_data : array();
-//_debug_array($custom_config->config_data);die();
-                       // required settings:
-/*
-                       integration_tab
-                       integration_height
-                       integration_url
-                       integration_parametres
-                       integration_action
-                       integration_action_view
-                       integration_action_edit
-                       integration_auth_key_name
-                       integration_auth_url
-                       integration_auth_hash_name
-                       integration_auth_hash_value
-                       integration_location_data
- */
+
                        $integration = array();
                        foreach ($_config as $_config_section => 
$_config_section_data)
                        {
@@ -1945,7 +1986,7 @@
                        $datatable_def[] = array
                        (
                                'container'             => 
'datatable-container_0',
-                               'requestUrl'    => 
json_encode(self::link(array('menuaction' => 
'property.uicondition_survey.get_files', 'id' => 
$id,'phpgw_return_as'=>'json'))),
+                               'requestUrl'    => 
json_encode(self::link(array('menuaction' => 'property.uientity.get_files', 
'entity_id'=>$this->entity_id, 'cat_id'=>$this->cat_id, 'id' => 
$id,'phpgw_return_as'=>'json'))),
                                'ColumnDefs'    => $file_def
                        );
 
@@ -2049,7 +2090,7 @@
                                        unset($_link);
                                }
 
-                               $related = 
$this->bo->read_entity_to_link(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
+                               //$related = 
$this->bo->read_entity_to_link(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
 
                                $_related = array();
                                if(isset($related['related']))
@@ -2103,7 +2144,7 @@
                                $datatable_def[] = array
                                (
                                        'container'             => 
'datatable-container_1',
-                                       'requestUrl'    => 
json_encode(self::link(array('menuaction' => 
'property.uicondition_survey.get_request', 'id' => 
$id,'phpgw_return_as'=>'json'))),
+                                       'requestUrl'    => 
json_encode(self::link(array('menuaction' => 'property.uientity.get_target', 
'id' => $id,'phpgw_return_as'=>'json'))),
                                        'ColumnDefs'    => $target_def
                                );
                                /*
@@ -2134,7 +2175,7 @@
                                $datatable_def[] = array
                                (
                                        'container'             => 
'datatable-container_2',
-                                       'requestUrl'    => 
json_encode(self::link(array('menuaction' => 
'property.uicondition_survey.get_summation', 'id' => 
$id,'phpgw_return_as'=>'json'))),
+                                       'requestUrl'    => 
json_encode(self::link(array('menuaction' => 'property.uientity.get_related', 
'entity_id'=>$this->entity_id, 'cat_id'=>$this->cat_id, 'id' => 
$id,'phpgw_return_as'=>'json'))),
                                        'ColumnDefs'    => $related_def
                                );
 




reply via email to

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