In order to get easier the installation and the upgrade of the database
a new module webbased has been created, the old version of install.sh
is now obsolete
This commit is contained in:
sparkyx 2005-02-06 01:05:14 +00:00
parent 29f5d52e33
commit 53234e02f3
32 changed files with 4798 additions and 0 deletions

110
html/admin/setup.php Normal file
View file

@ -0,0 +1,110 @@
<style type="text/css">
<!--
h2.info {
color:green;
font-size:20px;
}
h2.error {
color:red;
font-size:20px;
}
-->
</style>
<?
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
$inc_path=get_include_path();
$inc_path.=':../../include';
set_include_path($inc_path);
include_once('constant.php');
include_once('postgres.php');
include_once('debug.php');
include_once('ac_common.php');
include_once('variable.php');
// Verify some PHP parameters
// magic_quotes_gpc = Off
// magic_quotes_runtime = Off
// magic_quotes_sybase = Off
// include_path
// register_global
foreach (array('magic_quotes_gpc','magic_quotes_runtime') as $a) {
if ( ini_get($a) == false ) print $a.': Ok <br>';
else {
print ("<h2 class=\"error\">$a has a bad value !!!</h2>");
}
}
if ( ereg("\.\.\/include",ini_get('include_path')) == false )
print ("<h2 class=\"error\">include_path incorrect !!!".ini_get('include_path')."</h2>");
else
print 'include_path : ok ('.ini_get('include_path').')<br>';
$cn=DbConnect(-2,'phpcompta');
if ($cn == false ) {
print "<p> Vous devez absolument taper dans une console la commande 'createuser -d phpcompta'
puis la commande 'createdb -O phpcompta phpcompta'. </p>
<p>Ces commandes créeront l'utilisateur phpcompta
puis la base de données par défaut de phpcompta.</p>";
exit();
}
// Check if account_repository exists
$account=CountSql($cn,
"select * from pg_database where datname='account_repository'");
// Create the account_repository
if ($account == 0 ) {
ob_start();
echo "Creation of account_repository";
ExecSql($cn,"create database account_repository encoding='latin1'");
$r=system("$psql -U phpcompta account_repository -f sql/account_repository/schema.sql",$r);
$r=system("$psql -U phpcompta account_repository -f sql/account_repository/data.sql",$r);
echo "Creation of Démo";
ExecSql($cn,"create database dossier1 encoding='latin1'");
$r=system("$psql -U phpcompta dossier1 -f sql/dossier1/schema.sql",$r);
$r=system("$psql -U phpcompta dossier1 -f sql/dossier1/data.sql",$r);
echo "Creation of Modele1";
ExecSql($cn,"create database mod1 encoding='latin1'");
$r=system("$psql -U phpcompta mod1 -f sql/mod1/schema.sql",$r);
$r=system("$psql -U phpcompta mod1 -f sql/mod1/data.sql",$r);
ob_end_clean();
}
// _SERVER["DOCUMENT_ROOT"]
// Test the connection
$a=DbConnect();
if ( $a==false) {
exit ("<h2 class=\"error\">".__LINE__." test has failed !!!</h2>");
}
if ( ($Res=ExecSql($a,"select * from ac_users") ) == false ) {
exit ("<h2 class=\"error\">".__LINE__." test has failed !!!</h2>");
} else
print "Connect to database success <br>";
echo "<h2 class=\"info\"> Congratulation : Test successfull</h2>";

View file

