diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d85c18c123e..9b3ef49e1a4 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -189,6 +189,10 @@ class Conf extends stdClass * @var string */ public $format_hour_short; + /** + * @var string + */ + public $format_hour_sec_short; /** * @var string */ @@ -1079,6 +1083,7 @@ class Conf extends stdClass $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags $this->format_hour_short = "%H:%M"; + $this->format_hour_sec_short = "%H:%M:%S"; $this->format_hour_short_duration = "%H:%M"; $this->format_date_text_short = "%d %b %Y"; $this->format_date_text = "%d %B %Y"; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index aa194f8e6f9..366c4e919c5 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -297,43 +297,8 @@ class FormActions print ''.$actioncomm->getNomUrl(1, -1).''; // Date - print ''; - if ($actioncomm->datef) { // There is also a end date - $tmpa = dol_getdate($actioncomm->datep); - $tmpb = dol_getdate($actioncomm->datef); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { - // The same day - print '
'; - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes']) { - print dol_print_date($actioncomm->datep, 'dayreduceformat', 'tzuserrel'); - print '
'; - print dol_print_date($actioncomm->datep, 'hourreduceformat', 'tzuserrel'); - print '-'.dol_print_date($actioncomm->datef, 'hourreduceformat', 'tzuserrel'); - print ''; - } else { - print dol_print_date($actioncomm->datep, 'dayreduceformat', 'tzuserrel'); - print '
'; - print dol_print_date($actioncomm->datep, 'hourreduceformat', 'tzuserrel'); - print ''; - } - print '
'; - } else { - // Not the same day - print '
'; - print dol_print_date($actioncomm->datep, 'dayreduceformat', 'tzuserrel'); - print '
'; - print dol_print_date($actioncomm->datep, 'hourreduceformat', 'tzuserrel'); - print ''; - print '
'; - print ' '; - print '
'; - print dol_print_date($actioncomm->datef, 'dayreduceformat', 'tzuserrel'); - print '
'; - print dol_print_date($actioncomm->datef, 'hourreduceformat', 'tzuserrel'); - print ''; - print '
'; - } - } + print ''; + print dolOutputDates($actioncomm->datep, $actioncomm->datef, $actioncomm->fulldayevent, 0, '', 'tzuserrel', 1); print ''; // Owner diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 8c5fbd97e86..b3f8ffe32ac 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1899,7 +1899,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr $sql .= " a.percent as percent, 'action' as type,"; $sql .= " a.fk_element, a.elementtype,"; $sql .= " a.fk_contact,"; - $sql .= " a.code,"; + $sql .= " a.code, a.fulldayevent,"; $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) { @@ -2202,6 +2202,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr 'id' => (int) $obj->id, 'datestart' => $db->jdate($obj->dp), 'dateend' => $db->jdate($obj->dp2), + 'fulldayevent' => (int) $obj->fulldayevent, 'note' => $obj->label, 'percent' => (int) $obj->percent, @@ -2233,6 +2234,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr 'id' => (int) $obj->id, 'datestart' => $db->jdate($obj->dp), 'dateend' => $db->jdate($obj->dp2), + 'fulldayevent' => (int) $obj->fulldayevent, 'note' => $obj->label, 'percent' => (int) $obj->percent, @@ -2419,44 +2421,9 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr // Date $out .= ''; - if ($histo[$key]['dateend']) { // There is also a end date - $tmpa = dol_getdate($histo[$key]['datestart']); - $tmpb = dol_getdate($histo[$key]['dateend']); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { - // The same day - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes']) { - $out .= '
'; - $out .= dol_print_date($histo[$key]['datestart'], 'dayreduceformat', 'tzuserrel'); - $out .= '
'; - $out .= dol_print_date($histo[$key]['datestart'], 'hourreduceformat', 'tzuserrel'); - $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hourreduceformat', 'tzuserrel'); - $out .= ''; - $out .= '
'; - } else { - $out .= '
'; - $out .= dol_print_date($histo[$key]['datestart'], 'dayreduceformat', 'tzuserrel'); - $out .= '
'; - $out .= dol_print_date($histo[$key]['datestart'], 'hourreduceformat', 'tzuserrel'); - $out .= ''; - $out .= '
'; - } - } else { - // Not the same day - $out .= '
'; - $out .= dol_print_date($histo[$key]['datestart'], 'dayreduceformat', 'tzuserrel'); - $out .= '
'; - $out .= dol_print_date($histo[$key]['datestart'], 'hourreduceformat', 'tzuserrel'); - $out .= ''; - $out .= '
'; - $out .= ' - '; - $out .= '
'; - $out .= dol_print_date($histo[$key]['dateend'], 'dayreduceformat', 'tzuserrel'); - $out .= '
'; - $out .= dol_print_date($histo[$key]['dateend'], 'hourreduceformat', 'tzuserrel'); - $out .= ''; - $out .= '
'; - } - } + + $out .= dolOutputDates($histo[$key]['datestart'], $histo[$key]['dateend'], $histo[$key]['fulldayevent'], 0, '', 'tzuserrel', 1); + // Add the late warning $late = 0; if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9b0aa7b5d6a..b70b09c6574 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3983,6 +3983,12 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); } elseif ($format == 'hour') { $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); + } elseif ($format == 'hoursec') { + $s1 = $outputlangs->trans("FormatDateShort"); + $s2 = $outputlangs->trans("FormatDateHourSecShort"); + $s3 = trim(preg_replace('/'.preg_quote($s1, '/').'/', '', $s2)); // Try to guess the format for FormatHourSecShort using FormatDateShort and FormatDateHourSecShort + $format = $s3; + //$format = ($outputlangs->trans("FormatHourSecShort") != "FormatHourSecShort" ? $outputlangs->trans("FormatHourSecShort") : ($s3 ? $s3 : $conf->format_hour_sec_short)); } elseif ($format == 'hourduration') { $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); } elseif ($format == 'daytext') { @@ -4541,6 +4547,82 @@ function dol_print_email($email, $contactid = 0, $socid = 0, $addlink = 0, $max return $rep; } + +/** + * Print decorated date-hour + * + * @param int $datep Date + * @param int|null $datef Second date + * @param int $fullday Set to 1 for full day (hours are hidden) + * @param int $addseconds Add also seconds + * @param string $pictotoadd Picto to add + * @param string|bool $tzoutput true or 'gmt' => string is for Greenwich location + * false or 'tzserver' => output string is for local PHP server TZ usage + * 'tzuser' => output string is for user TZ (current browser TZ with current dst) => In a future, we should have same behaviour than 'tzuserrel' + * 'tzuserrel' => output string is for user TZ (current browser TZ with dst or not, depending on date position) + * @param string $reduceformat Use 1 to use a reduce format + * @return string Decorated date + */ +function dolOutputDates($datep, $datef = null, $fullday = 0, $addseconds = 0, $pictotoadd = '', $tzoutput = 'tzuserrel', $reduceformat = 0) +{ + $tmpa = dol_getdate($datep); + if (empty($datef)) { + $tmpb = $tmpa; + } else { + $tmpb = dol_getdate($datef); + } + + $s = ''; + + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { + // The same day + $s .= '
'; + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes']) { + // Not the same hour + $s .= dol_print_date($datep, 'day'.($reduceformat ? 'reduceformat' : ''), $tzoutput); + $s .= $pictotoadd; + if (empty($fullday)) { + $s .= '
'; + $s .= dol_print_date($datep, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput); + $s .= '-'.dol_print_date($datef, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput); + $s .= ''; + } + } else { + // The same hour + $s .= dol_print_date($datep, 'day'.($reduceformat ? 'reduceformat' : ''), 'tzuserrel'); + $s .= $pictotoadd; + if (empty($fullday)) { + $s .= '
'; + $s .= dol_print_date($datep, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput); + $s .= ''; + } + } + $s .= '
'; + } else { + // Not the same day + $s .= '
'; + $s .= dol_print_date($datep, 'day'.($reduceformat ? 'reduceformat' : ''), $tzoutput); + if (empty($fullday)) { + $s .= '
'; + $s .= dol_print_date($datep, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput); + $s .= ''; + } + $s .= '
'; + $s .= '
'; + $s .= dol_print_date($datef, 'day'.($reduceformat ? 'reduceformat' : ''), 'tzuserrel'); + $s .= $pictotoadd; + if (empty($fullday)) { + $s .= '
'; + $s .= dol_print_date($datef, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput); + $s .= ''; + } + $s .= '
'; + } + + return $s; +} + + /** * Get array of social network dictionary * diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index c75d4d3eb19..ca30c277f34 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -789,9 +789,9 @@ if ($num > 0) { } // Date start last run - print ''; + print ''; if (!empty($datelastrun)) { - print dol_print_date($datelastrun, 'dayhoursec', 'tzserver'); + print dolOutputDates($datelastrun, null, 0, 1, '', 'tzserver'); } print ''; if (!$i) { @@ -836,20 +836,24 @@ if ($num > 0) { } // Next run date - print ''; + print ''; if (!empty($obj->datenextrun)) { $datenextrun = $db->jdate($obj->datenextrun); if (empty($obj->status)) { print ''; } - print dol_print_date($datenextrun, 'dayhoursec'); + + $pictotoadd = ''; if ($obj->status == Cronjob::STATUS_ENABLED) { if ($obj->maxrun && $obj->nbrun >= $obj->maxrun) { - print img_warning($langs->trans("MaxRunReached")); + $pictotoadd .= img_warning($langs->trans("MaxRunReached")); } elseif ($datenextrun && $datenextrun < $now) { - print img_warning($langs->trans("Late")); + $pictotoadd .= img_warning($langs->trans("Late")); } } + + print dolOutputDates($datenextrun, null, 0, 1, $pictotoadd); + if (empty($obj->status)) { print ''; } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 99d3d3ff5ac..aa2f9fe189e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -22,6 +22,7 @@ FormatDateShortJQuery=mm/dd/yy FormatDateShortJQueryInput=mm/dd/yy FormatHourShortJQuery=HH:MI FormatHourShort=%I:%M %p +FormatHourSecShort=%I:%M:%S %p FormatHourShortDuration=%H:%M FormatDateTextShort=%b %d, %Y FormatDateText=%B %d, %Y diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 2c2edd09ace..61424af8224 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -662,12 +662,21 @@ span.userimg.notfirst, div.userimg.notfirst { div.userimg.notfirst { display: block-inline; } -.celldateheight { - line-height: 1.1em; -} .cell2linesheight { line-height: 1.4em; } +.celldateheight { + padding-top: 5px !important; + padding-bottom: 5px !important; + line-height: 1.2em; +} +.dateborderright { + padding-right: 4px !important; + margin-right: 4px !important; + border-right: 1px solid #ddd; +} +.dateborderleft { +} .smallheight { line-height: 1em; } @@ -1758,7 +1767,7 @@ select.flat.selectlimit { border-right: none !important; outline: none; } -.strikefordisabled { +.strikefordisabled, .strikefordisabled span, .strikefordisabled div { text-decoration: line-through; } .widthdate { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 75a1b9ab491..94f4f120d02 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -836,12 +836,21 @@ span.userimg.notfirst, div.userimg.notfirst { div.userimg.notfirst { display: block-inline; } -.celldateheight { - line-height: 1.1em; -} .cell2linesheight { line-height: 1.4em; } +.celldateheight { + padding-top: 5px !important; + padding-bottom: 5px !important; + line-height: 1.2em; +} +.dateborderright { + padding-right: 4px !important; + margin-right: 4px !important; + border-right: 1px solid #ddd; +} +.dateborderleft { +} /* Used by timesheets */ span.timesheetalreadyrecorded input { @@ -1883,7 +1892,7 @@ select.flat.selectlimit { border-right: none !important; outline: none; } -.strikefordisabled { +.strikefordisabled, .strikefordisabled span, .strikefordisabled div { text-decoration: line-through; } .widthdate {