diff --git a/src/templates/mouvements/entrees/ajouter_entree.tpl b/src/templates/mouvements/entrees/ajouter_entree.tpl
index 5c68bd7..d87cb1c 100644
--- a/src/templates/mouvements/entrees/ajouter_entree.tpl
+++ b/src/templates/mouvements/entrees/ajouter_entree.tpl
@@ -2,7 +2,7 @@
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="entrees"}
-{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}
{include file="admin/_foot.tpl"}
diff --git a/src/templates/mouvements/formulaire_mouvement.tpl b/src/templates/mouvements/formulaire_mouvement.tpl
index 9e76444..b700491 100644
--- a/src/templates/mouvements/formulaire_mouvement.tpl
+++ b/src/templates/mouvements/formulaire_mouvement.tpl
@@ -24,7 +24,7 @@
{input type="date" name="mvt_date" default=$default_date label=$label_date required=true}
- {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"}
@@ -32,7 +32,7 @@
- {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}
diff --git a/src/templates/mouvements/sorties/ajouter_sortie.tpl b/src/templates/mouvements/sorties/ajouter_sortie.tpl
index 8b8b05a..a98186f 100644
--- a/src/templates/mouvements/sorties/ajouter_sortie.tpl
+++ b/src/templates/mouvements/sorties/ajouter_sortie.tpl
@@ -2,7 +2,7 @@
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="sorties"}
-{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}
{include file="admin/_foot.tpl"}
diff --git a/src/templates/mouvements/sorties/emprunte.tpl b/src/templates/mouvements/sorties/emprunte.tpl
new file mode 100644
index 0000000..f64384c
--- /dev/null
+++ b/src/templates/mouvements/sorties/emprunte.tpl
@@ -0,0 +1,19 @@
+
+
+
diff --git a/src/www/admin/mouvements/entrees/non_repertorie.php b/src/www/admin/mouvements/entrees/non_repertorie.php
index 8832a89..2b972b8 100644
--- a/src/www/admin/mouvements/entrees/non_repertorie.php
+++ b/src/www/admin/mouvements/entrees/non_repertorie.php
@@ -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->setTimestamp(time());
$default_date = $date;
-$default_number = "1";
-$default_comment = "";
// make comment placeholder
$comment_placeholder = "ex: don reçu de la part de...";
@@ -83,7 +81,7 @@ $tpl_materiel_name = "non_repertorie";
$tpl->assign(compact(
'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'
));
diff --git a/src/www/admin/mouvements/entrees/repertorie.php b/src/www/admin/mouvements/entrees/repertorie.php
index dd38e3f..8399353 100644
--- a/src/www/admin/mouvements/entrees/repertorie.php
+++ b/src/www/admin/mouvements/entrees/repertorie.php
@@ -37,12 +37,10 @@ $eqmts_by_cat = $eqmt->listAllByCategory();
$kinds = $mvt->listEntryKinds();
$selected_kind = $kinds[0];
-// make default date (now), default number (1), and default comment (empty)
+// make default date (now)
$date = new \DateTime;
$date->setTimestamp(time());
$default_date = $date;
-$default_number = "1";
-$default_comment = "";
// make comment placeholder
$comment_placeholder = "ex: don reçu de la part de...";
@@ -57,7 +55,7 @@ $tpl_materiel_name = "repertorie";
$tpl->assign(compact(
'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'
));
diff --git a/src/www/admin/mouvements/entrees/retour.php b/src/www/admin/mouvements/entrees/retour.php
index 8acdc67..2e0f1e3 100644
--- a/src/www/admin/mouvements/entrees/retour.php
+++ b/src/www/admin/mouvements/entrees/retour.php
@@ -47,12 +47,10 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
}
}
-// make default date (now), default number (1) and default comment (empty)
-$default_number = "1";
+// make default date (now)
$date = new \DateTime;
$date->setTimestamp(time());
$default_date = $date;
-$default_comment = "";
// make comment placeholder
$comment_placeholder = "ex: retour de prêt...";
@@ -69,9 +67,8 @@ $selected_kind = false;
// send all to template
$tpl->assign(compact(
- 'eqmts_by_cat', 'default_date', 'default_number',
- 'default_comment', 'cancel_link', 'legend_part', 'comment_placeholder',
- 'tpl_materiel_name', 'csrf_key', 'selected_eqmt', 'kinds', 'selected_kind',
+ 'eqmts_by_cat', 'default_date', 'cancel_link', 'legend_part', 'comment_placeholder', 'tpl_materiel_name', 'csrf_key', 'selected_eqmt',
+ 'kinds', 'selected_kind',
));
$tpl->display(PLUGIN_ROOT . '/templates/mouvements/entrees/ajouter_entree.tpl');
diff --git a/src/www/admin/mouvements/sorties/emprunte.php b/src/www/admin/mouvements/sorties/emprunte.php
new file mode 100644
index 0000000..c2ff3cb
--- /dev/null
+++ b/src/www/admin/mouvements/sorties/emprunte.php
@@ -0,0 +1,75 @@
+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');
diff --git a/src/www/admin/mouvements/sorties/stock_disponible.php b/src/www/admin/mouvements/sorties/stock_disponible.php
index 447f04c..4568288 100644
--- a/src/www/admin/mouvements/sorties/stock_disponible.php
+++ b/src/www/admin/mouvements/sorties/stock_disponible.php
@@ -28,7 +28,7 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
$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 return entry
+ // check if it's possible to output this equipment
if ($mvt->PossibilityOwnedEqmtOutput($eqmt_id, $eqmt_number, $mvt_date_format))
{
// 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->setTimestamp(time());
$default_date = $date;
-$default_number = "1";
-$default_comment = "";
// make comment placeholder
$comment_placeholder = "ex: don fait à...";
@@ -71,7 +69,7 @@ $tpl_materiel_name = "stock_disponible";
$tpl->assign(compact(
'csrf_key', 'cancel_link', 'legend_part', 'tpl_materiel_name',
- 'kinds', 'selected_eqmt', 'selected_kind', 'default_date', 'default_number',
- 'default_comment', 'comment_placeholder', 'eqmts_by_cat'));
+ 'kinds', 'selected_eqmt', 'selected_kind', 'default_date',
+ 'comment_placeholder', 'eqmts_by_cat'));
$tpl->display(PLUGIN_ROOT . '/templates/mouvements/sorties/ajouter_sortie.tpl');