@ -0,0 +1,14 @@
ALTER TABLE ONLY ac_users
ADD CONSTRAINT ac_users_pkey PRIMARY KEY (use_id);
ALTER TABLE ONLY ac_users
ADD CONSTRAINT ac_users_use_login_key UNIQUE (use_login);
ALTER TABLE ONLY ac_dossier
ADD CONSTRAINT ac_dossier_pkey PRIMARY KEY (dos_id);
ALTER TABLE ONLY ac_dossier
ADD CONSTRAINT ac_dossier_dos_name_key UNIQUE (dos_name);
ALTER TABLE ONLY jnt_use_dos
ADD CONSTRAINT jnt_use_dos_pkey PRIMARY KEY (use_id, dos_id);
ALTER TABLE ONLY jnt_use_dos
ADD CONSTRAINT "$1" FOREIGN KEY (use_id) REFERENCES ac_users(use_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY modeledef
ADD CONSTRAINT modeledef_pkey PRIMARY KEY (mod_id);

View file

@ -0,0 +1,152 @@
--
-- PostgreSQL database dump
--
SET search_path = public, pg_catalog;
--
-- Data for TOC entry 6 (OID 44866)
-- Name: ac_users; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_theme, use_usertype) VALUES (4, 'demo', 'demo', 'demo', 1, 'fe01ce2a7fbac8fafaed7c982a04e229', 0, 'Light', 'user');
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_theme, use_usertype) VALUES (5, 'dany', 'dany', 'dany', 1, '1b9fc02e98389d29c1506fe944b07d16', 0, 'classic', 'compta');
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_theme, use_usertype) VALUES (1, NULL, NULL, 'phpcompta', 1, 'b1cc88e1907cde80cb2595fa793b3da9', 1, 'Light', 'user');
--
-- Data for TOC entry 7 (OID 44876)
-- Name: ac_dossier; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (1, 'Demo', 'Base de données pour développement & démo', 0);
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (4, 'Test Sécurité', 'Test pour la sécurité', 0);
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (5, 'Alchimerys 2003', '', 0);
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (8, 'Alchimerys 2004', '', 0);
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (9, 'DB Supp', 'Db supp', 0);
--
-- Data for TOC entry 8 (OID 44885)
-- Name: jnt_use_dos; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (1, 1, 1);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (2, 1, 2);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (3, 1, 5);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (4, 1, 6);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (13, 4, 1);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (14, 1, 7);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (15, 1, 8);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (16, 1, 9);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (27, 5, 5);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (28, 5, 8);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (19, 1, 3);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (20, 1, 4);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (29, 5, 9);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (22, 5, 4);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (23, 5, 1);
--
-- Data for TOC entry 9 (OID 44888)
-- Name: version; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO "version" (val) VALUES (3);
--
-- Data for TOC entry 10 (OID 44892)
-- Name: priv_user; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (1, 5, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (2, 6, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (3, 7, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (4, 8, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (5, 9, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (6, 10, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (7, 11, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (8, 12, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (9, 13, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (10, 21, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (13, 27, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (14, 28, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (15, 29, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (12, 23, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (11, 22, 'W');
--
-- Data for TOC entry 11 (OID 44898)
-- Name: theme; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('classic', 'style.css', NULL);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Aqua', 'style-aqua.css', NULL);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Elegant', 'style-elegant.css', NULL);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Light', 'style-light.css', NULL);
--
-- Data for TOC entry 12 (OID 44905)
-- Name: modeledef; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (1, '(BE) Basique', 'Comptabilité Belge, tout doit être adaptée');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (14, 'test1', 'Si vous voulez récupérer toutes les adaptations d''un dossier dans un autre dossier, vous pouvez en faire un modèle. Seules les fiches, la structure des journaux, les périodes,... seront reprises et aucune données du dossier sur lequel le dossier est basé.');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (2, 'test2', 'test');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (15, 'test1', 'Si vous voulez récupérer toutes les adaptations d''un dossier dans un autre dossier, vous pouvez en faire un modèle. Seules les fiches, la structure des journaux, les périodes,... seront reprises et aucune données du dossier sur lequel le dossier est basé.');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (16, 'test1', 'Si vous voulez récupérer toutes les adaptations d''un dossier dans un autre dossier, vous pouvez en faire un modèle. Seules les fiches, la structure des journaux, les périodes,... seront reprises et aucune données du dossier sur lequel le dossier est basé.');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (17, 'test1', 'Si vous voulez récupérer toutes les adaptations d''un dossier dans un autre dossier, vous pouvez en faire un modèle. Seules les fiches, la structure des journaux, les périodes,... seront reprises et aucune données du dossier sur lequel le dossier est basé.');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (13, 'Autre', 'Test');
--
-- Data for TOC entry 13 (OID 679377)
-- Name: log; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
--
-- TOC entry 1 (OID 44864)
-- Name: users_id; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('users_id', 5, true);
--
-- TOC entry 2 (OID 44883)
-- Name: seq_jnt_use_dos; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('seq_jnt_use_dos', 29, true);
--
-- TOC entry 3 (OID 44890)
-- Name: seq_priv_user; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('seq_priv_user', 15, true);
--
-- TOC entry 4 (OID 44903)
-- Name: s_modid; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('s_modid', 17, true);
--
-- TOC entry 5 (OID 44911)
-- Name: dossier_id; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('dossier_id', 9, true);

View file

@ -0,0 +1,2 @@
CREATE INDEX fk_jnt_use_dos ON jnt_use_dos USING btree (use_id);
CREATE INDEX fk_jnt_dos_id ON jnt_use_dos USING btree (dos_id);

View file

@ -0,0 +1,12 @@
pg_dump -s account_repository | awk '!/--/ {if ( ! /^$/) print $0;}' > schema.sql
awk '/SEQUENCE/,/;/ { print $0;}' < schema.sql > sequence.sql
awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql > table.sql
awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql
awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql
awk '/ALTER TABLE/,/;/ { print $0;}' < schema.sql > constraint.sql
awk '/FUNCTION/,/LANGUAGE/ { print $0;}' < schema.sql > function.sql
awk '/COMMENT/,/;/ {print $0;}' < schema.sql > comment.sql
grep setval schema.sql >> sequence.sql
pg_dump -D -a -O account_repository > data.sql

View file

@ -0,0 +1,96 @@
\connect - phpcompta
SET search_path = public, pg_catalog;
CREATE SEQUENCE users_id
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE ac_users (
use_id integer DEFAULT nextval('users_id'::text) NOT NULL,
use_first_name text,
use_name text,
use_login text NOT NULL,
use_active integer DEFAULT 0,
use_pass text,
use_admin integer DEFAULT 0,
use_theme text DEFAULT 'Light',
use_usertype text NOT NULL,
CHECK (((use_active = 0) OR (use_active = 1)))
);
CREATE TABLE ac_dossier (
dos_id integer DEFAULT nextval('dossier_id'::text) NOT NULL,
dos_name text NOT NULL,
dos_description text,
dos_jnt_user integer DEFAULT 0
);
CREATE SEQUENCE seq_jnt_use_dos
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE jnt_use_dos (
jnt_id integer DEFAULT nextval('seq_jnt_use_dos'::text) NOT NULL,
use_id integer NOT NULL,
dos_id integer NOT NULL
);
CREATE TABLE "version" (
val integer
);
CREATE SEQUENCE seq_priv_user
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE priv_user (
priv_id integer DEFAULT nextval('seq_priv_user'::text) NOT NULL,
priv_jnt integer NOT NULL,
priv_priv text
);
CREATE TABLE theme (
the_name text NOT NULL,
the_filestyle text,
the_filebutton text
);
CREATE SEQUENCE s_modid
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE modeledef (
mod_id integer DEFAULT nextval('s_modid'::text) NOT NULL,
mod_name text NOT NULL,
mod_desc text
);
CREATE SEQUENCE dossier_id
START 3
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 3
CACHE 1;
CREATE TABLE log (
lg_timestamp timestamp without time zone DEFAULT now(),
lg_file text,
lg_type text DEFAULT 'debug',
lg_line text,
lg_msg text
);
CREATE INDEX fk_jnt_use_dos ON jnt_use_dos USING btree (use_id);
CREATE INDEX fk_jnt_dos_id ON jnt_use_dos USING btree (dos_id);
ALTER TABLE ONLY ac_users
ADD CONSTRAINT ac_users_pkey PRIMARY KEY (use_id);
ALTER TABLE ONLY ac_users
ADD CONSTRAINT ac_users_use_login_key UNIQUE (use_login);
ALTER TABLE ONLY ac_dossier
ADD CONSTRAINT ac_dossier_pkey PRIMARY KEY (dos_id);
ALTER TABLE ONLY ac_dossier
ADD CONSTRAINT ac_dossier_dos_name_key UNIQUE (dos_name);
ALTER TABLE ONLY jnt_use_dos
ADD CONSTRAINT jnt_use_dos_pkey PRIMARY KEY (use_id, dos_id);
ALTER TABLE ONLY jnt_use_dos
ADD CONSTRAINT "$1" FOREIGN KEY (use_id) REFERENCES ac_users(use_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY modeledef
ADD CONSTRAINT modeledef_pkey PRIMARY KEY (mod_id);

View file

@ -0,0 +1,30 @@
CREATE SEQUENCE users_id
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE seq_jnt_use_dos
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE seq_priv_user
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_modid
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE dossier_id
START 3
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 3
CACHE 1;

View file

@ -0,0 +1,48 @@
CREATE TABLE ac_users (
use_id integer DEFAULT nextval('users_id'::text) NOT NULL,
use_first_name text,
use_name text,
use_login text NOT NULL,
use_active integer DEFAULT 0,
use_pass text,
use_admin integer DEFAULT 0,
use_theme text DEFAULT 'Light',
use_usertype text NOT NULL,
CHECK (((use_active = 0) OR (use_active = 1)))
);
CREATE TABLE ac_dossier (
dos_id integer DEFAULT nextval('dossier_id'::text) NOT NULL,
dos_name text NOT NULL,
dos_description text,
dos_jnt_user integer DEFAULT 0
);
CREATE TABLE jnt_use_dos (
jnt_id integer DEFAULT nextval('seq_jnt_use_dos'::text) NOT NULL,
use_id integer NOT NULL,
dos_id integer NOT NULL
);
CREATE TABLE "version" (
val integer
);
CREATE TABLE priv_user (
priv_id integer DEFAULT nextval('seq_priv_user'::text) NOT NULL,
priv_jnt integer NOT NULL,
priv_priv text
);
CREATE TABLE theme (
the_name text NOT NULL,
the_filestyle text,
the_filebutton text
);
CREATE TABLE modeledef (
mod_id integer DEFAULT nextval('s_modid'::text) NOT NULL,
mod_name text NOT NULL,
mod_desc text
);
CREATE TABLE log (
lg_timestamp timestamp without time zone DEFAULT now(),
lg_file text,
lg_type text DEFAULT 'debug',
lg_line text,
lg_msg text
);

View file

@ -0,0 +1,21 @@
COMMENT ON TABLE tmp_pcmn IS 'Plan comptable minimum normalisé';
COMMENT ON TABLE parm_money IS 'Currency conversion';
COMMENT ON TABLE parm_periode IS 'Periode definition';
COMMENT ON TABLE jrn_type IS 'Type of journal (Sell, Buy, Financial...)';
COMMENT ON TABLE jrn_def IS 'Definition of a journal, his properties';
COMMENT ON TABLE jrnx IS 'Journal: content one line for each accountancy writing';
COMMENT ON TABLE form IS 'Forms content';
COMMENT ON TABLE centralized IS 'The centralized journal';
COMMENT ON TABLE "action" IS 'The different privileges';
COMMENT ON TABLE jrn_action IS 'Possible action when we are in journal (menu)';
COMMENT ON TABLE tva_rate IS 'Rate of vat';
COMMENT ON TABLE fiche_def_ref IS 'Family Cards definition';
COMMENT ON TABLE fiche_def IS 'Cards definition';
COMMENT ON TABLE attr_def IS 'The available attributs for the cards';
COMMENT ON TABLE fiche IS 'Cards';
COMMENT ON TABLE jnt_fic_att_value IS 'join between the card and the attribut definition';
COMMENT ON TABLE jnt_fic_attr IS 'join between the family card and the attribut definition';
COMMENT ON TABLE jrn_rapt IS 'Rapprochement between operation';
COMMENT ON TABLE jrn IS 'Journal: content one line for a group of accountancy writing';
COMMENT ON TABLE stock_goods IS 'About the goods';
COMMENT ON TABLE attr_min IS 'The value of attributs for the cards';

View file

@ -0,0 +1,86 @@
ALTER TABLE ONLY tmp_pcmn
ADD CONSTRAINT tmp_pcmn_pkey PRIMARY KEY (pcm_val);
ALTER TABLE ONLY parm_money
ADD CONSTRAINT parm_money_pkey PRIMARY KEY (pm_code);
ALTER TABLE ONLY parm_periode
ADD CONSTRAINT parm_periode_pkey PRIMARY KEY (p_id);
ALTER TABLE ONLY parm_periode
ADD CONSTRAINT parm_periode_p_start_key UNIQUE (p_start);
ALTER TABLE ONLY jrn_type
ADD CONSTRAINT jrn_type_pkey PRIMARY KEY (jrn_type_id);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT jrn_def_pkey PRIMARY KEY (jrn_def_id);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT jrn_def_jrn_def_name_key UNIQUE (jrn_def_name);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT "$1" FOREIGN KEY (jrn_def_type) REFERENCES jrn_type(jrn_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrnx
ADD CONSTRAINT jrnx_pkey PRIMARY KEY (j_id);
ALTER TABLE ONLY jrnx
ADD CONSTRAINT "$1" FOREIGN KEY (j_poste) REFERENCES tmp_pcmn(pcm_val) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrnx
ADD CONSTRAINT "$2" FOREIGN KEY (j_jrn_def) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY user_pref
ADD CONSTRAINT user_pref_pkey PRIMARY KEY (pref_user);
ALTER TABLE ONLY formdef
ADD CONSTRAINT formdef_pkey PRIMARY KEY (fr_id);
ALTER TABLE ONLY form
ADD CONSTRAINT form_pkey PRIMARY KEY (fo_id);
ALTER TABLE ONLY form
ADD CONSTRAINT "$1" FOREIGN KEY (fo_fr_id) REFERENCES formdef(fr_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY centralized
ADD CONSTRAINT centralized_pkey PRIMARY KEY (c_id);
ALTER TABLE ONLY centralized
ADD CONSTRAINT "$1" FOREIGN KEY (c_jrn_def) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY centralized
ADD CONSTRAINT "$2" FOREIGN KEY (c_poste) REFERENCES tmp_pcmn(pcm_val) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY user_sec_jrn
ADD CONSTRAINT user_sec_jrn_pkey PRIMARY KEY (uj_id);
ALTER TABLE ONLY user_sec_jrn
ADD CONSTRAINT "$1" FOREIGN KEY (uj_jrn_id) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY "action"
ADD CONSTRAINT action_pkey PRIMARY KEY (ac_id);
ALTER TABLE ONLY user_sec_act
ADD CONSTRAINT user_sec_act_pkey PRIMARY KEY (ua_id);
ALTER TABLE ONLY user_sec_act
ADD CONSTRAINT "$1" FOREIGN KEY (ua_act_id) REFERENCES "action"(ac_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn_action
ADD CONSTRAINT jrn_action_pkey PRIMARY KEY (ja_id);
ALTER TABLE ONLY jrn_action
ADD CONSTRAINT "$1" FOREIGN KEY (ja_jrn_type) REFERENCES jrn_type(jrn_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY fiche_def_ref
ADD CONSTRAINT fiche_def_ref_pkey PRIMARY KEY (frd_id);
ALTER TABLE ONLY fiche_def
ADD CONSTRAINT fiche_def_pkey PRIMARY KEY (fd_id);
ALTER TABLE ONLY fiche_def
ADD CONSTRAINT "$1" FOREIGN KEY (frd_id) REFERENCES fiche_def_ref(frd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_def
ADD CONSTRAINT attr_def_pkey PRIMARY KEY (ad_id);
ALTER TABLE ONLY fiche
ADD CONSTRAINT fiche_pkey PRIMARY KEY (f_id);
ALTER TABLE ONLY fiche
ADD CONSTRAINT "$1" FOREIGN KEY (fd_id) REFERENCES fiche_def(fd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT jnt_fic_att_value_pkey PRIMARY KEY (jft_id);
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT "$1" FOREIGN KEY (f_id) REFERENCES fiche(f_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_value
ADD CONSTRAINT "$1" FOREIGN KEY (jft_id) REFERENCES jnt_fic_att_value(jft_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_attr
ADD CONSTRAINT "$1" FOREIGN KEY (fd_id) REFERENCES fiche_def(fd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_attr
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn_rapt
ADD CONSTRAINT jrn_rapt_pkey PRIMARY KEY (jra_id);
ALTER TABLE ONLY jrn
ADD CONSTRAINT "$1" FOREIGN KEY (jr_def_id) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn
ADD CONSTRAINT jrn_pkey PRIMARY KEY (jr_id, jr_def_id);
ALTER TABLE ONLY stock_goods
ADD CONSTRAINT stock_goods_pkey PRIMARY KEY (sg_id);
ALTER TABLE ONLY attr_min
ADD CONSTRAINT "$1" FOREIGN KEY (frd_id) REFERENCES fiche_def_ref(frd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_min
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;

View file

@ -0,0 +1,152 @@
--
-- PostgreSQL database dump
--
SET search_path = public, pg_catalog;
--
-- Data for TOC entry 6 (OID 44866)
-- Name: ac_users; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_theme, use_usertype) VALUES (4, 'demo', 'demo', 'demo', 1, 'fe01ce2a7fbac8fafaed7c982a04e229', 0, 'Light', 'user');
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_theme, use_usertype) VALUES (5, 'dany', 'dany', 'dany', 1, '1b9fc02e98389d29c1506fe944b07d16', 0, 'classic', 'compta');
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_theme, use_usertype) VALUES (1, NULL, NULL, 'phpcompta', 1, 'b1cc88e1907cde80cb2595fa793b3da9', 1, 'Light', 'user');
--
-- Data for TOC entry 7 (OID 44876)
-- Name: ac_dossier; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (1, 'Demo', 'Base de données pour développement & démo', 0);
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (4, 'Test Sécurité', 'Test pour la sécurité', 0);
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (5, 'Alchimerys 2003', '', 0);
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (8, 'Alchimerys 2004', '', 0);
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (9, 'DB Supp', 'Db supp', 0);
--
-- Data for TOC entry 8 (OID 44885)
-- Name: jnt_use_dos; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (1, 1, 1);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (2, 1, 2);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (3, 1, 5);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (4, 1, 6);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (13, 4, 1);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (14, 1, 7);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (15, 1, 8);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (16, 1, 9);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (27, 5, 5);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (28, 5, 8);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (19, 1, 3);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (20, 1, 4);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (29, 5, 9);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (22, 5, 4);
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (23, 5, 1);
--
-- Data for TOC entry 9 (OID 44888)
-- Name: version; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO "version" (val) VALUES (3);
--
-- Data for TOC entry 10 (OID 44892)
-- Name: priv_user; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (1, 5, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (2, 6, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (3, 7, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (4, 8, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (5, 9, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (6, 10, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (7, 11, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (8, 12, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (9, 13, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (10, 21, 'NO');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (13, 27, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (14, 28, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (15, 29, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (12, 23, 'W');
INSERT INTO priv_user (priv_id, priv_jnt, priv_priv) VALUES (11, 22, 'W');
--
-- Data for TOC entry 11 (OID 44898)
-- Name: theme; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('classic', 'style.css', NULL);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Aqua', 'style-aqua.css', NULL);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Elegant', 'style-elegant.css', NULL);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Light', 'style-light.css', NULL);
--
-- Data for TOC entry 12 (OID 44905)
-- Name: modeledef; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (1, '(BE) Basique', 'Comptabilité Belge, tout doit être adaptée');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (14, 'test1', 'Si vous voulez récupérer toutes les adaptations d''un dossier dans un autre dossier, vous pouvez en faire un modèle. Seules les fiches, la structure des journaux, les périodes,... seront reprises et aucune données du dossier sur lequel le dossier est basé.');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (2, 'test2', 'test');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (15, 'test1', 'Si vous voulez récupérer toutes les adaptations d''un dossier dans un autre dossier, vous pouvez en faire un modèle. Seules les fiches, la structure des journaux, les périodes,... seront reprises et aucune données du dossier sur lequel le dossier est basé.');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (16, 'test1', 'Si vous voulez récupérer toutes les adaptations d''un dossier dans un autre dossier, vous pouvez en faire un modèle. Seules les fiches, la structure des journaux, les périodes,... seront reprises et aucune données du dossier sur lequel le dossier est basé.');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (17, 'test1', 'Si vous voulez récupérer toutes les adaptations d''un dossier dans un autre dossier, vous pouvez en faire un modèle. Seules les fiches, la structure des journaux, les périodes,... seront reprises et aucune données du dossier sur lequel le dossier est basé.');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (13, 'Autre', 'Test');
--
-- Data for TOC entry 13 (OID 679377)
-- Name: log; Type: TABLE DATA; Schema: public; Owner: phpcompta
--
--
-- TOC entry 1 (OID 44864)
-- Name: users_id; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('users_id', 5, true);
--
-- TOC entry 2 (OID 44883)
-- Name: seq_jnt_use_dos; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('seq_jnt_use_dos', 29, true);
--
-- TOC entry 3 (OID 44890)
-- Name: seq_priv_user; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('seq_priv_user', 15, true);
--
-- TOC entry 4 (OID 44903)
-- Name: s_modid; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('s_modid', 17, true);
--
-- TOC entry 5 (OID 44911)
-- Name: dossier_id; Type: SEQUENCE SET; Schema: public; Owner: phpcompta
--
SELECT pg_catalog.setval ('dossier_id', 9, true);

View file

View file

@ -0,0 +1,16 @@
CREATE UNIQUE INDEX x_act ON "action" USING btree (ac_description);
CREATE UNIQUE INDEX x_usr_jrn ON user_sec_jrn USING btree (uj_login, uj_jrn_id);
CREATE INDEX fk_centralized_c_jrn_def ON centralized USING btree (c_jrn_def);
CREATE INDEX fk_centralized_c_poste ON centralized USING btree (c_poste);
CREATE INDEX fk_fiche_def_frd_id ON fiche_def USING btree (frd_id);
CREATE INDEX fk_attr_value_jft_id ON attr_value USING btree (jft_id);
CREATE INDEX fk_fiche_fd_id ON fiche USING btree (fd_id);
CREATE INDEX fk_form_fo_fr_id ON form USING btree (fo_fr_id);
CREATE INDEX fk_jrnx_j_poste ON jrnx USING btree (j_poste);
CREATE INDEX fk_jrn_def ON jrnx USING btree (j_jrn_def);
CREATE INDEX fk_jrn_action_ja_jrn_type ON jrn_action USING btree (ja_jrn_type);
CREATE INDEX fk_user_sec_jrn ON user_sec_jrn USING btree (uj_jrn_id);
CREATE INDEX fk_user_sec_act ON user_sec_act USING btree (ua_act_id);
CREATE UNIQUE INDEX x_jrn_jr_id ON jrn USING btree (jr_id);
CREATE INDEX fk_stock_goods_j_id ON stock_goods USING btree (j_id);
CREATE INDEX fk_stock_goods_f_id ON stock_goods USING btree (f_id);

View file

@ -0,0 +1,12 @@
pg_dump -s dossier1 | awk '!/--/ {if ( ! /^$/) print $0;}' > schema.sql
awk '/SEQUENCE/,/;/ { print $0;}' < schema.sql > sequence.sql
awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql > table.sql
awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql
awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql
awk '/ALTER TABLE/,/;/ { print $0;}' < schema.sql > constraint.sql
awk '/FUNCTION/,/LANGUAGE/ { print $0;}' < schema.sql > function.sql
awk '/COMMENT/,/;/ {print $0;}' < schema.sql > comment.sql
grep setval schema.sql >> sequence.sql
pg_dump -D -a -O account_repository > data.sql

View file

@ -0,0 +1,466 @@
\connect - phpcompta
SET search_path = public, pg_catalog;
CREATE TABLE tmp_pcmn (
pcm_val integer NOT NULL,
pcm_lib text,
pcm_val_parent integer DEFAULT 0,
pcm_country character(2) DEFAULT 'BE' NOT NULL
);
CREATE TABLE "version" (
val integer
);
CREATE SEQUENCE s_periode
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_currency
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE parm_money (
pm_id integer DEFAULT nextval('s_currency'::text),
pm_code character(3) NOT NULL,
pm_rate double precision
);
CREATE TABLE parm_periode (
p_id integer DEFAULT nextval('s_periode'::text) NOT NULL,
p_start date NOT NULL,
p_end date,
p_exercice text DEFAULT to_char(now(), 'YYYY'::text) NOT NULL,
p_closed boolean DEFAULT false
);
CREATE SEQUENCE s_jrn_def
START 5
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_grpt
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jrn_op
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jrn
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE jrn_type (
jrn_type_id character(3) NOT NULL,
jrn_desc text
);
CREATE TABLE jrn_def (
jrn_def_id integer DEFAULT nextval('s_jrn_def'::text) NOT NULL,
jrn_def_name text NOT NULL,
jrn_def_class_deb text,
jrn_def_class_cred text,
jrn_def_fiche_deb text,
jrn_def_fiche_cred text,
jrn_deb_max_line integer DEFAULT 1,
jrn_cred_max_line integer DEFAULT 1,
jrn_def_ech boolean DEFAULT false,
jrn_def_ech_lib text,
jrn_def_type character(3) NOT NULL,
jrn_def_code text NOT NULL
);
CREATE SEQUENCE s_jrnx
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE jrnx (
j_id integer DEFAULT nextval('s_jrn_op'::text) NOT NULL,
j_date date DEFAULT now(),
j_montant double precision DEFAULT 0,
j_poste integer NOT NULL,
j_grpt integer NOT NULL,
j_rapt text,
j_jrn_def integer NOT NULL,
j_debit boolean DEFAULT true,
j_text text,
j_centralized boolean DEFAULT false,
j_internal text,
j_tech_user text NOT NULL,
j_tech_date timestamp without time zone DEFAULT now() NOT NULL,
j_tech_per integer,
j_montant_n numeric(200,100)
);
CREATE TABLE user_pref (
pref_user text NOT NULL,
pref_periode integer NOT NULL
);
CREATE SEQUENCE s_formdef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_form
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE formdef (
fr_id integer DEFAULT nextval('s_formdef'::text) NOT NULL,
fr_label text
);
CREATE TABLE form (
fo_id integer DEFAULT nextval('s_form'::text) NOT NULL,
fo_fr_id integer,
fo_pos integer,
fo_label text,
fo_formula text
);
CREATE SEQUENCE s_idef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_centralized
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE centralized (
c_id integer DEFAULT nextval('s_centralized'::text) NOT NULL,
c_j_id integer,
c_date date NOT NULL,
c_internal text NOT NULL,
c_montant double precision NOT NULL,
c_debit boolean DEFAULT 't',
c_jrn_def integer NOT NULL,
c_poste integer,
c_description text,
c_grp integer NOT NULL,
c_comment text,
c_rapt text,
c_periode integer
);
CREATE SEQUENCE s_user_jrn
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_user_act
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE user_sec_jrn (
uj_id integer DEFAULT nextval('s_user_jrn'::text) NOT NULL,
uj_login text,
uj_jrn_id integer,
uj_priv text
);
CREATE TABLE "action" (
ac_id integer NOT NULL,
ac_description text NOT NULL
);
CREATE TABLE user_sec_act (
ua_id integer DEFAULT nextval('s_user_act'::text) NOT NULL,
ua_login text,
ua_act_id integer
);
CREATE SEQUENCE s_jrnaction
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE jrn_action (
ja_id integer DEFAULT nextval('s_jrnaction'::text) NOT NULL,
ja_name text NOT NULL,
ja_desc text,
ja_url text NOT NULL,
ja_action text NOT NULL,
ja_lang text DEFAULT 'FR',
ja_jrn_type character(3)
);
CREATE TABLE tva_rate (
tva_id integer NOT NULL,
tva_label text NOT NULL,
tva_rate double precision DEFAULT 0.0 NOT NULL,
tva_comment text,
tva_poste text
);
CREATE SEQUENCE s_fiche
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_fiche_def_ref
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_fdef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_attr_def
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jnt_fic_att_value
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE fiche_def_ref (
frd_id integer DEFAULT nextval('s_fiche_def_ref'::text) NOT NULL,
frd_text text,
frd_class_base integer
);
CREATE TABLE fiche_def (
fd_id integer DEFAULT nextval('s_fdef'::text) NOT NULL,
fd_class_base integer,
fd_label text NOT NULL,
fd_create_account boolean DEFAULT false,
frd_id integer NOT NULL
);
CREATE TABLE attr_def (
ad_id integer DEFAULT nextval('s_attr_def'::text) NOT NULL,
ad_text text
);
CREATE TABLE fiche (
f_id integer DEFAULT nextval('s_fiche'::text) NOT NULL,
fd_id integer
);
CREATE TABLE jnt_fic_att_value (
jft_id integer DEFAULT nextval('s_jnt_fic_att_value'::text) NOT NULL,
f_id integer,
ad_id integer
);
CREATE TABLE attr_value (
jft_id integer,
av_text text
);
CREATE TABLE jnt_fic_attr (
fd_id integer,
ad_id integer
);
CREATE SEQUENCE s_jrn_rapt
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE jrn_rapt (
jra_id integer DEFAULT nextval('s_jrn_rapt'::text) NOT NULL,
jr_id integer NOT NULL,
jra_concerned integer NOT NULL
);
CREATE VIEW vw_fiche_attr AS
SELECT a.f_id, fd_id, a.av_text AS vw_name, b.av_text AS vw_sell, c.av_text AS vw_buy, d.av_text AS tva_code, tva_id, tva_rate, tva_label, e.av_text AS vw_addr, f.av_text AS vw_cp, frd_id FROM ((((((((SELECT f_id, fd_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 1)) a LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 6)) b ON ((a.f_id = b.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 7)) c ON ((a.f_id = c.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 2)) d ON ((a.f_id = d.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 14)) e ON ((a.f_id = e.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 15)) f ON ((a.f_id = f.f_id))) LEFT JOIN tva_rate ON ((d.av_text = (tva_rate.tva_id)::text))) JOIN fiche_def USING (fd_id));
CREATE SEQUENCE s_stock_goods
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE TABLE jrn (
jr_id integer DEFAULT nextval('s_jrn'::text) NOT NULL,
jr_def_id integer NOT NULL,
jr_montant double precision NOT NULL,
jr_comment text,
jr_date date,
jr_grpt_id integer NOT NULL,
jr_internal text,
jr_tech_date timestamp without time zone DEFAULT now() NOT NULL,
jr_tech_per integer NOT NULL,
jrn_ech date,
jr_ech date,
jr_rapt text,
jr_valid boolean DEFAULT true
);
CREATE TABLE stock_goods (
sg_id integer DEFAULT nextval('s_stock_goods'::text) NOT NULL,
j_id integer,
f_id integer NOT NULL,
sg_code text,
sg_quantity integer DEFAULT 0,
sg_type character(1) DEFAULT 'c' NOT NULL,
sg_date date,
sg_tech_date date DEFAULT now(),
sg_tech_user text,
CONSTRAINT stock_goods_sg_type CHECK (((sg_type = 'c'::bpchar) OR (sg_type = 'd'::bpchar)))
);
CREATE TABLE attr_min (
frd_id integer,
ad_id integer
);
\connect - dany
SET search_path = public, pg_catalog;
CREATE TABLE jrnx_back (
j_id integer,
j_date date,
j_montant double precision,
j_poste integer,
j_grpt integer,
j_rapt text,
j_jrn_def integer,
j_debit boolean,
j_text text,
j_centralized boolean,
j_internal text,
j_tech_user text,
j_tech_date timestamp without time zone,
j_tech_per integer
);
\connect - phpcompta
SET search_path = public, pg_catalog;
CREATE TABLE log (
lg_timestamp timestamp without time zone DEFAULT now(),
lg_file text,
lg_type text DEFAULT 'debug',
lg_line text,
lg_msg text
);
CREATE UNIQUE INDEX x_act ON "action" USING btree (ac_description);
CREATE UNIQUE INDEX x_usr_jrn ON user_sec_jrn USING btree (uj_login, uj_jrn_id);
CREATE INDEX fk_centralized_c_jrn_def ON centralized USING btree (c_jrn_def);
CREATE INDEX fk_centralized_c_poste ON centralized USING btree (c_poste);
CREATE INDEX fk_fiche_def_frd_id ON fiche_def USING btree (frd_id);
CREATE INDEX fk_attr_value_jft_id ON attr_value USING btree (jft_id);
CREATE INDEX fk_fiche_fd_id ON fiche USING btree (fd_id);
CREATE INDEX fk_form_fo_fr_id ON form USING btree (fo_fr_id);
CREATE INDEX fk_jrnx_j_poste ON jrnx USING btree (j_poste);
CREATE INDEX fk_jrn_def ON jrnx USING btree (j_jrn_def);
CREATE INDEX fk_jrn_action_ja_jrn_type ON jrn_action USING btree (ja_jrn_type);
CREATE INDEX fk_user_sec_jrn ON user_sec_jrn USING btree (uj_jrn_id);
CREATE INDEX fk_user_sec_act ON user_sec_act USING btree (ua_act_id);
CREATE UNIQUE INDEX x_jrn_jr_id ON jrn USING btree (jr_id);
CREATE INDEX fk_stock_goods_j_id ON stock_goods USING btree (j_id);
CREATE INDEX fk_stock_goods_f_id ON stock_goods USING btree (f_id);
ALTER TABLE ONLY tmp_pcmn
ADD CONSTRAINT tmp_pcmn_pkey PRIMARY KEY (pcm_val);
ALTER TABLE ONLY parm_money
ADD CONSTRAINT parm_money_pkey PRIMARY KEY (pm_code);
ALTER TABLE ONLY parm_periode
ADD CONSTRAINT parm_periode_pkey PRIMARY KEY (p_id);
ALTER TABLE ONLY parm_periode
ADD CONSTRAINT parm_periode_p_start_key UNIQUE (p_start);
ALTER TABLE ONLY jrn_type
ADD CONSTRAINT jrn_type_pkey PRIMARY KEY (jrn_type_id);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT jrn_def_pkey PRIMARY KEY (jrn_def_id);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT jrn_def_jrn_def_name_key UNIQUE (jrn_def_name);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT "$1" FOREIGN KEY (jrn_def_type) REFERENCES jrn_type(jrn_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrnx
ADD CONSTRAINT jrnx_pkey PRIMARY KEY (j_id);
ALTER TABLE ONLY jrnx
ADD CONSTRAINT "$1" FOREIGN KEY (j_poste) REFERENCES tmp_pcmn(pcm_val) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrnx
ADD CONSTRAINT "$2" FOREIGN KEY (j_jrn_def) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY user_pref
ADD CONSTRAINT user_pref_pkey PRIMARY KEY (pref_user);
ALTER TABLE ONLY formdef
ADD CONSTRAINT formdef_pkey PRIMARY KEY (fr_id);
ALTER TABLE ONLY form
ADD CONSTRAINT form_pkey PRIMARY KEY (fo_id);
ALTER TABLE ONLY form
ADD CONSTRAINT "$1" FOREIGN KEY (fo_fr_id) REFERENCES formdef(fr_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY centralized
ADD CONSTRAINT centralized_pkey PRIMARY KEY (c_id);
ALTER TABLE ONLY centralized
ADD CONSTRAINT "$1" FOREIGN KEY (c_jrn_def) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY centralized
ADD CONSTRAINT "$2" FOREIGN KEY (c_poste) REFERENCES tmp_pcmn(pcm_val) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY user_sec_jrn
ADD CONSTRAINT user_sec_jrn_pkey PRIMARY KEY (uj_id);
ALTER TABLE ONLY user_sec_jrn
ADD CONSTRAINT "$1" FOREIGN KEY (uj_jrn_id) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY "action"
ADD CONSTRAINT action_pkey PRIMARY KEY (ac_id);
ALTER TABLE ONLY user_sec_act
ADD CONSTRAINT user_sec_act_pkey PRIMARY KEY (ua_id);
ALTER TABLE ONLY user_sec_act
ADD CONSTRAINT "$1" FOREIGN KEY (ua_act_id) REFERENCES "action"(ac_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn_action
ADD CONSTRAINT jrn_action_pkey PRIMARY KEY (ja_id);
ALTER TABLE ONLY jrn_action
ADD CONSTRAINT "$1" FOREIGN KEY (ja_jrn_type) REFERENCES jrn_type(jrn_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY fiche_def_ref
ADD CONSTRAINT fiche_def_ref_pkey PRIMARY KEY (frd_id);
ALTER TABLE ONLY fiche_def
ADD CONSTRAINT fiche_def_pkey PRIMARY KEY (fd_id);
ALTER TABLE ONLY fiche_def
ADD CONSTRAINT "$1" FOREIGN KEY (frd_id) REFERENCES fiche_def_ref(frd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_def
ADD CONSTRAINT attr_def_pkey PRIMARY KEY (ad_id);
ALTER TABLE ONLY fiche
ADD CONSTRAINT fiche_pkey PRIMARY KEY (f_id);
ALTER TABLE ONLY fiche
ADD CONSTRAINT "$1" FOREIGN KEY (fd_id) REFERENCES fiche_def(fd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT jnt_fic_att_value_pkey PRIMARY KEY (jft_id);
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT "$1" FOREIGN KEY (f_id) REFERENCES fiche(f_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_value
ADD CONSTRAINT "$1" FOREIGN KEY (jft_id) REFERENCES jnt_fic_att_value(jft_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_attr
ADD CONSTRAINT "$1" FOREIGN KEY (fd_id) REFERENCES fiche_def(fd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_attr
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn_rapt
ADD CONSTRAINT jrn_rapt_pkey PRIMARY KEY (jra_id);
ALTER TABLE ONLY jrn
ADD CONSTRAINT "$1" FOREIGN KEY (jr_def_id) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn
ADD CONSTRAINT jrn_pkey PRIMARY KEY (jr_id, jr_def_id);
ALTER TABLE ONLY stock_goods
ADD CONSTRAINT stock_goods_pkey PRIMARY KEY (sg_id);
ALTER TABLE ONLY attr_min
ADD CONSTRAINT "$1" FOREIGN KEY (frd_id) REFERENCES fiche_def_ref(frd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_min
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
COMMENT ON TABLE tmp_pcmn IS 'Plan comptable minimum normalisé';
COMMENT ON TABLE parm_money IS 'Currency conversion';
COMMENT ON TABLE parm_periode IS 'Periode definition';
COMMENT ON TABLE jrn_type IS 'Type of journal (Sell, Buy, Financial...)';
COMMENT ON TABLE jrn_def IS 'Definition of a journal, his properties';
COMMENT ON TABLE jrnx IS 'Journal: content one line for each accountancy writing';
COMMENT ON TABLE form IS 'Forms content';
COMMENT ON TABLE centralized IS 'The centralized journal';
COMMENT ON TABLE "action" IS 'The different privileges';
COMMENT ON TABLE jrn_action IS 'Possible action when we are in journal (menu)';
COMMENT ON TABLE tva_rate IS 'Rate of vat';
COMMENT ON TABLE fiche_def_ref IS 'Family Cards definition';
COMMENT ON TABLE fiche_def IS 'Cards definition';
COMMENT ON TABLE attr_def IS 'The available attributs for the cards';
COMMENT ON TABLE fiche IS 'Cards';
COMMENT ON TABLE jnt_fic_att_value IS 'join between the card and the attribut definition';
COMMENT ON TABLE jnt_fic_attr IS 'join between the family card and the attribut definition';
COMMENT ON TABLE jrn_rapt IS 'Rapprochement between operation';
COMMENT ON TABLE jrn IS 'Journal: content one line for a group of accountancy writing';
COMMENT ON TABLE stock_goods IS 'About the goods';
COMMENT ON TABLE attr_min IS 'The value of attributs for the cards';

View file

@ -0,0 +1,126 @@
CREATE SEQUENCE s_periode
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_currency
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jrn_def
START 5
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_grpt
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jrn_op
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jrn
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jrnx
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_formdef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_form
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_idef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_centralized
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_user_jrn
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_user_act
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jrnaction
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_fiche
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_fiche_def_ref
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_fdef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_attr_def
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jnt_fic_att_value
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_jrn_rapt
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
CREATE SEQUENCE s_stock_goods
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;

View file

@ -0,0 +1,209 @@
CREATE TABLE tmp_pcmn (
pcm_val integer NOT NULL,
pcm_lib text,
pcm_val_parent integer DEFAULT 0,
pcm_country character(2) DEFAULT 'BE' NOT NULL
);
CREATE TABLE "version" (
val integer
);
CREATE TABLE parm_money (
pm_id integer DEFAULT nextval('s_currency'::text),
pm_code character(3) NOT NULL,
pm_rate double precision
);
CREATE TABLE parm_periode (
p_id integer DEFAULT nextval('s_periode'::text) NOT NULL,
p_start date NOT NULL,
p_end date,
p_exercice text DEFAULT to_char(now(), 'YYYY'::text) NOT NULL,
p_closed boolean DEFAULT false
);
CREATE TABLE jrn_type (
jrn_type_id character(3) NOT NULL,
jrn_desc text
);
CREATE TABLE jrn_def (
jrn_def_id integer DEFAULT nextval('s_jrn_def'::text) NOT NULL,
jrn_def_name text NOT NULL,
jrn_def_class_deb text,
jrn_def_class_cred text,
jrn_def_fiche_deb text,
jrn_def_fiche_cred text,
jrn_deb_max_line integer DEFAULT 1,
jrn_cred_max_line integer DEFAULT 1,
jrn_def_ech boolean DEFAULT false,
jrn_def_ech_lib text,
jrn_def_type character(3) NOT NULL,
jrn_def_code text NOT NULL
);
CREATE TABLE jrnx (
j_id integer DEFAULT nextval('s_jrn_op'::text) NOT NULL,
j_date date DEFAULT now(),
j_montant double precision DEFAULT 0,
j_poste integer NOT NULL,
j_grpt integer NOT NULL,
j_rapt text,
j_jrn_def integer NOT NULL,
j_debit boolean DEFAULT true,
j_text text,
j_centralized boolean DEFAULT false,
j_internal text,
j_tech_user text NOT NULL,
j_tech_date timestamp without time zone DEFAULT now() NOT NULL,
j_tech_per integer,
j_montant_n numeric(200,100)
);
CREATE TABLE user_pref (
pref_user text NOT NULL,
pref_periode integer NOT NULL
);
CREATE TABLE formdef (
fr_id integer DEFAULT nextval('s_formdef'::text) NOT NULL,
fr_label text
);
CREATE TABLE form (
fo_id integer DEFAULT nextval('s_form'::text) NOT NULL,
fo_fr_id integer,
fo_pos integer,
fo_label text,
fo_formula text
);
CREATE TABLE centralized (
c_id integer DEFAULT nextval('s_centralized'::text) NOT NULL,
c_j_id integer,
c_date date NOT NULL,
c_internal text NOT NULL,
c_montant double precision NOT NULL,
c_debit boolean DEFAULT 't',
c_jrn_def integer NOT NULL,
c_poste integer,
c_description text,
c_grp integer NOT NULL,
c_comment text,
c_rapt text,
c_periode integer
);
CREATE TABLE user_sec_jrn (
uj_id integer DEFAULT nextval('s_user_jrn'::text) NOT NULL,
uj_login text,
uj_jrn_id integer,
uj_priv text
);
CREATE TABLE "action" (
ac_id integer NOT NULL,
ac_description text NOT NULL
);
CREATE TABLE user_sec_act (
ua_id integer DEFAULT nextval('s_user_act'::text) NOT NULL,
ua_login text,
ua_act_id integer
);
CREATE TABLE jrn_action (
ja_id integer DEFAULT nextval('s_jrnaction'::text) NOT NULL,
ja_name text NOT NULL,
ja_desc text,
ja_url text NOT NULL,
ja_action text NOT NULL,
ja_lang text DEFAULT 'FR',
ja_jrn_type character(3)
);
CREATE TABLE tva_rate (
tva_id integer NOT NULL,
tva_label text NOT NULL,
tva_rate double precision DEFAULT 0.0 NOT NULL,
tva_comment text,
tva_poste text
);
CREATE TABLE fiche_def_ref (
frd_id integer DEFAULT nextval('s_fiche_def_ref'::text) NOT NULL,
frd_text text,
frd_class_base integer
);
CREATE TABLE fiche_def (
fd_id integer DEFAULT nextval('s_fdef'::text) NOT NULL,
fd_class_base integer,
fd_label text NOT NULL,
fd_create_account boolean DEFAULT false,
frd_id integer NOT NULL
);
CREATE TABLE attr_def (
ad_id integer DEFAULT nextval('s_attr_def'::text) NOT NULL,
ad_text text
);
CREATE TABLE fiche (
f_id integer DEFAULT nextval('s_fiche'::text) NOT NULL,
fd_id integer
);
CREATE TABLE jnt_fic_att_value (
jft_id integer DEFAULT nextval('s_jnt_fic_att_value'::text) NOT NULL,
f_id integer,
ad_id integer
);
CREATE TABLE attr_value (
jft_id integer,
av_text text
);
CREATE TABLE jnt_fic_attr (
fd_id integer,
ad_id integer
);
CREATE TABLE jrn_rapt (
jra_id integer DEFAULT nextval('s_jrn_rapt'::text) NOT NULL,
jr_id integer NOT NULL,
jra_concerned integer NOT NULL
);
CREATE TABLE jrn (
jr_id integer DEFAULT nextval('s_jrn'::text) NOT NULL,
jr_def_id integer NOT NULL,
jr_montant double precision NOT NULL,
jr_comment text,
jr_date date,
jr_grpt_id integer NOT NULL,
jr_internal text,
jr_tech_date timestamp without time zone DEFAULT now() NOT NULL,
jr_tech_per integer NOT NULL,
jrn_ech date,
jr_ech date,
jr_rapt text,
jr_valid boolean DEFAULT true
);
CREATE TABLE stock_goods (
sg_id integer DEFAULT nextval('s_stock_goods'::text) NOT NULL,
j_id integer,
f_id integer NOT NULL,
sg_code text,
sg_quantity integer DEFAULT 0,
sg_type character(1) DEFAULT 'c' NOT NULL,
sg_date date,
sg_tech_date date DEFAULT now(),
sg_tech_user text,
CONSTRAINT stock_goods_sg_type CHECK (((sg_type = 'c'::bpchar) OR (sg_type = 'd'::bpchar)))
);
CREATE TABLE attr_min (
frd_id integer,
ad_id integer
);
CREATE TABLE jrnx_back (
j_id integer,
j_date date,
j_montant double precision,
j_poste integer,
j_grpt integer,
j_rapt text,
j_jrn_def integer,
j_debit boolean,
j_text text,
j_centralized boolean,
j_internal text,
j_tech_user text,
j_tech_date timestamp without time zone,
j_tech_per integer
);
CREATE TABLE log (
lg_timestamp timestamp without time zone DEFAULT now(),
lg_file text,
lg_type text DEFAULT 'debug',
lg_line text,
lg_msg text
);

View file

@ -0,0 +1,2 @@
CREATE VIEW vw_fiche_attr AS
SELECT a.f_id, fd_id, a.av_text AS vw_name, b.av_text AS vw_sell, c.av_text AS vw_buy, d.av_text AS tva_code, tva_id, tva_rate, tva_label, e.av_text AS vw_addr, f.av_text AS vw_cp, frd_id FROM ((((((((SELECT f_id, fd_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 1)) a LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 6)) b ON ((a.f_id = b.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 7)) c ON ((a.f_id = c.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 2)) d ON ((a.f_id = d.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 14)) e ON ((a.f_id = e.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 15)) f ON ((a.f_id = f.f_id))) LEFT JOIN tva_rate ON ((d.av_text = (tva_rate.tva_id)::text))) JOIN fiche_def USING (fd_id));

View file

@ -0,0 +1,42 @@
-- Name: TABLE tmp_pcmn; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE tmp_pcmn IS 'Plan comptable minimum normalisé';
-- Name: TABLE parm_money; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE parm_money IS 'Currency conversion';
-- Name: TABLE parm_periode; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE parm_periode IS 'Periode definition';
-- Name: TABLE jrn_type; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE jrn_type IS 'Type of journal (Sell, Buy, Financial...)';
-- Name: TABLE jrn_def; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE jrn_def IS 'Definition of a journal, his properties';
-- Name: TABLE jrnx; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE jrnx IS 'Journal: content one line for each accountancy writing';
-- Name: TABLE form; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE form IS 'Forms content';
-- Name: TABLE centralized; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE centralized IS 'The centralized journal';
-- Name: TABLE "action"; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE "action" IS 'The different privileges';
-- Name: TABLE jrn_action; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE jrn_action IS 'Possible action when we are in journal (menu)';
-- Name: TABLE tva_rate; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE tva_rate IS 'Rate of vat';
-- Name: TABLE fiche_def_ref; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE fiche_def_ref IS 'Family Cards definition';
-- Name: TABLE fiche_def; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE fiche_def IS 'Cards definition';
-- Name: TABLE attr_def; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE attr_def IS 'The available attributs for the cards';
-- Name: TABLE attr_min; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE attr_min IS 'The value of attributs for the cards';
-- Name: TABLE fiche; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE fiche IS 'Cards';
-- Name: TABLE jnt_fic_att_value; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE jnt_fic_att_value IS 'join between the card and the attribut definition';
-- Name: TABLE jnt_fic_attr; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE jnt_fic_attr IS 'join between the family card and the attribut definition';
-- Name: TABLE jrn_rapt; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE jrn_rapt IS 'Rapprochement between operation';
-- Name: TABLE jrn; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE jrn IS 'Journal: content one line for a group of accountancy writing';
-- Name: TABLE stock_goods; Type: COMMENT; Schema: public; Owner: phpcompta
COMMENT ON TABLE stock_goods IS 'About the goods';

View file

@ -0,0 +1,86 @@
ALTER TABLE ONLY tmp_pcmn
ADD CONSTRAINT tmp_pcmn_pkey PRIMARY KEY (pcm_val);
ALTER TABLE ONLY parm_money
ADD CONSTRAINT parm_money_pkey PRIMARY KEY (pm_code);
ALTER TABLE ONLY parm_periode
ADD CONSTRAINT parm_periode_pkey PRIMARY KEY (p_id);
ALTER TABLE ONLY parm_periode
ADD CONSTRAINT parm_periode_p_start_key UNIQUE (p_start);
ALTER TABLE ONLY jrn_type
ADD CONSTRAINT jrn_type_pkey PRIMARY KEY (jrn_type_id);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT jrn_def_pkey PRIMARY KEY (jrn_def_id);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT jrn_def_jrn_def_name_key UNIQUE (jrn_def_name);
ALTER TABLE ONLY jrn_def
ADD CONSTRAINT "$1" FOREIGN KEY (jrn_def_type) REFERENCES jrn_type(jrn_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrnx
ADD CONSTRAINT jrnx_pkey PRIMARY KEY (j_id);
ALTER TABLE ONLY jrnx
ADD CONSTRAINT "$1" FOREIGN KEY (j_poste) REFERENCES tmp_pcmn(pcm_val) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrnx
ADD CONSTRAINT "$2" FOREIGN KEY (j_jrn_def) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY user_pref
ADD CONSTRAINT user_pref_pkey PRIMARY KEY (pref_user);
ALTER TABLE ONLY formdef
ADD CONSTRAINT formdef_pkey PRIMARY KEY (fr_id);
ALTER TABLE ONLY form
ADD CONSTRAINT form_pkey PRIMARY KEY (fo_id);
ALTER TABLE ONLY form
ADD CONSTRAINT "$1" FOREIGN KEY (fo_fr_id) REFERENCES formdef(fr_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY centralized
ADD CONSTRAINT centralized_pkey PRIMARY KEY (c_id);
ALTER TABLE ONLY centralized
ADD CONSTRAINT "$1" FOREIGN KEY (c_jrn_def) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY centralized
ADD CONSTRAINT "$2" FOREIGN KEY (c_poste) REFERENCES tmp_pcmn(pcm_val) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY user_sec_jrn
ADD CONSTRAINT user_sec_jrn_pkey PRIMARY KEY (uj_id);
ALTER TABLE ONLY user_sec_jrn
ADD CONSTRAINT "$1" FOREIGN KEY (uj_jrn_id) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY "action"
ADD CONSTRAINT action_pkey PRIMARY KEY (ac_id);
ALTER TABLE ONLY user_sec_act
ADD CONSTRAINT user_sec_act_pkey PRIMARY KEY (ua_id);
ALTER TABLE ONLY user_sec_act
ADD CONSTRAINT "$1" FOREIGN KEY (ua_act_id) REFERENCES "action"(ac_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn_action
ADD CONSTRAINT jrn_action_pkey PRIMARY KEY (ja_id);
ALTER TABLE ONLY jrn_action
ADD CONSTRAINT "$1" FOREIGN KEY (ja_jrn_type) REFERENCES jrn_type(jrn_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY fiche_def_ref
ADD CONSTRAINT fiche_def_ref_pkey PRIMARY KEY (frd_id);
ALTER TABLE ONLY fiche_def
ADD CONSTRAINT fiche_def_pkey PRIMARY KEY (fd_id);
ALTER TABLE ONLY fiche_def
ADD CONSTRAINT "$1" FOREIGN KEY (frd_id) REFERENCES fiche_def_ref(frd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_def
ADD CONSTRAINT attr_def_pkey PRIMARY KEY (ad_id);
ALTER TABLE ONLY attr_min
ADD CONSTRAINT "$1" FOREIGN KEY (frd_id) REFERENCES fiche_def_ref(frd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_min
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY fiche
ADD CONSTRAINT fiche_pkey PRIMARY KEY (f_id);
ALTER TABLE ONLY fiche
ADD CONSTRAINT "$1" FOREIGN KEY (fd_id) REFERENCES fiche_def(fd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT jnt_fic_att_value_pkey PRIMARY KEY (jft_id);
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT "$1" FOREIGN KEY (f_id) REFERENCES fiche(f_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_att_value
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY attr_value
ADD CONSTRAINT "$1" FOREIGN KEY (jft_id) REFERENCES jnt_fic_att_value(jft_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_attr
ADD CONSTRAINT "$1" FOREIGN KEY (fd_id) REFERENCES fiche_def(fd_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jnt_fic_attr
ADD CONSTRAINT "$2" FOREIGN KEY (ad_id) REFERENCES attr_def(ad_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn_rapt
ADD CONSTRAINT jrn_rapt_pkey PRIMARY KEY (jra_id);
ALTER TABLE ONLY jrn
ADD CONSTRAINT "$1" FOREIGN KEY (jr_def_id) REFERENCES jrn_def(jrn_def_id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE ONLY jrn
ADD CONSTRAINT jrn_pkey PRIMARY KEY (jr_id, jr_def_id);
ALTER TABLE ONLY stock_goods
ADD CONSTRAINT stock_goods_pkey PRIMARY KEY (sg_id);

1414
html/admin/sql/mod1/data.sql Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
-- Name: plpgsql_call_handler (); Type: FUNCTION; Schema: public; Owner: dany
--
CREATE FUNCTION plpgsql_call_handler () RETURNS language_handler
AS '$libdir/plpgsql', 'plpgsql_call_handler'
LANGUAGE c;
-- Name: today_hour (); Type: FUNCTION; Schema: public; Owner: dany
--
CREATE FUNCTION today_hour () RETURNS text
AS '
declare
hour text ;
begin
select to_char(now(),''HHMI'') into hour;
return hour;
end;
'
LANGUAGE plpgsql;

View file

@ -0,0 +1,10 @@
-- Name: x_act; Type: INDEX; Schema: public; Owner: phpcompta
CREATE UNIQUE INDEX x_act ON "action" USING btree (ac_description);
-- Name: x_usr_jrn; Type: INDEX; Schema: public; Owner: phpcompta
CREATE UNIQUE INDEX x_usr_jrn ON user_sec_jrn USING btree (uj_login, uj_jrn_id);
-- Name: x_jrn_jr_id; Type: INDEX; Schema: public; Owner: phpcompta
CREATE UNIQUE INDEX x_jrn_jr_id ON jrn USING btree (jr_id);
-- Name: fk_stock_goods_j_id; Type: INDEX; Schema: public; Owner: phpcompta
CREATE INDEX fk_stock_goods_j_id ON stock_goods USING btree (j_id);
-- Name: fk_stock_goods_f_id; Type: INDEX; Schema: public; Owner: phpcompta
CREATE INDEX fk_stock_goods_f_id ON stock_goods USING btree (f_id);

12
html/admin/sql/mod1/make-sql Executable file
View file

@ -0,0 +1,12 @@
pg_dump -s mod1 > schema.sql
awk '/SEQUENCE/,/;/ { print $0;}' < schema.sql > sequence.sql
awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql > table.sql
awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql
awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql
awk '/ALTER TABLE/,/;/ { print $0;}' < schema.sql > constraint.sql
awk '/FUNCTION/,/LANGUAGE/ { print $0;}' < schema.sql > function.sql
awk '/COMMENT/,/;/ {print $0;}' < schema.sql > comment.sql
grep setval schema.sql >> sequence.sql
pg_dump -D -a -O mod1 > data.sql

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,154 @@
-- Name: s_periode; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_periode
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_currency; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_currency
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_jrn_def; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_jrn_def
START 5
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_grpt; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_grpt
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_jrn_op; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_jrn_op
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_jrn; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_jrn
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_jrnx; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_jrnx
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_formdef; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_formdef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_form; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_form
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_isup; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_isup
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_idef; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_idef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_centralized; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_centralized
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_user_jrn; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_user_jrn
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_user_act; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_user_act
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_jrnaction; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_jrnaction
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_fiche; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_fiche
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_fiche_def_ref; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_fiche_def_ref
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_fdef; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_fdef
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_attr_def; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_attr_def
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_jnt_fic_att_value; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_jnt_fic_att_value
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_stock_goods; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_stock_goods
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
-- Name: s_jrn_rapt; Type: SEQUENCE; Schema: public; Owner: phpcompta
CREATE SEQUENCE s_jrn_rapt
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;

View file

@ -0,0 +1,185 @@
CREATE TABLE tmp_pcmn (
pcm_val integer NOT NULL,
pcm_lib text,
pcm_val_parent integer DEFAULT 0,
pcm_country character(2) DEFAULT 'BE' NOT NULL
);
CREATE TABLE "version" (
val integer
);
CREATE TABLE parm_money (
pm_id integer DEFAULT nextval('s_currency'::text),
pm_code character(3) NOT NULL,
pm_rate double precision
);
CREATE TABLE parm_periode (
p_id integer DEFAULT nextval('s_periode'::text) NOT NULL,
p_start date NOT NULL,
p_end date,
p_exercice text DEFAULT to_char(now(), 'YYYY'::text) NOT NULL,
p_closed boolean DEFAULT false
);
CREATE TABLE jrn_type (
jrn_type_id character(3) NOT NULL,
jrn_desc text
);
CREATE TABLE jrn_def (
jrn_def_id integer DEFAULT nextval('s_jrn_def'::text) NOT NULL,
jrn_def_name text NOT NULL,
jrn_def_class_deb text,
jrn_def_class_cred text,
jrn_def_fiche_deb text,
jrn_def_fiche_cred text,
jrn_deb_max_line integer DEFAULT 1,
jrn_cred_max_line integer DEFAULT 1,
jrn_def_ech boolean DEFAULT false,
jrn_def_ech_lib text,
jrn_def_type character(3) NOT NULL,
jrn_def_code text NOT NULL
);
CREATE TABLE jrnx (
j_id integer DEFAULT nextval('s_jrn_op'::text) NOT NULL,
j_date date DEFAULT now(),
j_montant double precision DEFAULT 0,
j_poste integer NOT NULL,
j_grpt integer NOT NULL,
j_rapt text,
j_jrn_def integer NOT NULL,
j_debit boolean DEFAULT true,
j_text text,
j_centralized boolean DEFAULT false,
j_internal text,
j_tech_user text NOT NULL,
j_tech_date timestamp without time zone DEFAULT now() NOT NULL,
j_tech_per integer
);
CREATE TABLE user_pref (
pref_user text NOT NULL,
pref_periode integer NOT NULL
);
CREATE TABLE formdef (
fr_id integer DEFAULT nextval('s_formdef'::text) NOT NULL,
fr_label text
);
CREATE TABLE form (
fo_id integer DEFAULT nextval('s_form'::text) NOT NULL,
fo_fr_id integer,
fo_pos integer,
fo_label text,
fo_formula text
);
CREATE TABLE centralized (
c_id integer DEFAULT nextval('s_centralized'::text) NOT NULL,
c_j_id integer,
c_date date NOT NULL,
c_internal text NOT NULL,
c_montant double precision NOT NULL,
c_debit boolean DEFAULT 't',
c_jrn_def integer NOT NULL,
c_poste integer,
c_description text,
c_grp integer NOT NULL,
c_comment text,
c_rapt text,
c_periode integer
);
CREATE TABLE user_sec_jrn (
uj_id integer DEFAULT nextval('s_user_jrn'::text) NOT NULL,
uj_login text,
uj_jrn_id integer,
uj_priv text
);
CREATE TABLE "action" (
ac_id integer NOT NULL,
ac_description text NOT NULL
);
CREATE TABLE user_sec_act (
ua_id integer DEFAULT nextval('s_user_act'::text) NOT NULL,
ua_login text,
ua_act_id integer
);
CREATE TABLE jrn_action (
ja_id integer DEFAULT nextval('s_jrnaction'::text) NOT NULL,
ja_name text NOT NULL,
ja_desc text,
ja_url text NOT NULL,
ja_action text NOT NULL,
ja_lang text DEFAULT 'FR',
ja_jrn_type character(3)
);
CREATE TABLE tva_rate (
tva_id integer NOT NULL,
tva_label text NOT NULL,
tva_rate double precision DEFAULT 0.0 NOT NULL,
tva_comment text,
tva_poste text
);
CREATE TABLE fiche_def_ref (
frd_id integer DEFAULT nextval('s_fiche_def_ref'::text) NOT NULL,
frd_text text,
frd_class_base integer
);
CREATE TABLE fiche_def (
fd_id integer DEFAULT nextval('s_fdef'::text) NOT NULL,
fd_class_base integer,
fd_label text NOT NULL,
fd_create_account boolean DEFAULT false,
frd_id integer NOT NULL
);
CREATE TABLE attr_def (
ad_id integer DEFAULT nextval('s_attr_def'::text) NOT NULL,
ad_text text
);
CREATE TABLE attr_min (
frd_id integer,
ad_id integer
);
CREATE TABLE fiche (
f_id integer DEFAULT nextval('s_fiche'::text) NOT NULL,
fd_id integer
);
CREATE TABLE jnt_fic_att_value (
jft_id integer DEFAULT nextval('s_jnt_fic_att_value'::text) NOT NULL,
f_id integer,
ad_id integer
);
CREATE TABLE attr_value (
jft_id integer,
av_text text
);
CREATE TABLE jnt_fic_attr (
fd_id integer,
ad_id integer
);
CREATE TABLE jrn_rapt (
jra_id integer DEFAULT nextval('s_jrn_rapt'::text) NOT NULL,
jr_id integer NOT NULL,
jra_concerned integer NOT NULL
);
CREATE TABLE jrn (
jr_id integer DEFAULT nextval('s_jrn'::text) NOT NULL,
jr_def_id integer NOT NULL,
jr_montant double precision NOT NULL,
jr_comment text,
jr_date date,
jr_grpt_id integer NOT NULL,
jr_internal text,
jr_tech_date timestamp without time zone DEFAULT now() NOT NULL,
jr_tech_per integer NOT NULL,
jrn_ech date,
jr_ech date,
jr_rapt text,
jr_valid boolean DEFAULT true
);
CREATE TABLE stock_goods (
sg_id integer DEFAULT nextval('s_stock_goods'::text) NOT NULL,
j_id integer,
f_id integer NOT NULL,
sg_code text,
sg_quantity integer DEFAULT 0,
sg_type character(1) DEFAULT 'c' NOT NULL,
sg_date date,
sg_tech_date date DEFAULT now(),
sg_tech_user text,
CONSTRAINT stock_goods_sg_type CHECK (((sg_type = 'c'::bpchar) OR (sg_type = 'd'::bpchar)))
);

View file

@ -0,0 +1,2 @@
CREATE VIEW vw_fiche_attr AS
SELECT a.f_id, fd_id, a.av_text AS vw_name, b.av_text AS vw_sell, c.av_text AS vw_buy, d.av_text AS tva_code, tva_id, tva_rate, tva_label, e.av_text AS vw_addr, f.av_text AS vw_cp, frd_id FROM ((((((((SELECT f_id, fd_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 1)) a LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 6)) b ON ((a.f_id = b.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 7)) c ON ((a.f_id = c.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 2)) d ON ((a.f_id = d.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 14)) e ON ((a.f_id = e.f_id))) LEFT JOIN (SELECT f_id, av_text FROM (((fiche JOIN jnt_fic_att_value USING (f_id)) JOIN attr_value USING (jft_id)) JOIN attr_def USING (ad_id)) WHERE (ad_id = 15)) f ON ((a.f_id = f.f_id))) LEFT JOIN tva_rate ON ((d.av_text = (tva_rate.tva_id)::text))) JOIN fiche_def USING (fd_id));

5
html/admin/variable.php Normal file
View file

@ -0,0 +1,5 @@
<?
// Give the complete line for the psql command
// with the path
$psql='/opt/psql732/bin/psql';