Plugins  LAST
 All Data Structures Files Functions Variables Pages
imd_parameter.inc.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of NOALYSS.
5  *
6  * NOALYSS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * NOALYSS is distributed in the hope that it will be useful,
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 /* $Revision$ */
21 
22 // Copyright (c) 2002 Author Dany De Bontridder dany@alchimerys.be
23 
24 /**
25  * @file
26  * @brief matching between tva and rate
27  *
28  */
29 global $cn;
30 if (isset($_POST['ftvaadd']))
31 {
32  extract($_POST);
33  try
34  {
35  if (isNumber($pt_rate) == 0)
36  throw new Exception("le taux n'est pas un nombre");
37  if ($pt_rate < 0 || $pt_rate > 100)
38  throw new Exception("le taux est invalide");
39  $tva = new Acc_Tva($cn, $tva_id);
40  if ($tva->load() == -1)
41  throw new Exception('Cette tva est invalide');
42  $sql = "insert into impdol.parameter_tva(tva_id,pt_rate) values ($1,$2)";
43  $cn->exec_sql($sql, array($_POST['tva_id'], $_POST['pt_rate']));
44  }
45  catch (Exception $e)
46  {
47  alert($e->getMessage());
48  }
49 }
50 if (isset($_POST['mod']))
51 {
52  extract ($_POST);
53  $aparm = $cn->get_array("select pt_id from impdol.parameter_tva");
54  try
55  {
56  for ($i = 0; $i < count($aparm); $i++)
57  {
58  if (isset(${'tva_' . $aparm[$i]['pt_id']}))
59  {
60  $pt_rate = ${'rate' . $aparm[$i]['pt_id']};
61  $tva_id = ${'tva_' . $aparm[$i]['pt_id']};
62  if (isNumber($pt_rate) == 0)
63  throw new Exception("le taux n'est pas un nombre");
64  if ($pt_rate < 0 || $pt_rate > 100)
65  throw new Exception("le taux est invalide");
66  $tva = new Acc_Tva($cn, $tva_id);
67  if ($tva->load() == -1)
68  throw new Exception('Cette tva est invalide');
69  $sql = "update impdol.parameter_tva set tva_id = $1, pt_rate = $2 where pt_id=$3";
70  $cn->exec_sql($sql, array($tva_id, $pt_rate,$aparm[$i]['pt_id']));
71  }
72  }
73  }
74  catch (Exception $e)
75  {
76  alert($e->getMessage());
77  }
78 }
79 /**
80  * get data from database
81  */
82 $atva = $cn->get_array("select * from impdol.parameter_tva order by pt_rate");
83 require 'template/parameter_tva_add.php';
84 echo '<form method="POST">';
85 require 'template/parameter.php';
86 echo HtmlInput::submit("mod", "Modification");
87 
88 echo '</form>';
89 ?>
if(isset($_POST['ftvaadd'])) if(isset($_POST['mod'])) $atva
get data from database
global $cn
$sql