Plugins  LAST
 All Data Structures Files Functions Variables Pages
tva_param.inc.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 /* $Revision$ */
20 
21 // Copyright (c) 2002 Author Dany De Bontridder dany@alchimerys.be
22 
23 /*!\file
24  * \brief set up the parameters
25  */
26 require_once('class_tva_parameter.php');
27 $cn=Dossier::connect();
28 
29 // save all the parameters
30 if ( isset ($_POST['save_misc'])) {
31  extract($_POST);
32 
33  foreach ( array('CRTVA','ATVA','DTTVA') as $i){
34  $value=${$i};
35  if ( trim(${$i})=='') $value=null;
36  if ( $cn->get_value("select count(*) from tva_belge.parameter_chld where pcode=$1",array($i))==0)
37  {
38  $cn->exec_sql("insert into tva_belge.parameter_chld(pcode,pcm_val) values($1,$2) ",
39  array($i,$value));
40  }else {
41 
42  $cn->exec_sql("update tva_belge.parameter_chld set pcm_val=$1::account_type where pcode=$2",
43  array($value,$i));
44  }
45  }
46 
47  unset($_POST['save_misc']);
48 }
49 
50 if ( isset ($_POST['save_addparam'])){
51  extract ($_POST);
52  try {
53  if ( trim($tva_id)=="") throw new Exception("TVA n'existe pas");
54  if ( trim($paccount)=="") throw new Exception("Poste comptable vide");
55  if ( $cn->get_value("select count(tva_id) from tva_rate where tva_id=$1",array($tva_id))==0) throw new Exception("TVA $tva_id n'existe pas");
56  $cn->exec_sql("insert into tva_belge.parameter_chld(pcode,tva_id,pcm_val) values ($1,$2,$3::account_type)",
57  array($pcode,$tva_id,$paccount));
58  } catch(Exception $e) {
59  alert("Ne peut sauver : ".$e->getMessage());
60  }
61 }
62 if ( isset ($_POST['pi_id'])){
63  $cn->exec_sql("delete from tva_belge.parameter_chld where pi_id=$1",array($_POST['pi_id']));
64 }
65 /* show all the possible parameters */
67 require_once NOALYSS_INCLUDE.'/lib/class_itva_popup.php';
68 require_once NOALYSS_INCLUDE.'/lib/class_iposte.php';
69 
70 echo dossier::hidden();
71 echo HtmlInput::extension();
72 echo $tvap->display();
73 
if(isset($_POST['save_misc'])) if(isset($_POST['save_addparam'])) if(isset($_POST['pi_id'])) $tvap