NEW Add method dolOutputDates()
This commit is contained in:
parent
f852915171
commit
dc794ff2fb
8 changed files with 132 additions and 90 deletions
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -297,43 +297,8 @@ class FormActions
|
|||
print '<td class="nowraponall nopaddingrightimp">'.$actioncomm->getNomUrl(1, -1).'</td>';
|
||||
|
||||
// Date
|
||||
print '<td class="center nowraponall nopaddingtopimp nopaddingbottomimp">';
|
||||
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 '<div class="center inline-block celldateheight">';
|
||||
if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes']) {
|
||||
print dol_print_date($actioncomm->datep, 'dayreduceformat', 'tzuserrel');
|
||||
print '<br><span class="small opacitymedium">';
|
||||
print dol_print_date($actioncomm->datep, 'hourreduceformat', 'tzuserrel');
|
||||
print '-'.dol_print_date($actioncomm->datef, 'hourreduceformat', 'tzuserrel');
|
||||
print '</span>';
|
||||
} else {
|
||||
print dol_print_date($actioncomm->datep, 'dayreduceformat', 'tzuserrel');
|
||||
print '<br><span class="small opacitymedium">';
|
||||
print dol_print_date($actioncomm->datep, 'hourreduceformat', 'tzuserrel');
|
||||
print '</span>';
|
||||
}
|
||||
print '</div>';
|
||||
} else {
|
||||
// Not the same day
|
||||
print '<div class="center inline-block">';
|
||||
print dol_print_date($actioncomm->datep, 'dayreduceformat', 'tzuserrel');
|
||||
print '<br><span class="small opacitymedium">';
|
||||
print dol_print_date($actioncomm->datep, 'hourreduceformat', 'tzuserrel');
|
||||
print '</span>';
|
||||
print '</div>';
|
||||
print ' ';
|
||||
print '<div class="center inline-block">';
|
||||
print dol_print_date($actioncomm->datef, 'dayreduceformat', 'tzuserrel');
|
||||
print '<br><span class="small opacitymedium">';
|
||||
print dol_print_date($actioncomm->datef, 'hourreduceformat', 'tzuserrel');
|
||||
print '</span>';
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
print '<td class="center nowraponall celldateheight">';
|
||||
print dolOutputDates($actioncomm->datep, $actioncomm->datef, $actioncomm->fulldayevent, 0, '', 'tzuserrel', 1);
|
||||
print '</td>';
|
||||
|
||||
// Owner
|
||||
|
|
|
|||
|
|
@ -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 .= '<td class="center nowraponall nopaddingtopimp nopaddingbottomimp">';
|
||||
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 .= '<div class="center inline-block lineheightsmall">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'dayreduceformat', 'tzuserrel');
|
||||
$out .= '<br><span class="opacitymedium hourspan">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'hourreduceformat', 'tzuserrel');
|
||||
$out .= '-'.dol_print_date($histo[$key]['dateend'], 'hourreduceformat', 'tzuserrel');
|
||||
$out .= '</span>';
|
||||
$out .= '</div>';
|
||||
} else {
|
||||
$out .= '<div class="center inline-block lineheightsmall">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'dayreduceformat', 'tzuserrel');
|
||||
$out .= '<br><span class="opacitymedium hourspan">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'hourreduceformat', 'tzuserrel');
|
||||
$out .= '</span>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
} else {
|
||||
// Not the same day
|
||||
$out .= '<div class="center inline-block lineheightsmall">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'dayreduceformat', 'tzuserrel');
|
||||
$out .= '<br><span class="opacitymedium hourspan">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'hourreduceformat', 'tzuserrel');
|
||||
$out .= '</span>';
|
||||
$out .= '</div>';
|
||||
$out .= ' - ';
|
||||
$out .= '<div class="center inline-block lineheightsmall">';
|
||||
$out .= dol_print_date($histo[$key]['dateend'], 'dayreduceformat', 'tzuserrel');
|
||||
$out .= '<br><span class="opacitymedium hourspan">';
|
||||
$out .= dol_print_date($histo[$key]['dateend'], 'hourreduceformat', 'tzuserrel');
|
||||
$out .= '</span>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$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)) {
|
||||
|
|
|
|||
|
|
@ -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 .= '<div class="center inline-block">';
|
||||
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 .= '<br><span class="small opacitymedium">';
|
||||
$s .= dol_print_date($datep, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput);
|
||||
$s .= '-'.dol_print_date($datef, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput);
|
||||
$s .= '</span>';
|
||||
}
|
||||
} else {
|
||||
// The same hour
|
||||
$s .= dol_print_date($datep, 'day'.($reduceformat ? 'reduceformat' : ''), 'tzuserrel');
|
||||
$s .= $pictotoadd;
|
||||
if (empty($fullday)) {
|
||||
$s .= '<br><span class="small opacitymedium">';
|
||||
$s .= dol_print_date($datep, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput);
|
||||
$s .= '</span>';
|
||||
}
|
||||
}
|
||||
$s .= '</div>';
|
||||
} else {
|
||||
// Not the same day
|
||||
$s .= '<div class="center inline-block dateborderright">';
|
||||
$s .= dol_print_date($datep, 'day'.($reduceformat ? 'reduceformat' : ''), $tzoutput);
|
||||
if (empty($fullday)) {
|
||||
$s .= '<br><span class="small opacitymedium">';
|
||||
$s .= dol_print_date($datep, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput);
|
||||
$s .= '</span>';
|
||||
}
|
||||
$s .= '</div>';
|
||||
$s .= '<div class="center inline-block dateborderleft">';
|
||||
$s .= dol_print_date($datef, 'day'.($reduceformat ? 'reduceformat' : ''), 'tzuserrel');
|
||||
$s .= $pictotoadd;
|
||||
if (empty($fullday)) {
|
||||
$s .= '<br><span class="small opacitymedium">';
|
||||
$s .= dol_print_date($datef, 'hour'.($addseconds ? 'sec' : '').'reduceformat', $tzoutput);
|
||||
$s .= '</span>';
|
||||
}
|
||||
$s .= '</div>';
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get array of social network dictionary
|
||||
*
|
||||
|
|
|
|||
|
|
@ -789,9 +789,9 @@ if ($num > 0) {
|
|||
}
|
||||
|
||||
// Date start last run
|
||||
print '<td class="center lineheightsmall" title="'.dol_escape_htmltag($datefromto).'">';
|
||||
print '<td class="center celldateheight" title="'.dol_escape_htmltag($datefromto).'">';
|
||||
if (!empty($datelastrun)) {
|
||||
print dol_print_date($datelastrun, 'dayhoursec', 'tzserver');
|
||||
print dolOutputDates($datelastrun, null, 0, 1, '', 'tzserver');
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) {
|
||||
|
|
@ -836,20 +836,24 @@ if ($num > 0) {
|
|||
}
|
||||
|
||||
// Next run date
|
||||
print '<td class="center lineheightsmall">';
|
||||
print '<td class="center celldateheight">';
|
||||
if (!empty($obj->datenextrun)) {
|
||||
$datenextrun = $db->jdate($obj->datenextrun);
|
||||
if (empty($obj->status)) {
|
||||
print '<span class="opacitymedium strikefordisabled">';
|
||||
}
|
||||
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 '</span>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue