diff --git a/materiels.tar.gz b/materiels.tar.gz
index 3a210c6..4e35a82 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 7073614..6b3253d 100644
--- a/src/lib/Equipment.php
+++ b/src/lib/Equipment.php
@@ -47,21 +47,62 @@ class Equipment
return $entries - $outputs;
}
- public function listAllOwnedByCategory()
+ public function CalculateOutOfStock($id)
+ {
+ $entries = DB::getInstance()->firstColumn(
+ "SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind = 'Retour de location / prêt' AND equipment_id = ?;", $id);
+ $outputs = DB::getInstance()->firstColumn(
+ "SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind = 'Location / Prêt' AND equipment_id = ?;", $id);
+ return $outputs - $entries;
+ }
+
+ public function CalculateNoOwned($id)
+ {
+ $entries = DB::getInstance()->firstColumn(
+ "SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind = 'Location / Prêt' AND equipment_id = ?;", $id);
+ $outputs = DB::getInstance()->firstColumn(
+ "SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind = 'Retour de location / prêt' AND equipment_id = ?;", $id);
+ return $entries - $outputs;
+ }
+
+ public function GetAllListByCategory()
{
$eqmts_by_cat = $this->listAllByCategory();
$eqmts_owned_by_cat = array();
+ $eqmts_no_owned_by_cat = array();
+ $eqmts_just_listed_by_cat = array();
foreach ($eqmts_by_cat as $cat => $eqmts) {
$eqmts_owned = array();
+ $eqmts_no_owned = array();
+ $eqmts_just_listed = array();
foreach ($eqmts as $eqmt) {
- $stock = $this->CalculateStock($eqmt->id);
- if ($stock) {
- $eqmt->stock = $this->CalculateStock($eqmt->id);
- array_push($eqmts_owned, $eqmt);
- }
+ $stock = $this->CalculateStock($eqmt->id);
+ if ($stock) {
+ $eqmt->stock = $stock;
+ $out_of_stock = $this->CalculateOutOfStock($eqmt->id);
+ if ($out_of_stock) {
+ $eqmt->out_of_stock = $out_of_stock;
+ } else {
+ $eqmt->out_of_stock = 0;
+ }
+ array_push($eqmts_owned, $eqmt);
+ }
+ $no_owned = $this->CalculateNoOwned($eqmt->id);
+ if ($no_owned) {
+ $eqmt->no_owned = $no_owned;
+ array_push($eqmts_no_owned, $eqmt);
+ }
+ if ($stock + $no_owned == 0) {
+ array_push($eqmts_just_listed, $eqmt);
+ }
}
$eqmts_owned_by_cat[$cat] = $eqmts_owned;
+ $eqmts_no_owned_by_cat[$cat] = $eqmts_no_owned;
+ $eqmts_just_listed_by_cat[$cat] = $eqmts_just_listed;
}
- return $eqmts_owned_by_cat;
+ return array(
+ $eqmts_owned_by_cat, $eqmts_no_owned_by_cat,
+ $eqmts_just_listed_by_cat
+ );
}
}
diff --git a/src/lib/Output.php b/src/lib/Output.php
index fa81984..edccd08 100644
--- a/src/lib/Output.php
+++ b/src/lib/Output.php
@@ -17,4 +17,20 @@ class Output
'Retour de location / prêt',
);
}
+
+ public function add($data = [])
+ {
+ DB::getInstance()->insert('plugin_materiels_output', $data);
+ }
+
+ public function edit($id, $data = [])
+ {
+ $db = DB::getInstance();
+ $db->update('plugin_materiels_output', $data, $db->where('id', $id));
+ }
+
+ public function listAll()
+ {
+ return DB::getInstance()->get('SELECT * FROM plugin_materiels_output ORDER BY output_date DESC;');
+ }
}
diff --git a/src/templates/_nav.tpl b/src/templates/_nav.tpl
index 53d00bb..f864fad 100644
--- a/src/templates/_nav.tpl
+++ b/src/templates/_nav.tpl
@@ -3,7 +3,7 @@
Inventaire
Catégories
Entrées
- Sorties
+ Sorties
Recherche
diff --git a/src/templates/entrees/deja_repertorie.tpl b/src/templates/entrees/deja_repertorie.tpl
index 64bf151..37795a6 100644
--- a/src/templates/entrees/deja_repertorie.tpl
+++ b/src/templates/entrees/deja_repertorie.tpl
@@ -5,11 +5,13 @@
diff --git a/src/templates/entrees/index.tpl b/src/templates/entrees/index.tpl
index 8f85de4..15e08f6 100644
--- a/src/templates/entrees/index.tpl
+++ b/src/templates/entrees/index.tpl
@@ -8,25 +8,27 @@
{linkbutton shape="plus" label="Matériel déjà répertorié" href="deja_repertorie.php"}
-
-
- Date |
- Type |
- Nombre |
- Matériel |
- Remarques |
-
-
- {foreach from=$entries item="entry"}
-
- {$entry.entry_date} |
- {$entry.kind} |
- {$entry.equipment_number} |
- {$entry.equipment.designation} |
- {$entry.additional_comment} |
-
- {/foreach}
-
-
+{if $entries}
+
+
+ Date |
+ Type |
+ Nombre |
+ Matériel |
+ Remarques |
+
+
+ {foreach from=$entries item="entry"}
+
+ {$entry.entry_date} |
+ {$entry.kind} |
+ {$entry.equipment_number} |
+ {$entry.equipment.designation} |
+ {$entry.additional_comment} |
+
+ {/foreach}
+
+
+{/if}
{include file="admin/_foot.tpl"}
diff --git a/src/templates/index.tpl b/src/templates/index.tpl
index c9256dc..55dbb3f 100644
--- a/src/templates/index.tpl
+++ b/src/templates/index.tpl
@@ -21,8 +21,8 @@
{$eqmt.designation} |
{$eqmt.stock} |
- 0 |
- 0 |
+ {$eqmt.out_of_stock} |
+ {$eqmt.stock - $eqmt.out_of_stock} |
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
@@ -33,8 +33,56 @@
{/if}
{/foreach}
-Matériel dont l'association n'est pas propriétaire
+Matériel dont l'association n'est pas propriétaire (loué ou prêté)
+{foreach from=$eqmts_no_owned_by_cat key='cat' item="eqmts"}
+ {if $eqmts}
+ {$cat}
+
+
+
+ Désignation |
+ Nombre |
+ |
+
+
+
+ {foreach from=$eqmts item="eqmt"}
+
+ {$eqmt.designation} |
+ {$eqmt.no_owned} |
+
+ {linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
+ |
+
+ {/foreach}
+
+
+ {/if}
+{/foreach}
-Matériel déjà répertorié qui n'est plus en possession de l'association
+Matériel dont l'association n'est plus en possession
+{foreach from=$eqmts_just_listed_by_cat key='cat' item="eqmts"}
+ {if $eqmts}
+ {$cat}
+
+
+
+ Désignation |
+ |
+
+
+
+ {foreach from=$eqmts item="eqmt"}
+
+ {$eqmt.designation} |
+
+ {linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
+ |
+
+ {/foreach}
+
+
+ {/if}
+{/foreach}
{include file="admin/_foot.tpl"}
diff --git a/src/templates/sorties.tpl b/src/templates/sorties/en_stock.tpl
similarity index 91%
rename from src/templates/sorties.tpl
rename to src/templates/sorties/en_stock.tpl
index a458237..d099546 100644
--- a/src/templates/sorties.tpl
+++ b/src/templates/sorties/en_stock.tpl
@@ -2,4 +2,6 @@
{include file="%s_nav.tpl"|args:$plugin_tpl current="sorties"}
+en stock sortie
+
{include file="admin/_foot.tpl"}
diff --git a/src/templates/sorties/index.tpl b/src/templates/sorties/index.tpl
new file mode 100644
index 0000000..d292667
--- /dev/null
+++ b/src/templates/sorties/index.tpl
@@ -0,0 +1,34 @@
+{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"}
+
+
+
+{if $outputs}
+
+
+ Date |
+ Type |
+ Nombre |
+ Matériel |
+ Remarques |
+
+
+ {foreach from=$outputs item="output"}
+
+ {$output.output_date} |
+ {$output.kind} |
+ {$output.equipment_number} |
+ {$output.equipment.designation} |
+ {$output.additional_comment} |
+
+ {/foreach}
+
+
+{/if}
+
+{include file="admin/_foot.tpl"}
diff --git a/src/templates/sorties/pas_proprietaire.tpl b/src/templates/sorties/pas_proprietaire.tpl
new file mode 100644
index 0000000..4c30ce2
--- /dev/null
+++ b/src/templates/sorties/pas_proprietaire.tpl
@@ -0,0 +1,7 @@
+{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"}
+
+pas propriétaire sortie
+
+{include file="admin/_foot.tpl"}
diff --git a/src/www/admin/index.php b/src/www/admin/index.php
index f61213a..39ae74e 100644
--- a/src/www/admin/index.php
+++ b/src/www/admin/index.php
@@ -13,8 +13,13 @@ require_once __DIR__ . '/_inc.php';
$eqmt = new Equipment;
-$eqmts_owned_by_cat = $eqmt->listAllOwnedByCategory();
+list(
+ $eqmts_owned_by_cat, $eqmts_no_owned_by_cat,
+ $eqmts_just_listed_by_cat) = $eqmt->GetAllListByCategory();
-$tpl->assign(compact('eqmts_owned_by_cat'));
+$tpl->assign(compact(
+ 'eqmts_owned_by_cat', 'eqmts_no_owned_by_cat',
+ 'eqmts_just_listed_by_cat'
+));
$tpl->display(PLUGIN_ROOT . '/templates/index.tpl');
diff --git a/src/www/admin/sorties/en_stock.php b/src/www/admin/sorties/en_stock.php
new file mode 100644
index 0000000..f4cc7a2
--- /dev/null
+++ b/src/www/admin/sorties/en_stock.php
@@ -0,0 +1,21 @@
+assign(compact('csrf_key'));
+
+$tpl->display(PLUGIN_ROOT . '/templates/sorties/en_stock.tpl');
diff --git a/src/www/admin/sorties/index.php b/src/www/admin/sorties/index.php
new file mode 100644
index 0000000..351d909
--- /dev/null
+++ b/src/www/admin/sorties/index.php
@@ -0,0 +1,21 @@
+listAll();
+
+foreach ($outputs as $key => $value) {
+ $outputs[$key]->equipment = $eqmt->get($value->equipment_id);
+}
+
+$tpl->assign(compact('outputs'));
+
+$tpl->display(PLUGIN_ROOT . '/templates/sorties/index.tpl');
diff --git a/src/www/admin/sorties/pas_proprietaire.php b/src/www/admin/sorties/pas_proprietaire.php
new file mode 100644
index 0000000..7b32f79
--- /dev/null
+++ b/src/www/admin/sorties/pas_proprietaire.php
@@ -0,0 +1,21 @@
+assign(compact('csrf_key'));
+
+$tpl->display(PLUGIN_ROOT . '/templates/sorties/pas_proprietaire.tpl');