noalyss Version-9
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$g_user->check_dossier(dossier::id());
54
56
57$fLabel=$hi->request("l","string","none");
58$fTva_id=$hi->request("t","string","none");
59$fPrice_sale=$hi->request("p","string","none");
60$fPrice_purchase=$hi->request("b","string","none");
61
62if ( isset($_SESSION[SESSION_KEY.'isValid']) && $_SESSION[SESSION_KEY.'isValid'] == 1)
63{
64 $jrn=$hi->get('j', "number",'-1');
65 $d=$hi->get('d',"string", '');
66 $d=sql_string($d);
67
68 if ( $jrn == -1 )
69 $d='all';
70 if ( strpos($d,'sql') == false )
71 {
72
73 switch ($d)
74 {
75 case 'cred':
76 $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn));
77 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
78
79 break;
80 case 'deb':
81 $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn));
82 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
83 break;
84 case 'all':
85 $filter_card="";
86 break;
87 case 'filter':
88 $get_cred='jrn_def_fiche_cred';
89 $get_deb='jrn_def_fiche_deb';
90 $deb=$cn->get_value("select $get_deb from jrn_def where jrn_def_id=$1",array($jrn));
91 $cred=$cn->get_value("select $get_cred from jrn_def where jrn_def_id=$1",array($jrn));
92
93 $filter_jrn="";
94
95 if ($deb!=='' && $cred!='')
96 $filter_jrn =$deb.','.$cred;
97 elseif($deb != '')
98 $filter_jrn=$deb;
99 elseif($cred != '')
100 $filter_jrn=$cred;
101
102 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
103 break;
104 case 'all':
105 $filter_card='';
106 break;
107
108 default:
109 $d= ( empty($d) )?-1:$d;
110 $filter_card="and fd_id in ($d)";
111 }
112 }
113 else
114 {
115 $filter_card=$d;
116 $filter_card=noalyss_str_replace('[sql]','',$d);
117 }
118 $sql="select vw_name,vw_first_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id,tva_code
119 from vw_fiche_attr
120 where quick_code=upper($1)". $filter_card;
121
122 $array=$cn->get_array($sql, array($hi->request('FID')));
123
124 if ( empty($array))
125 {
126 echo '{"answer":"nok","flabel":"'.$fLabel.'"}';
127 exit;
128 }
129
130
131 $name=$array[0]['vw_name'];
132 // use for followup
133 $sell=(isNumber($array[0]['vw_sell']) == 1) ? $array[0]['vw_sell'] : 0 ;
134 $buy=(isNumber($array[0]['vw_buy']) == 1) ?$array[0]['vw_buy']:0;
135
136 $tva_id=(empty($array[0]['tva_id']))?$array[0]['tva_code']:$array[0]['tva_id'];
137
138 // Check null
139 $name=($name==null)?" ":noalyss_str_replace('"','',$name);
140 $sell=($sell==null)?"0":noalyss_str_replace('"','',$sell);
141 $buy=($buy==null)?"0":noalyss_str_replace('"','',$buy);
142 $tva_id=($tva_id==null)?" ":noalyss_str_replace('"','',$tva_id);
143 /* store the answer in an array and transform it later into a JSON object */
144 $tmp=array();
145 //$tmp[]=array('flabel',$fLabel);
146 $tmp['flabel']=$fLabel;
147 //$tmp[]=array('name',$name);
148 $tmp['name']=$name." ".$array[0]['vw_first_name'];
149 $tmp['ftva_id']=$fTva_id;
150 $tmp['tva_id']=$tva_id;
151 $tmp['fPrice_sale']=$fPrice_sale;
152 $tmp['sell']=$sell;
153 $tmp['fPrice_purchase']=$fPrice_purchase;
154 $tmp['buy']=$buy;
155 $tmp["answer"]="ok";
156 $a=json_encode($tmp);
157}
158else
159 $a='{"answer":"unauthorized"}';
160header("Content-type: text/html; charset: utf8",true);
161print $a;
162?>
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:53
for($e=0; $e< count($afiche); $e++) exit
$fPrice_sale
Definition fid.php:59
$fTva_id
Definition fid.php:58
$fPrice_purchase
Definition fid.php:60
$fLabel
Definition fid.php:57
$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