[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14453] bookingfrontend: added part of town as filter
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14453] bookingfrontend: added part of town as filter |
Date: |
Mon, 23 Nov 2015 15:26:49 +0000 |
Revision: 14453
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14453
Author: sigurdne
Date: 2015-11-23 15:26:47 +0000 (Mon, 23 Nov 2015)
Log Message:
-----------
bookingfrontend: added part of town as filter
Modified Paths:
--------------
branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
branches/dev-syncromind/booking/inc/class.socommon.inc.php
branches/dev-syncromind/booking/inc/class.uibuilding.inc.php
branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
Modified: branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
2015-11-23 08:08:09 UTC (rev 14452)
+++ branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
2015-11-23 15:26:47 UTC (rev 14453)
@@ -25,6 +25,15 @@
'deactivate_sendmessage' =>
array('type' => 'int'),
'extra_kalendar' => array('type' =>
'int'),
'location_code' =>array('type' =>
'string', 'required' => false),
+ 'part_of_town_id' => array('type'
=> 'string',
+ 'required' => false,
+ 'join' =>
array(
+ 'table' =>
'fm_location1',
+ 'fkey' =>
'location_code',
+ 'key' =>
'location_code',
+ 'column' =>
'location_code'
+ )),
+
'street' => array('type'
=> 'string', 'query' => true),
'zip_code' => array('type'
=> 'string'),
'district' => array('type'
=> 'string', 'query' => true),
Modified: branches/dev-syncromind/booking/inc/class.socommon.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.socommon.inc.php 2015-11-23
08:08:09 UTC (rev 14452)
+++ branches/dev-syncromind/booking/inc/class.socommon.inc.php 2015-11-23
15:26:47 UTC (rev 14453)
@@ -351,7 +351,9 @@
{
if($this->fields[$key])
{
- $table =
isset($this->fields[$key]['join']) && $this->fields[$key]['join'] ?
$this->fields[$key]['table'].'_'.$params['join']['column'] : $this->table_name;
+// $table =
isset($this->fields[$key]['join']) && $this->fields[$key]['join'] ?
$this->fields[$key]['table'].'_'.$params['join']['column'] : $this->table_name;
+ $table = $this->fields[$key]['join'] ?
$this->build_join_table_alias($key, $this->fields[$key]) : $this->table_name;
+
if(is_array($val) && count($val) == 0)
{
$clauses[] = '1=0';
Modified: branches/dev-syncromind/booking/inc/class.uibuilding.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uibuilding.inc.php
2015-11-23 08:08:09 UTC (rev 14452)
+++ branches/dev-syncromind/booking/inc/class.uibuilding.inc.php
2015-11-23 15:26:47 UTC (rev 14453)
@@ -161,6 +161,11 @@
public function query()
{
+ $filter_part_of_town_id =
phpgw::get_var(filter_part_of_town_id);
+ if(preg_match("/,/",$filter_part_of_town_id))
+ {
+ $_REQUEST['filter_part_of_town_id'] =
explode(',', $filter_part_of_town_id);
+ }
$buildings = $this->bo->read();
foreach($buildings['results'] as &$building)
{
Modified: branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
2015-11-23 08:08:09 UTC (rev 14452)
+++ branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
2015-11-23 15:26:47 UTC (rev 14453)
@@ -12,14 +12,12 @@
$this->soevent = CreateObject('booking.soevent');
}
- function search($searchterm, $activity_top_level, $building_id)
+ function search($searchterm, $activity_top_level, $building_id,
$filter_part_of_town)
{
- if($activity_top_level && !$building_id)
+ $building_filter = array();
+
+ if($type = phpgw::get_var('type', 'string'))
{
- $types = array('resource');
- }
- else if($type = phpgw::get_var('type', 'string','GET'))
- {
$types = array($type);
}
else
@@ -31,10 +29,21 @@
if(in_array('building', $types))
{
- $bui_result =
$this->sobuilding->read(array("query"=>$searchterm, "sort" => "name", "dir" =>
"asc", "filters" => array("active" => "1", 'id' => $building_id)));
- foreach($bui_result['results'] as &$bui)
+ $_filter_building = array("active" => "1");
+ if(isset($filter_part_of_town[0]) &&
$filter_part_of_town[0])
+ {
+ $_filter_building['part_of_town_id'] =
$filter_part_of_town;
+ }
+ if($building_id)
+ {
+ $_filter_building['id'] = $building_id;
+ }
+
+ $bui_result =
$this->sobuilding->read(array("query"=>$searchterm, "sort" => "name", "dir" =>
"asc", "filters" => $_filter_building));
+ foreach($bui_result['results'] as &$bui)
{
- $bui['type'] = "building";
+ $building_filter[] = $bui['id'];
+ $bui['type'] = "building";
$bui['link'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uibuilding.show', 'id' => $bui['id']));
$bui['img_container'] = "building-" . $bui['id'];
$bui['img_url'] =
$GLOBALS['phpgw']->link('/bookingfrontend/', array('menuaction' =>
'bookingfrontend.uidocument_building.index_images', 'filter_owner_id' =>
$bui['id'], 'phpgw_return_as' => 'json', 'results' => '1'));
@@ -68,10 +77,17 @@
{
$_filter_resource['activity_id'] =
$activity_top_level;
}
+
+ $_filter_resource['building_id'] =
$building_filter;
+
if($building_id)
{
- $_filter_resource['building_id'] =
$building_id;
+ $_filter_resource['building_id'][] =
$building_id;
}
+ if(isset($filter_part_of_town[0]) &&
$filter_part_of_town[0])
+ {
+ $_filter_resource['part_of_town_id'] =
$filter_part_of_town;
+ }
$res_result =
$this->soresource->read(array("query"=>$searchterm, "sort" => "name", "dir" =>
"asc", "filters" => $_filter_resource ));
foreach($res_result['results'] as &$res)
Modified: branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
2015-11-23 08:08:09 UTC (rev 14452)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
2015-11-23 15:26:47 UTC (rev 14453)
@@ -29,7 +29,8 @@
$type = phpgw::get_var('type','string', 'REQUEST',
null);
$activity_top_level =
phpgw::get_var('activity_top_level', 'int', 'REQUEST', null);
$building_id = phpgw::get_var('building_id', 'int',
'REQUEST', null);
-
+ $filter_part_of_town = explode(',',
phpgw::get_var('filter_part_of_town','string'));
+ $imploded_filter_part_of_town = implode(',',
$filter_part_of_town);
$search = null;
if ($config->config_data['frontpagetext'] != '')
{
@@ -40,21 +41,22 @@
$frontpagetext = 'Velkommen til AktivBy.<br
/>Her finner du informasjon om idrettsanlegg som leies ut<br />av
idrettsavdelingen.';
}
- if ($building_id || $type || $activity_top_level)
+ if ($building_id || $type || $activity_top_level ||
(isset($filter_part_of_town[0]) && $filter_part_of_town[0]))
{
$search = array(
- 'results' =>
$this->bo->search($searchterm, $activity_top_level, $building_id),
+ 'results' =>
$this->bo->search($searchterm, $activity_top_level, $building_id,
$filter_part_of_town),
'searchterm' => $searchterm,
'activity_top_level'=>
$activity_top_level
);
}
-
+
$params = is_null($search) ? array('baseurl' =>
"{$GLOBALS['phpgw_info']['server']['webserver_url']}", 'frontimage' =>
"{$GLOBALS['phpgw_info']['server']['webserver_url']}/phpgwapi/templates/bkbooking/images/newlayout/forsidebilde.jpg",
'frontpagetext' => $frontpagetext) : array('search' => $search);
$params['activity_top_level'] = $activity_top_level;
$bobuilding = CreateObject('booking.bobuilding');
$building = $bobuilding->read_single($building_id);
$params['building_name'] = $building['name'];
+ $params['building_id'] = $building_id;
$activities =
ExecMethod('booking.boactivity.get_top_level');
@@ -63,13 +65,20 @@
$activity['search_url'] = self::link(array(
'menuaction' =>
'bookingfrontend.uisearch.index',
'activity_top_level' =>
$activity['id'],
- 'building_id' =>
$building_id
+ 'building_id' =>
$building_id,
+ 'filter_part_of_town' =>
$imploded_filter_part_of_town
));
}
$params['activities'] = $activities;
+ $params['part_of_towns'] =
execMethod('property.sogeneric.get_list', array('type' => 'part_of_town'));
+// $params['selected_part_of_towns'] =
$imploded_filter_part_of_town;
+
+ foreach ($params['part_of_towns'] as &$part_of_town)
+ {
+ $part_of_town['checked'] =
in_array($part_of_town['id'], $filter_part_of_town);
+ }
-// self::render_template('search', $params);
self::render_template_xsl('search', $params);
}
Modified: branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
===================================================================
--- branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2015-11-23 08:08:09 UTC (rev 14452)
+++ branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2015-11-23 15:26:47 UTC (rev 14453)
@@ -1,31 +1,65 @@
var building_id_selection = "";
+var part_of_town_string = "";
+var part_of_towns = [];
$(document).ready(function () {
- oArgs = {menuaction: 'bookingfrontend.uibuilding.index'};
+ $("#part_of_town :checkbox:checked").each(function() {
+ part_of_towns.push($(this).val());
+ });
+ part_of_town_string = part_of_towns.join(',');
+ oArgs = {
+ menuaction: 'bookingfrontend.uibuilding.index',
+ filter_part_of_town_id: part_of_town_string
+ };
var requestUrl = phpGWLink('bookingfrontend/', oArgs, true);
JqueryPortico.autocompleteHelper(requestUrl, 'field_building_name',
'field_building_id', 'building_container');
+
+
+$("#part_of_town :checkbox").on('click', function() {
+ part_of_towns = [];
+ $("#part_of_town :checkbox:checked").each(function() {
+ part_of_towns.push($(this).val());
+ });
+ part_of_town_string = part_of_towns.join(',');
+
+ var activity_top_level = $('#activity_top_level').val();
+
+ var oArgs = {
+ menuaction: 'bookingfrontend.uisearch.index',
+ activity_top_level: activity_top_level,
+ building_id: $('#field_building_id').val(),
+ filter_part_of_town: part_of_town_string
+ };
+ var requestUrl = phpGWLink('bookingfrontend/', oArgs);
+
+ window.location.href = requestUrl;
+ });
+
});
$(window).load(function () {
var building_id = $('#field_building_id').val();
- if (building_id > 0) {
- populateTableChkResources(building_id, initialSelection);
- building_id_selection = building_id;
- }
$("#field_building_name").on("autocompleteselect", function (event, ui)
{
var building_id = ui.item.value;
if (building_id != building_id_selection) {
// var menuaction = $('#menuaction').val();
var activity_top_level = $('#activity_top_level').val();
+ $("#part_of_town :checkbox:checked").each(function() {
+ part_of_towns.push($(this).val());
+ });
+ part_of_town_string = part_of_towns.join(',');
- oArgs = {menuaction: 'bookingfrontend.uisearch.index',
activity_top_level: activity_top_level, building_id: building_id};
+ var oArgs = {
+ menuaction: 'bookingfrontend.uisearch.index',
+ activity_top_level: activity_top_level,
+ building_id: building_id,
+ filter_part_of_town: part_of_town_string
+ };
var requestUrl = phpGWLink('bookingfrontend/', oArgs);
window.location.href = requestUrl;
-// populateTableChkResources(building_id, []);
-
- building_id_selection = building_id;
+// building_id_selection = building_id;
}
});
});
Modified: branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
===================================================================
--- branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
2015-11-23 08:08:09 UTC (rev 14452)
+++ branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
2015-11-23 15:26:47 UTC (rev 14453)
@@ -14,123 +14,175 @@
</xsl:template>
<xsl:template match="data" xmlns:php="http://php.net/xsl">
- <div id="content">
- <form action="" method="GET" id="search">
- <input type="hidden" id="menuaction" name="menuaction"
value="bookingfrontend.uisearch.index" />
- <input type="hidden" id="activity_top_level"
name="activity_top_level" value="{activity_top_level}" />
- <div id="building_container">
- <input id="field_building_id" name="building_id" type="hidden">
- <xsl:attribute name="value">
- <xsl:value-of select="building_id"/>
- </xsl:attribute>
- </input>
- <input id="field_building_name" name="building_name"
type="text">
- <xsl:attribute name="value">
- <xsl:value-of select="building_name"/>
- </xsl:attribute>
- <xsl:attribute name="placeholder">
+ <script type="text/javascript">
+// var selected_part_of_towns = "<xsl:value-of
select="selected_part_of_towns"/>";
+ </script>
+ <div id="content">
+ <form action="" method="GET" id="search">
+ <input type="hidden" id="menuaction" name="menuaction"
value="bookingfrontend.uisearch.index" />
+ <input type="hidden" id="activity_top_level"
name="activity_top_level" value="{activity_top_level}" />
+ <div id="building_container">
+ <input id="field_building_id"
name="building_id" type="hidden">
+ <xsl:attribute name="value">
+ <xsl:value-of
select="building_id"/>
+ </xsl:attribute>
+ </input>
+ <input id="field_building_name"
name="building_name" type="text">
+ <xsl:attribute name="value">
+ <xsl:value-of
select="building_name"/>
+ </xsl:attribute>
+ <xsl:attribute name="placeholder">
<xsl:text> Søk
bygning</xsl:text>
- </xsl:attribute>
+ </xsl:attribute>
- </input>
- </div>
- <!--xsl:text> </xsl:text><input type="submit"
value="{php:function('lang', 'Search')}"/-->
- <div class="hint">
- F.eks. "<i>Haukelandshallen</i>", "<i>Nordnes bydelshus</i>",
"<i>idrett</i>" eller "<i>kor</i>".
- </div>
- </form>
- <ul>
- <xsl:for-each select="activities">
- <li>
- <a href="{search_url}">
- <xsl:choose>
- <xsl:when test="../activity_top_level = id">
- <xsl:text>[</xsl:text>
- <xsl:value-of select="name"/>
- <xsl:text>]</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="name"/>
- </xsl:otherwise>
- </xsl:choose>
- </a>
- </li>
- </xsl:for-each>
- </ul>
- <xsl:if test="not(search)">
- <div id="cloud">
- <div class="frontpagetext"><xsl:value-of
disable-output-escaping="yes" select="frontpagetext"/></div>
- </div>
- <div style="text-align:center;">
- <img alt="" >
- <xsl:attribute name="src">
- <xsl:value-of select="frontimage"/>
- </xsl:attribute>
- </img>
- </div>
- </xsl:if>
- <xsl:if test="search">
- <div id="result">
- <h5>
- <u><strong><xsl:value-of select="php:function('lang',
'Found %1 results', search/results/total_records_sum)" /></strong></u>
- </h5>
- <br />
- <br />
- <xsl:if test="search/results/total_records_sum > 0">
- <ol id="result">
- <xsl:for-each select="search/results/results">
- <li>
- <div class="header">
- <a
class="bui_single_view_link"><xsl:attribute name="href"><xsl:value-of
select="link"/></xsl:attribute><xsl:value-of select="name"/></a>
- (<xsl:value-of
select="php:function('lang', string(type))"/>)
- </div>
- <div class="details">
- <div>
- <dl>
- <dt><h4><xsl:value-of
select="php:function('lang', 'Description')" /></h4></dt>
- <dd class="description">
- <xsl:variable
name="tag_stripped_description">
- <xsl:call-template
name="strip-tags">
- <xsl:with-param
name="text" select="description"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:choose>
- <xsl:when
test="string-length($tag_stripped_description) > 1">
- <xsl:choose>
- <xsl:when
test="string-length($tag_stripped_description) > 100">
- <xsl:value-of
select="substring($tag_stripped_description, 0, 97)"/>...
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of
select="$tag_stripped_description"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of
select="php:function('lang', 'No description yet')" />
- </xsl:otherwise>
- </xsl:choose>
- <div id="{img_container}"/>
- <script type="text/javascript">
- $(window).load(function() {
-
JqueryPortico.booking.inlineImages('<xsl:value-of select="img_container"/>',
'<xsl:value-of select="img_url"/>');
- });
- </script>
- </dd>
- <xsl:if
test="string-length(homepage) > 1">
- <dt><h4><xsl:value-of
select="php:function('lang', 'Homepage')" /></h4></dt>
- <dd class="description">
- <a><xsl:attribute
name="href"><xsl:value-of select="homepage"/></xsl:attribute><xsl:value-of
select="homepage"/></a>
- </dd>
- </xsl:if>
- </dl>
- </div>
- <div class="clr"></div>
- </div>
- </li>
- </xsl:for-each>
- </ol>
- </xsl:if>
- </div>
- </xsl:if>
- </div>
+ </input>
+ </div>
+ <!--xsl:text> </xsl:text><input type="submit"
value="{php:function('lang', 'Search')}"/-->
+ <div class="hint">
+ F.eks. "<i>Haukelandshallen</i>", "<i>Nordnes
bydelshus</i>", "<i>idrett</i>" eller "<i>kor</i>".
+ </div>
+ </form>
+ <div>
+ <div class="heading">
+ <xsl:value-of select="php:function('lang',
'part of town')" />
+ </div>
+ <ul id="part_of_town">
+ <xsl:for-each select="part_of_towns">
+ <li>
+ <label>
+ <input type="checkbox"
name="part_of_town[]">
+ <xsl:attribute
name="value">
+
<xsl:value-of select="id"/>
+ </xsl:attribute>
+ <xsl:if
test="checked = 1">
+ <xsl:attribute
name="checked">
+
<xsl:text>checked</xsl:text>
+ </xsl:attribute>
+ </xsl:if>
+ </input>
+ <xsl:value-of
select="name"/>
+ </label>
+ </li>
+ </xsl:for-each>
+ </ul>
+ </div>
+
+ <ul>
+ <xsl:for-each select="activities">
+ <li>
+ <a href="{search_url}">
+ <xsl:choose>
+ <xsl:when
test="../activity_top_level = id">
+
<xsl:text>[</xsl:text>
+ <xsl:value-of
select="name"/>
+
<xsl:text>]</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="name"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </a>
+ </li>
+ </xsl:for-each>
+ </ul>
+ <xsl:if test="not(search)">
+ <div id="cloud">
+ <div class="frontpagetext">
+ <xsl:value-of
disable-output-escaping="yes" select="frontpagetext"/>
+ </div>
+ </div>
+ <div style="text-align:center;">
+ <img alt="" >
+ <xsl:attribute name="src">
+ <xsl:value-of
select="frontimage"/>
+ </xsl:attribute>
+ </img>
+ </div>
+ </xsl:if>
+ <xsl:if test="search">
+ <div id="result">
+ <h5>
+ <u>
+ <strong>
+ <xsl:value-of
select="php:function('lang', 'Found %1 results',
search/results/total_records_sum)" />
+ </strong>
+ </u>
+ </h5>
+ <br />
+ <br />
+ <xsl:if test="search/results/total_records_sum
> 0">
+ <ol id="result">
+ <xsl:for-each
select="search/results/results">
+ <li>
+ <div
class="header">
+ <a
class="bui_single_view_link">
+
<xsl:attribute name="href">
+
<xsl:value-of select="link"/>
+
</xsl:attribute>
+
<xsl:value-of select="name"/>
+ </a>
+
(<xsl:value-of select="php:function('lang', string(type))"/>)
+ </div>
+ <div
class="details">
+ <div>
+
<dl>
+
<dt>
+
<h4>
+
<xsl:value-of select="php:function('lang',
'Description')" />
+
</h4>
+
</dt>
+
<dd class="description">
+
<xsl:variable name="tag_stripped_description">
+
<xsl:call-template name="strip-tags">
+
<xsl:with-param name="text"
select="description"/>
+
</xsl:call-template>
+
</xsl:variable>
+
<xsl:choose>
+
<xsl:when
test="string-length($tag_stripped_description) > 1">
+
<xsl:choose>
+
<xsl:when
test="string-length($tag_stripped_description) > 100">
+
<xsl:value-of
select="substring($tag_stripped_description, 0, 97)"/>...
+
</xsl:when>
+
<xsl:otherwise>
+
<xsl:value-of
select="$tag_stripped_description"/>
+
</xsl:otherwise>
+
</xsl:choose>
+
</xsl:when>
+
<xsl:otherwise>
+
<xsl:value-of select="php:function('lang', 'No
description yet')" />
+
</xsl:otherwise>
+
</xsl:choose>
+
<div id="{img_container}"/>
+
<script type="text/javascript">
+
$(window).load(function() {
+
JqueryPortico.booking.inlineImages('<xsl:value-of
select="img_container"/>', '<xsl:value-of select="img_url"/>');
+
});
+
</script>
+
</dd>
+
<xsl:if test="string-length(homepage) > 1">
+
<dt>
+
<h4>
+
<xsl:value-of select="php:function('lang',
'Homepage')" />
+
</h4>
+
</dt>
+
<dd class="description">
+
<a>
+
<xsl:attribute name="href">
+
<xsl:value-of select="homepage"/>
+
</xsl:attribute>
+
<xsl:value-of select="homepage"/>
+
</a>
+
</dd>
+
</xsl:if>
+
</dl>
+ </div>
+ <div
class="clr"></div>
+ </div>
+ </li>
+ </xsl:for-each>
+ </ol>
+ </xsl:if>
+ </div>
+ </xsl:if>
+ </div>
</xsl:template>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14453] bookingfrontend: added part of town as filter,
Sigurd Nes <=