diff --git a/src/lib/Equipment.php b/src/lib/Equipment.php
index fd23201..eafd9e1 100644
--- a/src/lib/Equipment.php
+++ b/src/lib/Equipment.php
@@ -153,13 +153,42 @@ class Equipment
}
public function listAllReleasedRentByCategory()
+ {
+ $eqmts_by_cat = $this->listAllByCategory();
+ $eqmts_released_by_cat = array();
+ foreach ($eqmts_by_cat as $cat => $eqmts) {
+ $eqmts_released = array();
+ foreach ($eqmts as $eqmt) {
+ $released = $this->CalculateOutOfStock($eqmt->id);
+ if ($released) {
+ $eqmt->released = $released;
+ array_push($eqmts_released, $eqmt);
+ }
+ }
+ if ($eqmts_released) {
+ $eqmts_released_by_cat[$cat] = $eqmts_released;
+ }
+ }
+ return $eqmts_released_by_cat;
+ }
+
+ public function CalculateOutOfStockByDate($id, $date)
+ {
+ $entries = DB::getInstance()->firstColumn(
+ "SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND entry_date <= '{$date}';");
+ $outputs = DB::getInstance()->firstColumn(
+ "SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind = 'Location / Prêt' AND equipment_id = '{$id}' AND output_date <= '{$date}';");
+ return $outputs - $entries;
+ }
+
+ public function ListAllBorrowedByCategory()
{
$eqmts_by_cat = $this->listAllByCategory();
$eqmts_borrowed_by_cat = array();
foreach ($eqmts_by_cat as $cat => $eqmts) {
$eqmts_borrowed = array();
foreach ($eqmts as $eqmt) {
- $borrowed = $this->CalculateOutOfStock($eqmt->id);
+ $borrowed = $this->CalculateNoOwned($eqmt->id);
if ($borrowed) {
$eqmt->borrowed = $borrowed;
array_push($eqmts_borrowed, $eqmt);
@@ -171,13 +200,4 @@ class Equipment
}
return $eqmts_borrowed_by_cat;
}
-
- public function CalculateOutOfStockByDate($id, $date)
- {
- $entries = DB::getInstance()->firstColumn(
- "SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND entry_date <= '{$date}';");
- $outputs = DB::getInstance()->firstColumn(
- "SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind = 'Location / Prêt' AND equipment_id = '{$id}' AND output_date <= '{$date}';");
- return $outputs - $entries;
- }
}
diff --git a/src/templates/index.tpl b/src/templates/index.tpl
index e90de43..a4690fe 100644
--- a/src/templates/index.tpl
+++ b/src/templates/index.tpl
@@ -11,7 +11,7 @@
Désignation |
Stock |
- Sorti en location / prêt |
+ Sortie |
Disponible |
|
diff --git a/src/templates/sorties/ajouter_sortie.tpl b/src/templates/sorties/ajouter_sortie.tpl
index fbfdcaa..a1cd178 100644
--- a/src/templates/sorties/ajouter_sortie.tpl
+++ b/src/templates/sorties/ajouter_sortie.tpl
@@ -7,7 +7,7 @@
{form_errors}
- {if $tpl_materiel_name != 'retour'}
+ {if $tpl_materiel_name != 'emprunte'}
- (obligatoire)
-