Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_install_plugin.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 this class manages the installation and the patch of the plugin
25  */
26 
27 class Install_Plugin
28 {
29 
30  function __construct($p_cn) {
31  $this->cn=$p_cn;
32  }
33 
34  /**
35  *@brief install the plugin, create all the needed schema, tables, proc
36  * in the database
37  *@param $p_dossier is the dossier id
38  */
39  function install() {
40  $this->cn->start();
41  // create the schema
42  $this->create_schema();
43  // create table + put default values
44  $this->create_table_parameter();
46  $this->create_table_intra();
47  $this->create_table_intra_child();
48  $this->create_table_assujetti();
50 
51  $this->cn->commit();
52  }
53  function create_schema() {
54  $this->cn->exec_sql('create schema tva_belge');
55  }
57  $sql="
58 CREATE TABLE tva_belge.assujetti
59 (
60  a_id serial NOT NULL,
61  start_date date NOT NULL,
62  end_date date NOT NULL,
63  xml_oid oid,
64  periodicity character(1) NOT NULL,
65  tva_name text,
66  num_tva text,
67  adress text,
68  country text,
69  date_decl date DEFAULT now(),
70  periode_dec integer,
71  CONSTRAINT assujetti_pk PRIMARY KEY (a_id)
72 )
73 ";
74  $this->cn->exec_sql($sql);
75  }
77  $sql="
78 CREATE TABLE tva_belge.assujetti_chld
79 (
80  ac_id serial NOT NULL,
81  a_id bigint,
82  ac_tvanum text NOT NULL,
83  ac_amount numeric(20,4) NOT NULL,
84  ac_vat numeric(20,4) NOT NULL,
85  ac_qcode text NOT NULL,
86  ac_name text NOT NULL,
87  CONSTRAINT assujetti_chld_pk PRIMARY KEY (ac_id),
88  CONSTRAINT assujetti_fk FOREIGN KEY (a_id)
89  REFERENCES tva_belge.assujetti (a_id) MATCH SIMPLE
90  ON UPDATE NO ACTION ON DELETE CASCADE
91 )
92 ";
93  $this->cn->exec_sql($sql);
94  }
95  function create_table_intra() {
96  $sql=<<<EOF
97 
98 CREATE TABLE tva_belge.intracomm
99 (
100  i_id serial NOT NULL,
101  start_date date not null,
102  end_date date not null,
103  xml_oid oid,
104  periodicity char(1) not null,
105  tva_name text,
106  num_tva text,
107  adress text,
108  country text,
109  date_decl date default now(),
110  periode_dec integer,
111  CONSTRAINT intracom_pk PRIMARY KEY (i_id)
112 )
113 EOF;
114  $this->cn->exec_sql($sql);
115  }
117 $sql=<<<EOF
118 
119 CREATE TABLE tva_belge.intracomm_chld
120 (
121  ic_id serial,
122  i_id bigint,
123  ic_tvanum text NOT NULL,
124  ic_amount numeric(20,4) NOT NULL,
125  ic_code character varying(1) NOT NULL,
126  ic_periode character varying(6) NOT NULL,
127  ic_qcode text not null,
128  ic_name text not null,
129  CONSTRAINT intracom_chld_pk PRIMARY KEY (ic_id),
130  CONSTRAINT intracom_fk FOREIGN KEY (i_id)
131  REFERENCES tva_belge.intracomm (i_id) MATCH SIMPLE
132  ON UPDATE NO ACTION ON DELETE CASCADE
133 )
134 EOF;
135 $this->cn->exec_sql($sql);
136  }
137  /**
138  *@brief create the table tva_belge.declaration_amount
139  */
141  $sql=<<<EOF
142  create table tva_belge.declaration_amount
143 (
144  da_id serial,
145  d00 numeric(20,4) default 0.0 not null,
146  d01 numeric(20,4) default 0.0 not null,
147  d02 numeric(20,4) default 0.0 not null,
148  d03 numeric(20,4) default 0.0 not null,
149  d44 numeric(20,4) default 0.0 not null,
150  d45 numeric(20,4) default 0.0 not null,
151  d46 numeric(20,4) default 0.0 not null,
152  d47 numeric(20,4) default 0.0 not null,
153  d48 numeric(20,4) default 0.0 not null,
154  d49 numeric(20,4) default 0.0 not null,
155  d81 numeric(20,4) default 0.0 not null,
156  d82 numeric(20,4) default 0.0 not null,
157  d83 numeric(20,4) default 0.0 not null,
158  d84 numeric(20,4) default 0.0 not null,
159  d85 numeric(20,4) default 0.0 not null,
160  d86 numeric(20,4) default 0.0 not null,
161  d87 numeric(20,4) default 0.0 not null,
162  d88 numeric(20,4) default 0.0 not null,
163  d54 numeric(20,4) default 0.0 not null,
164  d55 numeric(20,4) default 0.0 not null,
165  d56 numeric(20,4) default 0.0 not null,
166  d57 numeric(20,4) default 0.0 not null,
167  d61 numeric(20,4) default 0.0 not null,
168  d63 numeric(20,4) default 0.0 not null,
169  dxx numeric(20,4) default 0.0 not null,
170  d59 numeric(20,4) default 0.0 not null,
171  d62 numeric(20,4) default 0.0 not null,
172  d64 numeric(20,4) default 0.0 not null,
173  dyy numeric(20,4) default 0.0 not null,
174  d71 numeric(20,4) default 0.0 not null,
175  d72 numeric(20,4) default 0.0 not null,
176  d91 numeric(20,4) default 0.0 not null,
177  start_date date not null,
178  end_date date not null,
179  xml_oid oid,
180  periodicity char(1) not null,
181  tva_name text,
182  num_tva text,
183  adress text,
184  country text,
185  date_decl date default now(),
186  periode_dec integer,
187  CONSTRAINT declaration_amount_pkey PRIMARY KEY (da_id)
188  );
189 EOF;
190 $this->cn->exec_sql($sql);
191 
192  }
194 $sql=<<<EOF
195 CREATE TABLE tva_belge.parameter
196 (
197  pcode text NOT NULL,
198  pvalue text,
199  paccount text,
200  CONSTRAINT parameter_pkey PRIMARY KEY (pcode)
201  );
202 EOF;
203 $this->cn->exec_sql($sql);
204 // load default value
205 $array=array(
206  'GRIL00'=>array('6',''),
207  'GRIL01'=>array('3',''),
208  'GRIL02'=>array('2',''),
209  'GRIL03'=>array('1',''),
210  'GRIL44'=>array('',''),
211  'GRIL45'=>array('',''),
212  'GRIL46'=>array('5','70%,71%'),
213  'GRIL47'=>array('',''),
214  'GRIL48'=>array('','7091'),
215  'GRIL49'=>array('','7092'),
216  'GRIL81'=>array('1,2,3','60%'),
217  'GRIL82'=>array('1,2,3','61%'),
218  'GRIL83'=>array('1,2,3','22%,23%,24%,25%'),
219  'GRIL84'=>array('1,2,3,4','6091'),
220  'GRIL85'=>array('',''),
221  'GRIL86'=>array('5','61%,22%,23%,24%,25%,60%'),
222  'GRIL87'=>array('',''),
223  'GRIL88'=>array('',''),
224  'GRIL54'=>array('1,2,3','7%'),
225  'GRIL55'=>array('',''),
226  'GRIL56'=>array('',''),
227  'GRIL57'=>array('',''),
228  'GRIL61'=>array('',''),
229  'GRIL63'=>array('',''),
230  'GRIL59'=>array('1,2,3','6%,22%,23%,24%,25%'),
231  'GRIL62'=>array('',''),
232  'GRIL64'=>array('',''),
233  'ATVA'=>array('','4117')
234  );
235 
236 foreach ($array as $code=>$value) {
237  $this->cn->exec_sql('insert into tva_belge.parameter(pcode,pvalue,paccount) values ($1,$2,$3)',
238  array($code,$value[0],$value[1]));
239  }
240 }
241 }
create_table_declaration_amount()
create the table tva_belge.declaration_amount
install()
install the plugin, create all the needed schema, tables, proc in the database
if(isset($_POST['remove'])) $array
$categorie_appel table
$sql