noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
fid.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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief Fid for the ajax request for cards
24 * \see fiche_search.php
25 * Valid parameter GET are
26 * - d type = cred, deb, all or filter or any sql where clause if the d starts with [sql]
27 * - j is the legdger
28 * - l field for the label
29 * - t field for the tva_id
30 * - p field for the price (sale)
31 * - b field for the price (purchase)
32 * - FID is the QuickCode
33 *\note if the j is -1 then all the card are shown
34 */
35require_once '../include/constant.php';
36require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
37MaintenanceMode("block.html");
38/**
39 * if not connected, session is expired then exit with a message NOCONX
40 */
41if ( ! isset($_SESSION[SESSION_KEY."g_user"])) {
42 echo "NOCONX";
43 die();
44}
45
46$gDossier=dossier::id();
47
48$cn=Dossier::connect();
49global $g_user;
51$g_user->check();
52/**
53 * check if 2FA is completed
54 */
55if ( ! $g_user->is_double_identified()) {
56 exit();
57}
58$g_user->check_dossier(dossier::id());
60
62
63$fLabel=$hi->request("l","string","none");
64$fTva_id=$hi->request("t","string","none");
65$fPrice_sale=$hi->request("p","string","none");
66$fPrice_purchase=$hi->request("b","string","none");
67
68if ( isset($_SESSION[SESSION_KEY.'isValid']) && $_SESSION[SESSION_KEY.'isValid'] == 1)
69{
70 $jrn=$hi->get('j', "number",'-1');
71 $d=$hi->get('d',"string", '');
72 $d=sql_string($d);
73
74 if ( $jrn == -1 )
75 $d='all';
76 if ( strpos($d,'sql') == false )
77 {
78
79 switch ($d)
80 {
81 case 'cred':
82 $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn));
83 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
84
85 break;
86 case 'deb':
87 $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn));
88 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
89 break;
90 case 'all':
91 $filter_card="";
92 break;
93 case 'filter':
94 $get_cred='jrn_def_fiche_cred';
95 $get_deb='jrn_def_fiche_deb';
96 $deb=$cn->get_value("select $get_deb from jrn_def where jrn_def_id=$1",array($jrn));
97 $cred=$cn->get_value("select $get_cred from jrn_def where jrn_def_id=$1",array($jrn));
98
99 $filter_jrn="";
100
101 if ($deb!=='' && $cred!='')
102 $filter_jrn =$deb.','.$cred;
103 elseif($deb != '')
104 $filter_jrn=$deb;
105 elseif($cred != '')
106 $filter_jrn=$cred;
107
108 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
109 break;
110 case 'all':
111 $filter_card='';
112 break;
113
114 default:
115 $d= ( empty($d) )?-1:$d;
116 $filter_card="and fd_id in ($d)";
117 }
118 }
119 else
120 {
121 $filter_card=$d;
122 $filter_card=noalyss_str_replace('[sql]','',$d);
123 }
124 $sql="select vw_name,vw_first_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id,tva_code
125 from vw_fiche_attr
126 where quick_code=upper($1)". $filter_card;
127
128 $array=$cn->get_array($sql, array($hi->request('FID')));
129
130 if ( empty($array))
131 {
132 echo '{"answer":"nok","flabel":"'.$fLabel.'"}';
133 exit;
134 }
135
136
137 $name=$array[0]['vw_name'];
138 // use for followup
139 $sell=(isNumber($array[0]['vw_sell']) == 1) ? $array[0]['vw_sell'] : 0 ;
140 $buy=(isNumber($array[0]['vw_buy']) == 1) ?$array[0]['vw_buy']:0;
141
142 $tva_id=(empty($array[0]['tva_id']))?$array[0]['tva_code']:$array[0]['tva_id'];
143
144 // Check null
145 $name=($name==null)?" ":noalyss_str_replace('"','',$name);
146 $sell=($sell==null)?"0":noalyss_str_replace('"','',$sell);
147 $buy=($buy==null)?"0":noalyss_str_replace('"','',$buy);
148 $tva_id=($tva_id==null)?" ":noalyss_str_replace('"','',$tva_id);
149 /* store the answer in an array and transform it later into a JSON object */
150 $tmp=array();
151 //$tmp[]=array('flabel',$fLabel);
152 $tmp['flabel']=$fLabel;
153 //$tmp[]=array('name',$name);
154 $tmp['name']=$name." ".$array[0]['vw_first_name'];
155 $tmp['ftva_id']=$fTva_id;
156 $tmp['tva_id']=$tva_id;
157 $tmp['fPrice_sale']=$fPrice_sale;
158 $tmp['sell']=$sell;
159 $tmp['fPrice_purchase']=$fPrice_purchase;
160 $tmp['buy']=$buy;
161 $tmp["answer"]="ok";
162 $a=json_encode($tmp);
163}
164else
165 $a='{"answer":"unauthorized"}';
166header("Content-type: text/html; charset: utf8",true);
167print $a;
168?>
isNumber($p_int)
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
manage the http input (get , post, request) and extract from an array
Data & function about connected users.
$hi
Definition export.php:67
for($e=0; $e< count($afiche); $e++) exit
$fPrice_sale
Definition fid.php:65
$fTva_id
Definition fid.php:64
$fPrice_purchase
Definition fid.php:66
$fLabel
Definition fid.php:63
$filter_card
Definition fid_card.php:60
print
Type of printing.
if( $delta< 0) elseif( $delta==0)
for($i=0;$i< $nb_jrn;$i++) $deb