[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] [20907] Feature : advanced search form
From: |
Pascal Vilarem |
Subject: |
[Phpgroupware-cvs] [20907] Feature : advanced search form |
Date: |
Tue, 05 Jan 2010 16:47:04 +0000 |
Revision: 20907
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20907
Author: maat
Date: 2010-01-05 16:47:03 +0000 (Tue, 05 Jan 2010)
Log Message:
-----------
Feature : advanced search form
Modified Paths:
--------------
modules/ged/trunk/inc/class.ged_dm.inc.php
modules/ged/trunk/inc/class.ged_ui.inc.php
modules/ged/trunk/templates/base/search.tpl
Modified: modules/ged/trunk/inc/class.ged_dm.inc.php
===================================================================
--- modules/ged/trunk/inc/class.ged_dm.inc.php 2010-01-05 16:28:14 UTC (rev
20906)
+++ modules/ged/trunk/inc/class.ged_dm.inc.php 2010-01-05 16:47:03 UTC (rev
20907)
@@ -3034,17 +3034,67 @@
}
// Searching
- function search($query, $start_date=null, $end_date=null, $status=null )
+ function search($query, $start_date=null, $end_date=null,
$status=null,$avancee=null )
{
+
$sql="SELECT ged_elements.*, ged_current_version.*,
ged_elements.description as descriptione, ged_current_version.description as
descriptionv ";
$sql.="FROM ( ged_elements ";
$sql.="INNER JOIN ged_versions as ged_current_version ";
$sql="SELECT ged_elements.*, ged_current_version.*,
ged_elements.description as descriptione, ged_current_version.description as
descriptionv ";
$sql.="FROM ( ged_elements ";
$sql.="INNER JOIN ged_versions as ged_current_version ";
- $sql.="ON
ged_elements.element_id=ged_current_version.element_id ) ";
- $sql.="WHERE ged_elements.name like '%".$query."%' OR
ged_elements.description like '%".$query."%' OR ged_elements.reference like
'%".$query."%' ";
- $sql.="OR ged_current_version.description like '%".$query."%'
";
+ $sql.="ON
ged_elements.element_id=ged_current_version.element_id ) WHERE";
+ if(!is_null($avancee))
+ {
+ if(isset($avancee['project_root']))
+ {
+ $sql.=" ged_elements.project_root IN (SELECT
element_id from ged_elements where name in ( ";
+ foreach($avancee['project_root'] as
$key=>$project_root)
+ {
+ $avancee['project_root'][$key]="'".
$project_root."'";
+ }
+ $sql.=implode(',',
$avancee['project_root']).")) AND";
+ }
+ if(isset($avancee['status_name']))
+ {
+ foreach($avancee['status_name'] as $key=>$item)
+ {
+
$avancee['status_name'][$key]="'". $item."'";
+ }
+ $sql.=" ged_current_version.status IN
(".implode(',', $avancee['status_name']).") AND";
+ }
+ if(isset($avancee['doc_type']))
+ {
+ foreach($avancee['doc_type'] as $key=>$item)
+ {
+
$avancee['doc_type'][$key]="'". $item."'";
+ }
+ $sql.=" ged_elements.doc_type IN
(".implode(',', $avancee['doc_type']).") AND";
+ }
+ }
+ if(!is_null($start_date))
+ {
+ $sql.=" ged_current_version.creation_date
>=".$start_date." AND";
+ }
+ if(!is_null($end_date))
+ {
+ $sql.=" ged_current_version.creation_date
<=".$end_date." AND";
+ }
+ if(is_array($query))
+ {
+ $sql.=" (";
+ foreach($query as $q)
+ {
+ $sql.=" (ged_elements.name like '%".$q."%' OR
ged_elements.description like '%".$q."%' OR ged_elements.reference like
'%".$q."%' ";
+ $sql.="OR ged_current_version.description like
'%".$q."%' ) OR";
+ }
+ $sql=substr_replace($sql,' )',-2,2);
+ }
+ else
+ {
+ $sql.=" (ged_elements.name like '%".$query."%' OR
ged_elements.description like '%".$query."%' OR ged_elements.reference like
'%".$query."%' ";
+ $sql.="OR ged_current_version.description like
'%".$query."%' )";
+ }
// DEBUG
//print ( $sql);
@@ -3054,6 +3104,9 @@
while ($this->db->next_record())
{
$element_id=$this->db->f('element_id');
+ $version_id=$this->db->f('version_id');
+ $version_status=$this->db->f('status');
+
if ( $this->can_write($element_id) ||
$this->can_read($element_id) && ( (!
isset($this->acl[$element_id]['statuses'])) || empty(
$this->acl[$element_id]['statuses'] ) || (
is_array($this->acl[$element_id]['statuses'] ) && in_array($version_status,
$this->acl[$element_id]['statuses'])) ))
{
$docs[$i]['element_id']=$element_id;
Modified: modules/ged/trunk/inc/class.ged_ui.inc.php
===================================================================
--- modules/ged/trunk/inc/class.ged_ui.inc.php 2010-01-05 16:28:14 UTC (rev
20906)
+++ modules/ged/trunk/inc/class.ged_ui.inc.php 2010-01-05 16:47:03 UTC (rev
20907)
@@ -2034,6 +2034,58 @@
$search_query=$this->get_var('search_query', array('GET',
'POST'));
$search=$this->get_var('search', array('GET', 'POST'));
+ $error_message='';
+ $querry_message='';
+ $new_status=$this->get_var('status_name', array('GET', 'POST'));
+ if($new_status[0] != 'All')
+ $avancee['status_name']=$new_status;
+
+ $project_root=$this->get_var('project_name', array('GET',
'POST'));
+ if($project_root[0] != 'All')
+ $avancee['project_root']=$project_root;
+
+ $doc_type=$this->get_var('doc_name', array('GET', 'POST'));
+ if($doc_type[0] != 'All')
+ $avancee['doc_type']=$doc_type;
+
+ $date_deb=$this->get_var('date_deb',array('GET', 'POST'))
;
+ if($date_deb!="DD/MM/YYYY" && $date_deb!='' &&
is_numeric(substr($date_deb,3,2)) && is_numeric(substr($date_deb,0,2)) &&
is_numeric(substr($date_deb,6,4)))
+ {
+ $date=mktime(0,0,0, substr($date_deb,3,2),
substr($date_deb,0,2),substr($date_deb,6,4) );
+ if(!$date)
+ $date_deb=null;
+ else
+ $date_deb=$date;
+ }
+ else
+ {
+ if($date_deb!='DD/MM/YYYY' && $date_deb!='')
+ $error_message="<p><b>".lang("error")." :
<br/>"." - ".$date_deb.lang(" is not correct");
+ $date_deb=null;
+ }
+
+ $date_fin=$this->get_var('date_fin',array('GET', 'POST'))
;
+ if($date_fin!='DD/MM/YYYY' && $date_fin!='' &&
is_numeric(substr($date_fin,3,2)) && is_numeric(substr($date_fin,0,2)) &&
is_numeric(substr($date_fin,6,4)))
+ {
+ $date=mktime(59,59,23, substr($date_fin,3,2),
substr($date_fin,0,2),substr($date_fin,6,4) );
+ if(!$date)
+ $date_fin=null;
+ else
+ $date_fin=$date;
+ }
+ else
+ {
+ if($date_fin!='DD/MM/YYYY' && $date_fin!='')
+ {
+ if($error_message=='')
+ $error_message="<p><b>".lang("error")."
: ";
+ $error_message.="<br/>"." - ".$date_fin.lang("
is not correct");
+ }
+ $date_fin=null;
+ }
+
+
+
$this->set_template_defaults();
$this->display_app_header();
@@ -2056,11 +2108,105 @@
$this->t->set_var('action_search',
$GLOBALS['phpgw']->link('/index.php', $link_data));
// Search
- $results_query= $this->ged_dm->search($search_query);
+ if($error_message!='')
+ {
+ $error_message.="</b></p>";
+ $results_query=null;
+ }
+ else
+ {
+ if(strpos($search_query,' '))
+ $results_query= $this->ged_dm->search(explode('
',$search_query),$date_deb,$date_fin,null,$avancee);
+ else
+ $results_query=
$this->ged_dm->search($search_query,$date_deb,$date_fin,null,$avancee);
+ /*
+ * querry_message
+ */
+ if(!is_null($search_query))
+ {
+ $querry_message=lang("word to find")." :
".$search_query;
+ if(!is_null($date_deb))
+ $querry_message.=lang(" and before
").date("d/m/Y",$date_deb);
+ if(!is_null($date_fin))
+ $querry_message.=lang(" and after
").date("d/m/Y",$date_fin);
+ if(!is_null($avancee['project_root']))
+ {
+ $querry_message.=lang(" into ");
+ foreach ($avancee['project_root'] as
$project)
+ {
+ $querry_message.=$project." ";
+ }
+ }
+ if(!is_null($avancee['status_name']))
+ {
+ $querry_message.=lang(" is ");
+ foreach ($avancee['status_name'] as
$statut)
+ {
+ $querry_message.=$statut." ";
+ }
+ }
+
+ }
+ }
$this->t->set_file(array('search_tpl'=>'search.tpl'));
+
+ /*
+ * récupération des status
+ */
+ $list_status= $this->ged_dm->list_ged_status();
+ $this->t->set_block('search_tpl', 'status_block',
'status_block_handle');
+
+ $this->t->set_var('status_value', lang("All"));
+ $this->t->set_var('status_id', 'All');
+ $this->t->fp('status_block_handle', 'status_block', True);
+ foreach($list_status as $statu)
+ {
+
+ $this->t->set_var('status_value',
$statu['status_name']);
+ $this->t->set_var('status_id', $statu['status_id']);
+ $this->t->fp('status_block_handle', 'status_block',
True);
+ }
+
+
+ /*
+ * récupération des projects
+ */
+
+ $list_projects= $this->ged_dm->list_wanted_projects();
+ $this->t->set_block('search_tpl', 'projects_block',
'projects_block_handle');
+
+ $this->t->set_var('project_name', lang("All"));
+ $this->t->set_var('project_id', 'All');
+ $this->t->fp('projects_block_handle', 'projects_block', True);
+ foreach($list_projects as $project)
+ {
+
+ $this->t->set_var('project_name', $project);
+ $this->t->set_var('project_id', $project);
+ $this->t->fp('projects_block_handle', 'projects_block',
True);
+ }
+
+ /*
+ * récupération des types de documents
+ */
+ $list_docs= $this->ged_dm->list_doc_types();
+ $this->t->set_block('search_tpl', 'docs_block',
'docs_block_handle');
+
+ $this->t->set_var('doc_value', lang("All"));
+ $this->t->set_var('doc_id', 'All');
+ $this->t->fp('docs_block_handle', 'docs_block', True);
+ foreach($list_docs as $doc)
+ {
+
+ $this->t->set_var('doc_value', $doc['type_desc']);
+ $this->t->set_var('doc_id', $doc['type_id']);
+ $this->t->fp('docs_block_handle', 'docs_block', True);
+ }
+
$this->t->set_block('search_tpl', 'search_results_block',
'search_results_block_handle');
+
$this->t->set_var('nbresult',"");
$Cpt = 0;
// Set block
@@ -2105,7 +2251,8 @@
}
// Display result
-
+ $this->t->set_var('errormessage',$error_message);
+ $this->t->set_var('querrymessage',$querry_message);
$this->t->set_var('search_query_field', "search_query");
$this->t->set_var('search_query_value', $search_query);
$this->t->set_var('do_search_command', "search");
Modified: modules/ged/trunk/templates/base/search.tpl
===================================================================
--- modules/ged/trunk/templates/base/search.tpl 2010-01-05 16:28:14 UTC (rev
20906)
+++ modules/ged/trunk/templates/base/search.tpl 2010-01-05 16:47:03 UTC (rev
20907)
@@ -1,10 +1,46 @@
-<div id="ged_top_menu">{top_link} {up_link} {update_folder} {add_folder}
{delete_folder} {add_file} {edit_file} {update_file} {refuse_file}
{accept_file} {submit_file} {deliver_file} {reject_file} {approve_file}
{delete_file} {change_acl} {search} {stats}</div>
+<div id="ged_top_menu" >{top_link} {up_link} {update_folder} {add_folder}
{delete_folder} {add_file} {edit_file} {update_file} {refuse_file}
{accept_file} {submit_file} {deliver_file} {reject_file} {approve_file}
{delete_file} {change_acl} {search} {stats}</div>
<br/>
-<div align=center>
+<div align=center >
<div id="ged_add_file" >{errormessage}</div>
-<form name="search" action="{action_search}" method="get">
+<form name="search" action="{action_search}" method="get" >
<input name="{search_query_field}" type="text" size="50"
value="{search_query_value}"> <input name="{do_search_command}" type="submit"
value="{do_search_value}">
+
+<li><a href="#"
onClick='document.getElementById("Avancee").style.visibility="visible";'>Advance</a></li>
+<div id="Avancee" style="visibility: hidden">
+<table cellspacing="0" cellpadding="0" >
+<tr><td>Projects :</td><td>Documents :</td><td>Status :</td>
+</tr>
+<tr>
+<td >
+<SELECT name="{project_field}" size=3 multiple style="width: 200px;">
+<!-- BEGIN projects_block -->
+ <OPTION value="{project_id}">{project_name}</OPTION>
+<!-- END projects_block -->
+</SELECT>
+</td>
+<td >
+<SELECT name="{docs_field}" size=3 multiple style="width: 200px;">
+<!-- BEGIN docs_block -->
+ <OPTION value="{doc_id}">{doc_value}</OPTION>
+<!-- END docs_block -->
+</SELECT>
+</td>
+<td >
+<SELECT name="{status_field}" size=3 multiple style="width: 200px;">
+<!-- BEGIN status_block -->
+ <OPTION value="{status_id}">{status_value}</OPTION>
+<!-- END status_block -->
+</SELECT>
+</td>
+<td >
+start date:<input type="text" name="{date_deb_field}" value="DD/MM/YYYY"/><br/>
+end date :<input type="text" name="{date_fin_field}" value="DD/MM/YYYY"/>
+ </td>
+</tr>
+</table>
+</div>
</form>
+{querrymessage}
<table cellspacing="0" cellpadding="0" width="70%">
<!-- BEGIN search_results_block -->
<tr>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] [20907] Feature : advanced search form,
Pascal Vilarem <=