From 443827ff42a04b62715cf69426fc899bc75968bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 17:10:26 +0200 Subject: [PATCH] FIX #18531 --- htdocs/comm/action/card.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 245f90edf72..461002029ae 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -70,6 +70,10 @@ $offsetvalue = GETPOST('offsetvalue', 'int'); $offsetunit = GETPOST('offsetunittype_duration', 'aZ09'); $remindertype = GETPOST('selectremindertype', 'aZ09'); $modelmail = GETPOST('actioncommsendmodel_mail', 'int'); +$complete = GETPOST('complete', 'alpha'); // 'na' must be allowed +if ($complete == 'na' || $complete == -2) { + $complete = -1; +} $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); @@ -240,7 +244,7 @@ if (empty($reshook) && $action == 'add') { exit; } - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status // Clean parameters $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser'); @@ -471,7 +475,7 @@ if (empty($reshook) && $action == 'update') { $apmin = GETPOST('apmin', 'int'); $p2hour = GETPOST('p2hour', 'int'); $p2min = GETPOST('p2min', 'int'); - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status // Clean parameters if ($aphour == -1) { @@ -1074,15 +1078,15 @@ if ($action == 'create') { // Status print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; print ''; - $percent = GETPOST('complete')!=='' ? GETPOST('complete') : -1; + $percent = $complete !=='' ? $complete : -1; if (GETPOSTISSET('status')) { $percent = GETPOST('status'); } elseif (GETPOSTISSET('percentage')) { - $percent = GETPOST('percentage'); + $percent = GETPOST('percentage', 'int'); } else { - if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) { + if ($complete == '0' || GETPOST("afaire") == 1) { $percent = '0'; - } elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) { + } elseif ($complete == 100 || GETPOST("afaire") == 2) { $percent = 100; } } @@ -1348,7 +1352,7 @@ if ($id > 0) { $result5 = $object->fetch_optionals(); if ($listUserAssignedUpdated || $donotclearsession) { - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser'); $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser'); @@ -1542,7 +1546,7 @@ if ($id > 0) { // Status print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - $percent = GETPOST("percentage") ? GETPOST("percentage") : $object->percentage; + $percent = GETPOSTISSET("percentage") ? GETPOST("percentage", "int") : $object->percentage; $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print '';