Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_install_impdol.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 /**
24  * @file
25  * @brief
26  *
27  */
29 {
30 
31  function install($p_cn)
32  {
33  try
34  {
35  $p_cn->start();
36  $p_cn->exec_sql("create schema impdol");
37  $p_cn->exec_sql("
38  create table impdol.version (
39  v_id bigint primary key,
40  v_date date default now(),
41  v_text text
42  )
43  ");
44  $p_cn->exec_sql("insert into impdol.version(v_id,v_text) values ($1,$2)", array(1, "Installation"));
45 
46  $p_cn->exec_sql("
47  CREATE TABLE impdol.import
48  (
49  i_id serial NOT NULL,
50  temp_file text,
51  send_file text,
52  i_date timestamp with time zone DEFAULT now(),
53  i_row bigint,
54  CONSTRAINT import_pkey PRIMARY KEY (i_id )
55  )");
56 
57  $p_cn->exec_sql('
58  CREATE TABLE impdol.parameter_tva
59  (
60  pt_id serial NOT NULL,
61  tva_id bigint,
62  pt_rate numeric(20,4) DEFAULT 0,
63  CONSTRAINT parameter_tva_pkey PRIMARY KEY (pt_id )
64  )
65  ');
66  $p_cn->exec_sql("
67  CREATE TABLE impdol.operation_tmp
68  (
69  o_id bigserial NOT NULL,
70  o_doli text,
71  o_date text,
72  o_qcode text,
73  f_id text,
74  o_label text,
75  o_pj text,
76  amount_unit text,
77  amount_vat text,
78  number_unit text,
79  vat_rate text,
80  amount_total text,
81  jrn_def_id text,
82  o_message text,
83  i_id bigint,
84  o_result char,
85  tva_id bigint,
86  o_type char,
87  o_poste text,
88  CONSTRAINT operation_tmp_pkey PRIMARY KEY (o_id ),
89  CONSTRAINT operation_tmp_i_id_fkey FOREIGN KEY (i_id)
90  REFERENCES impdol.import (i_id) MATCH SIMPLE
91  ON UPDATE CASCADE ON DELETE CASCADE
92  )
93  ");
94 
95  $p_cn->exec_sql("
96  CREATE TABLE impdol.operation_transfer
97  (
98  ot_id serial NOT NULL,
99  j_id bigint,
100  o_id bigint,
101  CONSTRAINT operation_transfer_pkey PRIMARY KEY (ot_id ),
102  CONSTRAINT operation_transfer_j_id_fkey FOREIGN KEY (j_id)
103  REFERENCES jrnx (j_id) MATCH SIMPLE
104  ON UPDATE CASCADE ON DELETE CASCADE,
105  CONSTRAINT operation_transfer_o_id_fkey FOREIGN KEY (o_id)
106  REFERENCES impdol.operation_tmp (o_id) MATCH SIMPLE
107  ON UPDATE CASCADE ON DELETE CASCADE
108  )");
109 
110 
111 
112  $p_cn->exec_sql("
113  COMMENT ON COLUMN impdol.operation_tmp.o_result IS 'result is T can be transferrable, N cannot be transferrable';
114  ");
115 
116  $p_cn->exec_sql("
117  COMMENT ON COLUMN impdol.operation_tmp.o_type IS 'S = marchandise, serviceT = tiers (fournisseurs, client)'
118  ");
119  $p_cn->commit();
120  }
121  catch (Exception $e)
122  {
123  $p_cn->rollback();
124  print_r($e->getTraceAsString());
125  }
126  }
127 
128 }
129 
130 ?>