diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 98641ae6192..4a78939a8e2 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -839,7 +839,6 @@ if ($action == 'create') $("#p2").removeAttr("disabled"); } } - setdatefields(); $("#fullday").change(function() { console.log("setdatefields"); setdatefields(); @@ -853,11 +852,25 @@ if ($action == 'create') { $("#doneby").val(-1); } - }); - $("#actioncode").change(function() { + }); + $("#actioncode").change(function() { if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired"); else $("#dateend").removeClass("fieldrequired"); - }); + }); + $("#aphour,#apmin").change(function() { + if ($("#actioncode").val() == \'AC_RDV\') { + console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2)); + $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2)); + $("#p2min").val($("#apmin").val()); + $("#p2day").val($("#apday").val()); + $("#p2month").val($("#apmonth").val()); + $("#p2year").val($("#apyear").val()); + $("#p2").val($("#ap").val()); + } + }); + if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired"); + else $("#dateend").removeClass("fieldrequired"); + setdatefields(); })'; print ''."\n"; } @@ -880,8 +893,8 @@ if ($action == 'create') if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''.$langs->trans("Type").''; - $default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ? '' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT); - $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : ($object->type_code ? $object->type_code : $default), "actioncode", "systemauto", 0, -1); + $default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ? 'AC_RDV' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT); + $formactions->select_type_actions(GETPOSTISSET("actioncode") ? GETPOST("actioncode", 'aZ09') : ($object->type_code ? $object->type_code : $default), "actioncode", "systemauto", 0, -1); print ''; } @@ -1204,15 +1217,15 @@ if ($action == 'create') $(".reminderparameters").hide(); } }); - - $("#selectremindertype").click(function(){ + + $("#selectremindertype").click(function(){ var selected_option = $("#selectremindertype option:selected").val(); if(selected_option == "email") { $("#select_actioncommsendmodel_mail").closest("tr").show(); } else { $("#select_actioncommsendmodel_mail").closest("tr").hide(); }; - }); + }); })'; print ''."\n"; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a09bcc455ea..ed80b07f480 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5594,9 +5594,11 @@ class Form if ($addnowlink == 1) { $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; } elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();'; } if ($fullday) $reset_scripts .= ' } '; @@ -5609,9 +5611,11 @@ class Form if ($addnowlink == 1) { $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; } elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();'; } if ($fullday) $reset_scripts .= ' } '; } @@ -5676,7 +5680,7 @@ class Form * @param string $modelType Model type * @return string HTML select string */ - public function select_type_duration($prefix, $selected = 'minute') + public function select_type_duration($prefix, $selected = 'minute') { global $langs;