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  function __construct($p_cn)
30  {
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_format_bank();
45  $this->create_table_import();
46  $this->create_table_temp_bank();
47  $this->create_table_version();
48 
49  $this->cn->commit();
50  }
51  function create_schema() {
52  $this->cn->exec_sql('create schema importbank');
53  }
55  $sql="
56  CREATE TABLE importbank.format_bank
57  (
58  id serial NOT NULL,
59  format_name text NOT NULL,
60  jrn_def_id integer,
61  pos_lib integer,
62  pos_amount integer,
63  pos_date integer,
64  pos_operation_nb integer,
65  sep_decimal character(1),
66  sep_thousand character(1),
67  sep_field character(1),
68  format_date text,
69  nb_col integer,
70  skip integer,
71  pos_third integer,
72  pos_extra integer,
73  CONSTRAINT format_bank_pkey PRIMARY KEY (id),
74  CONSTRAINT fk_jrn FOREIGN KEY (jrn_def_id)
75  REFERENCES jrn_def (jrn_def_id) MATCH SIMPLE
76  ON UPDATE CASCADE ON DELETE SET NULL
77  )";
78 
79  $this->cn->exec_sql($sql);
80  }
82  {
83  $sql="CREATE TABLE importbank.import
84  (
85  id serial NOT NULL,
86  i_date timestamp with time zone DEFAULT now(),
87  format_bank_id bigint,
88  CONSTRAINT import_pkey PRIMARY KEY (id),
89  CONSTRAINT fk_format_bank FOREIGN KEY (format_bank_id)
90  REFERENCES importbank.format_bank (id) MATCH SIMPLE
91  ON UPDATE CASCADE ON DELETE CASCADE )";
92  $this->cn->exec_sql($sql);
93  }
95  {
96  $sql="CREATE TABLE importbank.temp_bank
97  (
98  id serial NOT NULL,
99  tp_date date NOT NULL,
100  jrn_def_id integer,
101  libelle text,
102  amount numeric(20,4),
103  ref_operation text,
104  status character(1) DEFAULT 'N'::bpchar,
105  import_id bigint,
106  tp_third text,
107  tp_extra text,
108  f_id integer,
109  tp_rec text,
110  tp_error_msg text,
111  CONSTRAINT temp_bank_pkey PRIMARY KEY (id),
112  CONSTRAINT fk_import_id FOREIGN KEY (import_id)
113  REFERENCES importbank.import (id) MATCH SIMPLE
114  ON UPDATE CASCADE ON DELETE CASCADE,
115  CONSTRAINT fk_jrn_temp_bank FOREIGN KEY (jrn_def_id)
116  REFERENCES jrn_def (jrn_def_id) MATCH SIMPLE
117  ON UPDATE CASCADE ON DELETE SET NULL,
118  CONSTRAINT temp_bank_f_id_fkey FOREIGN KEY (f_id)
119  REFERENCES fiche (f_id) MATCH SIMPLE
120  ON UPDATE CASCADE ON DELETE CASCADE
121  )";
122  $this->cn->exec_sql($sql);
123  }
125  {
126  $sql="CREATE TABLE importbank.version
127  (
128  version integer NOT NULL,
129  CONSTRAINT version_pkey PRIMARY KEY (version)
130  )";
131  $this->cn->exec_sql($sql);
132  }
133 }
134 
135 ?>
install()
install the plugin, create all the needed schema, tables, proc in the database
$sql