diff --git a/materiels.tar.gz b/materiels.tar.gz
index 25040da..92c9038 100644
Binary files a/materiels.tar.gz and b/materiels.tar.gz differ
diff --git a/src/lib/Category.php b/src/lib/Category.php
index 3e89007..46ad77c 100644
--- a/src/lib/Category.php
+++ b/src/lib/Category.php
@@ -36,5 +36,5 @@ class Category
{
return DB::getInstance()->get(
'SELECT * FROM plugin_materiels_equipment WHERE category_id = ? ORDER BY designation;', $id);
- }
+ }
}
diff --git a/src/lib/Equipment.php b/src/lib/Equipment.php
index 53b6016..f0e8368 100644
--- a/src/lib/Equipment.php
+++ b/src/lib/Equipment.php
@@ -70,6 +70,37 @@ class Equipment
return $entries - $outputs;
}
+ public function AllListsAll($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 = $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);
+ }
+ }
+ return array(
+ $eqmts_owned, $eqmts_no_owned, $eqmts_just_listed
+ );
+ }
+
public function AllListsAllByCategory()
{
$eqmts_by_cat = $this->listAllByCategory();
@@ -77,30 +108,7 @@ class Equipment
$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 = $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);
- }
- }
+ list($eqmts_owned, $eqmts_no_owned, $eqmts_just_listed) = $this->AllListsAll($eqmts);
$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;
diff --git a/src/templates/_nav.tpl b/src/templates/_nav.tpl
index f864fad..6be036a 100644
--- a/src/templates/_nav.tpl
+++ b/src/templates/_nav.tpl
@@ -4,6 +4,5 @@
Catégories
Entrées
Sorties
- Recherche
diff --git a/src/templates/categories/materiels_par_categorie.tpl b/src/templates/categories/materiels_par_categorie.tpl
index f356113..f1dd46a 100644
--- a/src/templates/categories/materiels_par_categorie.tpl
+++ b/src/templates/categories/materiels_par_categorie.tpl
@@ -2,4 +2,79 @@
{include file="%s_nav.tpl"|args:$plugin_tpl current="categories"}
+{$cat_name}
+
+
+
+{if $eqmts_owned}
+
+
+
+ Matériel dont l'association est propriétaire |
+
+
+ Désignation |
+ Stock |
+ Sortie |
+ Disponible |
+
+
+
+ {foreach from=$eqmts_owned item="eqmt"}
+
+ {$eqmt.designation} |
+ {$eqmt.stock} |
+ {$eqmt.out_of_stock} |
+ {$eqmt.stock - $eqmt.out_of_stock} |
+
+ {/foreach}
+
+
+{/if}
+
+{if $eqmts_no_owned}
+
+
+
+ Matériel dont l'association n'est pas propriétaire (emprunté) |
+
+
+ Désignation |
+ Nombre |
+
+
+
+ {foreach from=$eqmts_no_owned item="eqmt"}
+
+ {$eqmt.designation} |
+ {$eqmt.no_owned} |
+
+ {/foreach}
+
+
+{/if}
+
+{if $eqmts_just_listed}
+
+
+
+ Matériel dont l'association n'est plus en possession |
+
+
+ Désignation |
+
+
+
+ {foreach from=$eqmts_just_listed item="eqmt"}
+
+ {$eqmt.designation} |
+
+
+ {/foreach}
+
+
+{/if}
+
+{linkbutton label="Retour" shape="export" href=$return_link}
+
{include file="admin/_foot.tpl"}
diff --git a/src/templates/index.tpl b/src/templates/index.tpl
index a4690fe..c4ed269 100644
--- a/src/templates/index.tpl
+++ b/src/templates/index.tpl
@@ -2,17 +2,22 @@
{include file="%s_nav.tpl"|args:$plugin_tpl current="index"}
-Matériel dont l'association est propriétaire
+Matériel dont l'association est propriétaire
+
+
+
{foreach from=$eqmts_owned_by_cat key='cat' item="eqmts"}
{if $eqmts}
- {$cat}
+
+ {$cat} |
+
Désignation |
- Stock |
- Sortie |
- Disponible |
+ Stock |
+ Sortie |
+ Disponible |
|
@@ -20,10 +25,10 @@
{foreach from=$eqmts item="eqmt"}
{$eqmt.designation} |
- {$eqmt.stock} |
- {$eqmt.out_of_stock} |
- {$eqmt.stock - $eqmt.out_of_stock} |
-
+ | {$eqmt.stock} |
+ {$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,15 +38,26 @@
{/if}
{/foreach}
-Matériel dont l'association n'est pas propriétaire (emprunté)
+
+
+
+
+
+
+Matériel dont l'association n'est pas propriétaire (emprunté)
+
+
+
{foreach from=$eqmts_no_owned_by_cat key='cat' item="eqmts"}
{if $eqmts}
- {$cat}
+
+ {$cat} |
+
Désignation |
- Nombre |
+ Nombre |
|
@@ -49,8 +65,8 @@
{foreach from=$eqmts item="eqmt"}
{$eqmt.designation} |
- {$eqmt.no_owned} |
-
+ | {$eqmt.no_owned} |
+
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
@@ -60,12 +76,23 @@
{/if}
{/foreach}
-Matériel dont l'association n'est plus en possession
+
+
+
+
+
+
+Matériel dont l'association n'est plus en possession
+
+
+
{foreach from=$eqmts_just_listed_by_cat key='cat' item="eqmts"}
{if $eqmts}
- {$cat}
+
+ {$cat} |
+
Désignation |
|
@@ -75,7 +102,7 @@
{foreach from=$eqmts item="eqmt"}
{$eqmt.designation} |
-
+ |
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
diff --git a/src/templates/recherche.tpl b/src/templates/recherche.tpl
deleted file mode 100644
index 894e6ed..0000000
--- a/src/templates/recherche.tpl
+++ /dev/null
@@ -1,5 +0,0 @@
-{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="recherche"}
-
-{include file="admin/_foot.tpl"}
diff --git a/src/www/admin/categories/materiels_par_categorie.php b/src/www/admin/categories/materiels_par_categorie.php
index 610d743..3aa5185 100644
--- a/src/www/admin/categories/materiels_par_categorie.php
+++ b/src/www/admin/categories/materiels_par_categorie.php
@@ -3,6 +3,7 @@
namespace Garradin;
use Garradin\Plugin\Materiels\Category;
+use Garradin\Plugin\Materiels\Equipment;
use Garradin\Utils;
require_once __DIR__ . '/../_inc.php';
@@ -15,6 +16,17 @@ if (!$c) {
throw new UserException("Cette catégorie n'existe pas.");
}
-$tpl->assign(compact('c'));
+$eqmts = $cat->listAllEquipments($c->id);
+
+$eqmt = new Equipment;
+
+list($eqmts_owned, $eqmts_no_owned, $eqmts_just_listed) = $eqmt->AllListsAll($eqmts);
+
+$cat_name = $c->name;
+
+$return_link = PLUGIN_URL . 'categories/index.php';
+
+$tpl->assign(compact(
+ 'cat_name', 'eqmts_owned', 'eqmts_no_owned', 'eqmts_just_listed', 'return_link'));
$tpl->display(PLUGIN_ROOT . '/templates/categories/materiels_par_categorie.tpl');
diff --git a/src/www/admin/recherche.php b/src/www/admin/recherche.php
deleted file mode 100644
index 189808f..0000000
--- a/src/www/admin/recherche.php
+++ /dev/null
@@ -1,7 +0,0 @@
-display(PLUGIN_ROOT . '/templates/recherche.tpl');