|
| __construct (&$p_cn) |
|
| install () |
| install the plugin, create all the needed schema, tables, proc in the database More...
|
|
| create_schema () |
|
| create_tables () |
|
| upgrade ($p_dest) |
| Upgrade schema amortissement. More...
|
|
| __construct ($p_cn) |
|
| install () |
| install the plugin, create all the needed schema, tables, proc in the database More...
|
|
| create_schema () |
|
| create_card () |
|
| create_table_parameter () |
|
| create_table () |
|
| upgrade () |
|
| __construct ($p_cn) |
|
| install () |
| install the plugin, create all the needed schema, tables, proc in the database More...
|
|
| create_schema () |
|
| create_table_format_bank () |
|
| create_table_import () |
|
| create_table_temp_bank () |
|
| create_table_version () |
|
| __construct ($p_cn) |
|
| install () |
| install the plugin, create all the needed schema, tables, proc in the database More...
|
|
| create_schema () |
|
| create_table_assujetti () |
|
| create_table_assujetti_child () |
|
| create_table_intra () |
|
| create_table_intra_child () |
|
| create_table_declaration_amount () |
| create the table tva_belge.declaration_amount More...
|
|
| create_table_parameter () |
|
Definition at line 27 of file class_install_plugin.php.
Install_Plugin::__construct |
( |
& |
$p_cn | ) |
|
Install_Plugin::__construct |
( |
|
$p_cn | ) |
|
Install_Plugin::__construct |
( |
|
$p_cn | ) |
|
Install_Plugin::__construct |
( |
|
$p_cn | ) |
|
Install_Plugin::create_card |
( |
| ) |
|
Definition at line 65 of file class_install_plugin.php.
References $copro, $lot, ATTR_COPROP, and ATTR_IMMEUBLE.
Referenced by install().
68 $fiche_def =
new Fiche_Def($this->cn);
71 $fiche_def->add(array(
73 'nom_mod' =>
'Copropriétaires - plugin',
74 'fd_description'=>
'Liste des copropriétaires, catégorie créée par le plugin copropriété',
78 $lot_def =
new Fiche_Def($this->cn);
82 'nom_mod' =>
'Lots - plugin',
83 'fd_description'=>
'Liste des lots, catégorie créée par le plugin copropriété',
88 $imm_def =
new Fiche_Def($this->cn);
91 'nom_mod' =>
'immeuble - plugin',
92 'fd_description'=>
'Liste des immeubles, catégorie créée par le plugin copropriété',
95 $immeuble = $imm_def->id;
98 $this->cn->exec_sql(
"insert into attr_def (ad_id,ad_text,ad_type,ad_size,ad_extra)
99 values (".
ATTR_COPROP.
",'Copropriétaire','select','22','select f_id,vw_name from vw_fiche_attr where fd_id = $copro ')");
100 $this->cn->exec_sql(
"insert into attr_def (ad_id,ad_text,ad_type,ad_size,ad_extra) values
101 (".
ATTR_IMMEUBLE.
",'Immeuble','select','22','select f_id,vw_name from vw_fiche_attr where fd_id = $immeuble ');");
106 $imm_def->InsertAttribut(14);
107 $imm_def->InsertAttribut(15);
108 $imm_def->InsertAttribut(24);
109 $imm_def->InsertAttribut(16);
111 $fiche_def->InsertAttribut(27);
112 $fiche_def->InsertAttribut(32);
113 $fiche_def->InsertAttribut(10);
114 $fiche_def->InsertAttribut(33);
117 $this->cn->exec_sql(
"CREATE OR REPLACE VIEW coprop.summary AS
118 SELECT a.f_id AS lot_id, m.ad_value AS building_id, c.ad_value AS coprop_id
120 JOIN fiche f1 ON f1.f_id = a.f_id
121 JOIN ( SELECT fd1.f_id, fd1.ad_value
122 FROM fiche_detail fd1
124 JOIN ( SELECT fd1.f_id, fd1.ad_value
125 FROM fiche_detail fd1
126 WHERE fd1.ad_id = ".
ATTR_COPROP.
") c ON c.f_id = a.f_id
127 WHERE f1.fd_id = ".
$lot.
" AND a.ad_id = 1");
129 $this->immeuble_id=$immeuble;
Install_Plugin::create_schema |
( |
| ) |
|
Install_Plugin::create_schema |
( |
| ) |
|
Install_Plugin::create_schema |
( |
| ) |
|
Install_Plugin::create_schema |
( |
| ) |
|
Definition at line 59 of file class_install_plugin.php.
61 $this->cn->exec_sql(
'create schema coprop');
62 $this->cn->exec_sql(
"create sequence coprop.appel_fond_id");
Install_Plugin::create_table |
( |
| ) |
|
Install_Plugin::create_table_assujetti |
( |
| ) |
|
Definition at line 56 of file class_install_plugin.php.
References $sql.
Referenced by install().
58 CREATE TABLE tva_belge.assujetti
61 start_date date NOT NULL,
62 end_date date NOT NULL,
64 periodicity character(1) NOT NULL,
69 date_decl date DEFAULT now(),
71 CONSTRAINT assujetti_pk PRIMARY KEY (a_id)
74 $this->cn->exec_sql(
$sql);
Install_Plugin::create_table_assujetti_child |
( |
| ) |
|
Definition at line 76 of file class_install_plugin.php.
References $sql.
Referenced by install().
78 CREATE TABLE tva_belge.assujetti_chld
80 ac_id serial NOT NULL,
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
93 $this->cn->exec_sql(
$sql);
Install_Plugin::create_table_declaration_amount |
( |
| ) |
|
create the table tva_belge.declaration_amount
Definition at line 140 of file class_install_plugin.php.
References $sql, and table.
Referenced by install().
142 create
table tva_belge.declaration_amount
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,
180 periodicity
char(1) not null,
185 date_decl date
default now(),
187 CONSTRAINT declaration_amount_pkey PRIMARY KEY (da_id)
190 $this->cn->exec_sql(
$sql);
Install_Plugin::create_table_format_bank |
( |
| ) |
|
Definition at line 54 of file class_install_plugin.php.
References $sql.
Referenced by install().
56 CREATE TABLE importbank.format_bank
59 format_name text NOT NULL,
64 pos_operation_nb integer,
65 sep_decimal character(1),
66 sep_thousand character(1),
67 sep_field character(1),
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
79 $this->cn->exec_sql(
$sql);
Install_Plugin::create_table_import |
( |
| ) |
|
Definition at line 81 of file class_install_plugin.php.
References $sql.
Referenced by install().
83 $sql=
"CREATE TABLE importbank.import
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);
Install_Plugin::create_table_intra |
( |
| ) |
|
Definition at line 95 of file class_install_plugin.php.
References $sql.
Referenced by install().
98 CREATE TABLE tva_belge.intracomm
100 i_id serial NOT NULL,
101 start_date date not null,
102 end_date date not null,
104 periodicity
char(1) not null,
109 date_decl date
default now(),
111 CONSTRAINT intracom_pk PRIMARY KEY (i_id)
114 $this->cn->exec_sql(
$sql);
Install_Plugin::create_table_intra_child |
( |
| ) |
|
Definition at line 116 of file class_install_plugin.php.
References $sql.
Referenced by install().
119 CREATE TABLE tva_belge.intracomm_chld
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
135 $this->cn->exec_sql(
$sql);
Install_Plugin::create_table_parameter |
( |
| ) |
|
Definition at line 134 of file class_install_plugin.php.
References $array, and $sql.
Referenced by install().
137 CREATE TABLE coprop.parameter
141 CONSTRAINT copro_parameter_pkey PRIMARY KEY (pr_id)
144 $this->cn->exec_sql(
$sql);
147 'categorie_lot' => $this->lot_id,
148 'categorie_coprop' => $this->coprop_id,
149 'categorie_immeuble' => $this->immeuble_id,
150 'categorie_appel' => 0,
152 'categorie_charge'=>0,
156 foreach (
$array as $code => $value)
158 $this->cn->exec_sql(
'insert into coprop.parameter(pr_id,pr_value) values ($1,$2)', array($code, $value));
if(isset($_POST['remove'])) $array
Install_Plugin::create_table_parameter |
( |
| ) |
|
Definition at line 193 of file class_install_plugin.php.
References $array, and $sql.
195 CREATE TABLE tva_belge.parameter
200 CONSTRAINT parameter_pkey PRIMARY KEY (pcode)
203 $this->cn->exec_sql(
$sql);
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')
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]));
if(isset($_POST['remove'])) $array
Install_Plugin::create_table_temp_bank |
( |
| ) |
|
Definition at line 94 of file class_install_plugin.php.
References $sql.
Referenced by install().
96 $sql=
"CREATE TABLE importbank.temp_bank
99 tp_date date NOT NULL,
102 amount numeric(20,4),
104 status character(1) DEFAULT 'N'::bpchar,
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
122 $this->cn->exec_sql(
$sql);
Install_Plugin::create_table_version |
( |
| ) |
|
Definition at line 124 of file class_install_plugin.php.
References $sql.
Referenced by install().
126 $sql=
"CREATE TABLE importbank.version
128 version integer NOT NULL,
129 CONSTRAINT version_pkey PRIMARY KEY (version)
131 $this->cn->exec_sql(
$sql);
Install_Plugin::create_tables |
( |
| ) |
|
Definition at line 52 of file class_install_plugin.php.
References $table.
Referenced by install().
55 $table=
"CREATE TABLE amortissement.amortissement
59 account_deb account_type,
60 account_cred account_type,
61 a_amount numeric(20,2) NOT NULL DEFAULT 0,
62 a_nb_year numeric(4,2) NOT NULL DEFAULT 0,
65 a_visible character(1) DEFAULT 'Y'::bpchar,
66 CONSTRAINT amortissement_pkey PRIMARY KEY (a_id),
67 CONSTRAINT amortissement_account_cred_fkey FOREIGN KEY (account_cred)
68 REFERENCES tmp_pcmn (pcm_val) MATCH SIMPLE
69 ON UPDATE NO ACTION ON DELETE NO ACTION,
70 CONSTRAINT amortissement_account_deb_fkey FOREIGN KEY (account_deb)
71 REFERENCES tmp_pcmn (pcm_val) MATCH SIMPLE
72 ON UPDATE NO ACTION ON DELETE NO ACTION,
73 CONSTRAINT amortissement_f_id_fkey FOREIGN KEY (f_id)
74 REFERENCES fiche (f_id) MATCH SIMPLE
75 ON UPDATE NO ACTION ON DELETE NO ACTION,
76 CONSTRAINT amortissement_f_id_key UNIQUE (f_id)
79 $this->cn->exec_sql(
$table);
81 $table=
"CREATE TABLE amortissement.version
83 val integer primary key
86 $this->cn->exec_sql(
$table);
88 $table=
"CREATE TABLE amortissement.amortissement_detail
90 ad_id serial NOT NULL,
91 ad_amount numeric(20,2) NOT NULL DEFAULT 0,
94 ad_percentage numeric(5,2),
95 CONSTRAINT amortissement_detail_pkey PRIMARY KEY (ad_id),
96 CONSTRAINT amortissement_detail_a_id_fkey FOREIGN KEY (a_id)
97 REFERENCES amortissement.amortissement (a_id) MATCH SIMPLE
98 ON UPDATE CASCADE ON DELETE CASCADE
101 $idx=
"CREATE INDEX fki_amortissement
102 ON amortissement.amortissement_detail
106 $this->cn->exec_sql(
$table);
109 CREATE TABLE amortissement.amortissement_histo
111 ha_id serial NOT NULL,
113 h_amount numeric(20,4) NOT NULL,
115 h_year integer NOT NULL,
117 CONSTRAINT amortissement_histo_pkey PRIMARY KEY (ha_id),
118 CONSTRAINT amortissement_histo_a_id_fkey FOREIGN KEY (a_id)
119 REFERENCES amortissement.amortissement (a_id) MATCH SIMPLE
120 ON UPDATE CASCADE ON DELETE CASCADE
123 $idx=
"CREATE UNIQUE INDEX amortissement_histo_uq
124 ON amortissement.amortissement_histo
129 $this->cn->exec_sql(
$table);
131 $fct=
"CREATE OR REPLACE FUNCTION amortissement.amortissement_ins()
137 n_ad_amount numeric(20,2);
145 if i = NEW.a_nb_year then
148 nyear := NEW.a_start +i;
149 n_ad_amount := NEW.a_amount/NEW.a_nb_year;
151 total := total + n_ad_amount;
153 if total > NEW.a_amount then
154 n_ad_amount := n_ad_amount - total + NEW.a_amount ;
157 insert into amortissement.amortissement_detail(ad_year,ad_amount,a_id,ad_percentage) values (nyear,n_ad_amount,NEW.a_id,1/NEW.a_nb_year) returning ad_id into last_ad_id;
158 insert into amortissement.amortissement_histo(a_id,h_amount,h_year) values (NEW.a_id,0,nyear);
161 if total < NEW.a_amount then
162 n_ad_amount := n_ad_amount+NEW.a_amount-total;
163 update amortissement.amortissement_detail set ad_amount=n_ad_amount where ad_id=last_ad_id;
172 $this->cn->exec_sql($fct);
174 $comment_fct=
"COMMENT ON FUNCTION amortissement.amortissement_ins() IS 'Fill the table amortissement_detail after an insert'";
176 $this->cn->exec_sql($comment_fct);
178 $fct=
"CREATE OR REPLACE FUNCTION amortissement.amortissement_up()
185 n_ad_amount numeric(20,2);
192 if NEW.a_nb_year != OLD.a_nb_year or NEW.a_start != OLD.a_start or NEW.a_amount != OLD.a_amount then
193 delete from amortissement.amortissement_detail where a_id=NEW.a_id;
194 delete from amortissement.amortissement_histo where a_id=NEW.a_id and
195 (h_year < NEW.a_start or h_year > NEW.a_start+NEW.a_nb_year-1);
197 n_ad_amount := round(NEW.a_amount/NEW.a_nb_year,2);
198 n_pct := round(n_ad_amount / NEW.a_amount ,2);
201 if i = NEW.a_nb_year then
204 nyear := NEW.a_start +i;
206 select ha_id into lha_id from amortissement.amortissement_histo where a_id=NEW.a_id and h_year = nyear;
209 insert into amortissement.amortissement_histo(a_id,h_year,h_amount) values (NEW.a_id,nyear,0);
212 total := round(total + n_ad_amount,2);
214 if total > NEW.a_amount then
215 n_ad_amount := NEW.a_amount - total - n_ad_amount;
217 insert into amortissement.amortissement_detail(ad_year,ad_amount,ad_percentage,a_id) values (nyear,n_ad_amount,1/NEW.a_nb_year,NEW.a_id) returning ad_id into last_ad_id;
220 if total < NEW.a_amount then
221 n_ad_amount := n_ad_amount+NEW.a_amount-total;
222 update amortissement.amortissement_detail set ad_amount=n_ad_amount where ad_id=last_ad_id;
229 LANGUAGE 'plpgsql' ";
231 $this->cn->exec_sql($fct);
234 $trigger=
"CREATE TRIGGER amortissement_after_ins
236 ON amortissement.amortissement
238 EXECUTE PROCEDURE amortissement.amortissement_ins();";
240 $this->cn->exec_sql($trigger);
242 $trigger=
"CREATE TRIGGER amortissement_after_up
244 ON amortissement.amortissement
246 EXECUTE PROCEDURE amortissement.amortissement_up();";
248 $this->cn->exec_sql($trigger);
249 $this->cn->exec_sql(
"insert into amortissement.version values (1)");
while(($row=fgetcsv($fbank, 0, $sp))!==false) $table
Install_Plugin::install |
( |
| ) |
|
Install_Plugin::install |
( |
| ) |
|
Install_Plugin::install |
( |
| ) |
|
Install_Plugin::install |
( |
| ) |
|
Install_Plugin::upgrade |
( |
| ) |
|
Install_Plugin::upgrade |
( |
|
$p_dest | ) |
|
Upgrade schema amortissement.
- Parameters
-
Definition at line 256 of file class_install_plugin.php.
References $file.
260 if ( $p_dest == 2 ) {
262 $add_column =
"alter table amortissement.amortissement add card_deb bigint";
263 $add_fk=
"alter table amortissement.amortissement add constraint card_deb_fk foreign key (card_deb) references public.fiche(f_id) on update cascade on delete set null";
264 $add_comment =
" comment on column amortissement.amortissement.card_deb is 'Charge d''amortissement' ";
265 $this->cn->exec_sql($add_column);
266 $this->cn->exec_sql($add_fk);
267 $this->cn->exec_sql($add_comment);
269 $add_column =
"alter table amortissement.amortissement add card_cred bigint";
270 $add_fk=
"alter table amortissement.amortissement add constraint card_cred_fk foreign key (card_cred) references public.fiche(f_id) on update cascade on delete set null";
271 $add_comment =
" comment on column amortissement.amortissement.card_cred is 'Poste amorti' ";
273 $this->cn->exec_sql($add_column);
274 $this->cn->exec_sql($add_fk);
275 $this->cn->exec_sql($add_comment);
277 create or replace view amortissement.v_amortissement_summary
279 select f_id,vw_name,vw_description,quick_code,
280 a_id,account_deb,account_cred,a_amount,a_nb_year,a_start,a_date,a_visible,
281 card_cred,(select j_qcode from vw_poste_qcode where f_id=card_cred) as card_cred_qcode,
282 card_deb,(select j_qcode from vw_poste_qcode where f_id=card_deb) as card_deb_qcode,
283 ( select coalesce(sum(h_amount),0) from amortissement.amortissement_histo where amortissement_histo.a_id=amortissement.a_id) as amort_done
284 from amortissement.amortissement
285 join public.vw_fiche_attr using (f_id)
287 $this->cn->exec_sql($sql_create_view);
288 $add_comment=
" comment on view amortissement.v_amortissement_summary is 'View of material with card'";
289 $this->cn->exec_sql($add_comment);
290 $this->cn->exec_sql(
' insert into amortissement.version values(2)');
295 $file=dirname(__FILE__);
296 $this->cn->execute_script(
$file.
'/../sql/upgrade2.sql');
298 }
catch (Exception $e) {
The documentation for this class was generated from the following file: