diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f3612133100..a181586815f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -58,23 +58,23 @@ $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); $confirm = GETPOST('confirm', 'alpha'); -$fulldayevent = GETPOST('fullday'); +$fulldayevent = GETPOST('fullday', 'alpha'); -$aphour = GETPOST('aphour'); -$apmin = GETPOST('apmin'); -$p2hour = GETPOST('p2hour'); -$p2min = GETPOST('p2min'); +$aphour = GETPOST('aphour', 'int'); +$apmin = GETPOST('apmin', 'int'); +$p2hour = GETPOST('p2hour', 'int'); +$p2min = GETPOST('p2min', 'int'); -$addreminder = GETPOST('addreminder'); -$offsetvalue = GETPOST('offsetvalue'); -$offsetunit = GETPOST('offsetunittype_duration'); -$remindertype = GETPOST('selectremindertype'); -$modelmail = GETPOST('actioncommsendmodel_mail'); +$addreminder = GETPOST('addreminder', 'alpha'); +$offsetvalue = GETPOST('offsetvalue', 'int'); +$offsetunit = GETPOST('offsetunittype_duration', 'aZ09'); +$remindertype = GETPOST('selectremindertype', 'aZ09'); +$modelmail = GETPOST('actioncommsendmodel_mail', 'int'); //var_dump($_POST); exit; -$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); -$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year")); +$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')); // Security check $socid = GETPOST('socid', 'int'); @@ -391,19 +391,7 @@ if (empty($reshook) && $action == 'add') if ($addreminder == 'on'){ $actionCommReminder = new ActionCommReminder($db); - if ($offsetunit == 'minute'){ - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); - } elseif ($offsetunit == 'hour'){ - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'h'); - } elseif ($offsetunit == 'day') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'd'); - } elseif ($offsetunit == 'week') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'w'); - } elseif ($offsetunit == 'month') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'm'); - } elseif ($offsetunit == 'year') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'y'); - } + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); $actionCommReminder->dateremind = $dateremind; $actionCommReminder->typeremind = $remindertype; @@ -418,15 +406,20 @@ if (empty($reshook) && $action == 'add') if ($res <= 0){ // If error - $db->rollback(); + $error++; $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation'); - setEventMessages($error, null, 'errors'); + $error = $langs->trans('ErrorReminderActionCommCreation').' '.$actionCommReminder->error; + setEventMessages($error, $actionCommReminder->errors, 'errors'); $action = 'create'; $donotclearsession = 1; } } - $db->commit(); + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + if (!empty($backtopage)) { dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); @@ -929,9 +922,9 @@ if ($action == 'create') print '     -     '; //print ' - '; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); } print ''; @@ -1208,7 +1201,7 @@ if ($action == 'create') //Time Type print ''.$langs->trans("TimeType").''; - print $form->selectTypeDuration('offsetunit'); + print $form->selectTypeDuration('offsetunit', 'i'); print ''; //Reminder Type diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 2d327cfc409..16384edfcde 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -50,6 +50,9 @@ class ActionCommReminder extends CommonObject */ public $picto = 'generic'; + const STATUS_TODO = 0; + const STATUS_DONE = 1; + /** * 'type' if the field format. @@ -79,7 +82,7 @@ class ActionCommReminder extends CommonObject 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), - 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"m, h, d, w",), + 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"y, m, d, w, h, i",), 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')), 'fk_actioncomm' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1, 'index'=>1,), 'fk_email_template' => array('type'=>'integer', 'label'=>'EmailTemplate', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>0), @@ -121,9 +124,6 @@ class ActionCommReminder extends CommonObject */ public $fk_email_template; - const STATUS_TODO = 0; - const STATUS_DONE = 1; - // END MODULEBUILDER PROPERTIES diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3daaf572ca6..7ec1a32f072 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5680,11 +5680,11 @@ class Form * @param string $selected Selected type * @return string HTML select string */ - public function selectTypeDuration($prefix, $selected = 'minute') + public function selectTypeDuration($prefix, $selected = 'i') { global $langs; - $TDurationTypes = array('year'=>$langs->trans('Years'), 'month'=>$langs->trans('Month'), 'week'=>$langs->trans('Weeks'), 'day'=>$langs->trans('Days'), 'hour'=>$langs->trans('Hours'), 'minute'=>$langs->trans('Minutes')); + $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); $retstring = '