Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_impacc_tva.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of PhpCompta.
5  *
6  * PhpCompta 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  * PhpCompta 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 PhpCompta; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 // Copyright (2014) Author Dany De Bontridder <dany@alchimerys.be>
21 
22 if (!defined('ALLOWED'))
23  die('Appel direct ne sont pas permis');
24 
25 /**
26  * @file
27  * @brief Match between Noalyss VAT code and VAT Code from CSV file
28  *
29  */
31 {
32  function display_list()
33  {
34  $cn=Dossier::connect();
35  $sql="select * from impacc.parameter_tva left join public.tva_rate using(tva_id) order by tva_code";
36  $ret=$cn->get_array($sql);
37  require_once DIR_IMPORT_ACCOUNT."/template/tva_parameter_list.php";
38  }
39  /// The TVA ID must exist
40  function check_exist($tva_id)
41  {
42 
43  }
44  /// the TVA Code must be unique
45  function check_valid($tva_code,$pt_id)
46  {
47  $cn=Dossier::connect();
48  $count=$cn->get_value(
49  "select
50  count(*)
51  from
52  impacc.parameter_tva
53  where
54  pt_id <> $1
55  and tva_code=$2",
56  array($pt_id,$tva_code)
57  );
58  return $count;
59  }
60  function insert($tva_id,$tva_code)
61  {
62  if ( $this->check_valid($tva_code,-1) > 0)
63  {
64  throw new Exception(_("Duplicate"));
65  }
66  $cn=Dossier::connect();
67 
68  $cn->exec_sql("insert into impacc.parameter_tva(tva_id,tva_code)
69  values ($1,$2)
70  returning pt_id", array($tva_id,$tva_code));
71  }
72  function update($id,$tva_id,$tva_code)
73  {
74  if ( $this->check_valid($tva_code,$id) > 0)
75  {
76  throw new Exception(_("Duplicate"));
77  }
78  $cn=Dossier::connect();
79  $cn->exec_sql("update impacc.parameter_tva set tva_id=$1,tva_code=$2 where pt_id=$3",
80  array($tva_id,$tva_code,$id));
81  }
82  function delete($p_id)
83  {
84  $cn=Dossier::connect();
85  $cn->exec_sql("delete from impacc.parameter_tva where pt_id=$1",array($p_id));
86  }
87  function display_modify($p_tva)
88  {
89  $cn=Dossier::connect();
90 
91  // Load parameter
92  $sql="select * from impacc.parameter_tva left join public.tva_rate using(tva_id) where pt_id=$1";
93  $ret=$cn->get_array($sql,array($p_tva));
94  $tva_id=$ret[0]["tva_id"];
95  $comment=h($ret[0]['tva_comment']);
96  $tva_code=h($ret[0]['tva_code']);
97  $id=$ret[0]['pt_id'];
98  $label=$ret[0]['tva_label'];
99 
100  // Display Box
101  require_once DIR_IMPORT_ACCOUNT."/template/tva_parameter_detail.php";
102  }
103  function display_add()
104  {
105  $tva_id="";
106  $comment="";
107  $tva_code="";
108  $id=-1;
109  $label="";
110  // Display empty Box
111  require_once DIR_IMPORT_ACCOUNT."/template/tva_parameter_detail.php";
112  }
113 }
update($id, $tva_id, $tva_code)
$ret
insert($tva_id, $tva_code)
display_modify($p_tva)
check_valid($tva_code, $pt_id)
the TVA Code must be unique
check_exist($tva_id)
The TVA ID must exist.
$sql
global $cn