diff --git a/src/lib/Equipment.php b/src/lib/Equipment.php
index b72757c..f35a4ff 100644
--- a/src/lib/Equipment.php
+++ b/src/lib/Equipment.php
@@ -9,7 +9,6 @@ class Equipment
protected $columns_order = array(
'id',
'category_id',
- 'location_id',
'number_of_equipments',
'designation'
);
@@ -20,4 +19,9 @@ class Equipment
$db->insert('plugin_materiels_equipment', $data);
return $db->lastInsertRowId();
}
+
+ public function listAll()
+ {
+ return DB::getInstance()->get('SELECT * FROM plugin_materiels_equipment ORDER BY designation;');
+ }
}
diff --git a/src/lib/Location.php b/src/lib/Location.php
deleted file mode 100644
index 886fe41..0000000
--- a/src/lib/Location.php
+++ /dev/null
@@ -1,40 +0,0 @@
-insert('plugin_materiels_location', $data);
- }
-
- public function edit($id, $data = [])
- {
- $db = DB::getInstance();
- $db->update('plugin_materiels_location', $data, $db->where('id', $id));
- }
-
-
- public function delete($id)
- {
- DB::getInstance()->delete('plugin_materiels_location', 'id = ' . $id);
- }
-
- public function get($id)
- {
- return DB::getInstance()->first('SELECT * FROM plugin_materiels_location WHERE id = ?;', $id);
- }
-
- public function listAll()
- {
- return DB::getInstance()->get('SELECT * FROM plugin_materiels_location ORDER BY name;');
- }
-}
diff --git a/src/schema.sql b/src/schema.sql
index 639d70a..27d23fc 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -4,21 +4,13 @@ CREATE TABLE IF NOT EXISTS plugin_materiels_category (
CONSTRAINT u_category_name UNIQUE ( name )
);
-CREATE TABLE IF NOT EXISTS plugin_materiels_location (
- id integer NOT NULL PRIMARY KEY autoincrement,
- name varchar(100) NOT NULL,
- CONSTRAINT u_location_name UNIQUE ( name )
-);
-
CREATE TABLE IF NOT EXISTS plugin_materiels_equipment (
id integer NOT NULL PRIMARY KEY autoincrement,
category_id integer NOT NULL,
- location_id integer NOT NULL,
number_of_equipments integer NOT NULL,
designation varchar(255) NOT NULL,
CONSTRAINT u_equipment_designation UNIQUE ( designation ),
- FOREIGN KEY ( category_id ) REFERENCES plugin_materiels_category( id ) ON DELETE RESTRICT ON UPDATE CASCADE,
- FOREIGN KEY ( localisation_id ) REFERENCES plugin_materiels_location( id ) ON DELETE RESTRICT ON UPDATE CASCADE
+ FOREIGN KEY ( category_id ) REFERENCES plugin_materiels_category( id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_entry (
diff --git a/src/templates/_nav.tpl b/src/templates/_nav.tpl
index 4a3f698..9ed7323 100644
--- a/src/templates/_nav.tpl
+++ b/src/templates/_nav.tpl
@@ -2,7 +2,6 @@
- Stock
- Catégories
- - Localisations
- Entrées définitives
- Entrées provisoires
- Sorties définitives
diff --git a/src/templates/entrees/definitives/non_repertorie.tpl b/src/templates/entrees/definitives/non_repertorie.tpl
index 02c297f..9a87bec 100644
--- a/src/templates/entrees/definitives/non_repertorie.tpl
+++ b/src/templates/entrees/definitives/non_repertorie.tpl
@@ -28,14 +28,6 @@
{/foreach}
-
- - (obligatoire)
- -
-
{input type="text" name="designation" label="Désignation" required=true maxlength="255"}
diff --git a/src/templates/index.tpl b/src/templates/index.tpl
index 6b73859..058e310 100644
--- a/src/templates/index.tpl
+++ b/src/templates/index.tpl
@@ -2,4 +2,22 @@
{include file="%s_nav.tpl"|args:$plugin_tpl current="index"}
+
+ Matériels
+
+ Nombre en stock |
+ Categorie |
+ Désignation |
+
+
+ {foreach from=$eqmts item="eqmt"}
+
+ {$eqmt.number_of_equipments} |
+ {$eqmt.category.name} |
+ {$eqmt.designation} |
+
+ {/foreach}
+
+
+
{include file="admin/_foot.tpl"}
diff --git a/src/templates/localisations/index.tpl b/src/templates/localisations/index.tpl
deleted file mode 100644
index 6bd7593..0000000
--- a/src/templates/localisations/index.tpl
+++ /dev/null
@@ -1,38 +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="localisations"}
-
-
-
-
-
- Nom |
- |
-
-
- {foreach from=$list item="loc"}
-
- {$loc.name} |
-
- {linkbutton shape="upload" label="Liste des matériels" href="materiels_par_localisation.php?id=%d"|args:$loc.id}
- {linkbutton shape="edit" label="Modifier" href="modifier_localisation.php?id=%d"|args:$loc.id}
- {linkbutton shape="delete" label="Supprimer" href="supprimer_localisation.php?id=%d"|args:$loc.id}
- |
-
- {/foreach}
-
-
-
-{include file="admin/_foot.tpl"}
diff --git a/src/templates/localisations/materiels_par_localisation.tpl b/src/templates/localisations/materiels_par_localisation.tpl
deleted file mode 100644
index f16a6db..0000000
--- a/src/templates/localisations/materiels_par_localisation.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="localisations"}
-
-{include file="admin/_foot.tpl"}
diff --git a/src/templates/localisations/modifier_localisation.tpl b/src/templates/localisations/modifier_localisation.tpl
deleted file mode 100644
index 80320e3..0000000
--- a/src/templates/localisations/modifier_localisation.tpl
+++ /dev/null
@@ -1,20 +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="localisations"}
-
-
-
-{include file="admin/_foot.tpl"}
diff --git a/src/templates/localisations/supprimer_localisation.tpl b/src/templates/localisations/supprimer_localisation.tpl
deleted file mode 100644
index a6a1bb1..0000000
--- a/src/templates/localisations/supprimer_localisation.tpl
+++ /dev/null
@@ -1,11 +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="localisations"}
-
-{include file="%scommon/delete_form.tpl"|args:$plugin_tpl
- legend="Supprimer cette localisation de matériels ?"
- warning="Êtes-vous sûr de vouloir supprimer la localisation « %s » ?"|args:$l.name
- alert="Attention, la localisation ne doit plus contenir de matériels pour pouvoir être supprimée."
-}
-
-{include file="admin/_foot.tpl"}
diff --git a/src/www/admin/entrees/definitives/non_repertorie.php b/src/www/admin/entrees/definitives/non_repertorie.php
index 56d59f8..bc57deb 100644
--- a/src/www/admin/entrees/definitives/non_repertorie.php
+++ b/src/www/admin/entrees/definitives/non_repertorie.php
@@ -4,7 +4,6 @@ namespace Garradin;
use Garradin\Plugin\Materiels\Entry;
use Garradin\Plugin\Materiels\Category;
-use Garradin\Plugin\Materiels\Location;
use Garradin\Plugin\Materiels\Equipment;
use Garradin\Utils;
@@ -24,10 +23,6 @@ $cat = new Category;
$cats = $cat->listAll();
$selected_cat = $cats[0]->id;
-$loc = new Location;
-$locs = $loc->listAll();
-$selected_loc = $locs[0]->id;
-
$csrf_key = 'add_entry';
if (f('save'))
@@ -36,7 +31,6 @@ if (f('save'))
$default_date = f('date_entree');
$default_number = f('number');
$selected_cat = f('category_id');
- $selected_loc = f('location_id');
if ($form->check($csrf_key) && !$form->hasErrors())
{
@@ -45,7 +39,6 @@ if (f('save'))
$eqmt = new Equipment;
$eqmt_id = $eqmt->add([
'category_id' => (int) f('category_id'),
- 'location_id' => (int) f('location_id'),
'number_of_equipments' => (int) f('number'),
'designation' => ucfirst(strtolower(f('designation'))),
]);
@@ -72,6 +65,6 @@ if (f('save'))
$cancel_link = PLUGIN_URL . 'entrees/definitives/index.php';
-$tpl->assign(compact('kinds', 'date', 'cats', 'locs', 'selected_kind', 'default_date', 'default_number', 'selected_cat', 'selected_loc', 'cancel_link', 'csrf_key'));
+$tpl->assign(compact('kinds', 'date', 'cats', 'selected_kind', 'default_date', 'default_number', 'selected_cat', 'cancel_link', 'csrf_key'));
$tpl->display(PLUGIN_ROOT . '/templates/entrees/definitives/non_repertorie.tpl');
diff --git a/src/www/admin/entrees_definitives.php b/src/www/admin/entrees_definitives.php
deleted file mode 100644
index bddb547..0000000
--- a/src/www/admin/entrees_definitives.php
+++ /dev/null
@@ -1,7 +0,0 @@
-display(PLUGIN_ROOT . '/templates/entrees_definitives.tpl');
diff --git a/src/www/admin/index.php b/src/www/admin/index.php
index 767f302..8248e3f 100644
--- a/src/www/admin/index.php
+++ b/src/www/admin/index.php
@@ -7,6 +7,20 @@ if ($plugin->needUpgrade())
$plugin->upgrade();
}
+use Garradin\Plugin\Materiels\Equipment;
+use Garradin\Plugin\Materiels\Category;
+
require_once __DIR__ . '/_inc.php';
+$eqmt = new Equipment;
+$cat = new Category;
+
+$eqmts = $eqmt->listAll();
+
+foreach ($eqmts as $key => $value) {
+ $eqmts[$key]->category = $cat->get($value->category_id);
+}
+
+$tpl->assign(compact('eqmts'));
+
$tpl->display(PLUGIN_ROOT . '/templates/index.tpl');
diff --git a/src/www/admin/localisations/index.php b/src/www/admin/localisations/index.php
deleted file mode 100644
index 416a923..0000000
--- a/src/www/admin/localisations/index.php
+++ /dev/null
@@ -1,39 +0,0 @@
-check($csrf_key) && !$form->hasErrors())
-{
- try
- {
- $loc->add([
- 'name' => ucfirst(f('name'))
- ]);
- Utils::redirect(PLUGIN_URL . 'localisations/index.php');
- }
- catch (\RuntimeException $e)
- {
- if (strstr($e->getMessage(), 'UNIQUE constraint failed'))
- {
- $form->addError('Cette localisation existe déjà.');
- } else
- {
- $form->addError($e->getMessage());
- }
- }
-}
-
-$list = $loc->listAll();
-
-$tpl->assign(compact('csrf_key', 'list'));
-
-$tpl->display(PLUGIN_ROOT . '/templates/localisations/index.tpl');
diff --git a/src/www/admin/localisations/materiels_par_localisation.php b/src/www/admin/localisations/materiels_par_localisation.php
deleted file mode 100644
index 10190e6..0000000
--- a/src/www/admin/localisations/materiels_par_localisation.php
+++ /dev/null
@@ -1,20 +0,0 @@
-get((int) qg('id'));
-
-if (!$l) {
- throw new UserException("Cette localisation n'existe pas.");
-}
-
-$tpl->assign(compact('l'));
-
-$tpl->display(PLUGIN_ROOT . '/templates/localisations/materiels_par_localisation.tpl');
diff --git a/src/www/admin/localisations/modifier_localisation.php b/src/www/admin/localisations/modifier_localisation.php
deleted file mode 100644
index fdf9d21..0000000
--- a/src/www/admin/localisations/modifier_localisation.php
+++ /dev/null
@@ -1,44 +0,0 @@
-get((int) qg('id'));
-
-if (!$l) {
- throw new UserException("Cette localisation n'existe pas.");
-}
-
-$csrf_key = 'edit_location_' . $l->id;
-
-if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
-{
- try
- {
- $loc->edit($l->id, [
- 'name' => ucfirst(f('name'))
- ]);
- Utils::redirect(PLUGIN_URL . 'localisations/index.php');
- }
- catch (\RuntimeException $e)
- {
- if (strstr($e->getMessage(), 'UNIQUE constraint failed'))
- {
- $form->addError('Cette localisation existe déjà.');
- } else
- {
- $form->addError($e->getMessage());
- }
- }
-}
-
-$cancel_link = PLUGIN_URL . 'localisations/index.php';
-
-$tpl->assign(compact('l', 'csrf_key', 'cancel_link'));
-
-$tpl->display(PLUGIN_ROOT . '/templates/localisations/modifier_localisation.tpl');
diff --git a/src/www/admin/localisations/supprimer_localisation.php b/src/www/admin/localisations/supprimer_localisation.php
deleted file mode 100644
index 5aa585f..0000000
--- a/src/www/admin/localisations/supprimer_localisation.php
+++ /dev/null
@@ -1,36 +0,0 @@
-get((int) qg('id'));
-
-if (!$l) {
- throw new UserException("Cette localisation n'existe pas.");
-}
-
-$csrf_key = 'delete_location_' . $l->id;
-
-if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
-{
- try
- {
- $loc->delete($l->id);
- Utils::redirect(PLUGIN_URL . 'localisations/index.php');
- }
- catch (\RuntimeException $e)
- {
- $form->addError($e->getMessage());
- }
-}
-
-$cancel_link = PLUGIN_URL . 'localisations/index.php';
-
-$tpl->assign(compact('l', 'csrf_key', 'cancel_link'));
-
-$tpl->display(PLUGIN_ROOT . '/templates/localisations/supprimer_localisation.tpl');