diff --git a/doc_db/LayoutwithTools.svg b/doc_db/LayoutwithTools.svg new file mode 100644 index 0000000..a89295c --- /dev/null +++ b/doc_db/LayoutwithTools.svg @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plugin materiels database + (c) DbSchema + Hover columns to read the comments. + + + + + + Fk Fk_plugin_materiels_entry +plugin_materiels_entry ref plugin_materiels_equipment ( equipment_id -> id ) + +Fk Fk_plugin_materiels_entry +plugin_materiels_entry ref plugin_materiels_equipment ( equipment_id -> id ) +Fk_plugin_materiels_entry + + + Fk Fk_plugin_materiels_output +plugin_materiels_output ref plugin_materiels_equipment ( equipment_id -> id ) + +Fk Fk_plugin_materiels_output +plugin_materiels_output ref plugin_materiels_equipment ( equipment_id -> id ) +Fk_plugin_materiels_output + + + Fk Fk_plugin_materiels_equipment +plugin_materiels_equipment ref plugin_materiels_category ( category_id -> id ) + +Fk Fk_plugin_materiels_equipment +plugin_materiels_equipment ref plugin_materiels_category ( category_id -> id ) +Fk_plugin_materiels_equipment + + + + +plugin_materiels_entryTable Default.plugin_materiels_entry + Pk pk_plugin_materiels_entry ( id ) idid +* integer +integer kindkind +* varchar(20) +Achat, Don, Récupération, ... +varchar(20) equipment_numberequipment_number +* integer +integer equipment_idequipment_id +* integer +integerReferences plugin_materiels_equipment ( equipment_id -> id ) + entry_dateentry_date +* date +date additional_commentadditional_comment +varchar(255) +varchar(255) + + + + +plugin_materiels_outputTable Default.plugin_materiels_output + Pk pk_plugin_materiels_output ( id ) idid +* integer +integer kindkind +* varchar(20) +Vente, Don, Prêt, ... +varchar(20) equipment_numberequipment_number +* integer +integer equipment_idequipment_id +* integer +integerReferences plugin_materiels_equipment ( equipment_id -> id ) + output_dateoutput_date +* date +date additional_commentadditional_comment +varchar(255) +varchar(255) + + + + +plugin_materiels_categoryTable Default.plugin_materiels_category + Pk pk_plugin_materiels_category ( id ) idid +* integer +integerReferred by plugin_materiels_equipment ( category_id -> id ) + Unq sqlite_autoindex_plugin_materiels_category_1 ( name ) namename +* varchar(100) +varchar(100) + + + + +plugin_materiels_equipmentTable Default.plugin_materiels_equipment + Pk pk_plugin_materiels_equipment ( id ) idid +* integer +integerReferred by plugin_materiels_entry ( equipment_id -> id ) +Referred by plugin_materiels_output ( equipment_id -> id ) + category_idcategory_id +* integer +integerReferences plugin_materiels_category ( category_id -> id ) + stock_numberstock_number +* integer +integer Unq sqlite_autoindex_plugin_materiels_equipment_1 ( designation ) designationdesignation +* varchar(255) +varchar(255) + \ No newline at end of file diff --git a/doc_db/doc_db.md b/doc_db/doc_db.md new file mode 100644 index 0000000..3d23546 --- /dev/null +++ b/doc_db/doc_db.md @@ -0,0 +1,55 @@ +## Plugin materiels database + +![img](./LayoutwithTools.svg) + +### Table plugin_materiels_category +| Idx | Field Name | Data Type | +|---|---|---| +| *🔑 ⬋ | id| integer autoincrement | +| *🔍 | name| varchar(100) | +| Indexes | +| 🔑 primary key | pk_plugin_materiels_category || +| 🔍 unique | u_category_name | + +### Table plugin_materiels_equipment +| Idx | Field Name | Data Type | +|---|---|---| +| *🔑 ⬋ | id| integer autoincrement | +| *⬈ | category_id| integer | +| *| stock_number| integer | +| *🔍 | designation| varchar(255) | +| Indexes | +| 🔑 primary key | pk_plugin_materiels_equipment || ON id| +| 🔍 unique | u_equipment_designation || ON designation| +| Foreign Keys | +| | Fk_plugin_materiels_equipment | ( category_id ) ref plugin_materiels_category (id) | + +### Table plugin_materiels_entry +| Idx | Field Name | Data Type | Description | +|---|---|---|---| +| *🔑 | id| integer autoincrement | | +| *| kind| varchar(20) | Achat, Don, Récupération, ... | +| *| equipment_number| integer | | +| *⬈ | equipment_id| integer | | +| *| entry_date| date | | +| | additional_comment| varchar(255) | | +| Indexes | +| 🔑 primary key | pk_plugin_materiels_entry | | +| Foreign Keys | +| | Fk_plugin_materiels_entry | ( equipment_id ) ref plugin_materiels_equipment (id) | | + +### Table plugin_materiels_output +| Idx | Field Name | Data Type | Description | +|---|---|---|---| +| *🔑 | id| integer autoincrement | | +| *| kind| varchar(20) | Vente, Don, Prêt, ... | +| *| equipment_number| integer | | +| *⬈ | equipment_id| integer | | +| *| output_date| date | | +| | additional_comment| varchar(255) | | +| Indexes | +| 🔑 primary key | pk_plugin_materiels_output || ON id | | +| Foreign Keys | +| | Fk_plugin_materiels_output | ( equipment_id ) ref plugin_materiels_equipment (id) | | + +| * -> NOT NULL diff --git a/materiels.tar.gz b/materiels.tar.gz index 0c46472..3a210c6 100644 Binary files a/materiels.tar.gz and b/materiels.tar.gz differ diff --git a/src/lib/Entry.php b/src/lib/Entry.php index a455462..8cd3942 100644 --- a/src/lib/Entry.php +++ b/src/lib/Entry.php @@ -9,9 +9,10 @@ class Entry protected $columns_order = array( 'id', 'kind', - 'number_of_equipments', + 'equipment_number', 'equipment_id', - 'date_of_entry', + 'entry_date', + 'additional_comment', ); public function listKinds() @@ -36,6 +37,6 @@ class Entry public function listAll() { - return DB::getInstance()->get('SELECT * FROM plugin_materiels_entry ORDER BY date_of_entry DESC;'); + return DB::getInstance()->get('SELECT * FROM plugin_materiels_entry ORDER BY entry_date DESC;'); } } diff --git a/src/lib/Equipment.php b/src/lib/Equipment.php index c8c2193..565a94b 100644 --- a/src/lib/Equipment.php +++ b/src/lib/Equipment.php @@ -9,8 +9,8 @@ class Equipment protected $columns_order = array( 'id', 'category_id', - 'number_of_equipments', - 'designation' + 'stock_number', + 'designation', ); public function add($data = []) diff --git a/src/schema.sql b/src/schema.sql index 8af9085..c29ffec 100644 --- a/src/schema.sql +++ b/src/schema.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS plugin_materiels_category ( CREATE TABLE IF NOT EXISTS plugin_materiels_equipment ( id integer NOT NULL PRIMARY KEY autoincrement, category_id integer NOT NULL, - number_of_equipments integer NOT NULL, + stock_number integer NOT NULL, designation varchar(255) NOT NULL, CONSTRAINT u_equipment_designation UNIQUE ( designation ), FOREIGN KEY ( category_id ) REFERENCES plugin_materiels_category( id ) ON DELETE RESTRICT ON UPDATE CASCADE @@ -16,17 +16,19 @@ CREATE TABLE IF NOT EXISTS plugin_materiels_equipment ( CREATE TABLE IF NOT EXISTS plugin_materiels_entry ( id integer NOT NULL PRIMARY KEY autoincrement, kind varchar(20) NOT NULL, - number_of_equipments integer NOT NULL, + equipment_number integer NOT NULL, equipment_id integer NOT NULL, - date_of_entry date NOT NULL, + entry_date date NOT NULL, + additional_comment varchar(255), 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, - number_of_equipments integer NOT NULL, + equipment_number integer NOT NULL, equipment_id integer NOT NULL, output_date date NOT NULL, + additional_comment varchar(255), FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE ); diff --git a/src/templates/entrees/index.tpl b/src/templates/entrees/index.tpl index 4f7500a..9b2854d 100644 --- a/src/templates/entrees/index.tpl +++ b/src/templates/entrees/index.tpl @@ -18,9 +18,9 @@ {foreach from=$entries item="entry"} - {$entry.date_of_entry} + {$entry.entry_date} {$entry.kind} - {$entry.number_of_equipments} + {$entry.equipment_number} {$entry.equipment.designation} {/foreach} diff --git a/src/templates/entrees/non_repertorie.tpl b/src/templates/entrees/non_repertorie.tpl index 504d976..e741bbd 100644 --- a/src/templates/entrees/non_repertorie.tpl +++ b/src/templates/entrees/non_repertorie.tpl @@ -15,8 +15,8 @@ {/foreach} - {input type="date" name="date_entree" default=$default_date label="Date d'entrée" required=true } - {input type="number" name="number" label="Nombre d'entrée" required=true step="1" min="1" default=$default_number} + {input type="date" name="entry_date" default=$default_date label="Date d'entrée" required=true } + {input type="number" name="equipment_number" label="Nombre" required=true step="1" min="1" default=$default_number}

