Last active
June 26, 2017 10:06
-
-
Save John-Dormevil/390f4f15ad06fb92f074694ae26f8a7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function saveDraft() { | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Tentative de sauvegarde des entrées en cours...") | |
}(), | |
data: { | |
operation: "save", | |
dataTable: findDateAstreinte($(".astreinte")) | |
} | |
}).done(function (data) { | |
$('.show-result').html(dataMsgParser(data)); | |
console.info(data); | |
}).fail(function (data) { | |
console.info(data); | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} | |
function saveDraftAndClose() { | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Tentative de sauvegarde des entrees en cours...") | |
}(), | |
data: { | |
operation: "save", | |
dataTable: findDateAstreinte($(".astreinte")) | |
} | |
}).done(function (data) { | |
$('.show-result').html(dataMsgParser(data)); | |
console.info(data); | |
if(isValidDateAstr() && isValidTimeInt() && !isOverlape() && !isOutside()) { | |
console.info("on peut fermer"); | |
window.close(); | |
} | |
}).fail(function (data) { | |
console.info(data); | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} | |
function deleteDraft() { | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Supression en base du draft en cours...") | |
}(), | |
data: { | |
operation: "delete", | |
dataTable: findDateAstreinte($(".astreinte")) | |
} | |
}).done(function (data) { | |
$('.show-result').html(dataMsgParser(data)); | |
console.info(data); | |
saveDraft(); | |
}).fail(function (data) { | |
console.info(data); | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} | |
function deleteDraftAndClose() { | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Supression en base du draft en cours...") | |
}(), | |
data: { | |
operation: "delete", | |
dataTable: findDateAstreinte($(".astreinte")) | |
} | |
}).done(function (data) { | |
$('.show-result').html(dataMsgParser(data)); | |
console.info(data); | |
saveDraftAndClose(); | |
}).fail(function (data) { | |
console.info(data); | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} | |
function deleteThisArrayAstreinte(arrayDate) { | |
var data = arrayDate; | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Mise a jours et synchronisation de la base...") | |
}(), | |
data: { | |
operation: "delete-this-array-astreinte", | |
dataTable: data | |
} | |
}).done(function (data) { | |
$('.show-result').html(dataMsgParser(data)); | |
console.info(data); | |
}).fail(function (data) { | |
console.info(data); | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} | |
function loader() { | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Chargement des données utilisateur..."); | |
}(), | |
data: { | |
operation: "load", | |
dataTable: findDateAstreinteFromUrl() | |
} | |
}).done(function (data) { | |
$('.show-result').html(dataMsgParseForLoad(data)); | |
loadAndUpdateDatepicker(data); | |
loadAndUpdateIntervention(data); | |
loadAllByMonthYear(); | |
console.info(data); | |
}).fail(function (data) { | |
console.info(data); | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} | |
function autoLoader(dateData) { | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Chargement des données utilisateur..."); | |
}(), | |
data: { | |
operation: "load", | |
dataTable: dateData | |
} | |
}).done(function (data) { | |
$('.show-result').html(dataMsgParseForLoad(data)); //dataMsgParseForLoad(data) | |
loadAndUpdateDatepicker(data); | |
loadAndUpdateIntervention(data); | |
hideModeReader(); | |
console.info(data); | |
}).fail(function (data) { | |
console.info(data); | |
hideModeReader(); | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} | |
function loaderReaderMode() { | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Chargement des données utilisateur mode lecture seule..."); | |
}(), | |
data: { | |
operation: "loadReaderMode", | |
dataTable: [url('?annee'),url('?mois')] | |
} | |
}).done(function (data) { | |
$('.show-result').html('Chargement mode lecture seule aucune anomalie').css("background-color", "#dff0d8"); | |
var arrayDate=[]; | |
data.forEach(function (date) { | |
arrayDate.push(date[0]); | |
}) | |
globalArrayDate = arrayDate; | |
generateDomStructureForTable(arrayDate); | |
autoLoader(arrayDate); | |
console.info(data, globalArrayDate); | |
}).fail(function (data) { | |
console.info('erreur d\'execution',data); | |
$('.show-result').html('Erreur d\'execution l\'ors du chargement en mode lecture seule').css("background-color", "#f2dede"); | |
}); | |
} | |
function loadAllByMonthYear() { | |
var arrayCurrentDays = findDaysInMonth(findCurrentMonthYear()[0], findCurrentMonthYear()[1]); | |
var firstDay = arrayCurrentDays[0]; | |
var lastDay = arrayCurrentDays[arrayCurrentDays.length - 1]; | |
var data = [firstDay, lastDay]; | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
beforeSend: function(){ | |
$('.show-result').html("Mise à jours des champs astreintes et interventions...") | |
}(), | |
data: { | |
operation: "load-all-by-month-year", | |
dataTable: data | |
} | |
}).done(function (data) { | |
$('.show-result').html(dataMsgParserLoadByMonth(data)); | |
compareAndDelete(data); | |
console.info(data); | |
}).fail(function (data) { | |
console.info(data); | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} | |
function loadAllAstreinte() { | |
$.ajax({ | |
method: "POST", | |
url: "https://172.16.145.102/cra35dev/cra35/astreinteAjaxHandler.php", | |
dataType: "json", | |
data: { | |
operation: "load-all-astreinte", | |
dataTable: {} | |
} | |
}).done(function (data) { | |
$('.show-result').html(data).css("background-color", "#dff0d8"); | |
console.info(data); | |
}).fail(function () { | |
$('.show-result').html(data.responseText).css("background-color", "#f2dede"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment