clean and comments for category templates and php files
This commit is contained in:
parent
5ee30cf9ed
commit
ff037ff75b
@ -76,4 +76,16 @@ class Entry
|
|||||||
$entry->equipment_id, $entry->equipment_number, $entry->entry_date);
|
$entry->equipment_id, $entry->equipment_number, $entry->entry_date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function AllDatesByEquipment($eqmt_id)
|
||||||
|
{
|
||||||
|
$entry_dates = DB::getInstance()->get(
|
||||||
|
'SELECT DISTINCT entry_date FROM plugin_materiels_entry WHERE equipment_id = ? ORDER BY entry_date DESC;', $eqmt_id);
|
||||||
|
$entry_dates_array = array();
|
||||||
|
foreach ($entry_dates as $row)
|
||||||
|
{
|
||||||
|
array_push($entry_dates_array, $row->entry_date);
|
||||||
|
}
|
||||||
|
return $entry_dates_array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,4 +91,16 @@ class Output
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function AllDatesByEquipment($eqmt_id)
|
||||||
|
{
|
||||||
|
$output_dates = DB::getInstance()->get(
|
||||||
|
'SELECT DISTINCT output_date FROM plugin_materiels_output WHERE equipment_id = ? ORDER BY output_date DESC;', $eqmt_id);
|
||||||
|
$output_dates_array = array();
|
||||||
|
foreach ($output_dates as $row)
|
||||||
|
{
|
||||||
|
array_push($output_dates_array, $row->output_date);
|
||||||
|
}
|
||||||
|
return $output_dates_array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,3 +31,15 @@ CREATE TABLE IF NOT EXISTS plugin_materiels_output (
|
|||||||
additional_comment varchar(255),
|
additional_comment varchar(255),
|
||||||
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE
|
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS plugin_materiels_movement (
|
||||||
|
id integer NOT NULL PRIMARY KEY autoincrement,
|
||||||
|
side boolean NOT NULL CHECK(side IN(0,1)), /*0 -> entry, 1 -> output*/
|
||||||
|
kind varchar(20) NOT NULL,
|
||||||
|
equipment_number integer NOT NULL,
|
||||||
|
equipment_id integer NOT NULL,
|
||||||
|
mvt_date date NOT NULL,
|
||||||
|
additional_comment varchar(255),
|
||||||
|
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
|
||||||
|
<!-- nav bar -->
|
||||||
<nav class="tabs">
|
<nav class="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="{if $current == 'index'}current{/if}"><a href="{plugin_url}">Inventaire</a></li>
|
<li class="{if $current_nav == 'index'}current{/if}"><a href="{plugin_url}">Inventaire</a></li>
|
||||||
<li class="{if $current == 'categories'}current{/if}"><a href="{plugin_url file="categories/index.php"}">Catégories</a></li>
|
<li class="{if $current_nav == 'categories'}current{/if}"><a href="{plugin_url file="categories/index.php"}">Catégories</a></li>
|
||||||
<li class="{if $current == 'entrees'}current{/if}"><a href="{plugin_url file="entrees/index.php"}">Entrées</a></li>
|
<li class="{if $current_nav == 'entrees'}current{/if}"><a href="{plugin_url file="entrees/index.php"}">Entrées</a></li>
|
||||||
<li class="{if $current == 'sorties'}current{/if}"><a href="{plugin_url file="sorties/index.php"}">Sorties</a></li>
|
<li class="{if $current_nav == 'sorties'}current{/if}"><a href="{plugin_url file="sorties/index.php"}">Sorties</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
<!-- -->
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
|
<!-- nav bar -->
|
||||||
|
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="categories"}
|
||||||
{include file="%s_nav.tpl"|args:$plugin_tpl current="categories"}
|
<!-- -->
|
||||||
|
<!-- add form -->
|
||||||
<form method="post" action="{$self_url}">
|
<form method="post" action="{$self_url}">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Ajouter une catégorie</legend>
|
<legend>Ajouter une catégorie</legend>
|
||||||
@ -15,7 +15,8 @@
|
|||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
<!-- -->
|
||||||
|
<!-- table with list of categories -->
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<th><b>Nom</b></th>
|
<th><b>Nom</b></th>
|
||||||
@ -34,5 +35,7 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<!-- -->
|
||||||
|
<!-- footer -->
|
||||||
{include file="admin/_foot.tpl"}
|
{include file="admin/_foot.tpl"}
|
||||||
|
<!-- -->
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
|
<!-- nav bar -->
|
||||||
|
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="categories"}
|
||||||
{include file="%s_nav.tpl"|args:$plugin_tpl current="categories"}
|
<!-- -->
|
||||||
|
<!-- title -->
|
||||||
<h2 style="text-align: center;">{$cat_name}</h2>
|
<h2 style="text-align: center;">{$cat_name}</h2>
|
||||||
|
<!-- -->
|
||||||
<br>
|
<br>
|
||||||
|
<!-- table with list of equipments owned -->
|
||||||
{if $eqmts_owned}
|
{if $eqmts_owned}
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -31,7 +31,8 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
|
<!-- -->
|
||||||
|
<!-- table with list of equipments no owned -->
|
||||||
{if $eqmts_no_owned}
|
{if $eqmts_no_owned}
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -53,7 +54,8 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
|
<!-- -->
|
||||||
|
<!-- table with list of equipments just listed -->
|
||||||
{if $eqmts_just_listed}
|
{if $eqmts_just_listed}
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -74,7 +76,8 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
|
<!-- -->
|
||||||
{linkbutton label="Retour" shape="export" href=$return_link}
|
{linkbutton label="Retour" shape="export" href=$return_link}
|
||||||
|
<!-- footer -->
|
||||||
{include file="admin/_foot.tpl"}
|
{include file="admin/_foot.tpl"}
|
||||||
|
<!-- -->
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
|
<!-- nav bar -->
|
||||||
|
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="categories"}
|
||||||
{include file="%s_nav.tpl"|args:$plugin_tpl current="categories"}
|
<!-- -->
|
||||||
|
<!-- edit form -->
|
||||||
<form method="post" action="{$self_url}" data-focus="1">
|
<form method="post" action="{$self_url}" data-focus="1">
|
||||||
{form_errors}
|
{form_errors}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Modifier cette catégorie</legend>
|
<legend>Modifier cette catégorie</legend>
|
||||||
<dl>
|
<dl>
|
||||||
{input type="text" name="name" label="Nom" required=true source=$c maxlength="100"}
|
{input type="text" name="name" label="Nom" required=true source=$cat_requested maxlength="100"}
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
@ -16,5 +16,7 @@
|
|||||||
{linkbutton label="Annuler" shape="export" href=$cancel_link}
|
{linkbutton label="Annuler" shape="export" href=$cancel_link}
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
<!-- -->
|
||||||
|
<!-- footer -->
|
||||||
{include file="admin/_foot.tpl"}
|
{include file="admin/_foot.tpl"}
|
||||||
|
<!-- -->
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
|
<!-- nav bar -->
|
||||||
|
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="categories"}
|
||||||
{include file="%s_nav.tpl"|args:$plugin_tpl current="categories"}
|
<!-- -->
|
||||||
|
<!-- delete form -->
|
||||||
{include file="%scommon/delete_form.tpl"|args:$plugin_tpl
|
{include file="%scommon/delete_form.tpl"|args:$plugin_tpl
|
||||||
legend="Supprimer cette catégorie de matériels ?"
|
legend="Supprimer cette catégorie de matériels ?"
|
||||||
warning="Êtes-vous sûr de vouloir supprimer la catégorie « %s » ?"|args:$c.name
|
warning="Êtes-vous sûr de vouloir supprimer la catégorie « %s » ?"|args:$cat_requested.name
|
||||||
alert="Attention, la catégorie ne doit plus contenir de matériels pour pouvoir être supprimée."
|
alert="Attention, la catégorie ne doit plus contenir de matériels pour pouvoir être supprimée."
|
||||||
}
|
}
|
||||||
|
<!-- -->
|
||||||
|
<!-- footer -->
|
||||||
{include file="admin/_foot.tpl"}
|
{include file="admin/_foot.tpl"}
|
||||||
|
<!-- -->
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<!-- delete form -->
|
||||||
<form method="post" action="{$self_url}" data-focus="1">
|
<form method="post" action="{$self_url}" data-focus="1">
|
||||||
{form_errors}
|
{form_errors}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@ -13,3 +14,4 @@
|
|||||||
{linkbutton label="Annuler" shape="export" href=$cancel_link}
|
{linkbutton label="Annuler" shape="export" href=$cancel_link}
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
<!-- -->
|
||||||
|
9
src/templates/historique.tpl
Normal file
9
src/templates/historique.tpl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{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="index"}
|
||||||
|
|
||||||
|
{foreach from=$all_dates item='date'}
|
||||||
|
<p>{$date}</p>
|
||||||
|
{/foreach}
|
||||||
|
|
||||||
|
{include file="admin/_foot.tpl"}
|
@ -1,6 +1,4 @@
|
|||||||
{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_nav="index"}
|
||||||
|
|
||||||
{include file="%s_nav.tpl"|args:$plugin_tpl current="index"}
|
|
||||||
|
|
||||||
<h2 style="text-align: center;">Matériel dont l'association est propriétaire</h2>
|
<h2 style="text-align: center;">Matériel dont l'association est propriétaire</h2>
|
||||||
|
|
||||||
@ -29,6 +27,7 @@
|
|||||||
<td style="text-align: center;">{$eqmt.out_of_stock}</td>
|
<td style="text-align: center;">{$eqmt.out_of_stock}</td>
|
||||||
<td style="text-align: center;">{$eqmt.stock - $eqmt.out_of_stock}</td>
|
<td style="text-align: center;">{$eqmt.stock - $eqmt.out_of_stock}</td>
|
||||||
<td class="actions" style="text-align: center;">
|
<td class="actions" style="text-align: center;">
|
||||||
|
{linkbutton shape="edit" label="Historique des entrées / sorties" href="historique.php?id=%d"|args:$eqmt.id}
|
||||||
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -67,6 +66,7 @@
|
|||||||
<td>{$eqmt.designation}</td>
|
<td>{$eqmt.designation}</td>
|
||||||
<td style="text-align: center;">{$eqmt.no_owned}</td>
|
<td style="text-align: center;">{$eqmt.no_owned}</td>
|
||||||
<td class="actions" style="text-align: center;">
|
<td class="actions" style="text-align: center;">
|
||||||
|
{linkbutton shape="edit" label="Historique des entrées / sorties" href="historique.php?id=%d"|args:$eqmt.id}
|
||||||
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -103,6 +103,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{$eqmt.designation}</td>
|
<td>{$eqmt.designation}</td>
|
||||||
<td class="actions" style="text-align: center;">
|
<td class="actions" style="text-align: center;">
|
||||||
|
{linkbutton shape="edit" label="Historique des entrées / sorties" href="historique.php?id=%d"|args:$eqmt.id}
|
||||||
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
9
src/www/admin/categories/_inc.php
Normal file
9
src/www/admin/categories/_inc.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// create variable with Category class
|
||||||
|
|
||||||
|
namespace Garradin;
|
||||||
|
|
||||||
|
use Garradin\Plugin\Materiels\Category;
|
||||||
|
|
||||||
|
$cat = new Category;
|
@ -2,17 +2,18 @@
|
|||||||
|
|
||||||
namespace Garradin;
|
namespace Garradin;
|
||||||
|
|
||||||
use Garradin\Plugin\Materiels\Category;
|
require_once __DIR__ . '/../_inc.php';
|
||||||
|
require_once __DIR__ . '/_inc.php';
|
||||||
|
|
||||||
use Garradin\Utils;
|
use Garradin\Utils;
|
||||||
|
|
||||||
require_once __DIR__ . '/../_inc.php';
|
// check if add form is submitted
|
||||||
|
|
||||||
$cat = new Category;
|
|
||||||
|
|
||||||
$csrf_key = 'cat_create';
|
$csrf_key = 'cat_create';
|
||||||
|
|
||||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||||
{
|
{
|
||||||
|
// try to add new category and if error catched add it in form
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$cat->add([
|
$cat->add([
|
||||||
@ -32,6 +33,8 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the list of all categories and send it to template
|
||||||
|
|
||||||
$list = $cat->listAll();
|
$list = $cat->listAll();
|
||||||
|
|
||||||
$tpl->assign(compact('csrf_key', 'list'));
|
$tpl->assign(compact('csrf_key', 'list'));
|
||||||
|
@ -2,30 +2,35 @@
|
|||||||
|
|
||||||
namespace Garradin;
|
namespace Garradin;
|
||||||
|
|
||||||
use Garradin\Plugin\Materiels\Category;
|
|
||||||
use Garradin\Plugin\Materiels\Equipment;
|
|
||||||
use Garradin\Utils;
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../_inc.php';
|
require_once __DIR__ . '/../_inc.php';
|
||||||
|
require_once __DIR__ . '/_inc.php';
|
||||||
|
|
||||||
$cat = new Category;
|
use Garradin\Plugin\Materiels\Equipment;
|
||||||
|
|
||||||
$c = $cat->get((int) qg('id'));
|
// get the category requested and his name
|
||||||
|
|
||||||
if (!$c) {
|
$cat_requested = $cat->get((int) qg('id'));
|
||||||
|
|
||||||
|
if (!$cat_requested) {
|
||||||
throw new UserException("Cette catégorie n'existe pas.");
|
throw new UserException("Cette catégorie n'existe pas.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$eqmts = $cat->listAllEquipments($c->id);
|
$cat_name = $cat_requested->name;
|
||||||
|
|
||||||
|
// get the list of all equipments for the requested category
|
||||||
|
|
||||||
|
$eqmts = $cat->listAllEquipments($cat_requested->id);
|
||||||
|
|
||||||
|
// get all lists of equipments founded
|
||||||
|
|
||||||
$eqmt = new Equipment;
|
$eqmt = new Equipment;
|
||||||
|
|
||||||
list($eqmts_owned, $eqmts_no_owned, $eqmts_just_listed) = $eqmt->AllListsAll($eqmts);
|
list($eqmts_owned, $eqmts_no_owned, $eqmts_just_listed) = $eqmt->AllListsAll($eqmts);
|
||||||
|
|
||||||
$cat_name = $c->name;
|
|
||||||
|
|
||||||
$return_link = PLUGIN_URL . 'categories/index.php';
|
$return_link = PLUGIN_URL . 'categories/index.php';
|
||||||
|
|
||||||
|
// send to template the category's name and all lists of its equipment
|
||||||
|
|
||||||
$tpl->assign(compact(
|
$tpl->assign(compact(
|
||||||
'cat_name', 'eqmts_owned', 'eqmts_no_owned', 'eqmts_just_listed', 'return_link'));
|
'cat_name', 'eqmts_owned', 'eqmts_no_owned', 'eqmts_just_listed', 'return_link'));
|
||||||
|
|
||||||
|
@ -1,26 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Garradin;
|
namespace Garradin;
|
||||||
use Garradin\Plugin\Materiels\Category;
|
|
||||||
use Garradin\Utils;
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../_inc.php';
|
require_once __DIR__ . '/../_inc.php';
|
||||||
|
require_once __DIR__ . '/_inc.php';
|
||||||
|
|
||||||
$cat = new Category;
|
use Garradin\Utils;
|
||||||
|
|
||||||
$c = $cat->get((int) qg('id'));
|
// get the category requested
|
||||||
|
|
||||||
if (!$c) {
|
$cat_requested = $cat->get((int) qg('id'));
|
||||||
|
|
||||||
|
if (!$cat_requested) {
|
||||||
throw new UserException("Cette catégorie n'existe pas.");
|
throw new UserException("Cette catégorie n'existe pas.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$csrf_key = 'edit_category_' . $c->id;
|
// check if edit form is submitted
|
||||||
|
|
||||||
|
$csrf_key = 'edit_category_' . $cat_requested->id;
|
||||||
|
|
||||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||||
{
|
{
|
||||||
|
// try to edit category selected and if error catched add it in form
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$cat->edit($c->id, [
|
$cat->edit($cat_requested->id, [
|
||||||
'name' => ucfirst(f('name'))
|
'name' => ucfirst(f('name'))
|
||||||
]);
|
]);
|
||||||
Utils::redirect(PLUGIN_URL . 'categories/index.php');
|
Utils::redirect(PLUGIN_URL . 'categories/index.php');
|
||||||
@ -39,6 +43,8 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
|||||||
|
|
||||||
$cancel_link = PLUGIN_URL . 'categories/index.php';
|
$cancel_link = PLUGIN_URL . 'categories/index.php';
|
||||||
|
|
||||||
$tpl->assign(compact('c', 'csrf_key', 'cancel_link'));
|
// send to template the category requested
|
||||||
|
|
||||||
|
$tpl->assign(compact('cat_requested', 'csrf_key', 'cancel_link'));
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/categories/modifier_categorie.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/categories/modifier_categorie.tpl');
|
||||||
|
@ -1,26 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Garradin;
|
namespace Garradin;
|
||||||
use Garradin\Plugin\Materiels\Category;
|
|
||||||
use Garradin\Utils;
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../_inc.php';
|
require_once __DIR__ . '/../_inc.php';
|
||||||
|
require_once __DIR__ . '/_inc.php';
|
||||||
|
|
||||||
$cat = new Category;
|
use Garradin\Utils;
|
||||||
|
|
||||||
$c = $cat->get((int) qg('id'));
|
// get the category selected
|
||||||
|
|
||||||
if (!$c) {
|
$cat_requested = $cat->get((int) qg('id'));
|
||||||
|
|
||||||
|
if (!$cat_requested) {
|
||||||
throw new UserException("Cette catégorie n'existe pas.");
|
throw new UserException("Cette catégorie n'existe pas.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$csrf_key = 'delete_category_' . $c->id;
|
// check if delete form is submitted
|
||||||
|
|
||||||
|
$csrf_key = 'delete_category_' . $cat_requested->id;
|
||||||
|
|
||||||
if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
|
if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$cat->delete($c->id);
|
// try to delete category selected and if error catched add it in form
|
||||||
|
$cat->delete($cat_requested->id);
|
||||||
Utils::redirect(PLUGIN_URL . 'categories/index.php');
|
Utils::redirect(PLUGIN_URL . 'categories/index.php');
|
||||||
}
|
}
|
||||||
catch (\RuntimeException $e)
|
catch (\RuntimeException $e)
|
||||||
@ -37,6 +41,8 @@ if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
|
|||||||
|
|
||||||
$cancel_link = PLUGIN_URL . 'categories/index.php';
|
$cancel_link = PLUGIN_URL . 'categories/index.php';
|
||||||
|
|
||||||
$tpl->assign(compact('c', 'csrf_key', 'cancel_link'));
|
// send to template the category requested
|
||||||
|
|
||||||
|
$tpl->assign(compact('cat_requested', 'csrf_key', 'cancel_link'));
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/categories/supprimer_categorie.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/categories/supprimer_categorie.tpl');
|
||||||
|
25
src/www/admin/historique.php
Normal file
25
src/www/admin/historique.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Garradin;
|
||||||
|
use Garradin\Plugin\Materiels\Equipment;
|
||||||
|
use Garradin\Plugin\Materiels\Entry;
|
||||||
|
use Garradin\Plugin\Materiels\Output;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/_inc.php';
|
||||||
|
|
||||||
|
$eqmt = new Equipment;
|
||||||
|
$entry = new Entry;
|
||||||
|
$output = new Output;
|
||||||
|
|
||||||
|
$eq = $eqmt->get((int) qg('id'));
|
||||||
|
|
||||||
|
$entry_dates = $entry->AllDatesByEquipment($eq->id);
|
||||||
|
$output_dates = $output->AllDatesByEquipment($eq->id);
|
||||||
|
$all_dates = array_unique(array_merge(
|
||||||
|
$entry_dates, $output_dates), SORT_REGULAR);
|
||||||
|
|
||||||
|
sort($all_dates);
|
||||||
|
|
||||||
|
$tpl->assign(compact('all_dates'));
|
||||||
|
|
||||||
|
$tpl->display(PLUGIN_ROOT . '/templates/historique.tpl');
|
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Garradin;
|
|
||||||
|
|
||||||
require_once __DIR__ . '/_inc.php';
|
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/sorties.tpl');
|
|
Loading…
Reference in New Issue
Block a user