Mutualisation onglets prêt et location
This commit is contained in:
parent
974f87e5a4
commit
546a9ea677
10 changed files with 176 additions and 421 deletions
14
_nav.html
14
_nav.html
|
|
@ -14,8 +14,8 @@
|
|||
<ul>
|
||||
<li {{if $current == 'inventaire'}} class="current"{{/if}}><a href="{{$module.url}}index.html">Inventaire</a></li>
|
||||
<li {{if $current == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}global_history.html">Historique</a></li>
|
||||
<li {{if $current == 'prêts'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html">Prêts</a></li>
|
||||
<li {{if $current == 'location'}} class="current"{{/if}}><a href="{{$module.url}}rent_history.html">Locations</a></li>
|
||||
<li {{if $current == 'prêt'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html?output_type=loan">Prêts</a></li>
|
||||
<li {{if $current == 'location'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html?output_type=rent">Locations</a></li>
|
||||
<li {{if $current == 'archives'}} class="current"{{/if}}><a href="{{$module.url}}archives.html">Archives</a></li>
|
||||
<li {{if $current == 'config'}} class="current"{{/if}}><a href="{{$module.url}}categories/index.html">Configuration</a></li>
|
||||
</ul>
|
||||
|
|
@ -26,15 +26,15 @@
|
|||
<li class="title"><strong>Historique — {{$eqpmt}} ({{$category}})</strong></li>
|
||||
</ul>
|
||||
{{/if}}
|
||||
{{elseif $current == 'prêts'}}
|
||||
{{elseif $current == 'prêt'}}
|
||||
<ul class="sub">
|
||||
<li {{if $subcurrent == 'encours'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html">En cours</a></li>
|
||||
<li {{if $subcurrent == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}loan_movements.html">Historique</a></li>
|
||||
<li {{if $subcurrent == 'encours'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html?output_type=loan">En cours</a></li>
|
||||
<li {{if $subcurrent == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}loan_movements.html?output_type=loan">Historique</a></li>
|
||||
</ul>
|
||||
{{elseif $current == 'location'}}
|
||||
<ul class="sub">
|
||||
<li {{if $subcurrent == 'encours'}} class="current"{{/if}}><a href="{{$module.url}}rent_history.html">En cours</a></li>
|
||||
<li {{if $subcurrent == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}rent_movements.html">Historique</a></li>
|
||||
<li {{if $subcurrent == 'encours'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html?output_type=rent">En cours</a></li>
|
||||
<li {{if $subcurrent == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}loan_movements.html?output_type=rent">Historique</a></li>
|
||||
</ul>
|
||||
{{elseif $current == 'archives'}}
|
||||
{{if $subsubcurrent == 'historique'}}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@
|
|||
THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage)
|
||||
ELSE ''
|
||||
END as 'Stockage';
|
||||
$$.comment AS 'Commentaire'
|
||||
$$.comment AS 'Remarque'
|
||||
"|args:$config.user_fields.name_sql
|
||||
where="%s AND %s"|args:$cat_condition:$prop_condition
|
||||
order=1
|
||||
|
|
|
|||
|
|
@ -2,14 +2,21 @@
|
|||
|
||||
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
|
||||
|
||||
{{:admin_header title="Prêts en cours" custom_css="../style.css" current="module_equipment"}}
|
||||
{{:include file="./_nav.html" current="prêts" subcurrent="encours"}}
|
||||
{{if $_GET.output_type == "loan"}}
|
||||
{{:assign label="prêt"}}
|
||||
{{elseif $_GET.output_type == "rent"}}
|
||||
{{:assign label="location"}}
|
||||
{{else}}
|
||||
{{:error message="Cette page n'existe pas !"}}
|
||||
{{/if}}
|
||||
|
||||
{{:admin_header title="%ss en cours"|args:$label|ucfirst custom_css="../style.css" current="module_equipment"}}
|
||||
{{:include file="./_nav.html" current="%s"|args:$label subcurrent="encours"}}
|
||||
|
||||
{{*
|
||||
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}}
|
||||
|
|
@ -36,13 +43,21 @@
|
|||
|
||||
{{* filtrer selon la catégorie *}}
|
||||
{{if $_GET.cat_key == null}}
|
||||
{{:assign selected_category=$module.config.loan_hist_cat_key}}
|
||||
{{:assign var="selected_category" from="module.config.%s_hist_cat_key"|args:$_GET.output_type}}
|
||||
{{elseif $_GET.cat_key == -1}}
|
||||
{{:assign selected_category=null}}
|
||||
{{:save key="config" loan_hist_cat_key=null}}
|
||||
{{if $_GET.output_type == "loan"}}
|
||||
{{:save key="config" loan_hist_cat_key=null}}
|
||||
{{elseif $_GET.output_type == "rent"}}
|
||||
{{:save key="config" rent_hist_cat_key=null}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign selected_category=$_GET.cat_key}}
|
||||
{{:save key="config" loan_hist_cat_key=$selected_category}}
|
||||
{{if $_GET.output_type == "loan"}}
|
||||
{{:save key="config" loan_hist_cat_key=$selected_category}}
|
||||
{{elseif $_GET.output_type == "rent"}}
|
||||
{{:save key="config" rent_hist_cat_key=$selected_category}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* condition de filtrage *}}
|
||||
|
|
@ -54,7 +69,12 @@
|
|||
{{/if}}
|
||||
|
||||
{{#foreach from=$config.output_nature key="key"}}
|
||||
{{if $type == 'temporaire' && $fee != 'payant'}}
|
||||
{{if $type != 'temporaire'}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{if $_GET.output_type == "loan" && $fee != 'payant'}}
|
||||
{{:assign var="out_keys." value=$key|quote_sql}}
|
||||
{{elseif $_GET.output_type == "rent" && $fee == 'payant'}}
|
||||
{{:assign var="out_keys." value=$key|quote_sql}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
|
@ -62,13 +82,13 @@
|
|||
{{:assign out_keys="("|cat:$out_keys|cat:")"}}
|
||||
|
||||
{{* sélecteur de catégorie *}}
|
||||
{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}}
|
||||
{{:assign var="cat_options." value="" label="Toutes les catégories" href="?output_type=%s&cat_key=-1"|args:$_GET.output_type}}
|
||||
{{#load type="category" order="$$.name"}}
|
||||
{{:assign
|
||||
var="cat_options."
|
||||
value=$key
|
||||
label=$name
|
||||
href="?cat_key=%s"|args:$key
|
||||
href="?output_type=%s&cat_key=%s"|args:$_GET.output_type:$key
|
||||
}}
|
||||
{{/load}}
|
||||
|
||||
|
|
@ -82,7 +102,7 @@
|
|||
</fieldset>
|
||||
|
||||
<div class="shortFormLeft">
|
||||
<p class="help">Location de matériel en cours</p>
|
||||
<p class="help">{{$label|ucfirst}} de matériel en cours</p>
|
||||
</div>
|
||||
|
||||
{{:assign premier=true}}
|
||||
|
|
@ -105,7 +125,7 @@
|
|||
AND !cat_condition
|
||||
GROUP BY mvt.key
|
||||
HAVING remain != 0
|
||||
ORDER BY out_date, nom
|
||||
ORDER BY out_date DESC, nom
|
||||
;
|
||||
!table=$module.table
|
||||
!op = $out_keys
|
||||
|
|
@ -161,9 +181,14 @@
|
|||
href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key
|
||||
shape="reset"
|
||||
target="_dialog"}}
|
||||
{{if $_GET.output_type == "loan"}}
|
||||
{{:assign from="lh"}}
|
||||
{{elseif $_GET.output_type == "rent"}}
|
||||
{{:assign from="rh"}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Détails"
|
||||
href="movements/movement_details.html?key=%s&prop=1&from=lh"|args:$mvt_key
|
||||
href="movements/movement_details.html?key=%s&prop=1&from=%s"|args:$mvt_key:$from
|
||||
shape="eye"
|
||||
}}
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -3,25 +3,66 @@
|
|||
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
|
||||
|
||||
{{*
|
||||
Afficher l'historique des prêts
|
||||
Afficher l'historique des prêts ou locations
|
||||
*}}
|
||||
|
||||
{{:admin_header title="Historique des prêts" custom_css="./style.css" current="module_equipment"}}
|
||||
{{if $_GET.output_type == "loan"}}
|
||||
{{:assign label="prêt"}}
|
||||
{{elseif $_GET.output_type == "rent"}}
|
||||
{{:assign label="location"}}
|
||||
{{else}}
|
||||
{{:error message="Cette page n'existe pas !"}}
|
||||
{{/if}}
|
||||
|
||||
{{:include file="./_nav.html" current="prêts" subcurrent="historique"}}
|
||||
{{:admin_header title="Historique des %ss"|args:$label custom_css="./style.css" current="module_equipment"}}
|
||||
|
||||
{{:include file="./_nav.html" current="%s"|args:$label subcurrent="historique"}}
|
||||
|
||||
{{*
|
||||
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}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="./_get_config.html" keep="config"}}
|
||||
|
||||
{{* filtrer selon la catégorie *}}
|
||||
{{if $_GET.cat_key == null}}
|
||||
{{:assign selected_category=$module.config.loan_cat_key}}
|
||||
{{:assign var="selected_category" from="module.config.%s_cat_key"|args:$_GET.output_type}}
|
||||
{{elseif $_GET.cat_key == -1}}
|
||||
{{:assign selected_category=null}}
|
||||
{{:save key="config" loan_cat_key=null}}
|
||||
{{if $_GET.output_type == "loan"}}
|
||||
{{:save key="config" loan_cat_key=null}}
|
||||
{{elseif $_GET.output_type == "rent"}}
|
||||
{{:save key="config" rent_cat_key=null}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign selected_category=$_GET.cat_key}}
|
||||
{{:save key="config" loan_cat_key=$selected_category}}
|
||||
{{if $_GET.output_type == "loan"}}
|
||||
{{:save key="config" loan_cat_key=$selected_category}}
|
||||
{{elseif $_GET.output_type == "rent"}}
|
||||
{{:save key="config" rent_cat_key=$selected_category}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* condition de filtrage *}}
|
||||
|
|
@ -34,7 +75,12 @@
|
|||
|
||||
{{* déterminer les types de mouvements *}}
|
||||
{{#foreach from=$config.output_nature key="key"}}
|
||||
{{if $type == 'temporaire' && $fee != 'payant'}}
|
||||
{{if $type != 'temporaire'}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{if $_GET.output_type == "loan" && $fee != 'payant'}}
|
||||
{{:assign var="out_keys." value=$key|quote_sql}}
|
||||
{{elseif $_GET.output_type == "rent" && $fee == 'payant'}}
|
||||
{{:assign var="out_keys." value=$key|quote_sql}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
|
@ -42,13 +88,13 @@
|
|||
{{:assign out_keys="("|cat:$out_keys|cat:")"}}
|
||||
|
||||
{{* sélecteur de catégorie *}}
|
||||
{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}}
|
||||
{{:assign var="cat_options." value="" label="Toutes les catégories" href="?output_type=%s&cat_key=-1"|args:$_GET.output_type}}
|
||||
{{#load type="category" order="$$.name"}}
|
||||
{{:assign
|
||||
var="cat_options."
|
||||
value=$key
|
||||
label=$name
|
||||
href="?cat_key=%s"|args:$key
|
||||
href="?output_type=%s&cat_key=%s"|args:$_GET.output_type:$key
|
||||
}}
|
||||
{{/load}}
|
||||
|
||||
|
|
@ -62,7 +108,7 @@
|
|||
</fieldset>
|
||||
|
||||
<div class="shortFormLeft">
|
||||
<p class="help">Historique des prêts</p>
|
||||
<p class="help">Historique des {{$label}}s</p>
|
||||
</div>
|
||||
|
||||
{{* lister les mouvements *}}
|
||||
|
|
@ -88,12 +134,9 @@
|
|||
INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
|
||||
LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
|
||||
LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
|
||||
WHERE
|
||||
json_extract(mvt.document, '$.type') = 'movement'
|
||||
AND
|
||||
json_extract(mvt.document, '$.operation') IN !op
|
||||
AND
|
||||
!cat_condition
|
||||
WHERE json_extract(mvt.document, '$.type') = 'movement'
|
||||
AND json_extract(mvt.document, '$.operation') IN !op
|
||||
AND !cat_condition
|
||||
),
|
||||
entrees AS
|
||||
(SELECT
|
||||
|
|
@ -123,12 +166,11 @@
|
|||
)
|
||||
SELECT * FROM sorties UNION SELECT * FROM entrees
|
||||
)
|
||||
ORDER BY date
|
||||
ORDER BY date DESC, user
|
||||
;
|
||||
!table=$module.table
|
||||
!op = $out_keys
|
||||
!cat_condition=$cat_condition
|
||||
assign="mvts."
|
||||
}}
|
||||
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
|
||||
{{:assign file_path="%s/%s/"|args:$module.storage_root:$key}}
|
||||
|
|
@ -150,7 +192,7 @@
|
|||
<td>Stockage</td>
|
||||
<td>Documents</td>
|
||||
<td>Écritures</td>
|
||||
<td>Remarques</td>
|
||||
<td>Remarque</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -170,9 +212,14 @@
|
|||
<td class="num">{{if $transactions != null}}{{:icon shape="money"}}{{/if}}</td>
|
||||
<td>{{$comment}}</td>
|
||||
<td class="actions">
|
||||
{{if $_GET.output_type == "loan"}}
|
||||
{{:assign from="lm"}}
|
||||
{{elseif $_GET.output_type == "rent"}}
|
||||
{{:assign from="rm"}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Détails"
|
||||
href="movements/movement_details.html?key=%s"|args:$key
|
||||
href="movements/movement_details.html?key=%s&prop=1&from=%s"|args:$key:$from
|
||||
shape="eye"
|
||||
}}
|
||||
</td>
|
||||
|
|
@ -181,5 +228,8 @@
|
|||
<p class="block alert">Aucun mouvement.</p>
|
||||
{{/select}}
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="block alert">Aucun mouvement.</p>
|
||||
{{/if}}
|
||||
{{:admin_footer}}
|
||||
|
|
|
|||
|
|
@ -207,12 +207,25 @@
|
|||
transactions=$transactions
|
||||
return_date=$return_date|parse_date
|
||||
}}
|
||||
{{if $_GET.from == "lh"}}
|
||||
{{:assign from="../loan_history.html"}}
|
||||
{{else}}
|
||||
{{:assign from="../equipment_history.html"}}
|
||||
|
||||
{{if $_GET.from|substr:0:1 == "l"}}
|
||||
{{:assign output_type="loan"}}
|
||||
{{elseif $_GET.from|substr:0:1 == "r"}}
|
||||
{{:assign output_type="rent"}}
|
||||
{{/if}}
|
||||
{{if $_GET.from|substr:1:1 == "h"}}
|
||||
{{:assign suffix="history"}}
|
||||
{{elseif $_GET.from|substr:1:1 == "m"}}
|
||||
{{:assign suffix="movements"}}
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.from == "eh"}}
|
||||
{{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}}
|
||||
{{elseif $suffix == null}}
|
||||
{{:redirect force="../index.html"}}
|
||||
{{else}}
|
||||
{{:redirect force="../loan_%s.html?output_type=%s&ok=1&key=%s&prop=%s&msg=copie"|args:$suffix:$output_type:$eqpmt_key:$prop}}
|
||||
{{/if}}
|
||||
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=copie"|args:$from:$eqpmt_key:$prop}}
|
||||
{{/form}}
|
||||
|
||||
{{if $mvt_new.direction == "input"}}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,25 @@
|
|||
{{: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 $_GET.from|substr:0:1 == "l"}}
|
||||
{{:assign output_type="loan"}}
|
||||
{{elseif $_GET.from|substr:0:1 == "r"}}
|
||||
{{:assign output_type="rent"}}
|
||||
{{/if}}
|
||||
{{if $_GET.from|substr:1:1 == "h"}}
|
||||
{{:assign suffix="history"}}
|
||||
{{elseif $_GET.from|substr:1:1 == "m"}}
|
||||
{{:assign suffix="movements"}}
|
||||
{{/if}}
|
||||
{{if $_GET.from == "eh"}}
|
||||
{{:assign from="../equipment_history.html"}}
|
||||
{{elseif $suffix == null}}
|
||||
{{:assign from="../index.html"}}
|
||||
{{else}}
|
||||
{{:assign from="../loan_%s.html"|args:$suffix}}
|
||||
{{:assign param="&output_type=%s"|args:$output_type}}
|
||||
{{/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}}
|
||||
|
|
@ -36,7 +50,7 @@
|
|||
{{:assign link_key=$key}}
|
||||
{{/load}}
|
||||
{{if $link_key != null}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression%s"|args:$from:$mvt_suppr.equipment:$_GET.prop:$param}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign dispo=0}}
|
||||
|
|
@ -69,7 +83,7 @@
|
|||
|
||||
{{* problème ? *}}
|
||||
{{if $dispo < 0 || $nonprop < 0}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression%s"|args:$from:$mvt_suppr.equipment:$_GET.prop:$param}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
|
@ -90,7 +104,7 @@
|
|||
{{:assign link_key=$key}}
|
||||
{{/load}}
|
||||
{{if $link_key != null}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression%s"|args:$from:$mvt_suppr.equipment:$_GET.prop:$param}}
|
||||
{{/if}}
|
||||
{{elseif $type_operation == 'retour'}}
|
||||
{{#load type="link" where="$$.return = :key" :key=$_GET.key}}
|
||||
|
|
@ -155,11 +169,11 @@
|
|||
out=$curr_eqpmt.out
|
||||
notowned=$curr_eqpmt.notowned
|
||||
}}
|
||||
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}}
|
||||
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=suppression%s"|args:$from:$mvt_suppr.equipment:$_GET.prop:$param}}
|
||||
{{else}}
|
||||
{{* supprimer le matériel *}}
|
||||
{{:delete key=$curr_eqpmt.key}}
|
||||
{{:redirect force="../index.html?ok=1&msg=supprmvtmat"}}
|
||||
{{:redirect force="%s?ok=1&msg=supprmvtmat%s"|args:$from:$param}}
|
||||
{{/if}}
|
||||
{{/form}}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,12 +224,25 @@
|
|||
transactions=$transactions
|
||||
return_date=$return_date|parse_date
|
||||
}}
|
||||
{{if $_GET.from == "lh"}}
|
||||
{{:assign from="../loan_history.html"}}
|
||||
{{else}}
|
||||
{{:assign from="../equipment_history.html"}}
|
||||
|
||||
{{if $_GET.from|substr:0:1 == "l"}}
|
||||
{{:assign output_type="loan"}}
|
||||
{{elseif $_GET.from|substr:0:1 == "r"}}
|
||||
{{:assign output_type="rent"}}
|
||||
{{/if}}
|
||||
{{if $_GET.from|substr:1:1 == "h"}}
|
||||
{{:assign suffix="history"}}
|
||||
{{elseif $_GET.from|substr:1:1 == "m"}}
|
||||
{{:assign suffix="movements"}}
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.from == "eh"}}
|
||||
{{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}}
|
||||
{{elseif $suffix == null}}
|
||||
{{:redirect force="../index.html"}}
|
||||
{{else}}
|
||||
{{:redirect force="../loan_%s.html?output_type=%s&ok=1&key=%s&prop=%s&msg=modification"|args:$suffix:$output_type:$eqpmt_key:$prop}}
|
||||
{{/if}}
|
||||
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=modification"|args:$from:$eqpmt_key:$prop}}
|
||||
{{/form}}
|
||||
|
||||
{{if $mvt_new.direction == "input"}}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
paramètres :
|
||||
- key : clé du mouvement
|
||||
- prop = 1 si matériel appartient à l'asso
|
||||
- from = page d'appel
|
||||
*}}
|
||||
|
||||
{{:admin_header title="Détails du mouvement" custom_css="../style.css" current="module_equipment"}}
|
||||
|
|
|
|||
|
|
@ -1,180 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
|
||||
|
||||
{{:admin_header title="Locations en cours" custom_css="../style.css" current="module_equipment"}}
|
||||
{{:include file="./_nav.html" current="location" subcurrent="encours"}}
|
||||
|
||||
{{*
|
||||
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"}}
|
||||
|
||||
{{* filtrer selon la catégorie *}}
|
||||
{{if $_GET.cat_key == null}}
|
||||
{{:assign selected_category=$module.config.rent_hist_cat_key}}
|
||||
{{elseif $_GET.cat_key == -1}}
|
||||
{{:assign selected_category=null}}
|
||||
{{:save key="config" rent_hist_cat_key=null}}
|
||||
{{else}}
|
||||
{{:assign selected_category=$_GET.cat_key}}
|
||||
{{:save key="config" rent_hist_cat_key=$selected_category}}
|
||||
{{/if}}
|
||||
|
||||
{{* condition de filtrage *}}
|
||||
{{if $selected_category != null}}
|
||||
{{:assign cat_key=$selected_category|quote_sql}}
|
||||
{{:assign cat_condition="json_extract(mat.document, '$.category') = %s"|args:$cat_key}}
|
||||
{{else}}
|
||||
{{:assign cat_condition=1}}
|
||||
{{/if}}
|
||||
|
||||
{{#foreach from=$config.output_nature key="key"}}
|
||||
{{if $type == 'temporaire' && $fee == 'payant'}}
|
||||
{{:assign var="out_keys." value=$key|quote_sql}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{:assign out_keys=$out_keys|implode:","}}
|
||||
{{:assign out_keys="("|cat:$out_keys|cat:")"}}
|
||||
|
||||
{{* sélecteur de catégorie *}}
|
||||
{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}}
|
||||
{{#load type="category" order="$$.name"}}
|
||||
{{:assign
|
||||
var="cat_options."
|
||||
value=$key
|
||||
label=$name
|
||||
href="?cat_key=%s"|args:$key
|
||||
}}
|
||||
{{/load}}
|
||||
|
||||
<fieldset class="shortFormRight">
|
||||
<legend>Filtrer par catégorie</legend>
|
||||
{{:dropdown
|
||||
title="Filtrer par catégorie"
|
||||
options=$cat_options
|
||||
value="%s"|args:$selected_category
|
||||
}}
|
||||
</fieldset>
|
||||
|
||||
<div class="shortFormLeft">
|
||||
<p class="help">Location de matériel en cours</p>
|
||||
</div>
|
||||
|
||||
{{:assign premier=true}}
|
||||
{{#select
|
||||
users.nom AS nom,
|
||||
users.id AS user,
|
||||
mvt.key AS mvt_key,
|
||||
json_extract(mat.document, '$.name') AS mat_name,
|
||||
json_extract(mvt.document, '$.date') AS out_date,
|
||||
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 !table AS mvt
|
||||
LEFT JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
||||
LEFT JOIN !table AS links ON mvt.key = json_extract(links.document, '$.temp_key')
|
||||
LEFT JOIN !table AS retour ON retour.key = json_extract(links.document, '$.return')
|
||||
INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
|
||||
WHERE json_extract(mvt.document, '$.type') = 'movement'
|
||||
AND json_extract(mvt.document, '$.operation') IN !op
|
||||
AND !cat_condition
|
||||
GROUP BY mvt.key
|
||||
HAVING remain != 0
|
||||
ORDER BY out_date, nom
|
||||
;
|
||||
!table=$module.table
|
||||
!op = $out_keys
|
||||
!cat_condition=$cat_condition
|
||||
}}
|
||||
{{if $premier}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Matériel</td>
|
||||
<td>Date prêt</td>
|
||||
<td>Quantité</td>
|
||||
<td>Membre</td>
|
||||
<td>Date retour</td>
|
||||
<td>Reste à rendre</td>
|
||||
<td>Remarque</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{:assign premier=false}}
|
||||
{{/if}}
|
||||
|
||||
{{if $return_date != null}}
|
||||
{{:assign ts_retour=$return_date|strtotime}}
|
||||
{{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}}
|
||||
{{/if}}
|
||||
<tr>
|
||||
<td>{{$mat_name}}</td>
|
||||
<td>{{$out_date|date_short}}</td>
|
||||
<td>{{$out_amount}}</td>
|
||||
<td>{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$nom}}</td>
|
||||
<td>{{$return_date|date_short}}</td>
|
||||
<td>{{$remain}}</td>
|
||||
<td>
|
||||
{{if $return_date != null}}
|
||||
{{: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 aujourd'hui"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Retour"
|
||||
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}}
|
||||
<p class="block alert">Aucun mouvement.</p>
|
||||
{{/select}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="block alert">Aucun mouvement.</p>
|
||||
{{/if}}
|
||||
|
||||
{{:admin_footer}}
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
|
||||
|
||||
{{*
|
||||
Afficher l'historique des locations
|
||||
*}}
|
||||
|
||||
{{:admin_header title="Historique des locations" custom_css="./style.css" current="module_equipment"}}
|
||||
|
||||
{{:include file="./_nav.html" current="location" subcurrent="historique"}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="./_get_config.html" keep="config"}}
|
||||
|
||||
{{* filtrer selon la catégorie *}}
|
||||
{{if $_GET.cat_key == null}}
|
||||
{{:assign selected_category=$module.config.rent_cat_key}}
|
||||
{{elseif $_GET.cat_key == -1}}
|
||||
{{:assign selected_category=null}}
|
||||
{{:save key="config" rent_cat_key=null}}
|
||||
{{else}}
|
||||
{{:assign selected_category=$_GET.cat_key}}
|
||||
{{:save key="config" rent_cat_key=$selected_category}}
|
||||
{{/if}}
|
||||
|
||||
{{* condition de filtrage *}}
|
||||
{{if $selected_category != null}}
|
||||
{{:assign cat_key=$selected_category|quote_sql}}
|
||||
{{:assign cat_condition="category = %s"|args:$cat_key}}
|
||||
{{else}}
|
||||
{{:assign cat_condition=1}}
|
||||
{{/if}}
|
||||
|
||||
{{* déterminer les types de mouvements *}}
|
||||
{{#foreach from=$config.output_nature key="key"}}
|
||||
{{if $type == 'temporaire' && $fee == 'payant'}}
|
||||
{{:assign var="out_keys." value=$key|quote_sql}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{:assign out_keys=$out_keys|implode:","}}
|
||||
{{:assign out_keys="("|cat:$out_keys|cat:")"}}
|
||||
|
||||
{{* sélecteur de catégorie *}}
|
||||
{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}}
|
||||
{{#load type="category" order="$$.name"}}
|
||||
{{:assign
|
||||
var="cat_options."
|
||||
value=$key
|
||||
label=$name
|
||||
href="?cat_key=%s"|args:$key
|
||||
}}
|
||||
{{/load}}
|
||||
|
||||
<fieldset class="shortFormRight">
|
||||
<legend>Filtrer par catégorie</legend>
|
||||
{{:dropdown
|
||||
title="Filtrer par catégorie"
|
||||
options=$cat_options
|
||||
value="%s"|args:$selected_category
|
||||
}}
|
||||
</fieldset>
|
||||
|
||||
<div class="shortFormLeft">
|
||||
<p class="help">Historique des locations</p>
|
||||
</div>
|
||||
|
||||
{{* lister les mouvements *}}
|
||||
{{:assign premier=true}}
|
||||
{{#select * FROM
|
||||
(WITH
|
||||
sorties AS
|
||||
(SELECT
|
||||
mvt.key,
|
||||
json_extract(mvt.document, '$.date') AS date,
|
||||
json_extract(mvt.document, '$.direction') AS direction,
|
||||
json_extract(mvt.document, '$.operation') AS operation,
|
||||
json_extract(mat.document, '$.name') AS materiel,
|
||||
json_extract(mat.document, '$.category') AS category,
|
||||
json_extract(mvt.document, '$.amount') AS amount,
|
||||
users.id AS user_id,
|
||||
users.nom AS user,
|
||||
json_extract(storage.document, '$.name') AS stockage,
|
||||
json_extract(mvt.document, '$.transactions') AS transactions,
|
||||
json_extract(mvt.document, '$.comment') AS comment,
|
||||
json_extract(mvt.document, '$.return_date') AS return_date
|
||||
FROM !table AS mvt
|
||||
INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
|
||||
LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
|
||||
LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
|
||||
WHERE json_extract(mvt.document, '$.type') = 'movement'
|
||||
AND json_extract(mvt.document, '$.operation') IN !op
|
||||
AND !cat_condition
|
||||
),
|
||||
entrees AS
|
||||
(SELECT
|
||||
mvt.key,
|
||||
json_extract(mvt.document, '$.date') AS date,
|
||||
json_extract(mvt.document, '$.direction') AS direction,
|
||||
json_extract(mvt.document, '$.operation') AS operation,
|
||||
json_extract(mat.document, '$.name') AS materiel,
|
||||
json_extract(mat.document, '$.category') AS category,
|
||||
json_extract(mvt.document, '$.amount') AS amount,
|
||||
users.id AS user_id,
|
||||
users.nom AS user,
|
||||
json_extract(storage.document, '$.name') AS stockage,
|
||||
json_extract(mvt.document, '$.transactions') AS transactions,
|
||||
json_extract(mvt.document, '$.comment') AS comment,
|
||||
json_extract(mvt.document, '$.return_date') AS return_date
|
||||
FROM !table AS mvt
|
||||
INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
|
||||
LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
|
||||
LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
|
||||
INNER JOIN (
|
||||
SELECT json_extract(links.document, '$.return') AS return_key
|
||||
FROM !table AS links
|
||||
INNER JOIN sorties ON json_extract(links.document, '$.temp_key') = sorties.key
|
||||
) AS filtered_links ON filtered_links.return_key = mvt.key
|
||||
WHERE !cat_condition
|
||||
)
|
||||
SELECT * FROM sorties UNION SELECT * FROM entrees
|
||||
)
|
||||
ORDER BY date
|
||||
;
|
||||
!table=$module.table
|
||||
!op = $out_keys
|
||||
!cat_condition=$cat_condition
|
||||
}}
|
||||
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
|
||||
{{:assign file_path="%s/%s/"|args:$module.storage_root:$key}}
|
||||
{{:assign file_path=$file_path|cat:"%"}}
|
||||
{{#select count(*) AS nb FROM files WHERE path LIKE :file_path ; :file_path=$file_path}}
|
||||
{{:assign nb_files=$nb}}
|
||||
{{/select}}
|
||||
|
||||
{{if $premier}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Date</td>
|
||||
<td>Mouvement</td>
|
||||
<td>Opération</td>
|
||||
<td>Matériel</td>
|
||||
<td class="num">Quantité</td>
|
||||
<td>Dépositaire</td>
|
||||
<td>Stockage</td>
|
||||
<td>Documents</td>
|
||||
<td>Écritures</td>
|
||||
<td>Remarques</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{:assign premier=false}}
|
||||
{{/if}}
|
||||
|
||||
<tr>
|
||||
<td>{{$date|date_short}}</td>
|
||||
<td>{{if $direction == "input"}}Entrée{{else}}Sortie{{/if}}</td>
|
||||
<td>{{$op_label}}</td>
|
||||
<td>{{$materiel}}</td>
|
||||
<td class="num">{{$amount}}</td>
|
||||
<td>{{:link href="/admin/users/details.php?id=%s"|args:$user_id label="%s"|args:$user}}</td>
|
||||
<td>{{$stockage}}</td>
|
||||
<td class="num">{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}</td>
|
||||
<td class="num">{{if $transactions != null}}{{:icon shape="money"}}{{/if}}</td>
|
||||
<td>{{$comment}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Détails"
|
||||
href="movements/movement_details.html?key=%s"|args:$key
|
||||
shape="eye"
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<p class="block alert">Aucun mouvement.</p>
|
||||
{{/select}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{:admin_footer}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue