[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14464] more on search
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14464] more on search |
Date: |
Tue, 24 Nov 2015 15:26:43 +0000 |
Revision: 14464
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14464
Author: sigurdne
Date: 2015-11-24 15:26:43 +0000 (Tue, 24 Nov 2015)
Log Message:
-----------
more on search
Modified Paths:
--------------
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/bookingfrontend/inc/class.uisearch.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
2015-11-24 08:27:38 UTC (rev 14463)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uisearch.inc.php
2015-11-24 15:26:43 UTC (rev 14464)
@@ -21,6 +21,7 @@
function index()
{
phpgwapi_jquery::load_widget('autocomplete');
+ phpgwapi_jquery::load_widget('treeview');
self::add_javascript('bookingfrontend',
'bookingfrontend', 'search.js');
$config = CreateObject('phpgwapi.config','booking');
@@ -60,25 +61,41 @@
$activities =
ExecMethod('booking.boactivity.get_top_level');
+ $filter_tree = array();
foreach($activities as &$activity)
{
- $activity['search_url'] = self::link(array(
- 'menuaction' =>
'bookingfrontend.uisearch.index',
- 'activity_top_level' =>
$activity['id'],
- 'building_id' =>
$building_id,
- 'filter_part_of_town' =>
$imploded_filter_part_of_town
- ));
+ $_url = self::link(array(
+ 'menuaction'
=> 'bookingfrontend.uisearch.index',
+ 'activity_top_level'
=> $activity['id'],
+ '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']}");
+ $filter_tree[] = array(
+ 'text' => $activity['id'] ==
$activity_top_level ? "[{$activity['name']}]" : $activity['name'],
+ 'state' => array (
+ 'opened' => true,
+ 'selected' =>
$activity['id'] == $activity_top_level ? 'true' : 'false'
+ ),
+ 'parent' => '#',
+ 'a_attr' => array('href' =>
$_url),
+ 'children' => $organized_fields,
+ );
+
+
}
-
- $params['activities'] = $activities;
+//_debug_array($filter_tree);
+//die();
$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);
}
+ $params['filter_tree'] = json_encode($filter_tree);
+
+
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-24 08:27:38 UTC (rev 14463)
+++ branches/dev-syncromind/bookingfrontend/js/bookingfrontend/search.js
2015-11-24 15:26:43 UTC (rev 14464)
@@ -1,3 +1,4 @@
+var filter_tree = null;
var building_id_selection = "";
var part_of_town_string = "";
var part_of_towns = [];
@@ -36,6 +37,42 @@
window.location.href = requestUrl;
});
+
+// Filter tree
+ $("#treeDiv1").jstree({
+ "core" : {
+ "multiple" : true,
+ "themes" : { "stripes" : true },
+ "data" : filter_tree
+ },
+ "plugins" : [ "themes","html_data","ui","state","checkbox" ]
+ });
+
+ $("#treeDiv1").bind("select_node.jstree", function (event, data) {
+ if(typeof(data.event) == 'undefined')
+ {
+ return false;
+ }
+ var href = data.node.a_attr.href;
+ if(href != "#")
+ {
+ window.location.href = href;
+ }
+ });
+
+ $('#collapse1').on('click',function(){
+ $(this).attr('href','javascript:;');
+ $('#treeDiv1').jstree('close_all');
+ })
+
+ $('#expand1').on('click',function(){
+ $(this).attr('href','javascript:;');
+ $('#treeDiv1').jstree('open_all');
+ });
+
+
+
+
});
$(window).load(function () {
Modified: branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
===================================================================
--- branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
2015-11-24 08:27:38 UTC (rev 14463)
+++ branches/dev-syncromind/bookingfrontend/templates/base/search.xsl
2015-11-24 15:26:43 UTC (rev 14464)
@@ -67,24 +67,26 @@
</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>
+ <div id="document">
+ <fieldset>
+ <!-- Some style for the expand/contract
section-->
+ <style>
+ #expandcontractdiv {border:1px dotted
#dedede; margin:0 0 .5em 0; padding:0.4em;}
+ #treeDiv1 { background: #fff;
padding:1em; margin-top:1em; }
+ </style>
+ <script type="text/javascript">
+ filter_tree = <xsl:value-of
select="filter_tree"/>;
+ </script>
+ <!-- markup for expand/contract links -->
+ <div id="treecontrol">
+ <a id="collapse1" title="Collapse the
entire tree below" href="#"><xsl:value-of select="php:function('lang',
'collapse all')"/></a>
+ <xsl:text> | </xsl:text>
+ <a id="expand1" title="Expand the
entire tree below" href="#"><xsl:value-of select="php:function('lang', 'expand
all')"/></a>
+ </div>
+ <div id="treeDiv1"></div>
+ </fieldset>
+ </div>
+
<xsl:if test="not(search)">
<div id="cloud">
<div class="frontpagetext">
Modified: branches/dev-syncromind/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- branches/dev-syncromind/phpgwapi/inc/class.custom_fields.inc.php
2015-11-24 08:27:38 UTC (rev 14463)
+++ branches/dev-syncromind/phpgwapi/inc/class.custom_fields.inc.php
2015-11-24 15:26:43 UTC (rev 14464)
@@ -80,6 +80,8 @@
protected $attribute_group_tree = array();
+ protected $node_id = 0;
+
/**
* Constructor
*
@@ -96,6 +98,7 @@
}
$this->_db =& $GLOBALS['phpgw']->db;
+ $this->_db2 =
clone($this->_db);
$this->_join =& $this->_db->join;
$this->_like =& $this->_db->like;
$this->_dateformat =
phpgwapi_db::date_format();
@@ -1259,6 +1262,7 @@
$this->attribute_group_tree[] = array
(
'id' =>
$group['id'],
+ 'text' =>
$group['name'],
'name' =>
$group['name'],
'parent_id' => 0,
'level' => 0,
@@ -1456,7 +1460,7 @@
* @return array the grouped attributes
*/
- public function get_attribute_groups($appname, $location,
$attributes = array())
+ public function get_attribute_groups($appname, $location,
$attributes = array(), $skip_no_group = false)
{
$no_group = array
(
@@ -1468,7 +1472,10 @@
)
);
$groups = $this->find_group($appname, $location, 0, '',
'ASC', 'group_sort', true);
- $groups = array_merge($no_group, $groups);
+ if(!$skip_no_group)
+ {
+ $groups = array_merge($no_group, $groups);
+ }
foreach ($groups as &$group)
{
@@ -1484,6 +1491,165 @@
}
/**
+ *
+ * @param type $appname
+ * @param type $location
+ * @param type $parent_id
+ * @return type
+ */
+ public function get_attribute_tree($appname, $location,
$parent_id = 0)
+ {
+ $this->node_id++;
+
+ $location_id =
$GLOBALS['phpgw']->locations->get_id($appname, $location);
+
+ $tree = array();
+
+ $table = 'phpgw_cust_attribute_group';
+
+ $filtermthod = "WHERE location_id = {$location_id}";
+ if($parent_id)
+ {
+ $filtermthod .= " AND parent_id = {$parent_id}";
+ }
+ else
+ {
+ $filtermthod .= ' AND (parent_id = 0 OR
parent_id IS NULL)';
+ }
+
+ $sql = "SELECT * FROM {$table} {$filtermthod} ORDER BY
group_sort";
+
+ $this->_db2->query($sql, __LINE__, __FILE__);
+ $this->total_records = $this->_db2->num_rows();
+
+ while($this->_db2->next_record())
+ {
+ $id = $this->_db2->f('id');
+ $tree[] = array(
+ 'db_id' => $id,
+ 'parent' =>
$this->_db2->f('parent_id'),
+ 'text' =>
$this->_db2->f('name',true),
+ );
+ }
+
+ foreach($tree as &$node)
+ {
+ $children =
$this->get_group_children($location_id, $node['db_id'], 0);
+ $attribute_children =
$this->get_attribute_children($location_id, $node['id'], $node['db_id']);
+ if($children)
+ {
+ $node['children'] = $children;
+ }
+
+ if($attribute_children)
+ {
+ if($children)
+ {
+ $node['children'] =
array_merge($children, $attribute_children);
+ }
+ else
+ {
+ $node['children'] =
$attribute_children;
+ }
+ }
+
+ }
+ return $tree;
+ }
+
+ /**
+ *
+ * @param type $location_id
+ * @param type $parent_id
+ * @param type $parent
+ * @return type
+ */
+ public function get_group_children($location_id, $parent_id,
$parent)
+ {
+
+ $parent = (int)$parent;
+ $children = array();
+
+ $table = 'phpgw_cust_attribute_group';
+
+ $filtermthod = " WHERE location_id = {$location_id} AND
parent_id = {$parent_id}";
+
+ $sql = "SELECT * FROM {$table} {$filtermthod}";
+ $this->_db2->query($sql, __LINE__, __FILE__);
+
+ while($this->_db2->next_record())
+ {
+ $children[] = array(
+ 'id' =>
"ajson{$this->node_id}",
+ 'db_id' => $id,
+ 'parent' => $parent,
+ 'parent_id' =>
$this->_db2->f('parent_id'),
+ 'text' => $this->_db2->f('name',true),
+ );
+ $this->node_id++;
+ }
+
+ foreach($children as &$child)
+ {
+ $_children =
$this->get_group_children($location_id, $child['db_id'], $child['id']);
+ if($_children)
+ {
+ $child['children'] = $_children;
+ }
+ }
+ return $children;
+
+ }
+
+ /**
+ *
+ * @param type $location_id
+ * @param type $parent
+ * @param type $group_id
+ * @return type
+ */
+ public function get_attribute_children($location_id, $parent,
$group_id)
+ {
+ $children = array();
+
+ $table = 'phpgw_cust_attribute';
+
+ $filtermthod = "WHERE location_id = {$location_id} AND
group_id = {$group_id}";
+
+ $sql = "SELECT * FROM {$table} {$filtermthod}";
+ $this->_db2->query($sql, __LINE__, __FILE__);
+
+ while($this->_db2->next_record())
+ {
+ $children[] = array(
+ 'id' => "ajson{$this->node_id}",
+ 'db_id' => $this->_db2->f('id'),
+ 'parent' => $parent,
+ 'text' =>
$this->_db2->f('input_text',true),
+ );
+ $this->node_id++;
+ }
+
+ foreach($children as &$child)
+ {
+ $_choices = $this->_get_choices($location_id,
$child['db_id']);
+ if($_choices)
+ {
+ foreach ($_choices as &$_choice)
+ {
+ $_choice['parent'] =
$child['id'];
+ $_choice['db_id'] =
$_choice['id'];
+ $_choice['id'] =
"ajson{$this->node_id}";
+ $this->node_id++;
+ }
+ $child['children'] = $_choices;
+ }
+ }
+ return $children;
+ }
+
+
+ /**
* Get the definition of a table
*
* @param string $table the name of the table to look up
@@ -1778,12 +1944,12 @@
$choices = array();
while ( $this->_db->next_record() )
{
- // $id = $this->_db->f('id');
- // $choices[$id] = array
+ $value = $this->_db->f('value', true);
$choices[] = array
(
'id' => $this->_db->f('id'),
- 'value' => $this->_db->f('value', true),
+ 'text' => $value,
+ 'value' => $value,
'title' => $this->_db->f('title', true),
'order' => $this->_db->f('choice_sort')
);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14464] more on search,
Sigurd Nes <=