diff --git a/README.md b/README.md index 4e11690..9397c1c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Plugin Materiels pour Garradin -Cette extension permet de gérer les matériels de l'association: stock, entrées, sorties, valorisation. +Cette extension permet de gérer les matériels de l'association: stock, entrées, sorties. ## Installation diff --git a/materiels.tar.gz b/materiels.tar.gz index a0baec7..a675845 100644 Binary files a/materiels.tar.gz and b/materiels.tar.gz differ diff --git a/src/schema.sql b/src/data/schema.sql similarity index 100% rename from src/schema.sql rename to src/data/schema.sql diff --git a/src/data/schema_remove.sql b/src/data/schema_remove.sql new file mode 100644 index 0000000..9acef8c --- /dev/null +++ b/src/data/schema_remove.sql @@ -0,0 +1,3 @@ +DROP TABLE plugin_materiels_movement; +DROP TABLE plugin_materiels_equipment; +DROP TABLE plugin_materiels_category; diff --git a/src/garradin_plugin.ini b/src/garradin_plugin.ini index cd68671..ed5bf1d 100644 --- a/src/garradin_plugin.ini +++ b/src/garradin_plugin.ini @@ -1,5 +1,5 @@ nom="Gestion des matériels" -description="Gestion des matériels: stock, entrées, sorties, valorisation." +description="Gestion des matériels: stock, entrées, sorties." auteur="JBthePenguin" url="https://gitlab.com/JBthePenguin" version="1.0" diff --git a/src/install.php b/src/install.php index 07a618a..87d499b 100644 --- a/src/install.php +++ b/src/install.php @@ -2,4 +2,6 @@ namespace Garradin; -$db->import(__DIR__ . '/schema.sql'); +$db = DB::getInstance(); + +$db->import(__DIR__ . '/data/schema.sql'); diff --git a/src/lib/Movement.php b/src/lib/Movement.php index 9200bf7..083b467 100644 --- a/src/lib/Movement.php +++ b/src/lib/Movement.php @@ -172,8 +172,9 @@ class Movement public function AllEqmtMovements($eqmt_id) // return list of all movements for a specific equipments // ordered by date and side + // if same date order by rent output and after put entry for return { return DB::getInstance()->get( - "SELECT * FROM plugin_materiels_movement WHERE equipment_id = '{$eqmt_id}' ORDER BY mvt_date DESC, side DESC;"); + "SELECT * FROM plugin_materiels_movement WHERE equipment_id = '{$eqmt_id}' ORDER BY mvt_date DESC, CASE WHEN (side = '1' AND kind = 'Location / Prêt') THEN 1 WHEN (side = '0' AND kind != 'Retour de location / prêt') THEN 2 ELSE 0 END, side DESC;"); } } diff --git a/src/uninstall.php b/src/uninstall.php index e69de29..f135345 100644 --- a/src/uninstall.php +++ b/src/uninstall.php @@ -0,0 +1,7 @@ +import(__DIR__ . '/data/schema_remove.sql');