ok for available equiment output tpl, next add validate form in php file
This commit is contained in:
parent
08e2af1f1d
commit
d58ae812b5
8 changed files with 121 additions and 30 deletions
|
|
@ -65,6 +65,19 @@ 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();
|
||||
|
|
@ -105,4 +118,22 @@ class Equipment
|
|||
$eqmts_just_listed_by_cat
|
||||
);
|
||||
}
|
||||
|
||||
public function GetAvailableListByCategory()
|
||||
{
|
||||
$eqmts_by_cat = $this->listAllByCategory();
|
||||
$eqmts_available_by_cat = array();
|
||||
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
||||
$eqmts_available = array();
|
||||
foreach ($eqmts as $eqmt) {
|
||||
$available = $this->CalculateAvailable($eqmt->id);
|
||||
if ($available) {
|
||||
$eqmt->available = $available;
|
||||
array_push($eqmts_available, $eqmt);
|
||||
}
|
||||
}
|
||||
$eqmts_available_by_cat[$cat] = $eqmts_available;
|
||||
}
|
||||
return $eqmts_available_by_cat;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue