diff --git a/src/lib/Entry.php b/src/lib/Entry.php
index 94e0dc2..0984aa2 100644
--- a/src/lib/Entry.php
+++ b/src/lib/Entry.php
@@ -27,4 +27,9 @@ class Entry // entrées définitives
{
DB::getInstance()->insert('plugin_materiels_entry', $data);
}
+
+ public function listAll()
+ {
+ return DB::getInstance()->get('SELECT * FROM plugin_materiels_entry ORDER BY date_of_entry DESC;');
+ }
}
diff --git a/src/lib/Equipment.php b/src/lib/Equipment.php
index f35a4ff..3e0d3de 100644
--- a/src/lib/Equipment.php
+++ b/src/lib/Equipment.php
@@ -20,6 +20,11 @@ class Equipment
return $db->lastInsertRowId();
}
+ public function get($id)
+ {
+ return DB::getInstance()->first('SELECT * FROM plugin_materiels_equipment WHERE id = ?;', $id);
+ }
+
public function listAll()
{
return DB::getInstance()->get('SELECT * FROM plugin_materiels_equipment ORDER BY designation;');
diff --git a/src/templates/entrees/definitives/index.tpl b/src/templates/entrees/definitives/index.tpl
index e09f9d8..a31691e 100644
--- a/src/templates/entrees/definitives/index.tpl
+++ b/src/templates/entrees/definitives/index.tpl
@@ -8,4 +8,23 @@
{linkbutton shape="plus" label="Matériel déjà répertorié" href="deja_repertorie.php"}
+
+
+ Date |
+ Type |
+ Nombre |
+ Matériel |
+
+
+ {foreach from=$entries item="entry"}
+
+ {$entry.date_of_entry} |
+ {$entry.kind} |
+ {$entry.number_of_equipments} |
+ {$entry.equipment.designation} |
+
+ {/foreach}
+
+
+
{include file="admin/_foot.tpl"}
diff --git a/src/templates/index.tpl b/src/templates/index.tpl
index 058e310..acb3416 100644
--- a/src/templates/index.tpl
+++ b/src/templates/index.tpl
@@ -3,7 +3,6 @@
{include file="%s_nav.tpl"|args:$plugin_tpl current="index"}
- Matériels
Nombre en stock |
Categorie |
diff --git a/src/www/admin/categories/supprimer_categorie.php b/src/www/admin/categories/supprimer_categorie.php
index d59b8af..00cedf4 100644
--- a/src/www/admin/categories/supprimer_categorie.php
+++ b/src/www/admin/categories/supprimer_categorie.php
@@ -25,7 +25,13 @@ if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
}
catch (\RuntimeException $e)
{
- $form->addError($e->getMessage());
+ if (strstr($e->getMessage(), 'FOREIGN KEY constraint failed'))
+ {
+ $form->addError('Cette catégorie contient des matériels et ne peut donc pas être supprimée.');
+ } else
+ {
+ $form->addError($e->getMessage());
+ }
}
}
diff --git a/src/www/admin/entrees/definitives/index.php b/src/www/admin/entrees/definitives/index.php
index 2f4b03c..db76ecb 100644
--- a/src/www/admin/entrees/definitives/index.php
+++ b/src/www/admin/entrees/definitives/index.php
@@ -2,6 +2,20 @@
namespace Garradin;
+use Garradin\Plugin\Materiels\Equipment;
+use Garradin\Plugin\Materiels\Entry;
+
require_once __DIR__ . '/../../_inc.php';
+$eqmt = new Equipment;
+$entry = new Entry;
+
+$entries = $entry->listAll();
+
+foreach ($entries as $key => $value) {
+ $entries[$key]->equipment = $eqmt->get($value->equipment_id);
+}
+
+$tpl->assign(compact('entries'));
+
$tpl->display(PLUGIN_ROOT . '/templates/entrees/definitives/index.tpl');