ok to display entries and equipments in templates
This commit is contained in:
parent
c74ba5ed85
commit
c3eb06ce0d
|
@ -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;');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;');
|
||||
|
|
|
@ -8,4 +8,23 @@
|
|||
{linkbutton shape="plus" label="Matériel déjà répertorié" href="deja_repertorie.php"}
|
||||
</fieldset>
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
<th>Date</th>
|
||||
<td>Type</td>
|
||||
<td>Nombre</td>
|
||||
<td>Matériel</td>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$entries item="entry"}
|
||||
<tr>
|
||||
<th>{$entry.date_of_entry}</th>
|
||||
<th>{$entry.kind}</th>
|
||||
<th>{$entry.number_of_equipments}</th>
|
||||
<th>{$entry.equipment.designation}</th>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
{include file="%s_nav.tpl"|args:$plugin_tpl current="index"}
|
||||
|
||||
<table class="list">
|
||||
<caption>Matériels</caption>
|
||||
<thead>
|
||||
<th>Nombre en stock</th>
|
||||
<td>Categorie</td>
|
||||
|
|
|
@ -24,10 +24,16 @@ if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
|
|||
Utils::redirect(PLUGIN_URL . 'categories/index.php');
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'categories/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');
|
||||
|
|
Loading…
Reference in New Issue