[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14634] more on bookingfrontend
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14634] more on bookingfrontend |
Date: |
Tue, 12 Jan 2016 18:39:41 +0000 |
Revision: 14634
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14634
Author: sigurdne
Date: 2016-01-12 18:39:40 +0000 (Tue, 12 Jan 2016)
Log Message:
-----------
more on bookingfrontend
Modified Paths:
--------------
branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
branches/dev-syncromind/booking/inc/class.soresource.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
branches/dev-syncromind/phpgwapi/inc/class.custom_fields.inc.php
Modified: branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
2016-01-11 09:40:01 UTC (rev 14633)
+++ branches/dev-syncromind/booking/inc/class.sobuilding.inc.php
2016-01-12 18:39:40 UTC (rev 14634)
@@ -95,11 +95,16 @@
* @param type $activity_id
* @return array building ids
*/
- function get_buildings_from_activity($activity_id = 0)
+ function get_buildings_from_activity($activities = array())
{
$soactivity =
createObject('booking.soactivity');
- $children =
$soactivity->get_children($activity_id);
- $activity_ids = array_merge(array($activity_id),
$children);
+
+ $activity_ids = array();
+ foreach($activities as $activity_id)
+ {
+ $children =
array_merge(array($activity_id), $soactivity->get_children($activity_id));
+ $activity_ids = array_merge($activity_ids,
$children);
+ }
$buildings = array();
if(!$activity_ids)
{
Modified: branches/dev-syncromind/booking/inc/class.soresource.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.soresource.inc.php
2016-01-11 09:40:01 UTC (rev 14633)
+++ branches/dev-syncromind/booking/inc/class.soresource.inc.php
2016-01-12 18:39:40 UTC (rev 14634)
@@ -95,40 +95,56 @@
function _get_conditions($query, $filters)
{
static $custom_fields_arr = array();
+ $activity_ids = array();
+ $soactivity =
createObject('booking.soactivity');
if(isset($filters['activity_id']) &&
$filters['activity_id'])
{
- $soactivity =
createObject('booking.soactivity');
- $children =
$soactivity->get_children($filters['activity_id']);
- $activity_ids =
array_merge(array($filters['activity_id']), $children);
- $filters['activity_id'] = $activity_ids;
+ // children =
$soactivity->get_children($filters['activity_id']);
+ // $activity_ids =
array_merge(array($filters['activity_id']), $children);
+ // $filters['activity_id'] = $activity_ids;
}
$conditions = parent::_get_conditions($query, $filters);
$custom_condition_arr = array();
if(isset($filters['custom_fields_criteria']) &&
is_array($filters['custom_fields_criteria']))
{
- foreach($filters['custom_fields_criteria'] as
$custom_fields_criteria)
+ //
_debug_array($filters['custom_fields_criteria']);
+ $custom_fields_criteria = array();
+ foreach($filters['custom_fields_criteria'] as
$activity_top_level => $_custom_fields_criteria)
{
+
if(!isset($activity_ids[$activity_top_level]))
+ {
+
$activity_ids[$activity_top_level] = array_merge(array($activity_top_level),
$soactivity->get_children($activity_top_level));
+ }
+
if(isset($_custom_fields_criteria['choice']))
+ {
+ $custom_fields_criteria =
array_merge($custom_fields_criteria, $_custom_fields_criteria['choice']);
+ }
+ }
+ unset($activity_top_level);
+
+ foreach ($custom_fields_criteria as $criteria)
+ {
$sub_condition = array();
- $location_id =
$custom_fields_criteria['location_id'];
+ $location_id = $criteria['location_id'];
if(!isset($custom_fields_arr[$location_id]))
{
$custom_fields =
$GLOBALS['phpgw']->custom_fields->find2($location_id, 0, '', 'ASC',
'attrib_sort', true, true);
$custom_fields_arr[$location_id] = $custom_fields;
- $sub_condition[] = "
json_representation @> '{\"schema_location\":$location_id}'";
}
- $field_name =
$custom_fields[$custom_fields_criteria['attribute_id']]['name'];
- $field_value =
isset($custom_fields_criteria['choice_id']) ?
$custom_fields_criteria['choice_id'] : false;
+ $field_name =
$custom_fields[$criteria['attribute_id']]['name'];
+ $field_value =
isset($criteria['choice_id']) ? $criteria['choice_id'] : false;
if(!$field_value)
{
continue;
}
+ $sub_condition[] = "
json_representation @> '{\"schema_location\":$location_id}'";
-
if($custom_fields[$custom_fields_criteria['attribute_id']]['datatype'] == 'CH')
// in array
+
if($custom_fields[$criteria['attribute_id']]['datatype'] == 'CH') // in array
{
/**
* Note: JSONB operator '?' is
troublesome: convert to '~@'
@@ -144,14 +160,37 @@
}
- $custom_condition_arr[] = '(' .
implode(' AND ', $sub_condition) . ')';
+
$custom_condition_arr[$criteria['cat_id']][] = '(' . implode(' AND ',
$sub_condition) . ')';
}
}
- if($custom_condition_arr)
+ $_conditions = array();
+ if(isset($filters['custom_fields_criteria']) &&
is_array($filters['custom_fields_criteria']))
{
- $conditions .= ' AND ' . implode(' OR ',
$custom_condition_arr);
+ foreach($filters['custom_fields_criteria'] as
$activity_top_level => $_custom_fields_criteria)
+ {
+
if(isset($custom_condition_arr[$activity_top_level]))
+ {
+ $_conditions[] = '('
.$conditions . ' AND (activity_id IN ('. implode(',',
$activity_ids[$activity_top_level]) . ') AND' . implode(' OR ',
$custom_condition_arr[$activity_top_level]) . '))';
+ }
+ else
+ {
+ $_conditions[] = '(' .
$conditions . ' AND activity_id IN ('. implode(',',
$activity_ids[$activity_top_level]) . '))';
+ }
+ }
}
+
+
+// if($custom_condition_arr)
+// {
+// foreach ($custom_condition_arr as
$activity_top_level => $custom_condition)
+// {
+// $_conditions[] = $conditions . ' AND '
. implode(' OR ', $custom_condition);
+// }
+// $conditions = $conditions . ' OR ' . implode('
OR ', $_conditions);
+// }
+ $conditions = implode(' OR ', $_conditions);
+ _debug_array($conditions);
return $conditions;
}
}
\ No newline at end of file
Modified: branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
2016-01-11 09:40:01 UTC (rev 14633)
+++ branches/dev-syncromind/bookingfrontend/inc/class.bosearch.inc.php
2016-01-12 18:39:40 UTC (rev 14634)
@@ -13,39 +13,55 @@
$this->soevent =
CreateObject('booking.soevent');
}
- function search($searchterm, $activity_top_level, $building_id,
$filter_part_of_town,$criteria = array())
+ function search($searchterm, $building_id,
$filter_part_of_town, $activity_criteria = array())
{
- $building_filter = array();
+ $building_filter = array(-1);
+ $activity_top_levels = array_keys($activity_criteria);
- if($type = phpgw::get_var('type', 'string'))
+ $_filter_search_type = explode(',',
phpgw::get_var('filter_search_type', 'string'));
+ $types = array();
+ foreach($_filter_search_type as $key => $value)
{
- $types = array($type);
+ if($value)
+ {
+ $types[] = $value;
+ }
}
- else
+
+ if($type= phpgw::get_var('type', 'string', 'REQUEST',
null))
{
- $types = array('building', 'resource');
//default
+ $types[] = $type;
}
- $bui_result = $org_result =
$res_result = $event_result = array();
+ $bui_result = $org_result = $res_result =
$event_result = array();
- if(in_array('building', $types))
+ $_filter_building = array("active" => "1");
+ if(!isset($filter_part_of_town) || !
$filter_part_of_town)
{
- $_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;
- }
+ $part_of_towns =
execMethod('property.sogeneric.get_list', array('type' => 'part_of_town'));
- if($activity_top_level && !$building_id)
+ $filter_part_of_town = array();
+ foreach($part_of_towns as &$part_of_town)
{
- $buildings
= $this->sobuilding->get_buildings_from_activity($activity_top_level);
- $_filter_building['id'] = $buildings;
+ $filter_part_of_town[] =
$part_of_town['id'];
}
- if($building_id)
- {
- $_filter_building['id'] = $building_id;
- }
+ }
+ $_filter_building['part_of_town_id'] =
$filter_part_of_town;
+
+ if($activity_criteria && !$building_id)
+ {
+ $buildings =
$this->sobuilding->get_buildings_from_activity($activity_top_levels);
+ $_filter_building['id'] = $buildings;
+ }
+ if($building_id)
+ {
+ $_filter_building['id'] = $building_id;
+ }
+
+ if(in_array('building', $types))
+ {
+
$bui_result =
$this->sobuilding->read(array("query" => $searchterm, "sort" => "name",
"dir" => "asc", "filters" =>
$_filter_building));
foreach($bui_result['results'] as &$bui)
@@ -85,10 +101,10 @@
{
$_filter_resource = array("active" => "1");
- if($activity_top_level)
- {
- $_filter_resource['activity_id'] =
$activity_top_level;
- }
+// if($activity_top_levels)
+// {
+// $_filter_resource['activity_id'] =
$activity_top_levels;
+// }
if($building_filter)
{
@@ -99,14 +115,20 @@
{
$_filter_resource['building_id'][] =
$building_id;
}
- if(isset($filter_part_of_town[0]) &&
$filter_part_of_town[0])
+ if(isset($filter_part_of_town) &&
$filter_part_of_town && !$bui_result)
{
- $_filter_resource['part_of_town_id'] =
$filter_part_of_town;
+ $_bui_result =
$this->sobuilding->read(array("filters" => $_filter_building));
+ foreach($_bui_result['results'] as
$_bui)
+ {
+
$_filter_resource['building_id'][] = $_bui['id'];
+ }
+
+ $_filter_resource['building_id'] =
array_unique($_filter_resource['building_id']);
}
- if($criteria)
+ if($activity_criteria)
{
-
$_filter_resource['custom_fields_criteria'] = $criteria;
+
$_filter_resource['custom_fields_criteria'] = $activity_criteria;
}
$res_result =
$this->soresource->read(array("query" => $searchterm, "sort" => "name",
Modified: branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
2016-01-11 09:40:01 UTC (rev 14633)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
2016-01-12 18:39:40 UTC (rev 14634)
@@ -72,7 +72,15 @@
'building_id' =>
$building_id,
'filter_part_of_town' =>
$imploded_filter_part_of_town));
- $organized_fields =
$GLOBALS['phpgw']->custom_fields->get_attribute_tree('booking',
".resource.{$activity['id']}");
+ $dummy_sub = array();
+ $organized_fields =
$GLOBALS['phpgw']->custom_fields->get_attribute_tree('booking',
".resource.{$activity['id']}", 0, $activity['id']);
+ if($organized_fields)
+ {
+ $dummy_sub[] = array(
+ 'text' =>
$activity['name'],
+ 'activity_top_level' =>
$activity['id'],
+ );
+ }
$filter_tree[] = array(
'text' => $activity['id'] ==
$activity_top_level ? "[{$activity['name']}]" : $activity['name'],
'state' => array(
@@ -83,10 +91,12 @@
// 'checkbox_hide' => true
),
'parent' => '#',
- 'a_attr' => array('href' =>
$_url, 'activity_top_level' => $activity['id'],
- // 'class' => "no_checkbox"
- ),
- 'children' => $organized_fields,
+// 'a_attr' => array('href' =>
$_url,
+// 'activity_top_level' =>
$activity['id'],
+// 'class' => "no_checkbox"
+// ),
+ 'activity_top_level' => $activity['id'],
+ 'children' =>
array_merge($dummy_sub,$organized_fields),
);
}
//_debug_array($filter_tree);
@@ -107,19 +117,44 @@
function query()
{
$searchterm
= trim(phpgw::get_var('searchterm', 'string', 'REQUEST', null));
- $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);
+ $_filter_part_of_town = explode(',',
phpgw::get_var('filter_part_of_town', 'string'));
$search
= null;
- $criteria = phpgw::get_var('criteria');
-// _debug_array($criteria);die();
- if($building_id || $type || $activity_top_level ||
(isset($filter_part_of_town[0]) && $filter_part_of_town[0]))
+ $filter_part_of_town = array();
+ foreach($_filter_part_of_town as $key => $value)
{
+ if($value)
+ {
+ $filter_part_of_town[] = $value;
+ }
+ }
+
+ $criteria = phpgw::get_var('criteria', 'string',
'REQUEST', array());
+ $activity_criteria = array();
+ foreach($criteria as $entry)
+ {
+ if(isset($entry['activity_top_level']) &&
$entry['activity_top_level'])
+ {
+
$activity_criteria[$entry['activity_top_level']]['activity_top_level'] =
$entry['activity_top_level'];
+ }
+ if(isset($entry['choice_id']) &&
isset($entry['cat_id']))
+ {
+
$activity_criteria[$entry['cat_id']]['activity_top_level'] = $entry['cat_id'];
+
$activity_criteria[$entry['cat_id']]['choice'][] = $entry;
+ }
+ }
+
+// _debug_array($building_id);
+// _debug_array($filter_part_of_town);
+// _debug_array($activity_criteria);
+// _debug_array($criteria);
+// die();
+ if($searchterm || $building_id || $activity_criteria ||
$filter_part_of_town)
+ {
$data = array(
- 'results' =>
$this->bo->search($searchterm, $activity_top_level, $building_id,
$filter_part_of_town, $criteria)
+ 'results' =>
$this->bo->search($searchterm, $building_id, $filter_part_of_town,
$activity_criteria)
);
}
self::render_template_xsl('search_details', $data);
Modified: branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
===================================================================
--- branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2016-01-11 09:40:01 UTC (rev 14633)
+++ branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2016-01-12 18:39:40 UTC (rev 14634)
@@ -2,6 +2,8 @@
var building_id_selection = "";
var part_of_town_string = "";
var part_of_towns = [];
+var search_types = [];
+var search_type_string = "";
var selected_building_id = null;
var selected_criteria = [];
@@ -20,6 +22,10 @@
update_search(selected_criteria);
});
+ $("#search_type :checkbox").on('click', function () {
+ update_search(selected_criteria);
+
+ });
//initate autocomplete;
update_autocompleteHelper();
@@ -61,13 +67,13 @@
var parents = data.node.parents;
var level = parents.length;
- var activity_top_level = 0;
+// var activity_top_level = 0;
if (!deselect)
{
//Top node
if (level < 2)
{
- activity_top_level =
data.node.a_attr.activity_top_level;
+// activity_top_level =
data.node.a_attr.activity_top_level;
}
else
{
@@ -76,13 +82,13 @@
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 =
top_node.a_attr.activity_top_level;
}
}
- $('#activity_top_level').val(activity_top_level);
+// $('#activity_top_level').val(activity_top_level);
- var href = data.node.a_attr.href;
- if (href == "#")
+ // var href = data.node.a_attr.href;
+ // if (href == "#")
{
selected_criteria =
$("#treeDiv1").jstree('get_selected', true);
}
@@ -106,15 +112,23 @@
});
part_of_town_string = part_of_towns.join(',');
+ search_types = [];
+ $("#search_type :checkbox:checked").each(function () {
+ search_types.push($(this).val());
+ });
+ search_type_string = search_types.join(',');
+
+
update_autocompleteHelper();
- var activity_top_level = $('#activity_top_level').val();
+// var activity_top_level = $('#activity_top_level').val();
var oArgs = {
menuaction: 'bookingfrontend.uisearch.query',
- activity_top_level: activity_top_level,
+// activity_top_level: activity_top_level,
building_id: selected_building_id,
- filter_part_of_town: part_of_town_string
+ filter_part_of_town: part_of_town_string,
+ filter_search_type: search_type_string
};
var requestUrl = phpGWLink('bookingfrontend/', oArgs);
Modified: branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
===================================================================
--- branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
2016-01-11 09:40:01 UTC (rev 14633)
+++ branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
2016-01-12 18:39:40 UTC (rev 14634)
@@ -51,8 +51,39 @@
</xsl:for-each>
</ul>
</div>
+ <div>
+ <div class="heading">
+ <xsl:value-of select="php:function('lang',
'type')" />
+ </div>
+ <ul id="search_type">
+ <li>
+ <label>
+ <input type="checkbox"
name="search_type[]" value="building"/>
+ <xsl:value-of
select="php:function('lang', 'building')" />
+ </label>
+ </li>
+ <li>
+ <label>
+ <input type="checkbox"
name="search_type[]" value="resource" checked="checked"/>
+ <xsl:value-of
select="php:function('lang', 'resource')" />
+ </label>
+ </li>
+ <!--li>
+ <label>
+ <input type="checkbox"
name="search_type[]" value="organization"/>
+ <xsl:value-of
select="php:function('lang', 'organization')" />
+ </label>
+ </li>
+ <li>
+ <label>
+ <input type="checkbox"
name="search_type[]" value="event"/>
+ <xsl:value-of
select="php:function('lang', 'event')" />
+ </label>
+ </li-->
+ </ul>
+ </div>
- <div id="document">
+ <div id="activity_tree">
<fieldset>
<!-- Some style for the expand/contract
section-->
<style>
Modified: branches/dev-syncromind/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- branches/dev-syncromind/phpgwapi/inc/class.custom_fields.inc.php
2016-01-11 09:40:01 UTC (rev 14633)
+++ branches/dev-syncromind/phpgwapi/inc/class.custom_fields.inc.php
2016-01-12 18:39:40 UTC (rev 14634)
@@ -1497,7 +1497,7 @@
* @param type $parent_id
* @return type
*/
- public function get_attribute_tree($appname, $location,
$parent_id = 0)
+ public function get_attribute_tree($appname, $location,
$parent_id = 0, $cat_id = 0)
{
$this->node_id++;
@@ -1530,14 +1530,15 @@
'db_id' => $id,
'parent' =>
$this->_db2->f('parent_id'),
'text' =>
$this->_db2->f('name',true),
+ 'cat_id' => $cat_id
);
$this->node_id++;
}
foreach($tree as &$node)
{
- $children =
$this->get_group_children($location_id, $node['db_id'], $node['db_id']);
- $attribute_children =
$this->get_attribute_children($location_id, $node['id'], $node['db_id']);
+ $children =
$this->get_group_children($location_id, $node['db_id'], $node['db_id'],
$cat_id);
+ $attribute_children =
$this->get_attribute_children($location_id, $node['id'], $node['db_id'],
$cat_id);
if($children)
{
$node['children'] = $children;
@@ -1566,7 +1567,7 @@
* @param type $parent
* @return type
*/
- public function get_group_children($location_id, $parent_id,
$parent)
+ public function get_group_children($location_id, $parent_id,
$parent, $cat_id = 0)
{
$parent = (int)$parent;
@@ -1587,13 +1588,14 @@
'parent' => $parent,
'parent_id' =>
$this->_db2->f('parent_id'),
'text' => $this->_db2->f('name',true),
+ 'cat_id' => $cat_id
);
$this->node_id++;
}
foreach($children as &$child)
{
- $_children =
$this->get_group_children($location_id, $child['db_id'], $child['id']);
+ $_children =
$this->get_group_children($location_id, $child['db_id'], $child['id'], $cat_id);
if($_children)
{
$child['children'] = $_children;
@@ -1610,7 +1612,7 @@
* @param type $group_id
* @return type
*/
- public function get_attribute_children($location_id, $parent,
$group_id)
+ public function get_attribute_children($location_id, $parent,
$group_id, $cat_id = 0)
{
$children = array();
@@ -1631,6 +1633,7 @@
'attribute_id' => $id,
'parent' => $parent,
'text' =>
$this->_db2->f('input_text',true),
+ 'cat_id' => $cat_id
);
$this->node_id++;
}
@@ -1648,6 +1651,7 @@
$_choice['attribute_id']=
$child['db_id'];
$_choice['choice_id'] =
$_choice['id'];
$_choice['id']
= "ajson{$this->node_id}";
+ $_choice['cat_id']
= $cat_id;
$this->node_id++;
}
$child['children'] = $_choices;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14634] more on bookingfrontend,
Sigurd Nes <=