[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9477] controller: register control to component
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [9477] controller: register control to component |
Date: |
Thu, 31 May 2012 12:41:38 +0000 |
Revision: 9477
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9477
Author: sigurdne
Date: 2012-05-31 12:41:38 +0000 (Thu, 31 May 2012)
Log Message:
-----------
controller: register control to component
Modified Paths:
--------------
trunk/controller/inc/class.uicontrol_location.inc.php
Modified: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php 2012-05-31
12:39:20 UTC (rev 9476)
+++ trunk/controller/inc/class.uicontrol_location.inc.php 2012-05-31
12:41:38 UTC (rev 9477)
@@ -61,9 +61,11 @@
'view_locations_for_control' => true,
'register_control_to_location' => true,
'register_control_to_location_2' => true,
+
'register_control_to_component' => true,
'get_locations_for_control' => true,
'get_location_category' => true,
-
'get_district_part_of_town' => true
+
'get_district_part_of_town' => true,
+
'entity' => true
);
function __construct()
@@ -269,13 +271,24 @@
);
}
- $tabs = array( array(
- 'label' =>
lang('View_locations_for_control'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol_location.index'))
-
- ), array(
- 'label' =>
lang('Add_locations_for_control')
- ));
+ $tabs = array
+ (
+ array
+ (
+ 'label' =>
lang('View_locations_for_control'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol_location.index'))
+ ),
+ array
+ (
+ 'label' =>
lang('Add_locations_for_control')
+ ),
+ array
+ (
+ 'label' => lang('add components
for control'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol_location.register_control_to_component'))
+ )
+
+ );
$data = array(
'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
@@ -360,6 +373,580 @@
}
}
+
+
+ function register_control_to_component()
+ {
+ $control_id = phpgw::get_var('control_id');
+ if(phpgw::get_var('save_location'))
+ {
+ $values = phpgw::get_var('values');
+ //add component to control using component item
ID
+ $values['control_location'] =
isset($values['control_location']) && $values['control_location'] ?
array_unique($values['control_location']) : array();
+ $values['control_location_orig'] =
isset($values['control_location_orig']) && $values['control_location_orig'] ?
array_unique($values['control_location_orig']) : array();
+
+ $ok =
$this->so_control->register_control_to_location($control_id, $values);
+
+/* if($ok)
+ {
+ return json_encode( array( "status" =>
"saved" ) );
+ }
+ else
+ {
+ return json_encode( array( "status" =>
"not_saved" ) );
+ }
+*/
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' =>
'controller.uicontrol_location.register_control_to_location', 'control_id' =>
$control_id));
+
+ }
+ else
+ {
+ if(phpgw::get_var('phpgw_return_as') == 'json')
{
+ return $this->query();
+ }
+ $building_types =
execMethod('property.soadmin_location.read',array());
+ //$type_id=phpgw::get_var('type_id');
+ //if(!isset($type_id))
+ $type_id = 1;
+
+ $category_types =
$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 selected'));
+ array_unshift($category_types,$default_value);
+
+ $district_list =
$this->bocommon->select_district_list('filter',$this->district_id);
+ $default_value = array
('id'=>'','name'=>lang('no district'));
+ array_unshift($district_list,$default_value);
+
+ $part_of_town_list =
$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($part_of_town_list,$default_value);
+
+ $_role_criteria = array
+ (
+ 'type' =>
'responsibility_role',
+ 'filter' =>
array('location_level' => (int)$type_id),
+ 'order' =>
'name'
+ );
+
+ $responsibility_roles_list =
execMethod('property.sogeneric.get_list',$_role_criteria);
+ $default_value = array
('id'=>'','name'=>lang('no role'));
+ array_unshift
($responsibility_roles,$default_value);
+
+ $cats = CreateObject('phpgwapi.categories',
-1, 'controller', '.control');
+ $cats->supress_info = true;
+
+ $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl'
=> $this->_category_acl));
+
+ $control_areas_array = array();
+ foreach($control_areas['cat_list'] as $cat_list)
+ {
+ $control_areas_array[] = array
+ (
+ 'id' => $cat_list['cat_id'],
+ 'name' => $cat_list['name'],
+ );
+ }
+
+ $control_info =
execMethod('controller.socontrol.get_single', $control_id);
+ if($control_info)
+ {
+ $control_array = array
+ (
+ 'id' => $control_id,
+ 'title' =>
$control_info->get_title()
+ );
+ }
+
+ $tabs = array
+ (
+ array
+ (
+ 'label' =>
lang('View_locations_for_control'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol_location.index'))
+ ),
+ array
+ (
+ 'label' =>
lang('Add_locations_for_control'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol_location.register_control_to_location'))
+ ),
+ array
+ (
+ 'label' => lang('add components
for control'),
+ )
+
+ );
+
+ $data = array(
+ 'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 2),
+ 'view'
=> "register_control_to_location",
+ 'control_id'
=> $control_id,
+ 'control_filters'
=> array(
+ 'control_areas_array' =>
$control_areas_array,
+ 'control_array'
=> $control_array
+ ),
+ 'filter_form'
=> array(
+ 'building_types'
=> $building_types,
+ 'category_types'
=> $category_types,
+ 'district_list'
=> $district_list,
+ 'part_of_town_list'
=> $part_of_town_list
+ ),
+ 'datatable' => array(
+ 'source' =>
self::link(array('menuaction' => 'controller.uicontrol_location.index',
'phpgw_return_as' => 'json', 'view_type' =>
'register_control','control_id_init' => $control_id)),
+ 'field' => array(
+ array(
+ 'key' =>
'location_registered',
+ 'hidden' => true
+ ),
+ array(
+ 'key' =>
'location_code',
+ 'label' =>
lang('Property'),
+ 'sortable'
=> true,
+ 'formatter' =>
'YAHOO.portico.formatLink'
+ ),
+ array(
+ 'key' =>
'loc1_name',
+ 'label' =>
lang('Property name'),
+ 'sortable'
=> false
+ ),
+ array(
+ 'key' =>
'adresse1',
+ 'label' =>
lang('Address'),
+ 'sortable'
=> false
+ ),
+ array(
+ 'key' =>
'postnummer',
+ 'label' =>
lang('Zip code'),
+ 'sortable'
=> false
+ ),
+ array(
+ 'key' =>
'control_name',
+ 'label' =>
lang('control'),
+ 'sortable'
=> false
+ ),
+ array(
+ 'key'
=> 'checked',
+ 'label'
=> 'Velg',
+
'sortable' => false,
+
'formatter' => 'formatterCheckLocation',
+
'className' => 'mychecks'
+ ),
+ array(
+ 'key' =>
'actions',
+ 'hidden' => true
+ ),
+ array(
+ 'key' =>
'labels',
+ 'hidden' => true
+ ),
+ array(
+ 'key' => 'ajax',
+ 'hidden' => true
+ ),array(
+ 'key' =>
'parameters',
+ 'hidden' => true
+ )
+ )
+ )
+ );
+
+ phpgwapi_yui::load_widget('paginator');
+
+ self::add_javascript('controller',
'controller', 'jquery.js');
+ self::add_javascript('controller',
'controller', 'ajax.js');
+ self::add_javascript('controller', 'yahoo',
'register_control_to_location.js');
+
+
self::render_template_xsl(array('control_location/control_location_tabs',
'control_location/register_control_to_location', 'common'), $data);
+ }
+ }
+
+
+
+ function entity()
+ {
+ $bocommon =
CreateObject('property.bocommon');
+ $boentity =
CreateObject('property.boentity');
+ $boadmin_entity =
CreateObject('property.boadmin_entity');
+ $this->start =
$boentity->start;
+ $this->query =
$boentity->query;
+ $this->sort =
$boentity->sort;
+ $this->order =
$boentity->order;
+ $this->filter =
$boentity->filter;
+ $this->cat_id =
$boentity->cat_id;
+ $this->part_of_town_id =
$boentity->part_of_town_id;
+ $this->district_id =
$boentity->district_id;
+ $this->entity_id =
$boentity->entity_id;
+ $this->location_code =
$boentity->location_code;
+ $this->criteria_id =
$boentity->criteria_id;
+
+ $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)
+ {
+ $this->bo->district_id = $default_district;
+ $this->district_id =
$default_district;
+ }
+
+ if( phpgw::get_var('phpgw_return_as') != 'json' )
+ {
+
+ $datatable['config']['base_url'] =
$GLOBALS['phpgw']->link('/index.php', array
+ (
+ 'menuaction' =>
'property.uilookup.entity',
+ 'entity_id'
=> $this->entity_id,
+ 'cat_id'
=> $this->cat_id,
+ 'district_id' =>
$this->district_id,
+ 'query'
=> $this->query,
+ 'filter'
=> $this->filter,
+ 'location_code' =>
$this->location_code,
+ 'criteria_id' =>
$this->criteria_id
+ ));
+
+ $datatable['config']['allow_allrows'] = true;
+
+ $datatable['config']['base_java_url'] =
"menuaction:'property.uilookup.entity',"
+ ."second_display:1,"
+ ."entity_id:'{$this->entity_id}',"
+ ."cat_id:'{$this->cat_id}',"
+ ."district_id:'{$this->district_id}',"
+ ."query:'{$this->query}',"
+ ."filter:'{$this->filter}',"
+ ."criteria_id:'{$this->criteria_id}',"
+
."location_code:'{$this->location_code}'";
+
+ $values_combo_box[0] =
$boentity->select_category_list('filter',$this->cat_id);
+ $default_value = array
('id'=>'','name'=>lang('no category'));
+ array_unshift
($values_combo_box[0],$default_value);
+
+ $values_combo_box[1] =
$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] =
$boentity->get_criteria_list($this->criteria_id);
+ $default_value = array
('id'=>'','name'=>lang('no criteria'));
+ array_unshift
($values_combo_box[2],$default_value);
+
+ $datatable['actions']['form'] = array
+ (
+ array
+ (
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',
+ array
+ (
+ 'menuaction'
=> 'property.uilookup.entity',
+
'second_display' => $second_display,
+ 'entity_id'
=> $this->entity_id,
+ 'cat_id'
=> $this->cat_id,
+ 'district_id'
=> $this->district_id,
+ 'query'
=> $this->query,
+ 'filter'
=> $this->filter
+ )
+ ),
+ '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
CATEGORY
+ 'id' =>
'btn_district_id',
+ 'name'
=> 'district_id',
+ 'value'
=> lang('District'),
+ 'type'
=> 'button',
+ 'style'
=> 'filter',
+
'tab_index' => 2
+ ),
+ array
+ ( //boton
search criteria
+ 'id' =>
'btn_criteria_id',
+ 'name'
=> 'criteria_id',
+ 'value'
=> lang('search criteria'),
+ 'type'
=> 'button',
+ 'style'
=> 'filter',
+
'tab_index' => 3
+ ),
+ array
+ ( //boton
SEARCH
+ 'id' =>
'btn_search',
+ 'name'
=> 'search',
+ 'value'
=> lang('search'),
+ 'type'
=> 'button',
+
'tab_index' => 5
+ ),
+ array
+ ( // TEXT IMPUT
+ 'name'
=> 'query',
+ 'id'
=> 'txt_query',
+ 'value'
=> '',//'',//$query,
+ 'type'
=> 'text',
+ 'size'
=> 28,
+
'onkeypress' => 'return pulsar(event)',
+
'tab_index' => 4
+ )
+ ),
+ 'hidden_value' => array
+ (
+ array
+ ( //div values
combo_box_0
+ 'id' =>
'values_combo_box_0',
+ 'value'
=> $bocommon->select2String($values_combo_box[0]) //i.e. id,value/id,vale/
+ ),
+ array
+ ( //div values
combo_box_1
+ 'id' =>
'values_combo_box_1',
+ 'value'
=> $bocommon->select2String($values_combo_box[1]) //i.e. id,value/id,vale/
+ ),
+ array
+ ( //div values
combo_box_2
+ 'id' =>
'values_combo_box_2',
+ 'value'
=> $bocommon->select2String($values_combo_box[2]) //i.e. id,value/id,vale/
+ )
+ )
+ )
+ )
+ );
+ }
+
+ $entity_list = $boentity->read(array('lookup'=>true));
+ $input_name =
$GLOBALS['phpgw']->session->appsession('lookup_fields','property');
+ $uicols = $boentity->uicols;
+
+ if (count($uicols['name']) > 0)
+ {
+ for ($m = 0; $m<count($input_name); $m++)
+ {
+ if
(!array_search($input_name[$m],$uicols['name']))
+ {
+ $uicols['name'][] =
$input_name[$m];
+ $uicols['descr'][] = '';
+ $uicols['input_type'][]
= 'hidden';
+ }
+ }
+ }
+ else
+ {
+
+ $uicols['name'][] = 'num';
+ $uicols['descr'][] = 'ID';
+ $uicols['input_type'][] = 'text';
+ }
+
+ $content = array();
+ $j=0;
+ if (isset($entity_list) && is_array($entity_list))
+ {
+ foreach($entity_list as $entity_entry)
+ {
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
$datatable['rows']['row'][$j]['column'][$i]['value'] =
($entity_entry[$uicols['name'][$i]] == null ? '' :
$entity_entry[$uicols['name'][$i]]);
+
$datatable['rows']['row'][$j]['column'][$i]['name'] = $uicols['name'][$i];
+
+ if(isset($uicols['datatype'])
&& isset($uicols['datatype'][$i]) && $uicols['datatype'][$i]=='link' &&
$entity_entry[$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'] =
$entity_entry[$uicols['name'][$i]];
+
$datatable['rows']['row'][$j]['column'][$i]['target'] = '_blank';
+ }
+ }
+
+ /*for ($i=0;$i<count($input_name);$i++)
+ {
+
$datatable['rows']['row'][$j]['hidden'][$i]['value'] =
$entity_entry[$input_name[$i]];
+
$datatable['rows']['row'][$j]['hidden'][$i]['name'] = $input_name[$i];
+ }*/
+ $j++;
+ }
+ }
+
+ $uicols_count = count($uicols['descr']);
+ $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]);
+
+ 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]['sortable'] = false;
+
+ if($uicols['name'][$i]=='loc1' ||
$uicols['name'][$i]=='num')
+ {
+
$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';
+ }
+ }
+
+ $function_exchange_values = '';
+
+ for ($i=0;$i<count($input_name);$i++)
+ {
+ $function_exchange_values .=
"opener.document.getElementsByName('{$input_name[$i]}')[0].value = '';\r\n";
+ }
+
+ for ($i=0;$i<count($input_name);$i++)
+ {
+ $function_exchange_values .=
"opener.document.getElementsByName('{$input_name[$i]}')[0].value =
data.getData('{$input_name[$i]}');\r\n";
+ }
+
+ $function_exchange_values .= 'window.close()';
+
+ $datatable['exchange_values'] =
$function_exchange_values;
+ $datatable['valida'] = '';
+
+ // path for property.js
+ $datatable['property_js'] =
$GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/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($entity_list);
+ $datatable['pagination']['records_total'] =
$boentity->total_records;
+
+ if ( (phpgw::get_var("start")== "") &&
(phpgw::get_var("order",'string')== ""))
+ {
+ $datatable['sorting']['order']
= 'num'; // name key Column in myColumnDef
+ $datatable['sorting']['sort']
= 'desc'; // 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
+ }
+
+
+ //-- 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(),
+ 'headers' =>
$uicols
+
+ );
+
+ // 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;
+ }
+
+ $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'),PHPGW_SERVER_ROOT .
'/phpgwapi/templates/base');
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',
$template_vars);
+
+ if($this->entity_id)
+ {
+ $entity =
$boadmin_entity->read_single($this->entity_id,false);
+ $appname = $entity['name'];
+ }
+ if($this->cat_id)
+ {
+ $category =
$boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+ $function_msg
= lang('lookup') . ' ' . $category['name'];
+ }
+
+ //Title of Page
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+
+ // Prepare YUI Library
+ $GLOBALS['phpgw']->js->validate_file( 'yahoo',
'lookup.entity.index', 'property' );
+
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+
+ phpgwapi_yui::load_widget('tabview');
+ 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');
+
+ 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');
+
+
+// $this->save_sessiondata();
+ }
+
+
// Returns locations for a control
public function get_locations_for_control()
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9477] controller: register control to component,
Sigurd Nes <=