408 lines
16 KiB
XML
408 lines
16 KiB
XML
<metal:block use-macro="main_template">
|
|
<div metal:fill-slot="content">
|
|
|
|
<div class="row">
|
|
<form id="change-eleve-details-form" class="form-horizontal container-fluid" action="${url}" method="post" tal:condition="eleve"
|
|
data-fv-framework="bootstrap"
|
|
data-fv-icon-valid="glyphicon glyphicon-ok"
|
|
data-fv-icon-invalid="glyphicon glyphicon-remove"
|
|
data-fv-icon-validating="glyphicon glyphicon-refresh">
|
|
|
|
<div class="form-group">
|
|
<label class="col-md-3 control-label" for="DATE">Date</label>
|
|
<div class="col-md-6">
|
|
<input class="form-control" tal:attributes="readonly iseditable==False and 'readonly' or None" type="text" id="DATE" name="DATE" value="${date_credit}" placeholder="JJ/MM/AAAA"
|
|
data-fv-notempty="true"
|
|
data-fv-notempty-message="La date est obligatoire" />
|
|
<div id="no_validate_data" class="hidden"><small class="help-block" style="color:#a94442;">Date invalidé </small></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="control-label col-md-3" for="INTITULE">Intitule</label>
|
|
<div class="col-md-6">
|
|
<input class="form-control" type="text" id="INTITULE" name="INTITULE" value="${compte.INTITULE}"
|
|
placeholder="40 caractères maximum"
|
|
data-fv-stringlength="true"
|
|
data-fv-notempty="true"
|
|
data-fv-notempty-message="Intitule est obligatoire" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="form-group " >
|
|
<label class="control-label col-md-6 hidden-xs hidden-sm" style="margin-top:25px;"></label>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6" for="CREDIT">Montant</label>
|
|
<div class="col-md-6">
|
|
<div class="input-group">
|
|
<input class="form-control" type="text" tal:attributes="readonly iseditable==False and 'readonly' or None"
|
|
data-fv-stringlength="true"
|
|
data-fv-stringlength-max="20"
|
|
data-fv-stringlength-message="20 caractères maximum"
|
|
data-fv-notempty="true"
|
|
data-fv-notempty-message="Montant obligatoire"
|
|
id="CREDIT" name="CREDIT" value="${compte.CREDIT}"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6" for="MODE_REGL">Mode de Reglément</label>
|
|
<div class="col-md-6">
|
|
<select class="form-control" name="MODE_REGL" id="MODE_REGL" tal:attributes="readonly iseditable==False and 'readonly' or None" >
|
|
<div tal:repeat="item mode_regls">
|
|
<option value="${item.CODE}" tal:attributes="selected compte.MODE_REGL == item.CODE and 'selected' or None">${item.CODE} | ${item.LIB4}</option>
|
|
</div>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-5">
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6"> Ventilation du montant en : </label>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6" for="MT1"> Leçon : </label>
|
|
<div class="col-md-6">
|
|
<div class="input-group">
|
|
<input class="form-control " tal:attributes="readonly iseditable==False and 'readonly' or None" type="text" id="MT1" name="MT1" value="${compte.MT1}"
|
|
data-fv-stringlength="true"
|
|
data-fv-stringlength-max="40"
|
|
data-fv-stringlength-message="40 caractères maximum"
|
|
data-fv-notempty="true"
|
|
data-fv-notempty-message="Vantilation du montant en Livre obligatoire" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6" for="MT3">Livre : </label>
|
|
<div class="col-md-6">
|
|
<div class="input-group">
|
|
<input class="form-control" tal:attributes="readonly iseditable==False and 'readonly' or None" type="text" id="MT3" name="MT3" value="${compte.MT3}"
|
|
data-fv-stringlength="true"
|
|
data-fv-stringlength-max="40"
|
|
data-fv-stringlength-message="40 caractères maximum"
|
|
data-fv-notempty="true"
|
|
data-fv-notempty-message="Vantilation du montant en Livre obligatoire" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="row" tal:condition="int(code)==9" >
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6">Comptabilisation </label>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6" for="DATE_VALEUR"> Date de valeur : </label>
|
|
<div class="col-md-6">
|
|
<div class="input-group">
|
|
<input class="form-control " tal:attributes="readonly code != 9 and 'readonly' or None" type="text" id="DATE_VALEUR" name="DATE_VALEUR" value="${date_valeur}"
|
|
data-fv-notempty="true"
|
|
data-fv-notempty-message="La date est obligatoire"
|
|
data-fv-date="true"
|
|
data-fv-date-format="DD/MM/YYYY"
|
|
data-fv-date-message="La date n'est pas valide (JJ/MM/AAAA)" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6" for="MTVAL">Montant valeur : </label>
|
|
<div class="col-md-6">
|
|
<div class="input-group">
|
|
<input class="form-control" type="text" id="MTVAL" name="MTVAL" value="${compte.MTVAL}"
|
|
data-fv-stringlength="true"
|
|
data-fv-stringlength-max="40"
|
|
data-fv-stringlength-message="40 caractères maximum"
|
|
data-fv-notempty="true"
|
|
data-fv-notempty-message="" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6" > Exporté le : ${date_exporte}</label>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label col-md-6">No Chrono : ${compte.no_chrono}</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<br/>
|
|
|
|
<div class="form-group">
|
|
<div class="col-md-offset-4 col-md-5">
|
|
<a class="btn btn-default" tal:condition="eleve.CD_CLI != 0" href="${request.application_url}/fiche_eleve/${eleve.CD_CLI}#compte">
|
|
<span class="glyphicon glyphicon-chevron-left"></span> Annuler</a>
|
|
<a class="btn btn-default" tal:condition="eleve.CD_CLI == 0" href="${request.application_url}/eleves">
|
|
<span class="glyphicon glyphicon-chevron-left" ></span> Annuler</a>
|
|
<button class="btn btn-default" type="submit" name="form.send-email" tal:condition="no_ligne != 0">
|
|
<span class="glyphicon glyphicon-envelope"></span> Email Reçu</button>
|
|
<button class="btn btn-primary" type="submit" name="form.submitted" tal:condition="ismodifiable == True">
|
|
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div> <!-- row -->
|
|
<br />
|
|
<br />
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
var code = ${code};
|
|
|
|
const notEmptyValidator = {
|
|
validators: {
|
|
callback: {
|
|
message: 'Date invalidé',
|
|
callback: function(input) {
|
|
return validateMontant(input)
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
function compareDate(input){
|
|
var replaced = input.replaceAll('/','-')
|
|
var mm = moment.utc(replaced,'DD-MM-YYYY',true)
|
|
if(mm.isValid()){
|
|
var today = moment.utc(new Date())
|
|
var times = mm.toDate().getTime() - today.toDate().getTime();
|
|
var days = Math.round(times /(1000 * 3600 * 24));
|
|
var mode = parseInt($('#MODE_REGL').val());
|
|
console.log(days)
|
|
if(days < 180 && days > -180 && ( code === 9 || (mode === 2 && days > 0 ))){
|
|
$('#DATE_VALEUR').val(input);
|
|
if((mode !== 2 && days !== -1) || (mode === 2 && days < 0)){
|
|
$('#no_validate_data').removeClass("hidden");
|
|
}
|
|
else{
|
|
$('#no_validate_data').addClass("hidden");
|
|
}
|
|
return {
|
|
valid: true,
|
|
}
|
|
}
|
|
else if(days === 0){
|
|
$('#DATE_VALEUR').val(input);
|
|
return {
|
|
valid: true
|
|
}
|
|
}
|
|
else{
|
|
return {
|
|
valid: false,
|
|
message: 'Date invalidé pour ce mode de règlement'
|
|
};
|
|
}
|
|
}
|
|
else{
|
|
return {
|
|
valid: false,
|
|
message: 'Date invalidé'
|
|
};
|
|
}
|
|
}
|
|
|
|
function verifyDate(input){
|
|
var today = new Date();
|
|
var replaced = input.replaceAll('/','-')
|
|
var mm = moment(replaced,'DD-MM-YYYY',true)
|
|
if(mm.isValid()){
|
|
return true;
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
}
|
|
function validateDateValeur(input){
|
|
var replaced = input.replaceAll('/','-')
|
|
var mm = moment.utc(replaced,'DD-MM-YYYY',true)
|
|
if(mm.isValid()){
|
|
var today = moment.utc(new Date())
|
|
var times = mm.toDate().getTime() - today.toDate().getTime();
|
|
var days = Math.round(times /(1000 * 3600 * 24));
|
|
if(days < 180 && days > -180 && (code === 9 || days >=0)){
|
|
$('#DATE').val(input);
|
|
return true
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function validateMontant(input){
|
|
var mt1 = parseFloat($('#MT1').val())
|
|
if(isNaN(mt1)){
|
|
mt1 = 0.0
|
|
}
|
|
var mt3 = parseFloat($('#MT3').val())
|
|
if(isNaN(mt3)){
|
|
mt3 = 0.0
|
|
}
|
|
var somme = parseFloat(mt1 + mt3);
|
|
var inputval = parseFloat(input) ;
|
|
if(isNaN(inputval) || inputval !== somme){
|
|
return false;
|
|
}
|
|
else{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
$('#CREDIT').on('change input',function(){
|
|
var credit = $('#CREDIT').val()
|
|
var val3 = parseFloat($('#MT3').val())
|
|
if(isNaN(val3)){
|
|
val3 = 0.0
|
|
}
|
|
if(val3 <= 0 ){
|
|
$('#MT1').val(credit)
|
|
}
|
|
})
|
|
$('#MT1').on('change input',function(){
|
|
var val1 = parseFloat($('#MT1').val())
|
|
if(isNaN(val1)){
|
|
val1 = 0.0
|
|
}
|
|
var val3 = parseFloat($('#MT3').val())
|
|
if(isNaN(val3)){
|
|
val3 = 0.0
|
|
}
|
|
var somme = val1+val3
|
|
if(!isNaN(somme) && !$('#CREDIT').is('[disabled]')){
|
|
$('#CREDIT').val(somme)
|
|
}
|
|
})
|
|
$('#MT3').on('change input',function(){
|
|
var val1 = parseFloat($('#MT1').val())
|
|
if(isNaN(val1)){
|
|
val1 = 0.0
|
|
}
|
|
var val3 = parseFloat($('#MT3').val())
|
|
if(isNaN(val3)){
|
|
val3 = 0.0
|
|
}
|
|
var somme = val1+val3
|
|
if(!isNaN(somme) && !$('#CREDIT').is('[disabled]')){
|
|
$('#CREDIT').val(somme)
|
|
}
|
|
})
|
|
|
|
var fv = $('#change-eleve-details-form').formValidation({
|
|
fields: {
|
|
DATE: {
|
|
validators: {
|
|
callback: {
|
|
message: 'Date invalidé pour ce mode de règlement',
|
|
callback: function(input) {
|
|
return compareDate(input)
|
|
}
|
|
}
|
|
}
|
|
},
|
|
DATE_VALEUR: {
|
|
validators: {
|
|
callback: {
|
|
message: 'Date invalidé',
|
|
callback: function(input) {
|
|
return validateDateValeur(input)
|
|
}
|
|
},
|
|
date: {
|
|
format: '/DD/MM/YYYY',
|
|
message: 'Date invalidé',
|
|
}
|
|
}
|
|
},
|
|
CREDIT: {
|
|
validators: {
|
|
callback: {
|
|
message: 'Montant incompatible',
|
|
callback: function(input) {
|
|
var flt = parseFloat(input);
|
|
return validateMontant(input) && !isNaN(flt);
|
|
}
|
|
},
|
|
numeric: {
|
|
message: 'Ce n\'est pas un montant validé',
|
|
thousandsSeparator: '',
|
|
decimalSeparator: '.'
|
|
}
|
|
}
|
|
},
|
|
MT1: {
|
|
validators: {
|
|
numeric: {
|
|
message: 'Ce n\'est pas un montant validé',
|
|
thousandsSeparator: '',
|
|
decimalSeparator: '.'
|
|
}
|
|
}
|
|
},
|
|
MT3: {
|
|
validators: {
|
|
numeric: {
|
|
message: 'Ce n\'est pas un montant validé',
|
|
thousandsSeparator: '',
|
|
decimalSeparator: '.'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}).data();
|
|
|
|
$('#MODE_REGL').on('change',function(){
|
|
var input = $('#DATE').val();
|
|
if(!compareDate(input).valid){
|
|
if(parseInt(this.value) != 2 ){
|
|
fv.formValidation.updateStatus($('#DATE'),'INVALID').revalidateField($('#DATE'));
|
|
fv.formValidation.validateField($('#DATE'));
|
|
}
|
|
else{
|
|
fv.formValidation.validateField($('#DATE'))
|
|
fv.formValidation.updateStatus($('#DATE'),'VALID');
|
|
}
|
|
}
|
|
else{
|
|
fv.formValidation.updateStatus($('#DATE'),'VALID');
|
|
}
|
|
});
|
|
|
|
$('#INTITULE').autocomplete({
|
|
source: function (request, response) {
|
|
$.ajax({
|
|
url:'/ajax_libelle_regl',
|
|
dataType: 'json',
|
|
data: {
|
|
recherche: request.term,
|
|
},
|
|
success: function (data) {
|
|
response( data );
|
|
},
|
|
});
|
|
},
|
|
minLength: 1,
|
|
});
|
|
|
|
$('form input').on('keypress', function(e) {
|
|
return e.which !== 13;
|
|
});
|
|
});
|
|
</script>
|
|
|
|
</div>
|
|
</metal:block>
|