diff --git a/README.md b/README.md index 628de01..4e11690 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Cette extension permet de gérer les matériels de l'association: stock, entrée ## Installation -- Télécharger le fichier materiels.tar.gz et l'ajouter dans le répertoire garradin/plugins. +- Télécharger le fichier [materiels.tar.gz](https://gitlab.com/JBthePenguin/garradin-plugin-materiels/-/raw/main/materiels.tar.gz) et l'ajouter dans le répertoire garradin/plugins. - Installer le plugin via le menu "Configuration > Extensions" de Garradin. ## Utilisation - Fonctionnalités diff --git a/materiels.tar.gz b/materiels.tar.gz index 88e8ef2..e251a4a 100644 Binary files a/materiels.tar.gz and b/materiels.tar.gz differ diff --git a/src/install.php b/src/install.php index e69de29..07a618a 100644 --- a/src/install.php +++ b/src/install.php @@ -0,0 +1,5 @@ +import(__DIR__ . '/schema.sql'); diff --git a/src/schema.sql b/src/schema.sql new file mode 100644 index 0000000..78365bb --- /dev/null +++ b/src/schema.sql @@ -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 +); diff --git a/src/templates/_nav.tpl b/src/templates/_nav.tpl new file mode 100644 index 0000000..1b9b263 --- /dev/null +++ b/src/templates/_nav.tpl @@ -0,0 +1,10 @@ + diff --git a/src/templates/config.tpl b/src/templates/config.tpl deleted file mode 100644 index 6c8ac79..0000000 --- a/src/templates/config.tpl +++ /dev/null @@ -1,20 +0,0 @@ -{include file="admin/_head.tpl" title="Configuration — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} - -{form_errors} - -
- -
- Configuration -
- {input type="checkbox" name="display_hello" value="1" default=$plugin.config label="Afficher un message de coucou"} -
-
- -

- {csrf_field key="config_plugin_%s"|args:$plugin.id} - {button type="submit" class="main" name="save" label="Enregistrer" shape="right"} -

-
- -{include file="admin/_foot.tpl"} diff --git a/src/templates/entrees_definitives.tpl b/src/templates/entrees_definitives.tpl new file mode 100644 index 0000000..131944a --- /dev/null +++ b/src/templates/entrees_definitives.tpl @@ -0,0 +1,5 @@ +{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} + +{include file="%s_nav.tpl"|args:$plugin_tpl current="entrees_definitives"} + +{include file="admin/_foot.tpl"} diff --git a/src/templates/entrees_provisoires.tpl b/src/templates/entrees_provisoires.tpl new file mode 100644 index 0000000..1c6b217 --- /dev/null +++ b/src/templates/entrees_provisoires.tpl @@ -0,0 +1,5 @@ +{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} + +{include file="%s_nav.tpl"|args:$plugin_tpl current="entrees_provisoires"} + +{include file="admin/_foot.tpl"} diff --git a/src/templates/index.tpl b/src/templates/index.tpl index ea1dd8d..6b73859 100644 --- a/src/templates/index.tpl +++ b/src/templates/index.tpl @@ -1,12 +1,5 @@ -{include file="admin/_head.tpl" title="Extension — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} - -

Gestion du materiel de l'association

- -{if $plugin.config.display_hello} -

L'affichage du message de bienvenue est activé

-{else} -

L'affichage du message de bienvenue est désactivé !

-{/if} +{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} +{include file="%s_nav.tpl"|args:$plugin_tpl current="index"} {include file="admin/_foot.tpl"} diff --git a/src/templates/recherche.tpl b/src/templates/recherche.tpl new file mode 100644 index 0000000..894e6ed --- /dev/null +++ b/src/templates/recherche.tpl @@ -0,0 +1,5 @@ +{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} + +{include file="%s_nav.tpl"|args:$plugin_tpl current="recherche"} + +{include file="admin/_foot.tpl"} diff --git a/src/templates/sorties_definitives.tpl b/src/templates/sorties_definitives.tpl new file mode 100644 index 0000000..3aaee83 --- /dev/null +++ b/src/templates/sorties_definitives.tpl @@ -0,0 +1,5 @@ +{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} + +{include file="%s_nav.tpl"|args:$plugin_tpl current="sorties_definitives"} + +{include file="admin/_foot.tpl"} diff --git a/src/templates/sorties_provisoires.tpl b/src/templates/sorties_provisoires.tpl new file mode 100644 index 0000000..6f8b5ff --- /dev/null +++ b/src/templates/sorties_provisoires.tpl @@ -0,0 +1,5 @@ +{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} + +{include file="%s_nav.tpl"|args:$plugin_tpl current="sorties_provisoires"} + +{include file="admin/_foot.tpl"} diff --git a/src/upgrade.php b/src/upgrade.php new file mode 100644 index 0000000..e69de29 diff --git a/src/www/admin/_inc.php b/src/www/admin/_inc.php new file mode 100644 index 0000000..d5947db --- /dev/null +++ b/src/www/admin/_inc.php @@ -0,0 +1,5 @@ +assign('plugin_tpl', PLUGIN_ROOT . '/templates/'); diff --git a/src/www/admin/config.php b/src/www/admin/config.php deleted file mode 100644 index f195b75..0000000 --- a/src/www/admin/config.php +++ /dev/null @@ -1,26 +0,0 @@ -requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN); - -if (f('save')) -{ - $form->check('config_plugin_' . $plugin->id(), [ - 'display_hello' => 'boolean', - ]); - - if (!$form->hasErrors()) - { - try { - $plugin->setConfig('display_hello', (bool) f('display_hello')); - utils::redirect(utils::plugin_url()); - } - catch (UserException $e) - { - $form->addError($e->getMessage()); - } - } -} - -$tpl->display(PLUGIN_ROOT . '/templates/config.tpl'); diff --git a/src/www/admin/entrees_definitives.php b/src/www/admin/entrees_definitives.php new file mode 100644 index 0000000..bddb547 --- /dev/null +++ b/src/www/admin/entrees_definitives.php @@ -0,0 +1,7 @@ +display(PLUGIN_ROOT . '/templates/entrees_definitives.tpl'); diff --git a/src/www/admin/entrees_provisoires.php b/src/www/admin/entrees_provisoires.php new file mode 100644 index 0000000..a329be4 --- /dev/null +++ b/src/www/admin/entrees_provisoires.php @@ -0,0 +1,7 @@ +display(PLUGIN_ROOT . '/templates/entrees_provisoires.tpl'); diff --git a/src/www/admin/index.php b/src/www/admin/index.php index fcd1b9c..767f302 100644 --- a/src/www/admin/index.php +++ b/src/www/admin/index.php @@ -2,4 +2,11 @@ namespace Garradin; +if ($plugin->needUpgrade()) +{ + $plugin->upgrade(); +} + +require_once __DIR__ . '/_inc.php'; + $tpl->display(PLUGIN_ROOT . '/templates/index.tpl'); diff --git a/src/www/admin/recherche.php b/src/www/admin/recherche.php new file mode 100644 index 0000000..189808f --- /dev/null +++ b/src/www/admin/recherche.php @@ -0,0 +1,7 @@ +display(PLUGIN_ROOT . '/templates/recherche.tpl'); diff --git a/src/www/admin/sorties_definitives.php b/src/www/admin/sorties_definitives.php new file mode 100644 index 0000000..359f80d --- /dev/null +++ b/src/www/admin/sorties_definitives.php @@ -0,0 +1,7 @@ +display(PLUGIN_ROOT . '/templates/sorties_definitives.tpl'); diff --git a/src/www/admin/sorties_provisoires.php b/src/www/admin/sorties_provisoires.php new file mode 100644 index 0000000..77ba811 --- /dev/null +++ b/src/www/admin/sorties_provisoires.php @@ -0,0 +1,7 @@ +display(PLUGIN_ROOT . '/templates/sorties_provisoires.tpl');