diff --git a/materiels.tar.gz b/materiels.tar.gz index 8ea1acd..1886c2b 100644 Binary files a/materiels.tar.gz and b/materiels.tar.gz differ diff --git a/src/lib/Equipment.php b/src/lib/Equipment.php index 738a67b..1350e69 100644 --- a/src/lib/Equipment.php +++ b/src/lib/Equipment.php @@ -65,19 +65,6 @@ class Equipment return $entries - $outputs; } - public function CalculateAvailable($id) - { - $entries = DB::getInstance()->firstColumn( - "SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind IN ( - 'Achat', 'Don', 'Récupération', - 'Retour de location / prêt') AND equipment_id = ?;", $id); - $outputs = DB::getInstance()->firstColumn( - "SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind IN ( - 'Vente', 'Don', 'Besoin', 'Autre (perte, vol, ...)', - 'Location / Prêt') AND equipment_id = ?;", $id); - return $entries - $outputs; - } - public function GetAllListByCategory() { $eqmts_by_cat = $this->listAllByCategory(); @@ -119,6 +106,19 @@ class Equipment ); } + public function CalculateAvailable($id) + { + $entries = DB::getInstance()->firstColumn( + "SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind IN ( + 'Achat', 'Don', 'Récupération', + 'Retour de location / prêt') AND equipment_id = ?;", $id); + $outputs = DB::getInstance()->firstColumn( + "SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind IN ( + 'Vente', 'Don', 'Besoin', 'Autre (perte, vol, ...)', + 'Location / Prêt') AND equipment_id = ?;", $id); + return $entries - $outputs; + } + public function GetAvailableListByCategory() { $eqmts_by_cat = $this->listAllByCategory(); diff --git a/src/templates/entrees/index.tpl b/src/templates/entrees/index.tpl index c755d07..c78908c 100644 --- a/src/templates/entrees/index.tpl +++ b/src/templates/entrees/index.tpl @@ -21,7 +21,7 @@ {foreach from=$entries item="entry"} - {$entry.entry_date} + {$entry.entry_date|date_format:'%d/%m/%y'} {$entry.kind} {$entry.equipment_number} {$entry.equipment} diff --git a/src/templates/sorties/index.tpl b/src/templates/sorties/index.tpl index c7d089f..b4f83fb 100644 --- a/src/templates/sorties/index.tpl +++ b/src/templates/sorties/index.tpl @@ -20,7 +20,7 @@ {foreach from=$outputs item="output"} - {$output.output_date} + {$entry.output_date|date_format:'%d/%m/%y'} {$output.kind} {$output.equipment_number} {$output.equipment} diff --git a/src/templates/sorties/stock_disponible.tpl b/src/templates/sorties/stock_disponible.tpl index d08f7ce..1d6e4cc 100644 --- a/src/templates/sorties/stock_disponible.tpl +++ b/src/templates/sorties/stock_disponible.tpl @@ -8,7 +8,7 @@ {if $eqmts} {foreach from=$eqmts item="eqmt"} - + {/foreach} {/if} diff --git a/src/www/admin/entrees/non_repertorie.php b/src/www/admin/entrees/non_repertorie.php index dd8aa83..4ae95ae 100644 --- a/src/www/admin/entrees/non_repertorie.php +++ b/src/www/admin/entrees/non_repertorie.php @@ -44,11 +44,13 @@ if (f('save')) 'category_id' => (int) f('category_id'), 'designation' => ucfirst(strtolower(f('designation'))), ]); + $entry_date_format = date_create_from_format( + "d/m/Y", f('entry_date'))->format("Y-m-d"); $entry->add([ 'kind' => f('kind'), 'equipment_number' => (int) f('equipment_number'), 'equipment_id' => $eqmt_id, - 'entry_date' => f('entry_date'), + 'entry_date' => $entry_date_format, 'additional_comment' => f('additional_comment'), ]); Utils::redirect(PLUGIN_URL . 'entrees/index.php'); diff --git a/src/www/admin/entrees/repertorie.php b/src/www/admin/entrees/repertorie.php index f7c8349..231fcc1 100644 --- a/src/www/admin/entrees/repertorie.php +++ b/src/www/admin/entrees/repertorie.php @@ -14,11 +14,14 @@ $csrf_key = 'add_entry'; if (f('save') && $form->check($csrf_key) && !$form->hasErrors()) { + $entry = new Entry; + $entry_date_format = date_create_from_format( + "d/m/Y", f('entry_date'))->format("Y-m-d"); $entry->add([ 'kind' => f('kind'), 'equipment_number' => (int) f('equipment_number'), 'equipment_id' => f('equipment_id'), - 'entry_date' => f('entry_date'), + 'entry_date' => $entry_date_format, 'additional_comment' => f('additional_comment'), ]); Utils::redirect(PLUGIN_URL . 'entrees/index.php'); diff --git a/src/www/admin/entrees/retour.php b/src/www/admin/entrees/retour.php index 075373c..f9f9711 100644 --- a/src/www/admin/entrees/retour.php +++ b/src/www/admin/entrees/retour.php @@ -15,11 +15,13 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors()) if ($form->check($csrf_key) && !$form->hasErrors()) { $entry = new Entry; + $entry_date_format = date_create_from_format( + "d/m/Y", f('entry_date'))->format("Y-m-d"); $entry->add([ 'kind' => 'Retour de location / prêt', 'equipment_number' => (int) f('equipment_number'), 'equipment_id' => f('equipment_id'), - 'entry_date' => f('entry_date'), + 'entry_date' => $entry_date_format, 'additional_comment' => f('additional_comment'), ]); Utils::redirect(PLUGIN_URL . 'entrees/index.php'); diff --git a/src/www/admin/sorties/stock_disponible.php b/src/www/admin/sorties/stock_disponible.php index 98ae594..3013298 100644 --- a/src/www/admin/sorties/stock_disponible.php +++ b/src/www/admin/sorties/stock_disponible.php @@ -14,6 +14,20 @@ $eqmts_by_cat = $eqmt->GetAvailableListByCategory(); $csrf_key = 'add_output'; +if (f('save') && $form->check($csrf_key) && !$form->hasErrors()) +{ + $output_date_format = date_create_from_format( + "d/m/Y", f('entry_date'))->format("Y-m-d"); + $output->add([ + 'kind' => f('kind'), + 'equipment_number' => (int) f('equipment_number'), + 'equipment_id' => f('equipment_id'), + 'output_date' => $output_date_format, + 'additional_comment' => f('additional_comment'), + ]); + Utils::redirect(PLUGIN_URL . 'entrees/index.php'); +} + $kinds = $output->listKinds(); $selected_kind = $kinds[0];