From 33e73afda6aaf1fd225e803cd4fcd24ec46a8412 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 3 Dec 2015 10:51:03 +0100 Subject: [PATCH] FIX : Cannot change the date of a contract #4088 --- htdocs/contrat/card.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5ddb0b343fa..e0d08dbc1fa 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -830,7 +830,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $result = $object->setValueFrom('ref',GETPOST('ref','alpha'));; + $result = $object->setValueFrom('ref',GETPOST('ref','alpha')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref'; @@ -843,6 +843,30 @@ if (empty($reshook)) header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); exit; } + } + elseif ($action=='setdate_contrat') + { + $cancelbutton = GETPOST('cancel'); + + if (!$cancelbutton) { + $result = $object->fetch($id); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + $datacontrat=dol_mktime(GETPOST('date_contrathour'), GETPOST('date_contratmin'), 0, GETPOST('date_contratmonth'), GETPOST('date_contratday'), GETPOST('date_contratyear')); + $result = $object->setValueFrom('date_contrat',$datacontrat,'',null,'date'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'editdate_contrat'; + } else { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit; + } + } + else { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + exit; + } } // Generation doc (depuis lien ou depuis cartouche doc) @@ -1278,8 +1302,15 @@ else print ""; // Date - print ''.$langs->trans("Date").''; - print ''.dol_print_date($object->date_contrat,"dayhour")."\n"; + print ''; + print ''; + print $form->editfieldkey("Date",'date_contrat',$object->date_contrat,$object,$user->rights->contrat->creer); + print ''; + print $form->editfieldval("Date",'date_contrat',$object->date_contrat,$object,$user->rights->contrat->creer,'datehourpicker'); + print ''; + print ''; + /* print ''.$langs->trans("Date").''; + print ''.dol_print_date($object->date_contrat,"dayhour")."\n";*/ // Projet if (! empty($conf->projet->enabled))