[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8203] Showing locations for a controller
From: |
Torstein |
Subject: |
[Fmsystem-commits] [8203] Showing locations for a controller |
Date: |
Mon, 28 Nov 2011 12:25:10 +0000 |
Revision: 8203
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8203
Author: vator
Date: 2011-11-28 12:25:09 +0000 (Mon, 28 Nov 2011)
Log Message:
-----------
Showing locations for a controller
Modified Paths:
--------------
trunk/controller/inc/class.socontrol.inc.php
trunk/controller/inc/class.uicheck_list_for_location.inc.php
trunk/controller/inc/class.uicontrol.inc.php
trunk/controller/js/controller/controller_datatable_test.js
trunk/controller/setup/phpgw_no.lang
trunk/controller/templates/base/locations.xsl
Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php 2011-11-28 10:52:56 UTC
(rev 8202)
+++ trunk/controller/inc/class.socontrol.inc.php 2011-11-28 12:25:09 UTC
(rev 8203)
@@ -125,7 +125,37 @@
}
}
+ function get_locations_for_control($control_id)
+ {
+ $results = array();
+
+ $sql = "SELECT DISTINCT c.id, c.title, cl.location_code ";
+ $sql .= "FROM controller_control c, controller_check_list cl ";
+ $sql .= "WHERE c.id = $control_id ";
+ $sql .= "AND cl.control_id = c.id";
+
+ $this->db->query($sql);
+
+ while($this->db->next_record()) {
+ $control_id = $this->unmarshal($this->db->f('id',
true), 'int');
+ $title = $this->unmarshal($this->db->f('title', true),
'string');
+ $location_code =
$this->unmarshal($this->db->f('location_code', true), 'int');
+
+ $controls_array[] = array("id" => $control_id, "title"
=> $title, "location_code" => $location_code);
+ }
+
+ if( count( $controls_array ) > 0 ){
+ return $controls_array;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+
function get_id_field_name($extended_info = false)
{
if(!$extended_info)
Modified: trunk/controller/inc/class.uicheck_list_for_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list_for_location.inc.php
2011-11-28 10:52:56 UTC (rev 8202)
+++ trunk/controller/inc/class.uicheck_list_for_location.inc.php
2011-11-28 12:25:09 UTC (rev 8203)
@@ -17,8 +17,9 @@
var $type_id;
var $location_code;
- private $so_control_area;
-
+ private $so_control_area;
+ private $so_control;
+
var $public_functions = array(
'index' => true,
);
@@ -33,7 +34,8 @@
$this->bo =
CreateObject('property.bolocation',true);
$this->bocommon = &
$this->bo->bocommon;
$this->so_control_area =
CreateObject('controller.socontrol_area');
-
+ $this->so_control =
CreateObject('controller.socontrol');
+
$this->type_id =
$this->bo->type_id;
$this->start =
$this->bo->start;
@@ -87,10 +89,15 @@
array_unshift ($responsibility_roles,$default_value);
$control_areas_array =
$this->so_control_area->get_control_areas_as_array();
-
- // Fetches prosedures that are related to first control
area in list
- $control_area_id = $control_areas_array[0]['id'];
+ $control_id = 186;
+
+ $locations_for_control_array =
$this->so_control->get_locations_for_control($control_id);
+
+
+
+
+ /*
$lists = array
(
'building_types' =>
$building_types,
@@ -100,11 +107,48 @@
'responsibility_roles_list' =>
$responsibility_roles_list,
'control_area_list' =>
$control_areas_array,
);
+*/
-
-
-
$data = array(
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array(
+ array('type' =>
'filter',
+ 'name' =>
'building_types',
+ 'text' => lang('Building_types').':',
+ 'list' => $building_types
+ ),
+ array('type' =>
'filter',
+ 'name' =>
'cat_id',
+ 'text' => lang('Category_types').':',
+ 'list' => $category_types
+ ),
+ array('type' =>
'filter',
+ 'name' =>
'district_id',
+ 'text' => lang('District_list').':',
+ 'list' => $district_list
+ ),
+ array('type' =>
'filter',
+ 'name' =>
'part_of_town_list',
+ 'text' => lang('Part_of_town_list').':',
+ 'list' => $part_of_town_list
+ ),
+ array('type' =>
'filter',
+ 'name' =>
'responsibility_roles_list',
+ 'text' =>
lang('responsibility_roles_list').':',
+ 'list' => $responsibility_roles_list
+ ),
+ array('type' => 'text',
+ 'name' => 'query'
+ ),
+ array(
+ 'type' =>
'submit',
+ 'name' =>
'search',
+ 'value' =>
lang('Search')
+ ),
+ ),
+ ),
+ ),
'datatable' => array(
'source' =>
self::link(array('menuaction' => 'controller.uicheck_list_for_location.index',
'phpgw_return_as' => 'json')),
'field' => array(
@@ -151,7 +195,9 @@
)
)
),
- 'lists' => $lists
+ 'lists' =>
$lists,
+ 'locations_for_control' =>
$locations_for_control_array,
+ 'control_area_list' =>
$control_areas_array
);
//self::add_javascript('controller', 'yahoo',
'datatable.js');
@@ -174,8 +220,6 @@
$location_list = $this->bo->read(array('user_id' =>
$user_id, 'role_id' =>$role_id,
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,
'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run'
=>$dry_run));
- $uicols = $this->bo->uicols;
-
$results = array();
foreach($location_list as $location)
@@ -205,7 +249,7 @@
$value['labels'][] = lang('show');
$value['ajax'][] = true;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'rental.uicomposite.add_unit', 'location_code' => $value['location_code'])));
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uilocation_check_list', 'location_code' =>
$value['location_code'])));
$value['labels'][] = lang('add_location');
}
}
\ No newline at end of file
Modified: trunk/controller/inc/class.uicontrol.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol.inc.php 2011-11-28 10:52:56 UTC
(rev 8202)
+++ trunk/controller/inc/class.uicontrol.inc.php 2011-11-28 12:25:09 UTC
(rev 8203)
@@ -610,7 +610,7 @@
self::render_template_xsl(array('control_tabs',
'tab_view_check_lists'), $data);
self::add_javascript('controller', 'yahoo',
'control_tabs.js');
}
-
+
// Returns control list info as JSON
public function get_controls_by_control_area()
{
Modified: trunk/controller/js/controller/controller_datatable_test.js
===================================================================
--- trunk/controller/js/controller/controller_datatable_test.js 2011-11-28
10:52:56 UTC (rev 8202)
+++ trunk/controller/js/controller/controller_datatable_test.js 2011-11-28
12:25:09 UTC (rev 8203)
@@ -205,18 +205,23 @@
//...create a handler for context menu clicks
var onContextMenuClick = function(eventString, args, table) {
-
//... the argument holds the selected index number in
the context menu
var task = args[1];
+
//... only act on a data table
if(table instanceof YAHOO.widget.DataTable) {
//... retrieve the record based on the selected
table row
var row =
table.getTrEl(this.contextEventTarget);
var record = table.getRecord(row);
-
+
//... check whether this action should be an
AJAX call
- if(record.getData().ajax[task.index]) {
-
+ if( record.getData().ajax[task.index] ) {
+
+ if(task.index == 1) {
+
+
+ }
+
var alertStatus = false;
// Check if confirm box should be
displayed before request is executed
@@ -508,7 +513,7 @@
*/
function formListener(event){
YAHOO.util.Event.stopEvent(event);
- var qs = YAHOO.controller.serializeForm(this.properties.form);
+ var qs = YAHOO.portico.serializeForm(this.properties.form);
this.source.liveData = this.url + qs + '&';
this.source.sendRequest('', {success: function(sRequest, oResponse,
oPayload) {
this.table.onDataReturnInitializeTable(sRequest, oResponse,
this.paginator);
Modified: trunk/controller/setup/phpgw_no.lang
===================================================================
--- trunk/controller/setup/phpgw_no.lang 2011-11-28 10:52:56 UTC (rev
8202)
+++ trunk/controller/setup/phpgw_no.lang 2011-11-28 12:25:09 UTC (rev
8203)
@@ -1,3 +1,4 @@
+Assign location to control controller no Knytte kontrol til bygg
control controller no Kontroll
controller common no Kontroll
control_helptext controller no Her kommer hjelpetekst for å
opprette en kontroll
Modified: trunk/controller/templates/base/locations.xsl
===================================================================
--- trunk/controller/templates/base/locations.xsl 2011-11-28 10:52:56 UTC
(rev 8202)
+++ trunk/controller/templates/base/locations.xsl 2011-11-28 12:25:09 UTC
(rev 8203)
@@ -15,17 +15,236 @@
</func:result>
</func:function>
-
<xsl:template match="data">
+
+ <div id="addedProperties">
+ <ul id="locations_for_control" name="locations_for_control">
+ <xsl:for-each select="locations_for_control">
+ <li>
+ <div><xsl:value-of select="id"/></div>
+ <div><xsl:value-of
select="title"/></div>
+ <div><xsl:value-of
select="location_code"/></div>
+ </li>
+ </xsl:for-each>
+ </ul>
+ </div>
+
+ <iframe id="yui-history-iframe"
src="phpgwapi/js/yahoo/history/assets/blank.html"
style="position:absolute;top:0; left:0;width:1px;
height:1px;visibility:hidden;"></iframe>
+ <input id="yui-history-field" type="hidden"/>
<xsl:call-template name="yui_booking_i18n"/>
- <xsl:apply-templates select="lists"/>
+ <xsl:apply-templates select="form" />
<xsl:apply-templates select="paging"/>
+ <div id="list_flash">
+ <xsl:call-template name="msgbox"/>
+ </div>
<xsl:apply-templates select="datatable"/>
+ <xsl:apply-templates select="form/list_actions"/>
+
</xsl:template>
+<xsl:template match="form">
+ <form id="queryForm" style="margin: 20px; width: 65%;">
+ <xsl:attribute name="method">
+ <xsl:value-of select="phpgw:conditional(not(method),
'GET', method)"/>
+ </xsl:attribute>
+
+ <xsl:attribute name="action">
+ <xsl:value-of select="phpgw:conditional(not(action),
'', action)"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="toolbar"/>
+ </form>
+
+ <form id="update_table_dummy" method='POST' action='' >
+ </form>
+
+</xsl:template>
+
+
+<xsl:template match="toolbar">
+ <div id="toolbar">
+ <table class='yui-skin-sam' border="0" cellspacing="0"
cellpadding="0" style="padding:0px; margin:0px;">
+ <tr>
+ <xsl:for-each select="item">
+ <xsl:variable name="filter_key"
select="concat('filter_', name)"/>
+ <xsl:variable name="filter_key_name"
select="concat(concat('filter_', name), '_name')"/>
+ <xsl:variable name="filter_key_id"
select="concat(concat('filter_', name), '_id')"/>
+
+ <xsl:choose>
+ <xsl:when test="type = 'date-picker'">
+ <td valign="top">
+ <div class="date-picker">
+ <input id="filter_{name}" name="filter_{name}"
type="text">
+ <xsl:attribute
name="value"><xsl:value-of select="../../../filters/*[local-name() =
$filter_key]"/></xsl:attribute>
+ </input>
+ </div>
+ </td>
+ </xsl:when>
+ <xsl:when test="type = 'autocomplete'">
+ <td valign="top" width="160px">
+ <div style="width:140px">
+ <input
id="filter_{name}_name" name="filter_{name}_name" type="text">
+ <xsl:attribute
name="value"><xsl:value-of select="../../../filters/*[local-name() =
$filter_key_name]"/></xsl:attribute>
+ </input>
+ <input
id="filter_{name}_id" name="filter_{name}_id" type="hidden">
+ <xsl:attribute
name="value"><xsl:value-of select="../../../filters/*[local-name() =
$filter_key_id]"/></xsl:attribute>
+ </input>
+ <div
id="filter_{name}_container"/>
+ </div>
+ <script type="text/javascript">
+
YAHOO.util.Event.onDOMReady(function() {
+ var name = "<xsl:value-of
select="name"/>";
+ var ui = "<xsl:value-of
select="ui"/>";
+
+ var itemSelectCallback
= false;
+ <xsl:if
test="onItemSelect">
+
itemSelectCallback = <xsl:value-of select="onItemSelect"/>;
+ </xsl:if>
+
+ var
onClearSelectionCallback = false;
+ <xsl:if
test="onClearSelection">
+
onClearSelectionCallback = <xsl:value-of select="onClearSelection"/>;
+ </xsl:if>
+
+ var requestGenerator =
false;
+ <xsl:if
test="requestGenerator">
+
requestGenerator = <xsl:value-of select="requestGenerator"/>;
+ </xsl:if>
+
+ <![CDATA[
+ var oAC =
YAHOO.portico.autocompleteHelper('index.php?menuaction=booking.ui'+ui+'.index&phpgw_return_as=json&',
+
'filter_'+name+'_name', 'filter_'+name+'_id', 'filter_'+name+'_container');
+
+ if (requestGenerator) {
+
oAC.generateRequest = requestGenerator;
+ }
+
+ if (itemSelectCallback)
{
+
oAC.itemSelectEvent.subscribe(itemSelectCallback);
+ }
+
+
YAHOO.util.Event.addBlurListener('filter_'+name+'_name', function()
+ {
+ if
(YAHOO.util.Dom.get('filter_'+name+'_name').value == "")
+ {
+
YAHOO.util.Dom.get('filter_'+name+'_id').value = "";
+ if
(onClearSelectionCallback) {
+
onClearSelectionCallback();
+ }
+ }
+ });
+
+
YAHOO.portico.addPreSerializeQueryFormListener(function(form)
+ {
+ if
(YAHOO.util.Dom.get('filter_'+name+'_name').value == "")
+ {
+
YAHOO.util.Dom.get('filter_'+name+'_id').value = "";
+ }
+ });
+ ]]>
+ });
+ </script>
+ </td>
+ </xsl:when>
+ <xsl:when test="type = 'filter'">
+ <td valign="top">
+ <xsl:variable name="name"><xsl:value-of
select="name"/></xsl:variable>
+
+ <select id="{$name}" name="{$name}"
onMouseout="window.status='';return true;">
+ <xsl:for-each select="list">
+ <xsl:variable name="id"><xsl:value-of
select="id"/></xsl:variable>
+ <xsl:if test="id =
'NEW'">
+ <option value="{$id}"
selected="selected">
+
<xsl:value-of select="name"/>
+ </option>
+ </xsl:if>
+ <xsl:if test="id !=
'NEW'">
+ <option value="{$id}">
+
<xsl:value-of select="name"/>
+ </option>
+ </xsl:if>
+ </xsl:for-each>
+ </select>
+ </td>
+ </xsl:when>
+ <xsl:otherwise>
+ <td valign="top">
+ <input id="innertoolbar">
+ <xsl:attribute
name="type"><xsl:value-of select="phpgw:conditional(not(type), '',
type)"/></xsl:attribute>
+ <xsl:attribute
name="name"><xsl:value-of select="phpgw:conditional(not(name), '',
name)"/></xsl:attribute>
+ <xsl:attribute
name="onclick"><xsl:value-of select="phpgw:conditional(not(onClick), '',
onClick)"/></xsl:attribute>
+ <xsl:attribute
name="value"><xsl:value-of select="phpgw:conditional(not(value), '',
value)"/></xsl:attribute>
+ <xsl:attribute
name="href"><xsl:value-of select="phpgw:conditional(not(href), '',
href)"/></xsl:attribute>
+ <xsl:attribute
name="class"><xsl:value-of select="phpgw:conditional(not(class), '',
class)"/></xsl:attribute>
+ </input>
+ </td>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </tr>
+ <xsl:if test="item/text and normalize-space(item/text)">
+ <thead style="background:none">
+ <tr>
+ <xsl:for-each select="item">
+ <td>
+ <xsl:if
test="name">
+ <label
style='margin:auto 0.25em'>
+
<xsl:attribute name="for"><xsl:value-of select="phpgw:conditional(not(name),
'', name)"/></xsl:attribute>
+
<xsl:value-of select="phpgw:conditional(not(text), '', text)"/>
+ </label>
+ </xsl:if>
+ </td>
+ </xsl:for-each>
+ </tr>
+ </thead>
+ </xsl:if>
+ </table>
+ </div>
+</xsl:template>
+
+<xsl:template match="datatable">
+ <div id="paginator"/>
+ <div id="datatable-container"/>
+ <xsl:call-template name="datasource-definition" />
+</xsl:template>
+
+
+<xsl:template name="datasource-definition">
+ <script>
+ YAHOO.namespace('controller');
+
+ YAHOO.controller.columnDefs = [
+ <xsl:for-each select="//datatable/field">
+ {
+ key: "<xsl:value-of
select="key"/>",
+ <xsl:if test="label">
+ label: "<xsl:value-of
select="label"/>",
+ </xsl:if>
+ sortable: <xsl:value-of
select="phpgw:conditional(not(sortable = 0), 'true', 'false')"/>,
+ <xsl:if test="hidden">
+ hidden: true,
+ </xsl:if>
+ <xsl:if test="formatter">
+ formatter: <xsl:value-of
select="formatter"/>,
+ </xsl:if>
+ className: "<xsl:value-of
select="className"/>"
+ }<xsl:value-of
select="phpgw:conditional(not(position() = last()), ',', '')"/>
+ </xsl:for-each>
+ ];
+
+ setDataSource('<xsl:value-of select="source"/>',
YAHOO.controller.columnDefs, 'queryForm', ['building_types', 'cat_id',
'district_id', 'part-of_town_list', 'responsibility_roles_list'],
'datatable-container', '_form', '_paginator', null);
+
+ </script>
+
+</xsl:template>
+<!--
<xsl:template match="lists">
-
+
<div style="background: none repeat scroll 0 0 #EDF5FF;border: 1px solid
#243356;margin: 20px;padding: 20px;">
+-->
+ <!-- When control area is chosen an ajax request is executed.
The operation fetches controls from db and populates the control list below.
+ The ajax opearation is handled in file ajax.js
+ -->
+ <!--
<select id="control_area_list" name="control_area_list">
<xsl:for-each select="control_area_list">
<xsl:variable
name="control_area_id"><xsl:value-of select="id"/></xsl:variable>
@@ -96,60 +315,5 @@
</xsl:for-each>
</select>
</div>
-
-
-
-
</xsl:template>
-
-
-
-
-
-<xsl:template match="datatable">
- <div id="paginator"/>
- <div id="datatable-container"/>
- <xsl:call-template name="datasource-definition" />
-</xsl:template>
-
-
-<xsl:template name="datasource-definition">
- <script>
- YAHOO.namespace('controller');
- <!--
- YAHOO.controller.setupDatasource = function() {
- <xsl:if test="source">
- YAHOO.controller.dataSourceUrl = '<xsl:value-of
select="source"/>';
- YAHOO.controller.initialSortedBy =
false;
- YAHOO.controller.initialFilters = false;
- <xsl:if test="sorted_by">
-
YAHOO.controller.initialSortedBy = {key: '<xsl:value-of
select="sorted_by/key"/>', dir: '<xsl:value-of select="sorted_by/dir"/>'};
- </xsl:if>
- </xsl:if>
-*/
- -->
-
- YAHOO.controller.columnDefs = [
- <xsl:for-each select="//datatable/field">
- {
- key: "<xsl:value-of
select="key"/>",
- <xsl:if test="label">
- label: "<xsl:value-of
select="label"/>",
- </xsl:if>
- sortable: <xsl:value-of
select="phpgw:conditional(not(sortable = 0), 'true', 'false')"/>,
- <xsl:if test="hidden">
- hidden: true,
- </xsl:if>
- <xsl:if test="formatter">
- formatter: <xsl:value-of
select="formatter"/>,
- </xsl:if>
- className: "<xsl:value-of
select="className"/>"
- }<xsl:value-of
select="phpgw:conditional(not(position() = last()), ',', '')"/>
- </xsl:for-each>
- ];
-
- setDataSource('<xsl:value-of select="source"/>',
YAHOO.controller.columnDefs, null, null, 'datatable-container', '_form',
'_paginator', null);
-
- </script>
-
-</xsl:template>
\ No newline at end of file
+-->
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8203] Showing locations for a controller,
Torstein <=