[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [12234] changes on uilocation to support datatable-jq
From: |
Alejandro |
Subject: |
[Fmsystem-commits] [12234] changes on uilocation to support datatable-jquery |
Date: |
Fri, 24 Oct 2014 23:35:37 +0000 |
Revision: 12234
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12234
Author: nudrick
Date: 2014-10-24 23:35:36 +0000 (Fri, 24 Oct 2014)
Log Message:
-----------
changes on uilocation to support datatable-jquery
Modified Paths:
--------------
branches/dev-syncromind/property/inc/class.uilocation.inc.php
Modified: branches/dev-syncromind/property/inc/class.uilocation.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.uilocation.inc.php
2014-10-24 23:05:54 UTC (rev 12233)
+++ branches/dev-syncromind/property/inc/class.uilocation.inc.php
2014-10-24 23:35:36 UTC (rev 12234)
@@ -31,10 +31,15 @@
* Description
* @package property
*/
- phpgw::import_class('phpgwapi.yui');
+ //phpgw::import_class('phpgwapi.yui');
- class property_uilocation
+ phpgw::import_class('phpgwapi.uicommon_jquery');
+ phpgw::import_class('phpgwapi.jquery');
+
+
+ class property_uilocation extends phpgwapi_uicommon_jquery
{
+ protected $appname = 'property';
var $grants;
var $cat_id;
var $start;
@@ -45,7 +50,7 @@
var $currentapp;
var $type_id;
var $location_code;
-
+
var $public_functions = array
(
'download' => true,
@@ -63,37 +68,129 @@
function __construct()
{
- // $GLOBALS['phpgw_info']['flags']['nonavbar'] = true; //
menus added where needed via bocommon::get_menu
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
- $GLOBALS['phpgw_info']['flags']['menu_selection'] =
'property::location';
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+// parent::__construct();
+//
+// // $GLOBALS['phpgw_info']['flags']['nonavbar'] = true; //
menus added where needed via bocommon::get_menu
+// $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+// $GLOBALS['phpgw_info']['flags']['menu_selection'] =
'property::location';
+// $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+// $this->bo =
CreateObject('property.bolocation',true);
+// $this->bocommon = &
$this->bo->bocommon;
+// $this->soadmin_location =
CreateObject('property.soadmin_location');
+// $this->acl = &
$GLOBALS['phpgw']->acl;
+//
+// $this->type_id =
$this->bo->type_id;
+//
+// $this->acl_location =
$this->bo->acl_location;
+// $this->acl_read =
$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'property');
+// $this->acl_add =
$this->acl->check($this->acl_location, PHPGW_ACL_ADD, 'property');
+// $this->acl_edit =
$this->acl->check($this->acl_location, PHPGW_ACL_EDIT, 'property');
+// $this->acl_delete =
$this->acl->check($this->acl_location, PHPGW_ACL_DELETE, 'property');
+//
+// $this->start =
$this->bo->start;
+// $this->query =
$this->bo->query;
+// $this->sort =
$this->bo->sort;
+// $this->order =
$this->bo->order;
+// $this->filter =
$this->bo->filter;
+// $this->cat_id =
$this->bo->cat_id;
+// $this->part_of_town_id =
$this->bo->part_of_town_id;
+// $this->district_id =
$this->bo->district_id;
+// $this->status =
$this->bo->status;
+// $this->allrows =
$this->bo->allrows;
+// $this->lookup =
$this->bo->lookup;
+// $this->location_code =
$this->bo->location_code;
+ parent::__construct();
+
+ //$GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+ //$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
$this->bo =
CreateObject('property.bolocation',true);
$this->bocommon = &
$this->bo->bocommon;
- $this->soadmin_location =
CreateObject('property.soadmin_location');
$this->acl = &
$GLOBALS['phpgw']->acl;
-
- $this->type_id =
$this->bo->type_id;
-
+ /*$this->acl_location =
$this->location_info['acl_location'];
+ $this->acl_read =
$this->acl->check($this->acl_location, PHPGW_ACL_READ,
$this->location_info['acl_app']);
+ $this->acl_add =
$this->acl->check($this->acl_location, PHPGW_ACL_ADD,
$this->location_info['acl_app']);
+ $this->acl_edit =
$this->acl->check($this->acl_location, PHPGW_ACL_EDIT,
$this->location_info['acl_app']);
+ $this->acl_delete =
$this->acl->check($this->acl_location, PHPGW_ACL_DELETE,
$this->location_info['acl_app']);
+ $this->acl_manage =
$this->acl->check($this->acl_location, 16, $this->location_info['acl_app']);*/
$this->acl_location =
$this->bo->acl_location;
$this->acl_read =
$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'property');
$this->acl_add =
$this->acl->check($this->acl_location, PHPGW_ACL_ADD, 'property');
$this->acl_edit =
$this->acl->check($this->acl_location, PHPGW_ACL_EDIT, 'property');
$this->acl_delete =
$this->acl->check($this->acl_location, PHPGW_ACL_DELETE, 'property');
+ $this->acl_manage =
$this->acl->check($this->acl_location, 16, 'property');
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->filter =
$this->bo->filter;
- $this->cat_id =
$this->bo->cat_id;
- $this->part_of_town_id =
$this->bo->part_of_town_id;
- $this->district_id =
$this->bo->district_id;
- $this->status =
$this->bo->status;
- $this->allrows =
$this->bo->allrows;
- $this->lookup =
$this->bo->lookup;
- $this->location_code =
$this->bo->location_code;
+ //$GLOBALS['phpgw_info']['flags']['menu_selection'] =
$this->location_info['menu_selection'];
+ //$GLOBALS['phpgw_info']['flags']['menu_selection'] =
$this->location_info['menu_selection'];
+
+// $this->start =
$this->bo->start;
+// $this->query =
$this->bo->query;
+// $this->sort =
$this->bo->sort;
+// $this->order =
$this->bo->order;
+// $this->allrows =
$this->bo->allrows;
+//
+// $this->type = $this->bo->type;
+// $this->type_id = $this->bo->type_id;
+
+
}
+
+ /**
+ * Fetch data from $this->bo based on parametres
+ * @return array
+ */
+ public function query()
+ {
+ $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'],
+ 'dir' => $order[0]['dir'],
+ 'cat_id' => phpgw::get_var('cat_id', 'int',
'REQUEST', 0),
+ 'allrows' => phpgw::get_var('length', 'int') ==
-1
+ );
+
+ foreach ( $this->location_info['fields'] as $field )
+ {
+ if (isset($field['filter']) && $field['filter'])
+ {
+ $params['filter'][$field['name']] =
phpgw::get_var($field['name']);
+ }
+ }
+
+ $result_objects = array();
+ $result_count = 0;
+
+ $values = $this->bo->read($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;
+
+ $link_data = array
+ (
+ 'menuaction' => 'property.uigeneric.edit',
+ 'appname' => $this->appname,
+ 'type' => $this->type,
+ 'type_id' => $this->type_id
+ );
+
+ array_walk( $result_data['results'], array($this,
'_add_links'), $link_data );
+
+ return $this->jquery_results($result_data);
+ }
+
function save_sessiondata()
{
$data = array
@@ -181,7 +278,22 @@
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
}
+ private function _get_categories($selected = 0)
+ {
+ $cats = CreateObject('phpgwapi.categories', -1,
'property', $this->acl_location);
+ $cats->supress_info = true;
+ $categories =
$cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$selected,'globals' => true,'use_acl' => $this->_category_acl));
+ $default_value = array ('cat_id'=>'','name'=> lang('no
category'));
+ array_unshift ($categories['cat_list'],$default_value);
+ foreach ($categories['cat_list'] as & $_category)
+ {
+ $_category['id'] = $_category['cat_id'];
+ }
+
+ return $categories['cat_list'];
+ }
+
function index()
{
@@ -218,869 +330,154 @@
$this->bocommon->no_access();
return;
}
-
- $second_display = phpgw::get_var('second_display',
'bool');
- $default_district =
(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['default_district'])?$GLOBALS['phpgw_info']['user']['preferences']['property']['default_district']:'');
-
- if ($default_district && !$second_display &&
!$this->district_id)
+
+ if (phpgw::get_var('phpgw_return_as') == 'json')
{
- $this->bo->district_id = $default_district;
- $this->district_id =
$default_district;
+ return $this->query();
}
+
+ self::add_javascript('phpgwapi', 'jquery',
'editable/jquery.jeditable.js');
+ self::add_javascript('phpgwapi', 'jquery',
'editable/jquery.dataTables.editable.js');
+
+
+
+
+
+ $categories = $this->_get_categories();
+
+ $data = array(
+ 'datatable_name' => lang('condition
survey'),
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array(
+ array('type' =>
'filter',
+ 'name' =>
'cat_id',
+ 'text' =>
lang('category') . ':',
+ 'list' =>
$categories,
+ ),
+ array(
+ 'type' =>
'link',
+ 'value' =>
lang('new'),
+ 'href' =>
self::link(array('menuaction' => 'property.uicondition_survey.add')),
+ 'class' =>
'new_item'
+ )
+ ),
+ ),
+ ),
+ 'datatable' => array(
+ 'source' =>
self::link(array('menuaction' => 'property.uilocation.index', 'phpgw_return_as'
=> 'json')),
+ 'download' =>
self::link(array('menuaction' => 'property.uilocation.download', 'export' =>
true, 'allrows' => true)),
+ 'allrows' => true,
+ 'editor_action' =>
self::link(array('menuaction' =>
'property.uicondition_survey.edit_survey_title')),
+ 'field' => array()
+ )
+ );
+
+ $this->bo->read();
+ $uicols = $this->bo->uicols;
- $datatable = array();
- $values_combo_box = array();
+ $count_uicols_name = count($uicols['name']);
- $location_id =
$GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
- $custom_config =
CreateObject('admin.soconfig',$location_id);
- $_config = isset($custom_config->config_data) &&
$custom_config->config_data ? $custom_config->config_data : array();
-
- $_integration_set = array();
- foreach ($_config as $_config_section =>
$_config_section_data)
+ for($k=0;$k<$count_uicols_name;$k++)
{
- $integrationurl = '';
- if(isset($_config_section_data['url']) &&
!isset($_config_section_data['tab']))
- {
-
if(isset($_config_section_data['auth_hash_name']) &&
$_config_section_data['auth_hash_name'] &&
isset($_config_section_data['auth_url']) && $_config_section_data['auth_url'])
- {
- //get session key from remote
system
-
- $arguments =
array($_config_section_data['auth_hash_name'] =>
$_config_section_data['auth_hash_value']);
- $query =
http_build_query($arguments);
- $auth_url =
$_config_section_data['auth_url'];
- $request =
"{$auth_url}?{$query}";
-
- $aContext = array
- (
- 'http' => array
- (
-
'request_fulluri' => true,
- ),
- );
-
-
if(isset($GLOBALS['phpgw_info']['server']['httpproxy_server']))
- {
-
$aContext['http']['proxy'] =
"{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}";
- }
-
- $cxContext =
stream_context_create($aContext);
- $response =
trim(file_get_contents($request, False, $cxContext));
+ $params = array(
+ 'key'
=> $uicols['name'][$k],
+ 'label'
=> $uicols['descr'][$k],
+
'sortable' => ($uicols['sortable'][$k]) ? true : false,
+
'hidden' => ($uicols['input_type'][$k] == 'hidden') ? true : false
+ );
+ if ($uicols['name'][$k] == 'id') {
+ $params['formatter'] =
'JqueryPortico.formatLink';
}
-
-
- $_config_section_data['url']
= htmlspecialchars_decode($_config_section_data['url']);
- $_config_section_data['parametres']=
htmlspecialchars_decode($_config_section_data['parametres']);
- $integration_name =
isset($_config_section_data['name']) && $_config_section_data['name'] ?
$_config_section_data['name'] : lang('integration');
-
-
parse_str($_config_section_data['parametres'], $output);
-
- foreach ($output as $_dummy =>
$_substitute)
- {
- $_keys[] = $_substitute;
- $__substitute =
trim($_substitute, '_');
- $_values[] =
$this->$__substitute;
- }
- unset($output);
-
- $_sep = '?';
- if
(stripos($_config_section_data['url'],'?'))
- {
- $_sep = '&';
- }
- $_param = str_replace($_keys, $_values,
$_config_section_data['parametres']);
-
- $integrationurl =
"{$_config_section_data['url']}{$_sep}{$_param}";
- $integrationurl .=
"&{$_config_section_data['auth_key_name']}={$response}";
-
-
- //in the form:
sakstittel=__loc1__.__loc4__
-
- $_config_section_data['location_data']=
htmlspecialchars_decode($_config_section_data['location_data']);
-
- $parameters_integration = array();
-
if($_config_section_data['location_data'])
- {
-
parse_str($_config_section_data['location_data'], $output);
-
- foreach ($output as $_name =>
$_substitute)
- {
- if($_substitute ==
'__loc1__') // This one is a link...
- {
- $_substitute =
'__location_code__';
- }
-
-
$parameters_integration['parameter'][] = array
- (
- 'name'
=> $_name,
- 'source'
=> trim($_substitute, '_'),
- );
- }
- }
-
- $_integration_set[] = array
- (
- 'name' =>
$integration_name,
- 'parameters' =>
$parameters_integration,
- 'url' =>
$integrationurl
- );
- }
+ array_push
($data['datatable']['field'], $params);
}
- if( phpgw::get_var('phpgw_return_as') != 'json' )
- {
- if(!$lookup)
- {
- $datatable['menu']
= $this->bocommon->get_menu();
- }
-
- $datatable['config']['base_url'] =
$GLOBALS['phpgw']->link('/index.php', array
+ $parameters = array
+ (
+ 'parameter' => array
(
- 'menuaction'
=> 'property.uilocation.index',
- 'type_id'
=> $type_id,
- 'query'
=> $this->query,
- 'district_id' =>
$this->district_id,
- 'part_of_town_id' =>
$this->part_of_town_id,
- 'lookup'
=> $lookup,
- 'lookup_tenant' =>
$lookup_tenant,
- 'lookup_name' =>
$lookup_name,
- 'cat_id'
=> $this->cat_id,
- 'status'
=> $this->status,
- 'location_code'
=> $this->location_code
- ));
- $datatable['config']['allow_allrows'] = true;
-
- $datatable['config']['base_java_url'] =
"menuaction:'property.uilocation.index',"
- ."type_id:'{$type_id}',"
- ."query:'{$this->query}',"
- ."district_id: '{$this->district_id}',"
-
."part_of_town_id:'{$this->part_of_town_id}',"
- ."lookup:'{$lookup}',"
- ."second_display:1,"
- ."lookup_tenant:'{$lookup_tenant}',"
- ."lookup_name:'{$lookup_name}',"
- ."cat_id:'{$this->cat_id}',"
- ."status:'{$this->status}',"
-
."location_code:'{$this->location_code}',"
- ."block_query:'{$block_query}'";
-
- // $values_combo_box se usar� para escribir en
el HTML, usando el XSLT
- $values_combo_box[0] =
$this->bocommon->select_category_list(array
- ('format'=>'filter',
- 'selected' => $this->cat_id,
- 'type' =>'location',
- 'type_id' =>$type_id,
- 'order'=>'descr')
- );
- $default_value = array
('id'=>'','name'=>lang('no category'));
- array_unshift
($values_combo_box[0],$default_value);
-
- $values_combo_box[1] =
$this->bocommon->select_district_list('filter',$this->district_id);
- $default_value = array
('id'=>'','name'=>lang('no district'));
- array_unshift
($values_combo_box[1],$default_value);
-
- $values_combo_box[2] =
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
- $default_value = array
('id'=>'','name'=>lang('no part of town'));
- array_unshift
($values_combo_box[2],$default_value);
-
-
if(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['property_filter'])
&&
$GLOBALS['phpgw_info']['user']['preferences']['property']['property_filter'] ==
'owner')
- {
- $values_combo_box[3] =
$this->bo->get_owner_list('filter', $this->filter);
- }
- else
- {
- $values_combo_box[3] =
$this->bo->get_owner_type_list('filter', $this->filter);
- }
- $default_value = array
('id'=>'','name'=>lang('show all'));
- array_unshift
($values_combo_box[3],$default_value);
-
- $datatable['actions']['form'] = array
- (
array
(
- 'action' =>
$GLOBALS['phpgw']->link('/index.php',
- array
- (
- 'menuaction'
=> 'property.uilocation.index',
- 'type_id'
=> $type_id,
- 'district_id'
=> $this->district_id,
-
'part_of_town_id' => $this->part_of_town_id,
- 'lookup'
=> $lookup,
- 'lookup_tenant'
=> $lookup_tenant,
- 'lookup_name'
=> $lookup_name,
- 'cat_id'
=> $this->cat_id,
- )
+ 'name' => 'id',
+ 'source' => 'id'
),
- 'fields' => array
- (
- 'field' => array
- (
- array
- ( //boton
CATEGORY
- 'id' =>
'btn_cat_id',
- 'name'
=> 'cat_id',
- 'value'
=> lang('Category'),
- 'type'
=> 'button',
- 'style'
=> 'filter',
-
'tab_index' => 1
- ),
- array
- ( //boton
DISTINT
- 'id' =>
'btn_district_id',
- 'name'
=> 'district_id',
- 'value'
=> lang('District'),
- 'type'
=> 'button',
- 'style'
=> 'filter',
-
'tab_index' => 2
- ),
- array
- ( //boton
PART OF TOWN
- 'id' =>
'btn_part_of_town_id',
- 'name'
=> 'part_of_town_id',
- 'value'
=> lang('Part of Town'),
- 'type'
=> 'button',
- 'style'
=> 'filter',
-
'tab_index' => 3
- ),
- array
- ( //boton
FILTER
- 'id' =>
'btn_owner_id',
- 'name'
=> 'owner_id',
- 'value'
=> lang('Filter'),
- 'type'
=> 'button',
- 'style'
=> 'filter',
-
'tab_index' => 4
- ),
- //for link
"columns", next to Export button
- array
- (
- 'type'
=> 'link',
- 'id' =>
'btn_columns',
- 'url'
=> "Javascript:window.open('".$GLOBALS['phpgw']->link('/index.php',
- array
- (
-
'menuaction' => 'property.uilocation.columns',
-
'type_id' => $type_id,
-
'lookup' => $this->lookup
-
))."','','width=300,height=600,scrollbars=1')",
- 'value'
=> lang('columns'),
-
'tab_index' => 9
- ),
- array
- (
- 'type'
=> 'button',
- 'id'
=> 'btn_export',
- 'value'
=> lang('download'),
-
'tab_index' => 8
- ),
- array
- ( //hidden
type_id
- 'type'
=> 'hidden',
- 'id'
=> 'type_id',
- 'value'
=> $type_id
- )
- ),
- 'hidden_value' => array
- (
- array
- ( //div values
combo_box_0
- 'id' =>
'values_combo_box_0',
- 'value'
=> $this->bocommon->select2String($values_combo_box[0]) //i.e.
id,value/id,vale/
- ),
- array
- ( //div values
combo_box_1
- 'id' =>
'values_combo_box_1',
- 'value'
=> $this->bocommon->select2String($values_combo_box[1])
- ),
- array
- ( //div values
combo_box_2
- 'id' =>
'values_combo_box_2',
- 'value'
=> $this->bocommon->select2String($values_combo_box[2])
- ),
- array
- ( //div values
combo_box_3
- 'id' =>
'values_combo_box_3',
- 'value'
=> $this->bocommon->select2String($values_combo_box[3])
- )
- )
- )
)
);
- $button_def[] = "oNormalButton_0";
- $button_def[] = "oNormalButton_1";
- $button_def[] = "oNormalButton_2";
- $code_inner[] = "{order:0,
name:'btn_search',funct:'onSearchClick'}";
- $code_inner[] = "{order:1, name:'btn_new',
funct:'onNewClick'}";
- $code_inner[] = "{order:2,
name:'btn_export',funct:'onDownloadClick'}";
- $_js_functions = '';
-
- foreach ($_integration_set as $i =>
$_integration)
- {
-
- $button_def[] = 'oNormalButton_' . ($i
+ 3);
- $code_inner[] = "{order:" . ($i + 3)
.", name:'btn_integration_{$i}',funct:'onIntegrationClick_{$i}'}";
-
-
$datatable['actions']['form'][0]['fields']['field'][] = array
+ $data['datatable']['actions'][] = array
(
- 'type' => 'button',
- 'id' =>
"btn_integration_{$i}",
- 'value' =>
$_integration['name'],
- 'tab_index' => 10 + $i
- );
-
- $_js_functions .= <<<JS
- this.onIntegrationClick_{$i} =
function()
- {
-
window.open(values_ds.integrationurl_{$i},'window');
- }
-JS;
- }
-
- $code = 'var ' . implode(',', $button_def) .
";\n";
- $code .= 'var normalButtons = [' . "\n" .
implode(",\n",$code_inner) . "\n];";
- $code .= $_js_functions;
-
- $GLOBALS['phpgw']->js->add_code('', $code);
-
- if(!$block_query)
- {
-
$datatable['actions']['form'][0]['fields']['field'][] = array
+ 'my_name' =>
'view_survey',
+ 'text' =>
lang('view'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
(
- 'id' => 'btn_search',
- 'name' => 'search',
- 'value' =>
lang('search'),
- 'type' => 'button',
- 'tab_index' => 6
- );
-
-
$datatable['actions']['form'][0]['fields']['field'][] = array
- (
- 'name' => 'query',
- 'id' => 'txt_query',
- 'value' =>
$this->query,//'',//$query,
- 'type' => 'text',
- 'size' => 28,
- 'onkeypress' => 'return
pulsar(event)',
- 'tab_index' => 5
- );
- }
-
- if(!$lookup)
- {
-
$datatable['actions']['form'][0]['fields']['field'][] = array
- (
- 'type' => 'button',
- 'id' => 'btn_new',
- 'value' => lang('add'),
- 'tab_index' => 7
- );
- }
-
- $dry_run=true;
-
- }
-
- $location_list = array();
- //cramirez: $dry_run avoid to load all data the first
time
- $location_list =
$this->bo->read(array('type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run'
=>$dry_run));
-
- $uicols = $this->bo->uicols;
-
- $content = array();
- $j=0;
- if (isset($location_list) && is_array($location_list))
- {
- foreach($location_list as $location)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
if(isset($location['query_location'][$uicols['name'][$i]]))
- {
-
$datatable['rows']['row'][$j]['column'][$i]['name'] =
$uicols['name'][$i];
-
$datatable['rows']['row'][$j]['column'][$i]['statustext'] =
lang('search');
-
$datatable['rows']['row'][$j]['column'][$i]['value'] =
$location[$uicols['name'][$i]];
-
$datatable['rows']['row'][$j]['column'][$i]['format'] =
'link';
-
$datatable['rows']['row'][$j]['column'][$i]['java_link'] = true;
-
$datatable['rows']['row'][$j]['column'][$i]['link']
= $location['query_location'][$uicols['name'][$i]];
- }
- else
- {
-
$datatable['rows']['row'][$j]['column'][$i]['value'] =
$location[$uicols['name'][$i]];
-
//$datatable['rows']['row'][$j]['column'][$i]['value'] = $i;
-
$datatable['rows']['row'][$j]['column'][$i]['name'] =
$uicols['name'][$i];
-
$datatable['rows']['row'][$j]['column'][$i]['lookup'] =
$lookup;
-
$datatable['rows']['row'][$j]['column'][$i]['align'] =
(isset($uicols['align'][$i])?$uicols['align'][$i]:'center');
-
-
if(isset($uicols['datatype']) && isset($uicols['datatype'][$i]) &&
$uicols['datatype'][$i]=='link' && $location[$uicols['name'][$i]])
- {
-
$datatable['rows']['row'][$j]['column'][$i]['format'] =
'link';
-
$datatable['rows']['row'][$j]['column'][$i]['value'] = lang('link');
-
$datatable['rows']['row'][$j]['column'][$i]['link'] =
$location[$uicols['name'][$i]];
-
$datatable['rows']['row'][$j]['column'][$i]['target'] = '_blank';
- }
- }
- }
- else
- {
-
$datatable['rows']['row'][$j]['column'][$i]['name'] =
$uicols['name'][$i];
-
$datatable['rows']['row'][$j]['column'][$i]['value'] =
$location[$uicols['name'][$i]];
- }
-
-
$datatable['rows']['row'][$j]['hidden'][$i]['value'] =
$location[$uicols['name'][$i]];
-
$datatable['rows']['row'][$j]['hidden'][$i]['name'] =
$uicols['name'][$i];
- }
-
- $j++;
- }
- }
- // NO pop-up
- $datatable['rowactions']['action'] = array();
- if(!$lookup)
- {
- $parameters = array
- (
- 'parameter' => array
- (
- array
- (
- 'name'
=> 'location_code',
- 'source'
=> 'location_code'
- ),
- )
+ 'menuaction' =>
'property.uicondition_survey.view'
+ )),
+ 'parameters' =>
json_encode($parameters)
);
- $parameters2 = array
+ $data['datatable']['actions'][] = array
(
- 'parameter' => array
+ 'my_name' =>
'edit_survey',
+ 'text' =>
lang('edit'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
(
- array
- (
- 'name'
=> 'sibling',
- 'source'
=> 'location_code'
- ),
- )
+ 'menuaction' =>
'property.uicondition_survey.edit'
+ )),
+ 'parameters' =>
json_encode($parameters)
);
- $parameters3 = array
+ $data['datatable']['actions'][] = array
(
- 'parameter' => array
+ 'my_name' =>
'import_survey',
+ 'text' =>
lang('import'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
(
- array
- (
- 'name'
=> 'search_for',
- 'source'
=> 'location_code'
- ),
- )
+ 'menuaction' =>
'property.uicondition_survey.import'
+ )),
+ 'parameters' =>
json_encode($parameters)
);
- if($this->acl->check('run', PHPGW_ACL_READ,
'rental'))
- {
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'view',
- 'text'
=> lang('contracts'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'rental.uicontract.index',
- 'search_type'
=> 'location_id',
-
'contract_status' => 'all',
- 'populate_form'
=> 'yes'
- )),
- 'parameters' =>
$parameters3
- );
-
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'view',
- 'text'
=> lang('composites'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'rental.uicomposite.index',
- 'search_type'
=> 'location_id',
- 'populate_form'
=> 'yes'
- )),
- 'parameters' =>
$parameters3
- );
- }
-
-
- if($this->acl_read)
- {
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'view',
- 'text'
=> lang('view'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'property.uilocation.view',
- 'lookup_tenant'
=> $lookup_tenant
- )),
- 'parameters' =>
$parameters
- );
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'view',
- 'text'
=> lang('open view in new window'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'property.uilocation.view',
- 'lookup_tenant'
=> $lookup_tenant,
- 'target'
=> '_blank'
- )),
- 'parameters' =>
$parameters
- );
- }
- if($this->acl_add)
- {
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'edit',
- 'text'
=> lang('add'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'property.uilocation.edit',
- 'lookup_tenant'
=> $lookup_tenant
- )),
- 'parameters' =>
$parameters2
- );
- }
- if($this->acl_edit)
- {
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'edit',
- 'text'
=> lang('edit'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'property.uilocation.edit',
- 'lookup_tenant'
=> $lookup_tenant
- )),
- 'parameters' =>
$parameters
- );
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'edit',
- 'text'
=> lang('open edit in new window'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'property.uilocation.edit',
- 'lookup_tenant'
=> $lookup_tenant,
- 'target'
=> '_blank'
- )),
- 'parameters' =>
$parameters
- );
-
- }
- $jasper = execMethod('property.sojasper.read',
array('location_id' => $GLOBALS['phpgw']->locations->get_id('property',
$this->acl_location)));
-
- foreach ($jasper as $report)
- {
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'edit',
- 'text'
=> lang('open JasperReport %1 in new window', $report['title']),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'property.uijasper.view',
- 'jasper_id'
=> $report['id'],
- 'target'
=> '_blank'
- )),
- 'parameters'
=> $parameters
- );
- }
-
- foreach ($_integration_set as $_integration )
- {
- $datatable['rowactions']['action'][] =
array
+ if($GLOBALS['phpgw']->acl->check('.admin',
PHPGW_ACL_DELETE, 'property'))
+ {
+ $data['datatable']['actions'][] = array
(
- 'my_name' =>
'integration',
- 'text' =>
$_integration['name'],
- 'action' =>
$_integration['url'].'&target=_blank',
- 'parameters' =>
$_integration['parameters']
- );
- }
-
- if($this->acl_delete)
- {
- $datatable['rowactions']['action'][] =
array
+ 'my_name' =>
'delete_imported_records',
+ 'text' =>
lang('delete imported records'),
+ 'confirm_msg' => lang('do you
really want to delete this entry') . '?',
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
(
- 'my_name'
=> 'delete',
- 'text'
=> lang('delete'),
- 'confirm_msg' =>
lang('do you really want to delete this entry'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'property.uilocation.delete',
- 'lookup_tenant'
=> $lookup_tenant
- )),
- 'parameters' =>
$parameters
- );
- }
- if($this->acl_add)
- {
- $datatable['rowactions']['action'][] =
array
- (
- 'my_name'
=> 'add',
- 'text'
=> lang('add'),
- 'action'
=> $GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction'
=> 'property.uilocation.edit',
- 'type_id'
=> $type_id,
- 'parent'
=> $this->location_code
- ))
- );
- }
-
- unset($parameters);
+ 'menuaction' =>
'property.uicondition_survey.delete_imported_records'
+ )),
+ 'parameters' =>
json_encode($parameters)
+ );
}
- //$uicols_count indicates the number of columns to
display in actuall option-menu. this variable was set in $this->bo->read()
- $uicols_count = count($uicols['descr']);
- for ($i=0;$i<$uicols_count;$i++)
+ if($GLOBALS['phpgw']->acl->check('.admin',
PHPGW_ACL_DELETE, 'property'))
{
- //all colums should be have formatter
-
$datatable['headers']['header'][$i]['formatter'] =
!isset($uicols['formatter'][$i]) || !$uicols['formatter'][$i] ? '""' :
$uicols['formatter'][$i];
-
- if($uicols['input_type'][$i]!='hidden')
- {
-
$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]['format'] =
$this->bocommon->translate_datatype_format($uicols['datatype'][$i]);
-
$datatable['headers']['header'][$i]['sortable'] = false;
-
//$datatable['headers']['header'][$i]['formatter'] =
(isset($uicols['formatter'][$i])? $uicols['formatter'][$i]:"");
- if($uicols['name'][$i]=='loc1')
- {
-
$datatable['headers']['header'][$i]['sortable'] = true;
-
$datatable['headers']['header'][$i]['sort_field'] = 'fm_location1.loc1';
- }
- else
if($uicols['name'][$i]=='street_name')
- {
-
$datatable['headers']['header'][$i]['sortable'] = true;
-
$datatable['headers']['header'][$i]['sort_field'] = 'street_name';
- }
- else
if(isset($uicols['cols_return_extra'][$i]) &&
($uicols['cols_return_extra'][$i]!='T' ||
$uicols['cols_return_extra'][$i]!='CH'))
- {
-
$datatable['headers']['header'][$i]['sortable'] = true;
-
$datatable['headers']['header'][$i]['sort_field'] = $uicols['name'][$i];
- }
- }
- else
- {
-
$datatable['headers']['header'][$i]['name'] =
$uicols['name'][$i];
-
$datatable['headers']['header'][$i]['text'] =
$uicols['descr'][$i];
-
$datatable['headers']['header'][$i]['visible'] = false;
-
$datatable['headers']['header'][$i]['sortable'] = false;
-
$datatable['headers']['header'][$i]['format'] = 'hidden';
- }
+ $data['datatable']['actions'][] = array
+ (
+ 'my_name' =>
'delete_survey',
+ 'text' =>
lang('delete'),
+ 'confirm_msg' => lang('do you
really want to delete this entry') . '?',
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' =>
'property.uicondition_survey.delete'
+ )),
+ 'parameters' =>
json_encode($parameters)
+ );
}
- // for POP-UPs
- if($lookup)
- {
- $input_name =
phpgwapi_cache::session_get('property', 'lookup_fields');
- $function_exchange_values = '';
+
+ self::render_template_xsl('datatable_jquery', $data);
+
+
+
+
+
+
- if(is_array($input_name))
- {
- for ($k=0;$k<count($input_name);$k++)
- {
- $function_exchange_values .=
'parent.document.getElementsByName("'.$input_name[$k].'")[0].value = "";'
."\r\n";
- }
- }
+
- for ($i=0;$i<count($uicols['name']);$i++)
- {
- if(isset($uicols['exchange'][$i]) &&
$uicols['exchange'][$i])
- {
- $function_exchange_values .=
'parent.document.getElementsByName("'.$uicols['name'][$i].'")[0].value = "";'
."\r\n";
- $function_exchange_values .=
'parent.document.getElementsByName("'.$uicols['name'][$i].'")[0].value =
valida(data.getData("'.$uicols['name'][$i].'"));' ."\r\n";
- }
- }
-
- $function_exchange_values
.='window.parent.TINY.box.hide();';
-
- $datatable['exchange_values'] =
$function_exchange_values;
-
- $function_valida = <<<JS
- var pos = data.indexOf('</a>');
- if(pos==-1)
- {
- return data;
- }
- else
- {
- pos = data.indexOf('>');
- var valor =
data.slice(pos+1);
- pos =
valor.indexOf('<');
- valor =
valor.slice(0,pos);
- return valor;
- }
-JS;
- $datatable['valida'] = $function_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->bo->start;
- $datatable['pagination']['records_limit'] =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-
- if($dry_run)
- {
- $datatable['pagination']['records_returned'] =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $datatable['pagination']['records_returned']=
count($location_list);
- }
-
- $datatable['pagination']['records_total'] =
$this->bo->total_records;
-
- if ( (phpgw::get_var("start")== "") &&
(phpgw::get_var("order",'string')== ""))
- {
- $datatable['sorting']['order']
= 'loc1'; // 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('location');
-
- if($lookup)
- {
- $lookup_list =
$GLOBALS['phpgw']->session->appsession('lookup_name','property');
- $function_msg = $lookup_list[$lookup_name];
- }
- else
- {
- if($lookup_tenant)
- {
- $function_msg = lang('Tenant');
- }
- else
- {
- $function_msg
= $uicols['descr'][($type_id)];
- }
- }
-
-
- //-- 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()
- );
-
- foreach ($_integration_set as $i =>
$_integration)
- {
- $json["integrationurl_{$i}"] =
$_integration['url'];
- }
-
- // 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" && isset($column['java_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;
- }
- }
-
- // values for control select
- //address@hidden 10/09/08 values passed for update
select in YUI
- $opt_cb_depend =
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
- $default_value = array ('id'=>'','name'=>'!no part of
town');
- array_unshift ($opt_cb_depend,$default_value);
-
- $json['hidden']['dependent'][] = array ( 'id' =>
$this->part_of_town_id,
- 'value' =>
$this->bocommon->select2String($opt_cb_depend)
- );
-
- // 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 ----------------------
-
- // 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);
-
- phpgwapi_yui::load_widget('dragdrop');
- phpgwapi_yui::load_widget('datatable');
- phpgwapi_yui::load_widget('menu');
- phpgwapi_yui::load_widget('connection');
- //// cramirez: necesary for include a partucular js
- phpgwapi_yui::load_widget('loader');
- //cramirez: necesary for use opener . Avoid error JS
- phpgwapi_yui::load_widget('tabview');
- phpgwapi_yui::load_widget('paginator');
- //FIXME this one is only needed when $lookup==true - so
there is probably an error
- phpgwapi_yui::load_widget('animation');
-
- if ( !isset($GLOBALS['phpgw']->css) ||
!is_object($GLOBALS['phpgw']->css) )
- {
- $GLOBALS['phpgw']->css =
createObject('phpgwapi.css');
- }
- // Prepare CSS Style
- $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/container/assets/skins/sam/container.css');
-
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
-
- //Title of Page
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-
- // Prepare YUI Library
- $GLOBALS['phpgw']->js->validate_file( 'yahoo',
'location.index', 'property' );
-
//$this->save_sessiondata();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [12234] changes on uilocation to support datatable-jquery,
Alejandro <=