mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
work on date edit event (#31112)
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -1227,7 +1227,29 @@ if ($action == 'create') {
|
||||
console.log("setdatefields");
|
||||
setdatefields();
|
||||
});
|
||||
|
||||
var old_startdate = null;
|
||||
$("#ap").focus(function() {
|
||||
old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
|
||||
});
|
||||
$("#ap").next(".ui-datepicker-trigger").click(function() {
|
||||
old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
|
||||
});
|
||||
$("#ap").change(function() {
|
||||
setTimeout(function() {
|
||||
if ($("#p2").val() !== "") {
|
||||
var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
|
||||
var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
|
||||
if (new_startdate > old_enddate) {
|
||||
var timeDiff = old_enddate - old_startdate;
|
||||
var new_enddate = new Date(new_startdate.getTime() + timeDiff);
|
||||
$("#p2").val(formatDate(new_enddate, "' . $langs->trans('FormatDateShortJavaInput') . '"));
|
||||
$("#p2day").val(new_enddate.getDate());
|
||||
$("#p2month").val(new_enddate.getMonth() + 1);
|
||||
$("#p2year").val(new_enddate.getFullYear());
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
$("#actioncode").change(function() {
|
||||
if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
|
||||
else $("#dateend").removeClass("fieldrequired");
|
||||
@@ -1819,6 +1841,29 @@ if ($id > 0) {
|
||||
$("#fullday").change(function() {
|
||||
setdatefields();
|
||||
});
|
||||
var old_startdate = null;
|
||||
$("#ap").focus(function() {
|
||||
old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
|
||||
});
|
||||
$("#ap").next(".ui-datepicker-trigger").click(function() {
|
||||
old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
|
||||
});
|
||||
$("#ap").change(function() {
|
||||
setTimeout(function() {
|
||||
if ($("#p2").val() !== "") {
|
||||
var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
|
||||
var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
|
||||
if (new_startdate > old_enddate) {
|
||||
var timeDiff = old_enddate - old_startdate;
|
||||
var new_enddate = new Date(new_startdate.getTime() + timeDiff);
|
||||
$("#p2").val(formatDate(new_enddate, "' . $langs->trans('FormatDateShortJavaInput') . '"));
|
||||
$("#p2day").val(new_enddate.getDate());
|
||||
$("#p2month").val(new_enddate.getMonth() + 1);
|
||||
$("#p2year").val(new_enddate.getFullYear());
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
$("#actioncode").change(function() {
|
||||
if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
|
||||
else $("#dateend").removeClass("fieldrequired");
|
||||
|
||||
Reference in New Issue
Block a user