add tpl and php for return of rent in entries
This commit is contained in:
parent
54858e2d18
commit
08e2af1f1d
BIN
materiels.tar.gz
BIN
materiels.tar.gz
Binary file not shown.
|
@ -13,7 +13,6 @@ class Entry
|
|||
'Don',
|
||||
'Récupération',
|
||||
'Location / Prêt',
|
||||
'Retour de location / prêt',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,17 +4,19 @@
|
|||
|
||||
<form method="post" action="{$self_url}">
|
||||
<fieldset>
|
||||
<legend>Ajouter une entrée d'un matériel {$legend_part} répertorié</legend>
|
||||
<legend>Ajouter une entrée d'un matériel {$legend_part}</legend>
|
||||
{form_errors}
|
||||
<dl>
|
||||
<dt><label for="f_kind">Type</label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="kind" id="f_kind">
|
||||
{foreach from=$kinds item="kind"}
|
||||
<option value="{$kind}"{if $selected_kind == $kind} selected="selected"{/if}>{$kind}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
{if $tpl_materiel_name != 'retour'}
|
||||
<dt><label for="f_kind">Type</label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="kind" id="f_kind">
|
||||
{foreach from=$kinds item="kind"}
|
||||
<option value="{$kind}"{if $selected_kind == $kind} selected="selected"{/if}>{$kind}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
{/if}
|
||||
{input type="date" name="entry_date" default=$default_date label="Date d'entrée" required=true }
|
||||
{input type="number" name="equipment_number" label="Nombre" required=true step="1" min="1" default=$default_number}
|
||||
</dl>
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
<fieldset>
|
||||
<legend>Ajouter une entrée pour du </legend>
|
||||
{linkbutton shape="plus" label="Matériel pas encore répertorié" href="non_repertorie.php"}
|
||||
{linkbutton shape="plus" label="Matériel déjà répertorié" href="deja_repertorie.php"}
|
||||
{linkbutton shape="plus" label="Matériel répertorié" href="repertorie.php"}
|
||||
{linkbutton shape="plus" label="Matériel non répertorié" href="non_repertorie.php"}
|
||||
{linkbutton shape="plus" label="Matériel en retour de location / prêt" href="retour.php"}
|
||||
</fieldset>
|
||||
|
||||
{if $entries}
|
||||
|
@ -23,7 +24,7 @@
|
|||
<td>{$entry.entry_date}</td>
|
||||
<td>{$entry.kind}</td>
|
||||
<td>{$entry.equipment_number}</td>
|
||||
<td>{$entry.equipment.designation}</td>
|
||||
<td>{$entry.equipment}</td>
|
||||
<td>{$entry.additional_comment}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<fieldset>
|
||||
<legend><h3>Matériel</h3></legend>
|
||||
<dl>
|
||||
<dt><label for="f_eqmt"></label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="equipment_id" id="f_eqmt">
|
||||
{foreach from=$eqmts_by_cat key='cat' item="eqmts"}
|
||||
{if $eqmts}
|
||||
<optgroup label="-- {$cat} --">
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<option value="{$eqmt.id}">{$eqmt.designation}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
|
@ -23,7 +23,7 @@
|
|||
<td>{$output.output_date}</td>
|
||||
<td>{$output.kind}</td>
|
||||
<td>{$output.equipment_number}</td>
|
||||
<td>{$output.equipment.designation}</td>
|
||||
<td>{$output.equipment}</td>
|
||||
<td>{$output.additional_comment}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
|
|
@ -13,7 +13,8 @@ $entry = new Entry;
|
|||
$entries = $entry->listAll();
|
||||
|
||||
foreach ($entries as $key => $value) {
|
||||
$entries[$key]->equipment = $eqmt->get($value->equipment_id);
|
||||
$entry_eqmt = $eqmt->get($value->equipment_id);
|
||||
$entries[$key]->equipment = $entry_eqmt->designation;
|
||||
}
|
||||
|
||||
$tpl->assign(compact('entries'));
|
||||
|
|
|
@ -10,6 +10,7 @@ use Garradin\Utils;
|
|||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$entry = new Entry;
|
||||
|
||||
$kinds = $entry->listKinds();
|
||||
$selected_kind = $kinds[0];
|
||||
|
||||
|
@ -66,7 +67,7 @@ if (f('save'))
|
|||
}
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'entrees/index.php';
|
||||
$legend_part = "pas encore";
|
||||
$legend_part = "non répertorié";
|
||||
$tpl_materiel_name = "non_repertorie";
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Materiels\Entry;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$entry = new Entry;
|
||||
|
||||
$csrf_key = 'add_entry';
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$entry->add([
|
||||
'kind' => f('kind'),
|
||||
'equipment_number' => (int) f('equipment_number'),
|
||||
'equipment_id' => f('equipment_id'),
|
||||
'entry_date' => f('entry_date'),
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
}
|
||||
|
||||
$eqmt = new Equipment;
|
||||
$eqmts_by_cat = $eqmt->listAllByCategory();
|
||||
|
||||
$kinds = $entry->listKinds();
|
||||
$selected_kind = $kinds[0];
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$default_date = $date;
|
||||
|
||||
$default_number = "1";
|
||||
$default_comment = "";
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'entrees/index.php';
|
||||
$legend_part = "répertorié";
|
||||
$tpl_materiel_name = "repertorie";
|
||||
|
||||
|
||||
$tpl->assign(compact(
|
||||
'kinds', 'eqmts_by_cat', 'selected_kind', 'default_date',
|
||||
'default_number', 'default_comment', 'cancel_link',
|
||||
'legend_part', 'tpl_materiel_name', 'csrf_key'
|
||||
));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/entrees/ajouter_entree.tpl');
|
|
@ -8,17 +8,15 @@ use Garradin\Utils;
|
|||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$entry = new Entry;
|
||||
$eqmt = new Equipment;
|
||||
|
||||
$csrf_key = 'add_entry';
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
if ($form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$entry = new Entry;
|
||||
$entry->add([
|
||||
'kind' => f('kind'),
|
||||
'kind' => 'Retour de location / prêt',
|
||||
'equipment_number' => (int) f('equipment_number'),
|
||||
'equipment_id' => f('equipment_id'),
|
||||
'entry_date' => f('entry_date'),
|
||||
|
@ -28,11 +26,9 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
|||
}
|
||||
}
|
||||
|
||||
$eqmt = new Equipment;
|
||||
$eqmts_by_cat = $eqmt->listAllByCategory();
|
||||
|
||||
$kinds = $entry->listKinds();
|
||||
$selected_kind = $kinds[0];
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$default_date = $date;
|
||||
|
@ -41,14 +37,13 @@ $default_number = "1";
|
|||
$default_comment = "";
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'entrees/index.php';
|
||||
$legend_part = "déjà";
|
||||
$tpl_materiel_name = "deja_repertorie";
|
||||
|
||||
$legend_part = "en retour de location / prêt";
|
||||
$tpl_materiel_name = "retour";
|
||||
|
||||
$tpl->assign(compact(
|
||||
'kinds', 'eqmts_by_cat', 'selected_kind', 'default_date',
|
||||
'default_number', 'default_comment', 'cancel_link',
|
||||
'legend_part', 'tpl_materiel_name', 'csrf_key'
|
||||
'eqmts_by_cat', 'default_date', 'default_number',
|
||||
'default_comment', 'cancel_link', 'legend_part',
|
||||
'tpl_materiel_name', 'csrf_key'
|
||||
));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/entrees/ajouter_entree.tpl');
|
|
@ -13,7 +13,8 @@ $output = new Output;
|
|||
$outputs = $output->listAll();
|
||||
|
||||
foreach ($outputs as $key => $value) {
|
||||
$outputs[$key]->equipment = $eqmt->get($value->equipment_id);
|
||||
$output_eqmt = $eqmt->get($value->equipment_id);
|
||||
$outputs[$key]->equipment = $output_eqmt->designation;
|
||||
}
|
||||
|
||||
$tpl->assign(compact('outputs'));
|
||||
|
|
Loading…
Reference in New Issue