[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14483] bookingfrontend: more on search
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14483] bookingfrontend: more on search |
Date: |
Thu, 26 Nov 2015 14:37:43 +0000 |
Revision: 14483
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14483
Author: sigurdne
Date: 2015-11-26 14:37:42 +0000 (Thu, 26 Nov 2015)
Log Message:
-----------
bookingfrontend: more on search
Modified Paths:
--------------
branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
Modified: branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
2015-11-26 10:23:55 UTC (rev 14482)
+++ branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
2015-11-26 14:37:42 UTC (rev 14483)
@@ -33,7 +33,6 @@
'key' =>
'location_code',
'column' =>
'location_code'
)),
-
'street' => array('type'
=> 'string', 'query' => true),
'zip_code' => array('type'
=> 'string'),
'district' => array('type'
=> 'string', 'query' => true),
@@ -87,4 +86,28 @@
return $this->read($params);
}
+
+ /**
+ * Returns buildins with resources within top level activity
+ * @param type $activity_id
+ * @return array building ids
+ */
+ function get_buildings_from_activity($activity_id = 0)
+ {
+ $soactivity = createObject('booking.soactivity');
+ $children = $soactivity->get_children($activity_id);
+ $activity_ids =
array_merge(array($activity_id),$children);
+ $buildings = array();
+ if(!$activity_ids)
+ {
+ return $buildings;
+ }
+ $sql = 'SELECT building_id FROM bb_resource WHERE
activity_id IN (' . implode(',', $activity_ids) . ')';
+ $this->db->query($sql, __LINE__, __FILE__);
+ while($this->db->next_record())
+ {
+ $buildings[] = $this->db->f('building_id');
+ }
+ return $buildings;
+ }
}
Modified: branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
2015-11-26 10:23:55 UTC (rev 14482)
+++ branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
2015-11-26 14:37:42 UTC (rev 14483)
@@ -34,6 +34,12 @@
{
$_filter_building['part_of_town_id'] =
$filter_part_of_town;
}
+
+ if($activity_top_level && !$building_id)
+ {
+ $buildings =
$this->sobuilding->get_buildings_from_activity($activity_top_level);
+ $_filter_building['id'] = $buildings;
+ }
if($building_id)
{
$_filter_building['id'] = $building_id;
Modified: branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
===================================================================
--- branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2015-11-26 10:23:55 UTC (rev 14482)
+++ branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2015-11-26 14:37:42 UTC (rev 14483)
@@ -2,6 +2,8 @@
var building_id_selection = "";
var part_of_town_string = "";
var part_of_towns = [];
+var selected_building_id = null;
+
var selected_criteria = [];
$(document).ready(function () {
update_autocompleteHelper = function () {
@@ -14,6 +16,7 @@
}
$("#part_of_town :checkbox").on('click', function () {
+ selected_building_id = null;
update_search(selected_criteria);
});
@@ -28,7 +31,7 @@
themes: {"stripes": true}
},
checkbox: {whole_node: true, three_state: false, cascade:
"up+down+undetermined"},
- plugins: ["themes", "state", "checkbox"]
+ plugins: ["themes", "checkbox"]
});
@@ -37,17 +40,8 @@
{
return false;
}
- var href = data.node.a_attr.href;
- if (href == "#")
- {
- selected_criteria =
$("#treeDiv1").jstree('get_selected', true);
- }
- else
- {
- var activity_top_level = 0;
- $('#activity_top_level').val(activity_top_level);
+ update_activity_top_level(data, true);
- }
update_search(selected_criteria);
});
@@ -58,19 +52,42 @@
{
return false;
}
+ update_activity_top_level(data, false);
+
+ update_search(selected_criteria);
+ });
+
+ update_activity_top_level = function (data, deselect) {
+
+ var parents = data.node.parents;
+ var level = parents.length;
+ var activity_top_level = 0;
+ if (!deselect)
+ {
+ //Top node
+ if (level < 2)
+ {
+ activity_top_level =
data.node.a_attr.activity_top_level;
+ }
+ else
+ {
+ //Find top node
+ var top_node_id = parents[(level - 2)];
+
+ var treeInst = $('#treeDiv1').jstree(true);
+ top_node = treeInst.get_node(top_node_id)
+ activity_top_level =
top_node.a_attr.activity_top_level;
+ }
+ }
+ $('#activity_top_level').val(activity_top_level);
+
var href = data.node.a_attr.href;
if (href == "#")
{
selected_criteria =
$("#treeDiv1").jstree('get_selected', true);
}
- else
- {
- var activity_top_level =
data.node.a_attr.activity_top_level;
- $('#activity_top_level').val(activity_top_level);
- }
- update_search(selected_criteria);
- });
+ }
update_search = function (selected_criteria) {
var criteria = [];
@@ -96,7 +113,7 @@
var oArgs = {
menuaction: 'bookingfrontend.uisearch.query',
activity_top_level: activity_top_level,
- building_id: $('#field_building_id').val(),
+ building_id: selected_building_id,
filter_part_of_town: part_of_town_string
};
var requestUrl = phpGWLink('bookingfrontend/', oArgs);
@@ -127,14 +144,13 @@
$('#treeDiv1').jstree('open_all');
});
-
});
$(window).load(function () {
- var building_id = $('#field_building_id').val();
$("#field_building_name").on("autocompleteselect", function (event, ui)
{
var building_id = ui.item.value;
if (building_id != building_id_selection) {
+ selected_building_id = building_id;
update_search(selected_criteria);
}
});
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14483] bookingfrontend: more on search,
Sigurd Nes <=