Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 require_once '../include/constant.php';
00036 require_once('class_own.php');
00037 require_once ("constant.php");
00038 require_once('class_database.php');
00039 require_once ("user_common.php");
00040 require_once('class_dossier.php');
00041 $gDossier=dossier::id();
00042
00043 require_once('class_user.php');
00044
00045 $cn=new Database(dossier::id());
00046 global $g_user;
00047 $g_user=new User($cn);
00048 $g_user->check();
00049 $g_user->check_dossier(dossier::id());
00050
00051 $fLabel=(isset($_REQUEST['l']))?$_REQUEST['l']:'none';
00052 $fTva_id=(isset($_REQUEST['t']))?$_REQUEST['t']:'none';
00053 $fPrice_sale=(isset($_REQUEST['p']))?$_REQUEST['p']:'none';
00054 $fPrice_purchase=(isset($_REQUEST['b']))?$_REQUEST['b']:'none';
00055
00056
00057
00058 if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1)
00059 {
00060 $jrn=sql_string($_GET['j']);
00061 $d=sql_string($_GET['d']);
00062
00063 if ( $jrn == -1 )
00064 $d='all';
00065 if ( strpos($d,'sql') == false )
00066 {
00067
00068 switch ($d)
00069 {
00070 case 'cred':
00071 $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn));
00072 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
00073
00074 break;
00075 case 'deb':
00076 $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn));
00077 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
00078 break;
00079 case 'all':
00080 $filter_card="";
00081 break;
00082 case 'filter':
00083 $get_cred='jrn_def_fiche_cred';
00084 $get_deb='jrn_def_fiche_deb';
00085 $deb=$cn->get_value("select $get_deb from jrn_def where jrn_def_id=$1",array($jrn));
00086 $cred=$cn->get_value("select $get_cred from jrn_def where jrn_def_id=$1",array($jrn));
00087
00088 $filter_jrn="";
00089
00090 if ($deb!=='' && $cred!='')
00091 $filter_jrn =$deb.','.$cred;
00092 elseif($deb != '')
00093 $filter_jrn=$deb;
00094 elseif($cred != '')
00095 $filter_jrn=$cred;
00096
00097 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
00098 break;
00099 case 'all':
00100 $filter_card='';
00101 break;
00102
00103 default:
00104 $filter_card="and fd_id in ($d)";
00105 }
00106 }
00107 else
00108 {
00109 $filter_card=$d;
00110 $filter_card=str_replace('[sql]','',$d);
00111 }
00112 $sql="select vw_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id
00113 from vw_fiche_attr
00114 where quick_code=upper($1)". $filter_card;
00115
00116 $array=$cn->get_array($sql, array($_REQUEST['FID']));
00117
00118 if ( empty($array))
00119 {
00120 echo '{"answer":"nok","flabel":"'.$fLabel.'"}';
00121 exit;
00122 }
00123
00124
00125 $name=$array[0]['vw_name'];
00126 $sell=$array[0]['vw_sell'] ;
00127 $buy=$array[0]['vw_buy'];
00128 $tva_id=$array[0]['tva_id'];
00129
00130
00131 $name=($name==null)?" ":str_replace('"','',$name);
00132 $sell=($sell==null)?" ":str_replace('"','',$sell);
00133 $buy=($buy==null)?" ":str_replace('"','',$buy);
00134 $tva_id=($tva_id==null)?" ":str_replace('"','',$tva_id);
00135
00136 $tmp=array();
00137 $tmp[]=array('flabel',$fLabel);
00138 $tmp[]=array('name',$name);
00139 $tmp[]=array('ftva_id',$fTva_id);
00140 $tmp[]=array('tva_id',$tva_id);
00141 $tmp[]=array('fPrice_sale',$fPrice_sale);
00142 $tmp[]=array('sell',$sell);
00143 $tmp[]=array('fPrice_purchase',$fPrice_purchase);
00144 $tmp[]=array('buy',$buy);
00145 $a='{"answer":"ok"';
00146 for ($o=0;$o < count($tmp);$o++)
00147 {
00148 $a.=sprintf(',"%s":"%s"',$tmp[$o][0],$tmp[$o][1]);
00149 }
00150 $a.='}';
00151 }
00152 else
00153 $a='{"answer":"unauthorized"}';
00154 header("Content-type: text/html; charset: utf8",true);
00155 print $a;
00156 ?>