noalyss Version-9
recherche.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19// Copyright Author Dany De Bontridder danydb@aevalys.eu
20/*! \file
21 * \brief Search module
22 */
23define('ALLOWED',TRUE);
24require_once '../include/constant.php';
25require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
26include_once NOALYSS_INCLUDE.'/lib/ac_common.php';
27require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php';
28require_once NOALYSS_INCLUDE.'/class/acc_ledger_search.class.php';
29require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php';
30require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
31MaintenanceMode("block.html");
32
33if ( ! isset ($_SESSION[SESSION_KEY.'g_theme']))
34{
35 echo "<h2>"._('Vous êtes déconnecté')."</h2>";
36 die();
37}
38
39html_page_start($_SESSION[SESSION_KEY.'g_theme']);
40
42
44
46
47require_once NOALYSS_INCLUDE.'/class/database.class.php';
48/* Admin. Dossier */
49
51include_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php';
52
53global $g_user;
54$g_user=new Noalyss_user($cn);
55$g_user->Check();
56$act=$g_user->check_dossier($gDossier);
57// AC CODE = SEARCH
58if ($act =='P')
59{
60 redirect("extension.php?".dossier::get(),0);
61 exit();
62}
63if ( $act=='X')
64 {
65 alert(_('Accès interdit'));
66 exit();
67 }
68// display a search box
69?>
70<script>
71/**
72 * All the onload must be here otherwise the other will overwritten
73 * @returns {undefined}
74 */
75window.onload=function ()
76{
77 create_anchor_up();
78 init_scroll();
79 sorttable.init();
80}
81</script>
82<?php
84$search_box=$ledger->search_form();
85echo '<div class="content">';
86
87echo '<form method="GET">';
88echo $search_box;
89echo HtmlInput::submit("viewsearch",_("Recherche"));
90 $button_search=new IButton("button", _('Filtre'));
91$button_search->javascript=$ledger->build_search_filter();
92echo $button_search->input();
93?>
94<input type="button" class="smallbutton" onclick="window.close()" value="<?php echo _('Fermer')?>">
95
96<?php
97echo '</form>';
98
99//-----------------------------------------------------
100// Display search result
101//-----------------------------------------------------
102if ( isset ($_GET['viewsearch']))
103{
104
105 // Navigation bar
106 $step=$_SESSION[SESSION_KEY.'g_pagesize'];
107 $page=$http->get("page","number",1);
108 $offset=$http->get("offset","number",0);
109
110 if (count ($_GET) == 0)
111 $array=null;
112 else
114 $array['p_action']='ALL';
115 list($sql,$where)=$ledger->build_search_sql($array);
116 // Count nb of line
117 $max_line=$cn->count_sql($sql);
118
119 list($count,$a)=$ledger->list_operation($sql,$offset,0);
121
122 echo $bar;
123 echo $a;
124 echo $bar;
125 /*
126 * Export to csv
127 */
128 $r=HtmlInput::get_to_hidden(array('l','date_start','date_end','desc','amount_min','amount_max',
129 'qcode','accounting','unpaid','gDossier','ledger_type','tag_option'));
130 if (isset($_GET['r_jrn'])) {
131 $http=new HttpInput();
132 $a_rjrn=$http->get("r_jrn","array");
133 foreach ($a_rjrn as $k=>$v) {
134 // Protect : check that $k and $v are numeric
135 if (isNumber($k)&&isNumber($v)) {
136 $r.=HtmlInput::hidden('r_jrn['.$k.']',$v);
137 }
138 }
139 }
140 if (isset($_GET['tag'])) {
141 $http=new HttpInput();
142 $aTag=$http->get("tag","array");
143 foreach ($aTag as $k=>$v) {
144 // Protect : check that $k and $v are numeric
145 if (isNumber($k)&&isNumber($v)) {
146 $r.=HtmlInput::hidden('tag[]',$v);
147 }
148 }
149 }
150 echo '<form action="export.php" method="get">';
151 echo $r;
152 echo HtmlInput::hidden('act','CSV:histo');
153 echo HtmlInput::submit('viewsearch',_('Export vers CSV'));
154 echo HtmlInput::hidden('p_action','ALL');
155 ?>
156 <input type="button" class="smallbutton" onclick="window.close()" value="<?php echo _('Fermer')?>">
157
158<?php
159 echo '</form>';
160}
161echo '</div>';
162?>
isNumber($p_int)
Definition: ac_common.php:215
MaintenanceMode($p_file)
When you want to prevent users to connect, create a file in noalyss/ (NOALYSS_BASE) with the message ...
Definition: ac_common.php:1663
html_page_start($p_theme="", $p_script="", $p_script2="")
Default page header for each page.
Definition: ac_common.php:275
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$input_from id
Definition: balance.inc.php:63
$input_from type
Definition: balance.inc.php:65
$_GET['qcode']
static connect()
static hidden($p_name, $p_value, $p_id="")
static get_to_hidden($array)
transform $_GET data to hidden
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
Html Input.
$count
for($e=0; $e< count($afiche); $e++) exit
load_all_script()
load all the javascript only one time
$gDossier
Definition: recherche.php:45
$cn
Definition: recherche.php:50
if( $act=='P') if( $act=='X') $ledger
Definition: recherche.php:83
$http
Definition: recherche.php:43
global $g_user
Definition: recherche.php:53
$search_box
Definition: recherche.php:84
$button_search
Definition: recherche.php:90
$act
Definition: recherche.php:56
redirect($p_string, $p_time=0)
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)
Definition: user_common.php:76