extranet/public/themes/default/scripts/scorecutoff.js
2013-08-12 12:08:03 +00:00

90 lines
2.5 KiB
JavaScript

function validate() {
var allvals = true;
$("[required]").each(function() {
if(!$(this).val()) {
allvals = false;
$(this).addClass('brsr');
}
else { $(this).removeClass('brsr'); }
});
if ($('[name=encours]').val()<0 || $('[name=encours]').val()>500 || !$('[name=encours]').val()){
allvals = false;
$('[name=encours]').addClass('brsr');
}
else { $('[name=encours]').removeClass('brsr'); }
return allvals;
}
function loading() {
if ($('.loading').css('display')=='none') {
$('.loading').css('display', 'block');
$('.ui-dialog-content').css('overflow','hidden');
$(".ui-dialog-buttonpane button").button("disable");
}
else { $('.loading').css('display', 'none');}
}
$(document).ready(function(){
validate();
});
$('[required]').blur(function(){
validate();
});
$('#dialog').dialog({ buttons: [
{ text: "Valider", click: function() {
var values = $(this).find('form').serialize();
if (validate()) {
loading();
$.post('/saisie/scorecutoff', values, function(data) {
$('#dialog').html(data);
});
}
}},
{ text: "Supprimer", click: function() {
if (validate()) {
$('<div></div>').html('<div style="line-height:25px;">Supprimer Cut-off ?</div><div style="font-size:10px; color:#999;">Toutes les valeurs seront effacées.</div>')
.dialog({
modal: true,
title: 'Confirmation de suppression',
zIndex: 10000,
autoOpen: true,
width: '250',
resizable: false,
buttons: {
Oui: function () {
$('#dialog [name=delete]').val('1');
var values = $('#dialog').find('form').serialize();
$(this).dialog("close");
loading();
$.post('/saisie/scorecutoff', values, function(data) {
$('#dialog').html(data);
});
},
Non: function () {
$(this).dialog("close");
}
},
close: function (event, ui) {
$(this).remove();
}
});
}
}},
{ text: "Fermer", click: function() {
if($(".message p").attr('id')==1) {
loading();
location.reload();
}
else {$(this).dialog('close');}
}
}
] });
if($('#dateInsert').text()!='') {
$(".ui-dialog-buttonpane button:contains('Supprimer')").show();
}
else {
$(".ui-dialog-buttonpane button:contains('Supprimer')").hide();
}