Compare commits
8 commits
return_dat
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fc09554f0 | ||
|
|
09fa44e6aa | ||
|
|
6e2a9104ef | ||
|
|
2f8a3a9db8 | ||
|
|
83c4a46342 | ||
|
|
572dfc172a | ||
|
|
65ee10453c | ||
|
|
ec29f26176 |
10 changed files with 151 additions and 43 deletions
34
config/misc.html
Normal file
34
config/misc.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{:admin_header title="Configuration" current="module_equipment"}}
|
||||
|
||||
{{#form on="save"}}
|
||||
{{:save
|
||||
key="config"
|
||||
loan_duration=$_POST.loan_duration
|
||||
}}
|
||||
{{/form}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{:include file="../_nav.html" current="config" subcurrent="divers"}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
<p class="block confirm">Configuration enregistrée.</p>
|
||||
{{/if}}
|
||||
|
||||
{{* lecture config (défaut ou enregistrée) *}}
|
||||
{{:include file="../_get_config.html" keep="loan_duration"}}
|
||||
|
||||
<form method="post" action="" data-focus="1">
|
||||
<fieldset class="storage">
|
||||
<legend>Autres paramètres</legend>
|
||||
<dl>
|
||||
{{:input type="number" name="loan_duration" label="Durée de prêt par défaut" min=1 required=true default=$loan_duration help="Durée en nombre de jours"}}
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||
</p>
|
||||
</form>
|
||||
{{:admin_footer}}
|
||||
|
|
@ -224,7 +224,7 @@
|
|||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Détails"
|
||||
href="movements/movement_details.html?key=%s&prop=%s"|args:$key:$_GET.prop
|
||||
href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$_GET.prop
|
||||
shape="eye"
|
||||
}}
|
||||
{{/if}}
|
||||
|
|
@ -314,7 +314,7 @@
|
|||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Détails"
|
||||
href="movements/movement_details.html?key=%s&prop=%s"|args:$key:$_GET.prop
|
||||
href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$_GET.prop
|
||||
shape="eye"
|
||||
}}
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,33 @@
|
|||
{{:admin_header title="Matériels hors de l'asso" custom_css="../style.css" current="module_equipment"}}
|
||||
{{:include file="./_nav.html" current="historique" subcurrent="prêts"}}
|
||||
|
||||
{{*
|
||||
vérifier l'existence de la table du module
|
||||
eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans
|
||||
*}}
|
||||
|
||||
{{#load limit="1"}}
|
||||
{{:assign table_presente=true}}
|
||||
{{else}}
|
||||
{{:assign table_presente=false}}
|
||||
{{/load}}
|
||||
|
||||
{{if $table_presente}}
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg == "modification"}}
|
||||
<p class="block confirm">Modification enregistrée</p>
|
||||
{{elseif $_GET.msg == "copie"}}
|
||||
<p class="block confirm">Mouvement copié</p>
|
||||
{{elseif $_GET.msg == "suppression"}}
|
||||
<p class="block confirm">Mouvement supprimé</p>
|
||||
{{/if}}
|
||||
{{elseif $_GET.err}}
|
||||
{{if $_GET.msg == "suppression"}}
|
||||
<p class="block error">Ce mouvement ne peut être supprimé</p>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{* lecture config (défaut ou enregistrée) *}}
|
||||
{{:include file="./_get_config.html" keep="config"}}
|
||||
|
||||
|
|
@ -24,11 +51,11 @@
|
|||
json_extract(mvt.document, '$.amount') AS out_amount,
|
||||
json_extract(mvt.document, '$.return_date') AS return_date,
|
||||
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(retour.document, '$.amount')), 0) AS remain
|
||||
FROM module_data_equipment AS mvt
|
||||
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
||||
LEFT JOIN module_data_equipment AS links ON mvt.key = json_extract(links.document, '$.temp_key')
|
||||
LEFT JOIN module_data_equipment AS retour ON retour.key = json_extract(links.document, '$.return')
|
||||
INNER JOIN module_data_equipment AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
|
||||
FROM {!$module.table} AS mvt
|
||||
LEFT JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
||||
LEFT JOIN {!$module.table} AS links ON mvt.key = json_extract(links.document, '$.temp_key')
|
||||
LEFT JOIN {!$module.table} AS retour ON retour.key = json_extract(links.document, '$.return')
|
||||
INNER JOIN {!$module.table} AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
|
||||
WHERE
|
||||
json_extract(mvt.document, '$.type') = 'movement'
|
||||
AND
|
||||
|
|
@ -70,14 +97,17 @@
|
|||
<td>{{$remain}}</td>
|
||||
<td>
|
||||
{{if $return_date != null}}
|
||||
{{if $nb_jours > 0}}
|
||||
{{:tag color="darkred" label="Retard %s jours"|args:$nb_jours}}
|
||||
{{elseif $nb_jours < 0}}
|
||||
{{:assign delai="abs(%d)"|math:$nb_jours}}
|
||||
{{"Reste %s jours"|args:$delai}}
|
||||
{{else}}
|
||||
{{:tag color="darkgreen" label="À rendre aujourdh'ui"}}
|
||||
{{/if}}
|
||||
{{:assign jour="jour}}
|
||||
{{if $nb_jours > 0}}
|
||||
{{if $nb_jours > 1}}{{:assign jour="jours"}}{{/if}}
|
||||
{{:tag color="darkred" label="Retard %s %s"|args:$nb_jours:$jour}}
|
||||
{{elseif $nb_jours < 0}}
|
||||
{{:assign delai="abs(%d)"|math:$nb_jours}}
|
||||
{{if $nb_jours < -1}}{{:assign jour="jours"}}{{/if}}
|
||||
{{"Reste %s %s"|args:$delai:$jour}}
|
||||
{{else}}
|
||||
{{:tag color="darkgreen" label="À rendre aujourdh'ui"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>
|
||||
|
|
@ -86,6 +116,11 @@
|
|||
href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key
|
||||
shape="reset"
|
||||
target="_dialog"}}
|
||||
{{:linkbutton
|
||||
label="Détails"
|
||||
href="movements/movement_details.html?key=%s&prop=1&from=lh"|args:$mvt_key
|
||||
shape="eye"
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
|
|
@ -93,5 +128,8 @@
|
|||
{{/select}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="block alert">Aucun mouvement.</p>
|
||||
{{/if}}
|
||||
|
||||
{{:admin_footer}}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,12 @@
|
|||
transactions=$transactions
|
||||
return_date=$return_date|parse_date
|
||||
}}
|
||||
{{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}}
|
||||
{{if $_GET.from == "lh"}}
|
||||
{{:assign from="../loan_history.html"}}
|
||||
{{else}}
|
||||
{{:assign from="../equipment_history.html"}}
|
||||
{{/if}}
|
||||
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=copie"|args:$from:$eqpmt_key:$prop}}
|
||||
{{/form}}
|
||||
|
||||
{{if $mvt_new.direction == "input"}}
|
||||
|
|
@ -273,9 +278,9 @@
|
|||
{{/if}}
|
||||
{{if $mvt_new.direction == "input"}}
|
||||
{{:input type="select" name="storage" default=$mvt_new.storage label="Lieu de stockage" default_empty="— Aucun —" options=$storage required=false}}
|
||||
{{if $type_mvt != "retour"}}
|
||||
{{:input type="list" name="transactions" label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{if $type_mvt != "retour"}}
|
||||
{{:input type="list" name="transactions" label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}}
|
||||
{{/if}}
|
||||
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_new.comment}}
|
||||
{{if $mvt_new.direction == "output" && $type_mvt == "temporaire"}}
|
||||
|
|
@ -292,6 +297,7 @@
|
|||
{{:input id="set_return_date" type="checkbox" value=1 name="set_return_date" label="Fixer une date de retour" help="Cocher pour fixer une date de retour" checked="%s"|args:$checked}}
|
||||
<div id="div_return_date" style="visibility:{{$visibility}}">
|
||||
{{:input type="date" name="return_date" label="Date de retour" default=$return_date}}
|
||||
<input type="hidden" id="loan_duration" name="loan_duration" value="{{$loan_duration}}">
|
||||
</div>
|
||||
{{/if}}
|
||||
</dl>
|
||||
|
|
@ -311,7 +317,13 @@ function changeVisibility(evt, idcheck = 'f_set_return_date_1', fields = ['div_r
|
|||
toggleVisibility(idcheck, fields);
|
||||
}
|
||||
|
||||
function changeReturnDate(evt, id_date = 'f_date', id_return_date = 'f_return_date', id_loan_duration='loan_duration')
|
||||
{
|
||||
setReturnDate(id_date, id_return_date, id_loan_duration);
|
||||
}
|
||||
|
||||
(function () {
|
||||
document.getElementById('f_set_return_date_1').onclick = changeVisibility;
|
||||
document.getElementById('f_date').onchange = changeReturnDate;
|
||||
})();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@
|
|||
{{:include file="../_get_config.html" keep="config"}}
|
||||
|
||||
{{#form on="delete"}}
|
||||
{{if $_GET.from == "lh"}}
|
||||
{{:assign from="../loan_history.html"}}
|
||||
{{else}}
|
||||
{{:assign from="../equipment_history.html"}}
|
||||
{{/if}}
|
||||
{{* vérifier s'il est possible de supprimer le mouvement *}}
|
||||
{{if $mvt_suppr.direction == 'input'}}
|
||||
{{:assign var="type_operation" from="config.input_nature.%s.type"|args:$mvt_suppr.operation}}
|
||||
|
|
@ -29,7 +34,7 @@
|
|||
{{:assign link_key=$key}}
|
||||
{{/load}}
|
||||
{{if $link_key != null}}
|
||||
{{:redirect force="../equipment_history.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign dispo=0}}
|
||||
|
|
@ -62,7 +67,7 @@
|
|||
|
||||
{{* problème ? *}}
|
||||
{{if $dispo < 0 || $nonprop < 0}}
|
||||
{{:redirect force="../equipment_history.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
|
@ -83,7 +88,7 @@
|
|||
{{:assign link_key=$key}}
|
||||
{{/load}}
|
||||
{{if $link_key != null}}
|
||||
{{:redirect force="../equipment_history.html?key=%s&prop=%s&err=1&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{/if}}
|
||||
{{elseif $type_operation == 'retour'}}
|
||||
{{#load type="link" where="$$.return = :key" :key=$_GET.key}}
|
||||
|
|
@ -148,7 +153,7 @@
|
|||
out=$curr_eqpmt.out
|
||||
notowned=$curr_eqpmt.notowned
|
||||
}}
|
||||
{{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=suppression"|args:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{else}}
|
||||
{{* supprimer le matériel *}}
|
||||
{{:delete key=$curr_eqpmt.key}}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
{{:assign var="equipment.notowned" value="%d+%d"|math:$equipment.notowned:$_POST.amount|intval}}
|
||||
{{/if}}
|
||||
|
||||
{{* documents liés *}}
|
||||
{{* écritures liées *}}
|
||||
{{#foreach from=$_POST.transactions item="value"}}
|
||||
{{:assign var="transactions." value=$value|intval}}
|
||||
{{/foreach}}
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@
|
|||
|
||||
{{* enregistrer le mouvement modifié *}}
|
||||
{{if $user == null}}
|
||||
{{:assign user_id=$mvt_new.user}}
|
||||
{{:assign user_id=null}}
|
||||
{{else}}
|
||||
{{:assign user_id=$user.id}}
|
||||
{{/if}}
|
||||
|
|
@ -222,7 +222,12 @@
|
|||
transactions=$transactions
|
||||
return_date=$return_date|parse_date
|
||||
}}
|
||||
{{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$prop}}
|
||||
{{if $_GET.from == "lh"}}
|
||||
{{:assign from="../loan_history.html"}}
|
||||
{{else}}
|
||||
{{:assign from="../equipment_history.html"}}
|
||||
{{/if}}
|
||||
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=modification"|args:$from:$eqpmt_key:$prop}}
|
||||
{{/form}}
|
||||
|
||||
{{if $mvt_new.direction == "input"}}
|
||||
|
|
@ -231,8 +236,8 @@
|
|||
{{:assign mvt_label="sortie"}}
|
||||
{{/if}}
|
||||
{{:admin_header title="Modifier une %s"|args:$mvt_label custom_css="./../style.css" current="module_equipment"}}
|
||||
{{:form_errors}}
|
||||
|
||||
{{:form_errors}}
|
||||
{{*
|
||||
-------------------- Préparer la saisie --------------------
|
||||
*}}
|
||||
|
|
@ -299,9 +304,9 @@
|
|||
{{if $storage != null}}
|
||||
{{:input type="select" name="storage" label="Lieu de stockage" default=$mvt_new.storage default_empty="— Aucun —" options=$storage required=false}}
|
||||
{{/if}}
|
||||
{{if $type_mvt != "retour"}}
|
||||
{{:input type="list" name="transactions" default=$mvt_new.transactions label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{if $type_mvt != "retour"}}
|
||||
{{:input type="list" name="transactions" default=$mvt_new.transactions label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}}
|
||||
{{/if}}
|
||||
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_new.comment}}
|
||||
{{if $mvt_new.direction == "output" && $type_mvt == "temporaire"}}
|
||||
|
|
@ -338,11 +343,9 @@ function changeVisibility(evt, idcheck = 'f_set_return_date_1', fields = ['div_r
|
|||
toggleVisibility(idcheck, fields);
|
||||
}
|
||||
|
||||
function changeReturnDate(evt, id_date = 'f_date', id_return_date = 'f_return_date', id_loan_duration='loan_duration') {
|
||||
const loan_duration = document.getElementById(id_loan_duration).value;
|
||||
let nbsec = getDate(id_date) + loan_duration*24*60*60;
|
||||
const date_retour = new Date(nbsec * 1000);
|
||||
document.getElementById(id_return_date).value = date_retour.toLocaleDateString();
|
||||
function changeReturnDate(evt, id_date = 'f_date', id_return_date = 'f_return_date', id_loan_duration='loan_duration')
|
||||
{
|
||||
setReturnDate(id_date, id_return_date, id_loan_duration);
|
||||
}
|
||||
|
||||
(function () {
|
||||
|
|
|
|||
|
|
@ -42,18 +42,18 @@
|
|||
<nav class="tabs">
|
||||
{{:linkbutton
|
||||
label="Modifier ce mouvement"
|
||||
href="modify_movement.html?key=%s"|args:$_GET.key
|
||||
href="modify_movement.html?key=%s&from=%s"|args:$_GET.key:$_GET.from
|
||||
shape="edit"
|
||||
target="_dialog"}}
|
||||
{{:linkbutton
|
||||
label="Supprimer ce mouvement"
|
||||
href="delete_movement.html?key=%s&prop=%s"|args:$_GET.key:$_GET.prop
|
||||
href="delete_movement.html?key=%s&prop=%s&from=%s"|args:$_GET.key:$_GET.prop:$_GET.from
|
||||
shape="delete"
|
||||
target="_dialog"}}
|
||||
{{if $type_mvt != "retour"}}
|
||||
{{:linkbutton
|
||||
label="Dupliquer ce mouvement"
|
||||
href="copy_movement.html?key=%s&prop=%s"|args:$_GET.key:$_GET.prop
|
||||
href="copy_movement.html?key=%s&prop=%s&from=%s"|args:$_GET.key:$_GET.prop:$_GET.from
|
||||
shape="plus"
|
||||
target="_dialog"}}
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,11 @@
|
|||
{{:assign var="equipment.out" value="%d+%d"|math:$equipment.out:$_POST.amount|intval}}
|
||||
{{/if}}
|
||||
|
||||
{{* écritures liées *}}
|
||||
{{#foreach from=$_POST.transactions item="value"}}
|
||||
{{:assign var="transactions." value=$value|intval}}
|
||||
{{/foreach}}
|
||||
|
||||
{{:save
|
||||
key=$equipment.key
|
||||
validate_schema="../equipment.schema.json"
|
||||
|
|
@ -152,6 +157,7 @@
|
|||
comment=$_POST.remarques|trim
|
||||
user=$user.id
|
||||
return_date=$return_date|parse_date
|
||||
transactions=$transactions
|
||||
}}
|
||||
{{:redirect force="../equipment_history.html?ok=1&key=%s&prop=1&msg=sortie"|args:$_GET.key}}
|
||||
{{/form}}
|
||||
|
|
@ -205,6 +211,7 @@
|
|||
multiple=true
|
||||
max=1
|
||||
}}
|
||||
{{:input type="list" name="transactions" label="Écritures liées" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture avec facture"}}
|
||||
{{:input type="textarea" name="remarques" label="Remarques" cols="40" rows="3" required=false}}
|
||||
{{:input id="set_return_date" type="checkbox" value=1 name="set_return_date" label="Fixer une date de retour" help="Cocher pour fixer une date de retour"}}
|
||||
<div id="div_return_date" style="visibility:hidden">
|
||||
|
|
@ -230,11 +237,9 @@ function changeVisibility(evt, idcheck = 'f_set_return_date_1', fields = ['div_r
|
|||
toggleVisibility(idcheck, fields);
|
||||
}
|
||||
|
||||
function changeReturnDate(evt, id_date = 'f_date', id_return_date = 'f_return_date', id_loan_duration='loan_duration') {
|
||||
const loan_duration = document.getElementById(id_loan_duration).value;
|
||||
let nbsec = getDate(id_date) + loan_duration*24*60*60;
|
||||
const date_retour = new Date(nbsec * 1000);
|
||||
document.getElementById(id_return_date).value = date_retour.toLocaleDateString();
|
||||
function changeReturnDate(evt, id_date = 'f_date', id_return_date = 'f_return_date', id_loan_duration='loan_duration')
|
||||
{
|
||||
setReturnDate(id_date, id_return_date, id_loan_duration);
|
||||
}
|
||||
|
||||
(function () {
|
||||
|
|
|
|||
11
scripts.js
11
scripts.js
|
|
@ -52,3 +52,14 @@ function str2sec(date) {
|
|||
function getDate(idelem) {
|
||||
return str2sec(document.getElementById(idelem).value);
|
||||
}
|
||||
|
||||
/**
|
||||
* modifier la date de retour en fonction de la date de sortie et de la durée du prêt
|
||||
*/
|
||||
function setReturnDate(id_date, id_return_date, id_loan_duration)
|
||||
{
|
||||
const loan_duration = document.getElementById(id_loan_duration).value;
|
||||
let nbsec = getDate(id_date) + loan_duration*24*60*60;
|
||||
const date_retour = new Date(nbsec * 1000);
|
||||
document.getElementById(id_return_date).value = date_retour.toLocaleDateString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue