ok for borrowed equipments output in movement
This commit is contained in:
parent
98cbe7f4a8
commit
46e6fe8330
|
@ -2,7 +2,7 @@
|
||||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="entrees"}
|
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="entrees"}
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- add entry form -->
|
<!-- add entry form -->
|
||||||
{include file="%smouvements/formulaire_mouvement.tpl"|args:$plugin_tpl legend="entrée d'un matériel %s"|args:$legend_part tpl_materiel_name=$tpl_materiel_name kinds=$kinds selected_kind=$selected_kind default_date=$default_date label_date="Date d'entrée" default_number=$default_number tpl_materiel_path="entrees" default_comment=$default_comment comment_placeholder=$comment_placeholder csrf_key=$csrf_key cancel_link=$cancel_link}
|
{include file="%smouvements/formulaire_mouvement.tpl"|args:$plugin_tpl legend="entrée d'un matériel %s"|args:$legend_part tpl_materiel_name=$tpl_materiel_name kinds=$kinds selected_kind=$selected_kind default_date=$default_date label_date="Date d'entrée" tpl_materiel_path="entrees" comment_placeholder=$comment_placeholder csrf_key=$csrf_key cancel_link=$cancel_link}
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- footer -->
|
<!-- footer -->
|
||||||
{include file="admin/_foot.tpl"}
|
{include file="admin/_foot.tpl"}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
{input type="date" name="mvt_date" default=$default_date label=$label_date required=true}
|
{input type="date" name="mvt_date" default=$default_date label=$label_date required=true}
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- number -->
|
<!-- number -->
|
||||||
{input type="number" name="equipment_number" label="Nombre" required=true step="1" min="1" default=$default_number}
|
{input type="number" name="equipment_number" label="Nombre" required=true step="1" min="1" default="1"}
|
||||||
<!-- -->
|
<!-- -->
|
||||||
</dl>
|
</dl>
|
||||||
<!-- materiel -->
|
<!-- materiel -->
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- comment -->
|
<!-- comment -->
|
||||||
<dl>
|
<dl>
|
||||||
{input type="textarea" name="additional_comment" label="Remarques" placeholder=$comment_placeholder default=$default_comment maxlength="255" rows=4 cols=30}
|
{input type="textarea" name="additional_comment" label="Remarques" placeholder=$comment_placeholder default="" maxlength="255" rows=4 cols=30}
|
||||||
</dl>
|
</dl>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="sorties"}
|
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="sorties"}
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- add output form -->
|
<!-- add output form -->
|
||||||
{include file="%smouvements/formulaire_mouvement.tpl"|args:$plugin_tpl legend="sortie d'un matériel %s"|args:$legend_part tpl_materiel_name=$tpl_materiel_name kinds=$kinds selected_kind=$selected_kind default_date=$default_date label_date="Date de sortie" default_number=$default_number tpl_materiel_path="sorties" default_comment=$default_comment comment_placeholder=$comment_placeholder csrf_key=$csrf_key cancel_link=$cancel_link}
|
{include file="%smouvements/formulaire_mouvement.tpl"|args:$plugin_tpl legend="sortie d'un matériel %s"|args:$legend_part tpl_materiel_name=$tpl_materiel_name kinds=$kinds selected_kind=$selected_kind default_date=$default_date label_date="Date de sortie" tpl_materiel_path="sorties" comment_placeholder=$comment_placeholder csrf_key=$csrf_key cancel_link=$cancel_link}
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- footer -->
|
<!-- footer -->
|
||||||
{include file="admin/_foot.tpl"}
|
{include file="admin/_foot.tpl"}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<!-- materiel borrowed for output part for add movement form -->
|
||||||
|
<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"}
|
||||||
|
<optgroup label="-- {$cat} --">
|
||||||
|
{foreach from=$eqmts item="eqmt"}
|
||||||
|
<option value="{$eqmt.id}"{if ($selected_eqmt !== "") && ($selected_eqmt == $eqmt.id)} selected="selected"{/if}>{$eqmt.designation} - emprunt: {$eqmt.borrowed}</option>
|
||||||
|
{/foreach}
|
||||||
|
</optgroup>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</fieldset>
|
||||||
|
<!-- -->
|
|
@ -63,12 +63,10 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make default date (now), default number (1), and default comment (empty)
|
// make default date (now)
|
||||||
$date = new \DateTime;
|
$date = new \DateTime;
|
||||||
$date->setTimestamp(time());
|
$date->setTimestamp(time());
|
||||||
$default_date = $date;
|
$default_date = $date;
|
||||||
$default_number = "1";
|
|
||||||
$default_comment = "";
|
|
||||||
|
|
||||||
// make comment placeholder
|
// make comment placeholder
|
||||||
$comment_placeholder = "ex: don reçu de la part de...";
|
$comment_placeholder = "ex: don reçu de la part de...";
|
||||||
|
@ -83,7 +81,7 @@ $tpl_materiel_name = "non_repertorie";
|
||||||
|
|
||||||
$tpl->assign(compact(
|
$tpl->assign(compact(
|
||||||
'kinds', 'cats', 'selected_kind', 'default_date',
|
'kinds', 'cats', 'selected_kind', 'default_date',
|
||||||
'default_number', 'default_comment', 'comment_placeholder', 'selected_cat',
|
'comment_placeholder', 'selected_cat',
|
||||||
'cancel_link', 'legend_part', 'tpl_materiel_name', 'csrf_key'
|
'cancel_link', 'legend_part', 'tpl_materiel_name', 'csrf_key'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,10 @@ $eqmts_by_cat = $eqmt->listAllByCategory();
|
||||||
$kinds = $mvt->listEntryKinds();
|
$kinds = $mvt->listEntryKinds();
|
||||||
$selected_kind = $kinds[0];
|
$selected_kind = $kinds[0];
|
||||||
|
|
||||||
// make default date (now), default number (1), and default comment (empty)
|
// make default date (now)
|
||||||
$date = new \DateTime;
|
$date = new \DateTime;
|
||||||
$date->setTimestamp(time());
|
$date->setTimestamp(time());
|
||||||
$default_date = $date;
|
$default_date = $date;
|
||||||
$default_number = "1";
|
|
||||||
$default_comment = "";
|
|
||||||
|
|
||||||
// make comment placeholder
|
// make comment placeholder
|
||||||
$comment_placeholder = "ex: don reçu de la part de...";
|
$comment_placeholder = "ex: don reçu de la part de...";
|
||||||
|
@ -57,7 +55,7 @@ $tpl_materiel_name = "repertorie";
|
||||||
|
|
||||||
$tpl->assign(compact(
|
$tpl->assign(compact(
|
||||||
'kinds', 'eqmts_by_cat', 'selected_kind', 'default_date',
|
'kinds', 'eqmts_by_cat', 'selected_kind', 'default_date',
|
||||||
'default_number', 'default_comment', 'comment_placeholder', 'cancel_link',
|
'comment_placeholder', 'cancel_link',
|
||||||
'legend_part', 'tpl_materiel_name', 'csrf_key'
|
'legend_part', 'tpl_materiel_name', 'csrf_key'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -47,12 +47,10 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make default date (now), default number (1) and default comment (empty)
|
// make default date (now)
|
||||||
$default_number = "1";
|
|
||||||
$date = new \DateTime;
|
$date = new \DateTime;
|
||||||
$date->setTimestamp(time());
|
$date->setTimestamp(time());
|
||||||
$default_date = $date;
|
$default_date = $date;
|
||||||
$default_comment = "";
|
|
||||||
|
|
||||||
// make comment placeholder
|
// make comment placeholder
|
||||||
$comment_placeholder = "ex: retour de prêt...";
|
$comment_placeholder = "ex: retour de prêt...";
|
||||||
|
@ -69,9 +67,8 @@ $selected_kind = false;
|
||||||
|
|
||||||
// send all to template
|
// send all to template
|
||||||
$tpl->assign(compact(
|
$tpl->assign(compact(
|
||||||
'eqmts_by_cat', 'default_date', 'default_number',
|
'eqmts_by_cat', 'default_date', 'cancel_link', 'legend_part', 'comment_placeholder', 'tpl_materiel_name', 'csrf_key', 'selected_eqmt',
|
||||||
'default_comment', 'cancel_link', 'legend_part', 'comment_placeholder',
|
'kinds', 'selected_kind',
|
||||||
'tpl_materiel_name', 'csrf_key', 'selected_eqmt', 'kinds', 'selected_kind',
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/mouvements/entrees/ajouter_entree.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/mouvements/entrees/ajouter_entree.tpl');
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// add output for a borrowed equipment
|
||||||
|
|
||||||
|
namespace Garradin;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../_inc.php';
|
||||||
|
|
||||||
|
use Garradin\Plugin\Materiels\Equipment;
|
||||||
|
use Garradin\Utils;
|
||||||
|
|
||||||
|
$eqmt = new Equipment;
|
||||||
|
$selected_eqmt = "";
|
||||||
|
|
||||||
|
// check if add form is submitted
|
||||||
|
$csrf_key = 'add_output';
|
||||||
|
|
||||||
|
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||||
|
{
|
||||||
|
$eqmt_id = f('equipment_id');
|
||||||
|
$eqmt_number = (int) f('equipment_number');
|
||||||
|
$mvt_date_format = date_create_from_format(
|
||||||
|
"d/m/Y", f('mvt_date'))->format("Y-m-d");
|
||||||
|
// check if it's possible to output this equipment
|
||||||
|
if ($mvt->PossibilityNoOwnedEqmtOutput($eqmt_id, $eqmt_number, $mvt_date_format))
|
||||||
|
{
|
||||||
|
// it's possible, add new output
|
||||||
|
$mvt->add([
|
||||||
|
'side' => 1,
|
||||||
|
'kind' => 'Retour de location / prêt',
|
||||||
|
'equipment_number' => $eqmt_number,
|
||||||
|
'equipment_id' => $eqmt_id,
|
||||||
|
'mvt_date' => $mvt_date_format,
|
||||||
|
'additional_comment' => f('additional_comment'),
|
||||||
|
]);
|
||||||
|
Utils::redirect(PLUGIN_URL . 'mouvements/sorties/index.php');
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// not possible, add error to form
|
||||||
|
$equiment = $eqmt->get($eqmt_id);
|
||||||
|
$form->addError(
|
||||||
|
"Il est impossible de sortir " . (string) $eqmt_number . " " . $equiment->designation . " à la date du " . (string) f('mvt_date') . '.');
|
||||||
|
// keep the datas submitted as selected
|
||||||
|
$selected_eqmt = $eqmt_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get list of borrowed equipments ordered by category
|
||||||
|
$eqmts_by_cat = $eqmt->ListAllBorrowedByCategory();
|
||||||
|
|
||||||
|
// make default date (now)
|
||||||
|
$date = new \DateTime;
|
||||||
|
$date->setTimestamp(time());
|
||||||
|
$default_date = $date;
|
||||||
|
|
||||||
|
// make comment placeholder
|
||||||
|
$comment_placeholder = "ex: matériel rendu...";
|
||||||
|
|
||||||
|
// make cancel link, legend for the title of the form
|
||||||
|
// and the template name for equipment to use in form
|
||||||
|
$cancel_link = PLUGIN_URL . 'mouvements/sorties/index.php';
|
||||||
|
$legend_part = "emprunté";
|
||||||
|
$tpl_materiel_name = "emprunte";
|
||||||
|
|
||||||
|
// no kinds needed
|
||||||
|
$kinds = false;
|
||||||
|
$selected_kind = false;
|
||||||
|
|
||||||
|
// send all to template
|
||||||
|
$tpl->assign(compact(
|
||||||
|
'csrf_key', 'cancel_link', 'legend_part', 'tpl_materiel_name',
|
||||||
|
'selected_eqmt', 'default_date', 'comment_placeholder',
|
||||||
|
'eqmts_by_cat', 'kinds', 'selected_kind'));
|
||||||
|
|
||||||
|
$tpl->display(PLUGIN_ROOT . '/templates/mouvements/sorties/ajouter_sortie.tpl');
|
|
@ -28,7 +28,7 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||||
$eqmt_number = (int) f('equipment_number');
|
$eqmt_number = (int) f('equipment_number');
|
||||||
$mvt_date_format = date_create_from_format(
|
$mvt_date_format = date_create_from_format(
|
||||||
"d/m/Y", f('mvt_date'))->format("Y-m-d");
|
"d/m/Y", f('mvt_date'))->format("Y-m-d");
|
||||||
// check if it's possible to output this return entry
|
// check if it's possible to output this equipment
|
||||||
if ($mvt->PossibilityOwnedEqmtOutput($eqmt_id, $eqmt_number, $mvt_date_format))
|
if ($mvt->PossibilityOwnedEqmtOutput($eqmt_id, $eqmt_number, $mvt_date_format))
|
||||||
{
|
{
|
||||||
// it's possible, add new output
|
// it's possible, add new output
|
||||||
|
@ -53,12 +53,10 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make default date (now), default number (1), and default comment (empty)
|
// make default date (now)
|
||||||
$date = new \DateTime;
|
$date = new \DateTime;
|
||||||
$date->setTimestamp(time());
|
$date->setTimestamp(time());
|
||||||
$default_date = $date;
|
$default_date = $date;
|
||||||
$default_number = "1";
|
|
||||||
$default_comment = "";
|
|
||||||
|
|
||||||
// make comment placeholder
|
// make comment placeholder
|
||||||
$comment_placeholder = "ex: don fait à...";
|
$comment_placeholder = "ex: don fait à...";
|
||||||
|
@ -71,7 +69,7 @@ $tpl_materiel_name = "stock_disponible";
|
||||||
|
|
||||||
$tpl->assign(compact(
|
$tpl->assign(compact(
|
||||||
'csrf_key', 'cancel_link', 'legend_part', 'tpl_materiel_name',
|
'csrf_key', 'cancel_link', 'legend_part', 'tpl_materiel_name',
|
||||||
'kinds', 'selected_eqmt', 'selected_kind', 'default_date', 'default_number',
|
'kinds', 'selected_eqmt', 'selected_kind', 'default_date',
|
||||||
'default_comment', 'comment_placeholder', 'eqmts_by_cat'));
|
'comment_placeholder', 'eqmts_by_cat'));
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/mouvements/sorties/ajouter_sortie.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/mouvements/sorties/ajouter_sortie.tpl');
|
||||||
|
|
Loading…
Reference in New Issue