From e18a2f7667ac9169c087a62688b9d9d1007b2eed Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 9 Nov 2021 15:53:44 +0100 Subject: [PATCH] [SQL] add: Data model for accident --- sql/accident/index.php | 2 + sql/accident/llx_c_accident_location.sql | 23 +++++++++++ sql/accident/llx_c_lesion_localization.sql | 23 +++++++++++ sql/accident/llx_c_lesion_nature.sql | 23 +++++++++++ .../llx_digiriskdolibarr_accident.key.sql | 18 +++++++++ .../llx_digiriskdolibarr_accident.sql | 32 +++++++++++++++ ...iriskdolibarr_accident_extrafields.key.sql | 16 ++++++++ ..._digiriskdolibarr_accident_extrafields.sql | 22 ++++++++++ ...igiriskdolibarr_accident_signature.key.sql | 17 ++++++++ ...lx_digiriskdolibarr_accident_signature.sql | 40 +++++++++++++++++++ .../llx_digiriskdolibarr_accidentdet.key.sql | 18 +++++++++ .../llx_digiriskdolibarr_accidentdet.sql | 25 ++++++++++++ ...skdolibarr_accidentdet_extrafields.key.sql | 16 ++++++++ ...giriskdolibarr_accidentdet_extrafields.sql | 22 ++++++++++ ..._digiriskdolibarr_accidentmetadata.key.sql | 16 ++++++++ .../llx_digiriskdolibarr_accidentmetadata.sql | 32 +++++++++++++++ 16 files changed, 345 insertions(+) create mode 100644 sql/accident/index.php create mode 100644 sql/accident/llx_c_accident_location.sql create mode 100644 sql/accident/llx_c_lesion_localization.sql create mode 100644 sql/accident/llx_c_lesion_nature.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accident.key.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accident.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accident_extrafields.key.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accident_extrafields.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accident_signature.key.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accident_signature.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accidentdet.key.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accidentdet.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accidentdet_extrafields.key.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accidentdet_extrafields.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accidentmetadata.key.sql create mode 100644 sql/accident/llx_digiriskdolibarr_accidentmetadata.sql diff --git a/sql/accident/index.php b/sql/accident/index.php new file mode 100644 index 000000000..cd6990e24 --- /dev/null +++ b/sql/accident/index.php @@ -0,0 +1,2 @@ + +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_c_accident_location( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer default 1, + ref varchar(128), + label varchar(255), + description text, + active tinyint(4) DEFAULT 0 +) ENGINE=innodb; diff --git a/sql/accident/llx_c_lesion_localization.sql b/sql/accident/llx_c_lesion_localization.sql new file mode 100644 index 000000000..53ddb4d41 --- /dev/null +++ b/sql/accident/llx_c_lesion_localization.sql @@ -0,0 +1,23 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_c_lesion_localization( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer default 1, + ref varchar(128), + label varchar(255), + description text, + active tinyint(4) DEFAULT 0 +) ENGINE=innodb; diff --git a/sql/accident/llx_c_lesion_nature.sql b/sql/accident/llx_c_lesion_nature.sql new file mode 100644 index 000000000..3347cd805 --- /dev/null +++ b/sql/accident/llx_c_lesion_nature.sql @@ -0,0 +1,23 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_c_lesion_nature( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer default 1, + ref varchar(128), + label varchar(255), + description text, + active tinyint(4) DEFAULT 0 +) ENGINE=innodb; diff --git a/sql/accident/llx_digiriskdolibarr_accident.key.sql b/sql/accident/llx_digiriskdolibarr_accident.key.sql new file mode 100644 index 000000000..a7fa15c46 --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accident.key.sql @@ -0,0 +1,18 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +ALTER TABLE llx_digiriskdolibarr_accident ADD INDEX idx_digiriskdolibarr_accident_rowid (rowid); +ALTER TABLE llx_digiriskdolibarr_accident ADD INDEX idx_digiriskdolibarr_accident_ref_ext (ref_ext); +ALTER TABLE llx_digiriskdolibarr_accident ADD CONSTRAINT llx_digiriskdolibarr_accident_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); diff --git a/sql/accident/llx_digiriskdolibarr_accident.sql b/sql/accident/llx_digiriskdolibarr_accident.sql new file mode 100644 index 000000000..b2a92b3ec --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accident.sql @@ -0,0 +1,32 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_digiriskdolibarr_accident( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + ref_ext varchar(128), + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + tms timestamp, + status smallint, + label varchar(255) NOT NULL, + accident_date datetime NOT NULL, + description text, + photo text, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_element integer, + fk_user_victim integer +) ENGINE=innodb; diff --git a/sql/accident/llx_digiriskdolibarr_accident_extrafields.key.sql b/sql/accident/llx_digiriskdolibarr_accident_extrafields.key.sql new file mode 100644 index 000000000..8fb72f8f1 --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accident_extrafields.key.sql @@ -0,0 +1,16 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +ALTER TABLE llx_digiriskdolibarr_accident_extrafields ADD INDEX idx_fk_object(fk_object); diff --git a/sql/accident/llx_digiriskdolibarr_accident_extrafields.sql b/sql/accident/llx_digiriskdolibarr_accident_extrafields.sql new file mode 100644 index 000000000..ae4d54e43 --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accident_extrafields.sql @@ -0,0 +1,22 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +create table llx_digiriskdolibarr_accident_extrafields( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + import_key varchar(14), + fk_object integer NOT NULL +) ENGINE=innodb; + diff --git a/sql/accident/llx_digiriskdolibarr_accident_signature.key.sql b/sql/accident/llx_digiriskdolibarr_accident_signature.key.sql new file mode 100644 index 000000000..ccc75a58f --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accident_signature.key.sql @@ -0,0 +1,17 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +ALTER TABLE llx_digiriskdolibarr_accident_signature ADD INDEX idx_digiriskdolibarr_accident_signature_rowid (rowid); +ALTER TABLE llx_digiriskdolibarr_accident_signature ADD CONSTRAINT llx_digiriskdolibarr_accident_signature_fk_object FOREIGN KEY (fk_object) REFERENCES llx_digiriskdolibarr_accident(rowid); diff --git a/sql/accident/llx_digiriskdolibarr_accident_signature.sql b/sql/accident/llx_digiriskdolibarr_accident_signature.sql new file mode 100644 index 000000000..242ada833 --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accident_signature.sql @@ -0,0 +1,40 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_digiriskdolibarr_accident_signature( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + tms timestamp, + import_key integer DEFAULT NULL, + status smallint, + role varchar(255), + firstname varchar(255), + lastname varchar(255), + email varchar(255), + phone varchar(255), + address text, + society_name varchar(255), + signature_date datetime DEFAULT NULL, + signature_comment text DEFAULT NULL, + element_id integer NOT NULL, + element_type varchar(255), + signature text, + stamp text, + last_email_sent_date datetime DEFAULT NULL, + signature_url varchar(255), + transaction_url varchar(255), + fk_object integer NOT NULL +) ENGINE=innodb; diff --git a/sql/accident/llx_digiriskdolibarr_accidentdet.key.sql b/sql/accident/llx_digiriskdolibarr_accidentdet.key.sql new file mode 100644 index 000000000..37ac8044b --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accidentdet.key.sql @@ -0,0 +1,18 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +ALTER TABLE llx_digiriskdolibarr_accidentdet ADD INDEX idx_digiriskdolibarr_accidentdet_rowid (rowid); +ALTER TABLE llx_digiriskdolibarr_accidentdet ADD INDEX idx_digiriskdolibarr_accidentdet_ref_ext (ref_ext); +ALTER TABLE llx_digiriskdolibarr_accidentdet ADD CONSTRAINT llx_digiriskdolibarr_accidentdet_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); diff --git a/sql/accident/llx_digiriskdolibarr_accidentdet.sql b/sql/accident/llx_digiriskdolibarr_accidentdet.sql new file mode 100644 index 000000000..f34f30f53 --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accidentdet.sql @@ -0,0 +1,25 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_digiriskdolibarr_accidentdet( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + ref_ext varchar(128), + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + tms timestamp, + workstop_days integer, + fk_accident integer NOT NULL +) ENGINE=innodb; diff --git a/sql/accident/llx_digiriskdolibarr_accidentdet_extrafields.key.sql b/sql/accident/llx_digiriskdolibarr_accidentdet_extrafields.key.sql new file mode 100644 index 000000000..0b49108ae --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accidentdet_extrafields.key.sql @@ -0,0 +1,16 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +ALTER TABLE llx_digiriskdolibarr_accidentdet_extrafields ADD INDEX idx_fk_object(fk_object); diff --git a/sql/accident/llx_digiriskdolibarr_accidentdet_extrafields.sql b/sql/accident/llx_digiriskdolibarr_accidentdet_extrafields.sql new file mode 100644 index 000000000..21cfcbd31 --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accidentdet_extrafields.sql @@ -0,0 +1,22 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +create table llx_digiriskdolibarr_accidentdet_extrafields( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + import_key varchar(14), + fk_object integer NOT NULL +) ENGINE=innodb; + diff --git a/sql/accident/llx_digiriskdolibarr_accidentmetadata.key.sql b/sql/accident/llx_digiriskdolibarr_accidentmetadata.key.sql new file mode 100644 index 000000000..99d682b15 --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accidentmetadata.key.sql @@ -0,0 +1,16 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +ALTER TABLE llx_digiriskdolibarr_accidentmetadata ADD INDEX idx_digiriskdolibarr_accidentmetadata_rowid (rowid); diff --git a/sql/accident/llx_digiriskdolibarr_accidentmetadata.sql b/sql/accident/llx_digiriskdolibarr_accidentmetadata.sql new file mode 100644 index 000000000..3ec581e53 --- /dev/null +++ b/sql/accident/llx_digiriskdolibarr_accidentmetadata.sql @@ -0,0 +1,32 @@ +-- Copyright (C) 2021 EOXIA +-- +-- This program 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 3 of the License, or +-- (at your option) any later version. +-- +-- This program 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 this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_digiriskdolibarr_accident( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + tms timestamp, + relative_location varchar(255), + lesion_localization text, + lesion_nature text, + thirdparty_responsibility boolean, + fatal boolean, + accident_investigation boolean, + accident_investigation_link boolean, + accident_location text, + collateral_victim boolean, + police_report boolean, + fk_accident integer NOT NULL +) ENGINE=innodb;