noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
fid_card.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
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22
23/*!\file
24 * \brief this file is used by the autocomplete functionnality
25 *\see ICard
26 * * Received parameters are
27 * - j for the ledger
28 * - e for extra (typecard)poss. values : all , a sql condition or a list of fd_id (fiche_def.fd_id) separated by comma
29 * - type is the ledger type (ach, ven, fin, gl or nothing)
30 * - FID contains the string the user is typing
31 *\note the typecard can be
32 * - cred card for the debit only if j is set
33 * - deb card for the debit only if j is set
34 * - filter card for debit and credit only if j OR type is set
35 * - list of fd_id
36 *
37 */
38
39require_once '../include/constant.php';
40require_once NOALYSS_INCLUDE.'/class/database.class.php';
41require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
42require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
43require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
44MaintenanceMode("block.html");
45
46/**
47 * if not connected, session is expired then exit with a message NOCONX
48 */
49if ( ! isset($_SESSION[SESSION_KEY."g_user"])) {
50 echo "NOCONX";
51 die();
52}
53
55
56$jrn= $http->request("j","number",-1);
57$limit=$http->request("limit","number",12);
58
59$jrn= $http->request("j","number",-1);
61$cn=Dossier::connect();
62$typecard=$http->request('e');
64
65require_once('class/noalyss_user.class.php');
66global $g_user;
67$g_user=new Noalyss_user($cn);
68$g_user->check();
69/**
70 * check if 2FA is completed
71 */
72if ( ! $g_user->is_double_identified()) {
73 exit();
74}
75$g_user->check_dossier(dossier::id());
77
78if ( $typecard == 'all')
79{
80 $filter_card='';
81}
82else if (strpos($typecard,'sql]')==true)
83{
84 $filter_card= noalyss_str_replace('[sql]', " and ", $typecard);
85} else
86{
88 $filter_card="and fd_id in ($typecard)";
89}
90if ( $jrn != -1 )
91{
92 switch ($typecard)
93 {
94 case 'cred':
95 $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn));
96 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
97 break;
98 case 'deb':
99 $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn));
100 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
101 break;
102 case 'filter':
103 $get_cred='jrn_def_fiche_cred';
104 $get_deb='jrn_def_fiche_deb';
105 $deb=$cn->get_value("select $get_deb from jrn_def where jrn_def_id=$1",array($jrn));
106 $cred=$cn->get_value("select $get_cred from jrn_def where jrn_def_id=$1",array($jrn));
107
108 $filter_jrn="";
109
110 if ($deb!=='' && $cred!='')
111 $filter_jrn =$deb.','.$cred;
112 elseif($deb != '')
113 $filter_jrn=$deb;
114 elseif($cred != '')
115 $filter_jrn=$cred;
116
117 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
118
119 break;
120
121 }
122}
123else
124{
125 if (isset($_REQUEST['type']))
126 {
127 if ($_REQUEST['type']=='gl' || $_REQUEST['type']=='') {
128 $filter_card='';
129 }
130 else
131 {
132 $get_cred='jrn_def_fiche_cred';
133 $get_deb='jrn_def_fiche_deb';
134 $type=$http->request("type");
135 $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_type=$1",array($type));
136 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
137
138 }
139 }
140}
141// filter only enable card
142$filter_enable_card=" and f_enable='1' ";
143
144$sql_str="select distinct f_id
145 from fiche
146 join fiche_detail using (f_id)
147 where
148 ad_id in (9,1,23)
149 and ad_value ilike '%'||$1||'%' ".$filter_enable_card.$filter_card.' limit '.$limit;
150
151
152$fid=$http->request("FID");
153
154
155$sql=$cn->get_array($sql_str ,array($fid));
156
157if ($sql != false && sizeof($sql) != 0 )
158{
159 echo "<ul>";
160 $sql_get=$cn->prepare('get_name',"select ad_value from fiche_detail where f_id = $1 and ad_id=$2");
161
162 for ($i =0;$i<12 && $i < count($sql) ;$i++)
163 {
164 $name='';
165 $quick_code='';
166 $desc='';
167
168 $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],1));
169 if ( Database::num_row($sql_name) == 1) $name=Database::fetch_result($sql_name,0,0);
170
171 $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],9));
172 if ( Database::num_row($sql_name) == 1) $desc=Database::fetch_result($sql_name,0,0);
173
174 $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],23));
175 if (Database::num_row($sql_name) == 1) $quick_code=Database::fetch_result($sql_name,0,0);
176 $fid=htmlentities($fid);
177
178 /* Highlight the found pattern with bold format */
179 $name=str_ireplace($fid,'<em>'.$fid.'</em>',h($name));
180 $qcode=str_ireplace($fid,'<em>'.$fid.'</em>',h($quick_code));
181 $desc=str_ireplace($fid,'<em>'.$fid.'</em>',h($desc));
182 printf('<li id="%s">%s <span class="informal">%s %s</span></li>',
185 $name,
186 $desc
187 );
188 }
189 echo '</ul>';
190 if (count($sql) > $limit)
191 {
192 printf ('<i>...'._('Résultat limité à %s').' ...</i>',$limit);
193 }
194}
195else
196{
197 echo "<ul><li>"._("Non trouvé")."</li></ul>";
198}
199?>
MaintenanceMode($p_file)
When you want to prevent users to connect, create a file in noalyss/ (NOALYSS_BASE) with the message ...
noalyss_str_replace($search, $replace, $string)
sql_string($p_string)
Fix the problem with the quote char for the database.
set_language()
set the lang thanks the _SESSION['g_lang'] var.
global $g_user
if no group available , then stop
if(headers_sent() &&DEBUGNOALYSS > 0) else
h( $row[ 'oa_description'])
$_REQUEST['ac']
_("actif, passif,charge,...")
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all
static num_row($ret)
wrapper for the function pg_num_rows
manage the http input (get , post, request) and extract from an array
for($e=0; $e< count($afiche); $e++) exit
$fid
Definition fid_card.php:152
$sql_str
Definition fid_card.php:144
$filter_card
Definition fid_card.php:60
$typecard
Definition fid_card.php:62
if( $delta< 0) elseif( $delta==0)
for($i=0;$i< $nb_jrn;$i++) $deb