--- /tmp/dsg/dolibarr/htdocs/cron/admin/github_19.0.3_cron.php
+++ /tmp/dsg/dolibarr/htdocs/cron/admin/client_cron.php
@@ -35 +35 @@
-if (!$user->admin) {

+if (!$user->admin)

@@ -37 +36,0 @@
-}

@@ -39 +38 @@
-$actionsave = GETPOST("save", 'alphanohtml');

+$actionsave = GETPOST("save");

@@ -42 +41,2 @@
-if (!empty($actionsave)) {

+if (!empty($actionsave))

+{

@@ -47 +47 @@
-	$i += dolibarr_set_const($db, 'CRON_KEY', GETPOST("CRON_KEY"), 'chaine', 0, '', 0);

+	$i += dolibarr_set_const($db, 'CRON_KEY', trim(GETPOST("CRON_KEY")), 'chaine', 0, '', 0);

@@ -49 +49,2 @@
-	if ($i >= 1) {

+	if ($i >= 1)

+	{

@@ -52 +53,3 @@
-	} else {

+	}

+	else

+	{

@@ -63,2 +66 @@
-$help_url = '';

-llxHeader('', '', $help_url);

+llxHeader();

@@ -75,3 +77 @@
-print dol_get_fiche_head($head, 'setup', $langs->trans("Module2300Name"), -1, 'cron');

-

-print '<span class="opacitymedium">'.$langs->trans('CronInfo').'</span><br>';

+dol_fiche_head($head, 'setup', $langs->trans("Module2300Name"), -1, 'cron');

@@ -86 +86 @@
-print "<td></td>";

+print "<td>&nbsp;</td>";

@@ -89 +89 @@
-print '<tr class="oddeven">';

+print '<tr class="impair">';

@@ -92,2 +92,7 @@
-if (getDolGlobalString('CRON_DISABLE_KEY_CHANGE')) {

-	$disabled = ' disabled="disabled"';

+if (!empty($conf->global->CRON_DISABLE_KEY_CHANGE)) $disabled = ' disabled="disabled"';

+print '<td>';

+if (empty($conf->global->CRON_DISABLE_KEY_CHANGE))

+{

+    print '<input type="text" class="flat minwidth200"'.$disabled.' id="CRON_KEY" name="CRON_KEY" value="'.(GETPOST('CRON_KEY') ?GETPOST('CRON_KEY') : (!empty($conf->global->CRON_KEY) ? $conf->global->CRON_KEY : '')).'">';

+    if (!empty($conf->use_javascript_ajax))

+    	print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');

@@ -95,9 +100,4 @@
-print '<td>';

-if (!getDolGlobalString('CRON_DISABLE_KEY_CHANGE')) {

-	print '<input type="text" class="flat minwidth300 widthcentpercentminusx"'.$disabled.' id="CRON_KEY" name="CRON_KEY" value="'.(GETPOST('CRON_KEY') ? GETPOST('CRON_KEY') : getDolGlobalString('CRON_KEY')).'">';

-	if (!empty($conf->use_javascript_ajax)) {

-		print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');

-	}

-} else {

-	print getDolGlobalString('CRON_KEY');

-	print '<input type="hidden" id="CRON_KEY" name="CRON_KEY" value="'.(GETPOST('CRON_KEY') ? GETPOST('CRON_KEY') : getDolGlobalString('CRON_KEY')).'">';

+else

+{

+    print (!empty($conf->global->CRON_KEY) ? $conf->global->CRON_KEY : '');

+    print '<input type="hidden" id="CRON_KEY" name="CRON_KEY" value="'.(GETPOST('CRON_KEY') ?GETPOST('CRON_KEY') : (!empty($conf->global->CRON_KEY) ? $conf->global->CRON_KEY : '')).'">';

@@ -111 +111 @@
-print dol_get_fiche_end();

+dol_fiche_end();

@@ -113,3 +113,3 @@
-if (!getDolGlobalString('CRON_DISABLE_KEY_CHANGE')) {

-	print $form->buttonsSaveCancel("Save", '');

-}

+print '<div class="center">';

+print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';

+print '</div>';

@@ -122,4 +122,2 @@
-//print $langs->trans("UseMenuModuleToolsToAddCronJobs", dol_buildpath('/cron/list.php?leftmenu=admintools', 1)).'<br>';

-if (getDolGlobalString('CRON_WARNING_DELAY_HOURS')) {

-	print info_admin($langs->trans("WarningCronDelayed", getDolGlobalString('CRON_WARNING_DELAY_HOURS'))).'<br>';

-}

+print $langs->trans("UseMenuModuleToolsToAddCronJobs", dol_buildpath('/cron/list.php?leftmenu=admintools', 1)).'<br>';

+if (!empty($conf->global->CRON_WARNING_DELAY_HOURS)) print info_admin($langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS)).'<br>';

@@ -134,5 +132,16 @@
-$constname = 'CRON_KEY';

-

-// Add button to autosuggest a key

-include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';

-print dolJSToSetRandomPassword($constname);

+if (!empty($conf->use_javascript_ajax))

+{

+	print "\n".'<script type="text/javascript">';

+	print '$(document).ready(function () {

+		$("#generate_token").click(function() {

+		$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {

+			action: \'getrandompassword\',

+			generic: true

+},

+			function(token) {

+			$("#CRON_KEY").val(token);

+});

+});

+});';

+	print '</script>';

+}