Matériel

diff --git a/src/templates/index.tpl b/src/templates/index.tpl index 8caa002..db0a1eb 100644 --- a/src/templates/index.tpl +++ b/src/templates/index.tpl @@ -4,7 +4,7 @@ - + @@ -12,7 +12,7 @@ {foreach from=$eqmts item="eqmt"} - +
NombreNombre en stock Désignation Categorie
{$eqmt.number_of_equipments}{$eqmt.stock_number} {$eqmt.designation} {$eqmt.category.name} diff --git a/src/www/admin/entrees/non_repertorie.php b/src/www/admin/entrees/non_repertorie.php index beb1969..eb4c043 100644 --- a/src/www/admin/entrees/non_repertorie.php +++ b/src/www/admin/entrees/non_repertorie.php @@ -28,8 +28,8 @@ $csrf_key = 'add_entry'; if (f('save')) { $selected_kind = f('kind'); - $default_date = f('date_entree'); - $default_number = f('number'); + $default_date = f('entry_date'); + $default_number = f('equipment_number'); $selected_cat = f('category_id'); if ($form->check($csrf_key) && !$form->hasErrors()) @@ -39,14 +39,14 @@ if (f('save')) $eqmt = new Equipment; $eqmt_id = $eqmt->add([ 'category_id' => (int) f('category_id'), - 'number_of_equipments' => (int) f('number'), + 'stock_number' => (int) f('equipment_number'), 'designation' => ucfirst(strtolower(f('designation'))), ]); $entry->add([ 'kind' => f('kind'), - 'number_of_equipments' => (int) f('number'), + 'equipment_number' => (int) f('equipment_number'), 'equipment_id' => $eqmt_id, - 'date_of_entry' => f('date_entree'), + 'entry_date' => f('entry_date'), ]); Utils::redirect(PLUGIN_URL . 'entrees/index.php'); } @@ -65,6 +65,6 @@ if (f('save')) $cancel_link = PLUGIN_URL . 'entrees/index.php'; -$tpl->assign(compact('kinds', 'date', 'cats', 'selected_kind', 'default_date', 'default_number', 'selected_cat', 'cancel_link', 'csrf_key')); +$tpl->assign(compact('kinds', 'cats', 'selected_kind', 'default_date', 'default_number', 'selected_cat', 'cancel_link', 'csrf_key')); $tpl->display(PLUGIN_ROOT . '/templates/entrees/non_repertorie.tpl');