Add schema.sql to create database, add php files and templates for index, entries, exits and search.

This commit is contained in:
JBthePenguin 2021-06-02 15:17:34 +02:00
parent 16f10215e9
commit 4448a9bde1
21 changed files with 147 additions and 56 deletions

57
src/schema.sql Normal file
View file

@ -0,0 +1,57 @@
CREATE TABLE IF NOT EXISTS plugin_materiels_category (
id integer NOT NULL PRIMARY KEY autoincrement,
name varchar(100) NOT NULL,
CONSTRAINT u_category_name UNIQUE ( name )
);
CREATE TABLE IF NOT EXISTS plugin_materiels_location (
id integer NOT NULL PRIMARY KEY autoincrement,
name varchar(100) NOT NULL,
CONSTRAINT u_location_name UNIQUE ( name )
);
CREATE TABLE IF NOT EXISTS plugin_materiels_equipment (
id integer NOT NULL PRIMARY KEY autoincrement,
category_id integer NOT NULL,
designation varchar(255) NOT NULL,
localisation_id integer NOT NULL,
current_value decimal NOT NULL DEFAULT 0,
number_of_materiels integer NOT NULL DEFAULT 1,
CONSTRAINT u_equipment_designation UNIQUE ( designation ),
FOREIGN KEY ( category_id ) REFERENCES plugin_materiels_category( id ) ON DELETE RESTRICT ON UPDATE CASCADE,
FOREIGN KEY ( localisation_id ) REFERENCES plugin_materiels_location( id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_entry (
id integer NOT NULL PRIMARY KEY autoincrement,
kind varchar(20) NOT NULL,
equipment_id integer NOT NULL,
date_of_entry date NOT NULL,
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_temporary_entry (
id integer NOT NULL PRIMARY KEY autoincrement,
kind varchar(20) NOT NULL,
equipment_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_output (
id integer NOT NULL PRIMARY KEY autoincrement,
kind varchar(20) NOT NULL,
equipment_id integer NOT NULL,
output_date date NOT NULL,
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_entry( equipment_id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_temporary_output (
id integer NOT NULL PRIMARY KEY autoincrement,
kind varchar(20) NOT NULL,
equipment_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_entry( equipment_id ) ON DELETE RESTRICT ON UPDATE CASCADE
);