FIX Solve problem with TZ

This commit is contained in:
Laurent Destailleur
2021-01-03 18:42:45 +01:00
parent 645b7694c9
commit b0738643fb
12 changed files with 141 additions and 155 deletions

View File

@@ -462,10 +462,10 @@ if (empty($reshook) && $action == 'update')
if (empty($cancel)) if (empty($cancel))
{ {
$fulldayevent = GETPOST('fullday'); $fulldayevent = GETPOST('fullday');
$aphour = GETPOST('aphour'); $aphour = GETPOST('aphour', 'int');
$apmin = GETPOST('apmin'); $apmin = GETPOST('apmin', 'int');
$p2hour = GETPOST('p2hour'); $p2hour = GETPOST('p2hour', 'int');
$p2min = GETPOST('p2min'); $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(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status
// Clean parameters // Clean parameters
@@ -1324,8 +1324,8 @@ if ($id > 0)
{ {
$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(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // 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, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $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', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'));
$object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm');
$object->label = GETPOST("label", "alphanohtml"); $object->label = GETPOST("label", "alphanohtml");
@@ -1431,7 +1431,7 @@ if ($id > 0)
// Full day event // Full day event
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ? ' checked' : '').'></td></tr>'; print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ? ' checked' : '').'></td></tr>';
// Date start // Date start - end
print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").'</span></td><td colspan="3">'; print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").'</span></td><td colspan="3">';
if (GETPOST("afaire") == 1) { if (GETPOST("afaire") == 1) {
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart');

View File

@@ -208,7 +208,7 @@ if ($object->id > 0)
if (!empty($object->userassigned)) // Now concat assigned users if (!empty($object->userassigned)) // Now concat assigned users
{ {
// Restore array with key with same value than param 'id' // Restore array with key with same value than param 'id'
$tmplist1 = $object->userassigned; $tmplist2 = array(); $tmplist1 = $object->userassigned;
foreach ($tmplist1 as $key => $val) foreach ($tmplist1 as $key => $val)
{ {
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val; if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val;

View File

@@ -272,17 +272,17 @@ if (empty($action) || $action == 'show_month')
$next_year = $next['year']; $next_year = $next['year'];
$next_month = $next['month']; $next_month = $next['month'];
$max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year, 'gmt')); // Nb of days in previous month
$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month
// tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
$tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, 'gmt')) + 2; // date('w') is 0 fo sunday
$tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year, 'gmt');
$next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
if ($next_day < 6) $next_day += 7; if ($next_day < 6) $next_day += 7;
$lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year, 'gmt');
} }
if ($action == 'show_week') if ($action == 'show_week')
{ {
@@ -303,7 +303,7 @@ if ($action == 'show_week')
$next_day = $next['day']; $next_day = $next['day'];
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt');
$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd');
$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));
@@ -322,8 +322,8 @@ if ($action == 'show_day')
$next_day = $next['day']; $next_day = $next['day'];
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year, 'gmt');
$lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year, 'gmt');
} }
//print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
//print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
@@ -399,13 +399,14 @@ $param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : '');
$tabactive = ''; /*$tabactive = '';
if ($action == 'show_month') $tabactive = 'cardmonth'; if ($action == 'show_month') $tabactive = 'cardmonth';
if ($action == 'show_week') $tabactive = 'cardweek'; if ($action == 'show_week') $tabactive = 'cardweek';
if ($action == 'show_day') $tabactive = 'cardday'; if ($action == 'show_day') $tabactive = 'cardday';
if ($action == 'show_list') $tabactive = 'cardlist'; if ($action == 'show_list') $tabactive = 'cardlist';
if ($action == 'show_pertuser') $tabactive = 'cardperuser'; if ($action == 'show_pertuser') $tabactive = 'cardperuser';
if ($action == 'show_pertype') $tabactive = 'cardpertype'; if ($action == 'show_pertype') $tabactive = 'cardpertype';
*/
$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param);
@@ -704,9 +705,7 @@ if ($resql)
} }
// Check values // Check values
if ($event->date_end_in_calendar < $firstdaytoshow || if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
$event->date_start_in_calendar >= $lastdaytoshow)
{
// This record is out of visible range // This record is out of visible range
} else { } else {
if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow;
@@ -714,13 +713,15 @@ if ($resql)
// Add an entry in actionarray for each day // Add an entry in actionarray for each day
$daycursor = $event->date_start_in_calendar; $daycursor = $event->date_start_in_calendar;
$annee = date('Y', $daycursor); $annee = dol_print_date($daycursor, '%Y');
$mois = date('m', $daycursor); $mois = dol_print_date($daycursor, '%m');
$jour = date('d', $daycursor); $jour = dol_print_date($daycursor, '%d');
//var_dump(dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt'));
//var_dump($annee.'-'.$mois.'-'.$jour);
// Loop on each day covered by action to prepare an index to show on calendar // Loop on each day covered by action to prepare an index to show on calendar
$loop = true; $j = 0; $loop = true; $j = 0;
$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
do { do {
//if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>'; //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>';
@@ -787,9 +788,9 @@ if ($showbirthday)
// Add an entry in actionarray for each day // Add an entry in actionarray for each day
$daycursor = $event->date_start_in_calendar; $daycursor = $event->date_start_in_calendar;
$annee = date('Y', $daycursor); $annee = dol_print_date($daycursor, '%Y');
$mois = date('m', $daycursor); $mois = dol_print_date($daycursor, '%m');
$jour = date('d', $daycursor); $jour = dol_print_date($daycursor, '%d');
$loop = true; $loop = true;
$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee);
@@ -870,9 +871,11 @@ if ($conf->global->AGENDA_SHOW_HOLIDAYS)
$event->label = $obj->lastname; $event->label = $obj->lastname;
} }
$annee = date('Y', $event->date_start_in_calendar); $daycursor = $event->date_start_in_calendar;
$mois = date('m', $event->date_start_in_calendar); $annee = dol_print_date($daycursor, '%Y');
$jour = date('d', $event->date_start_in_calendar); $mois = dol_print_date($daycursor, '%m');
$jour = dol_print_date($daycursor, '%d');
$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee);
do { do {
@@ -1530,6 +1533,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$annee = date('Y', $daykey); $annee = date('Y', $daykey);
$mois = date('m', $daykey); $mois = date('m', $daykey);
$jour = date('d', $daykey); $jour = date('d', $daykey);
if ($day == $jour && $month == $mois && $year == $annee) if ($day == $jour && $month == $mois && $year == $annee)
{ {
foreach ($eventarray[$daykey] as $index => $event) foreach ($eventarray[$daykey] as $index => $event)
@@ -1696,6 +1700,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$tmpyearend = date('Y', $event->date_end_in_calendar); $tmpyearend = date('Y', $event->date_end_in_calendar);
$tmpmonthend = date('m', $event->date_end_in_calendar); $tmpmonthend = date('m', $event->date_end_in_calendar);
$tmpdayend = date('d', $event->date_end_in_calendar); $tmpdayend = date('d', $event->date_end_in_calendar);
/*var_dump($tmpyearstart.' '.$tmpmonthstart.' '.$tmpdaystart);
var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
var_dump($annee.' '.$mois.' '.$jour);*/
// Hour start // Hour start
if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour)
{ {

View File

@@ -265,13 +265,13 @@ $next_month = $month;
$next_day = $day; $next_day = $day;
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt');
$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd');
//print $firstday.'-'.$first_month.'-'.$first_year; //print $firstday.'-'.$first_month.'-'.$first_year;
//print dol_print_date($firstdaytoshow,'dayhour'); //print dol_print_date($firstdaytoshow,'dayhour');
//print dol_print_date($lastdaytoshow,'dayhour'); //print dol_print_date($lastdaytoshow,'dayhour');
$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt'));
$tmpday = $first_day; $tmpday = $first_day;
$picto = 'calendarweek'; $picto = 'calendarweek';
@@ -291,14 +291,6 @@ $param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.
//print 'x'.$param; //print 'x'.$param;
$tabactive = '';
if ($action == 'show_month') $tabactive = 'cardmonth';
if ($action == 'show_week') $tabactive = 'cardweek';
if ($action == 'show_day') $tabactive = 'cardday';
if ($action == 'show_list') $tabactive = 'cardlist';
if ($action == 'show_peruser') $tabactive = 'cardperuser';
if ($action == 'show_pertype') $tabactive = 'cardpertype';
$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param);
$head = calendars_prepare_head($paramnoaction); $head = calendars_prepare_head($paramnoaction);
@@ -598,13 +590,13 @@ if ($resql)
// Add an entry in actionarray for each day // Add an entry in actionarray for each day
$daycursor = $event->date_start_in_calendar; $daycursor = $event->date_start_in_calendar;
$annee = date('Y', $daycursor); $annee = dol_print_date($daycursor, '%Y');
$mois = date('m', $daycursor); $mois = dol_print_date($daycursor, '%m');
$jour = date('d', $daycursor); $jour = dol_print_date($daycursor, '%d');
// Loop on each day covered by action to prepare an index to show on calendar // Loop on each day covered by action to prepare an index to show on calendar
$loop = true; $j = 0; $loop = true; $j = 0;
$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
do { do {
//if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>'; //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>';
@@ -735,7 +727,7 @@ foreach ($typeofevents as $typeofevent)
if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1;
if ($today) $style = 'cal_today_peruser'; if ($today) $style = 'cal_today_peruser';
show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, $mont, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
$i++; $i++;
} }
@@ -848,8 +840,6 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
$cases1 = array(); // Color first half hour $cases1 = array(); // Color first half hour
$cases2 = array(); // Color second half hour $cases2 = array(); // Color second half hour
$curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0);
$i = 0; $nummytasks = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); $i = 0; $nummytasks = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
$ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
@@ -859,16 +849,16 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
// We are in a particular day for $username, now we scan all events // We are in a particular day for $username, now we scan all events
foreach ($eventarray as $daykey => $notused) foreach ($eventarray as $daykey => $notused)
{ {
$annee = date('Y', $daykey); $annee = dol_print_date($daykey, '%Y', 'gmt');
$mois = date('m', $daykey); $mois = dol_print_date($daykey, '%m', 'gmt');
$jour = date('d', $daykey); $jour = dol_print_date($daykey, '%d', 'gmt');
//print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n";
if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ? if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ?
{ {
// Scan all event for this date // Scan all event for this date
foreach ($eventarray[$daykey] as $index => $event) foreach ($eventarray[$daykey] as $index => $event)
{ {
//print $daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."<br>\n";
//var_dump($event); //var_dump($event);
$keysofuserassigned = array_keys($event->userassigned); $keysofuserassigned = array_keys($event->userassigned);
@@ -932,9 +922,9 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
$newcolor = ''; //init $newcolor = ''; //init
if (empty($event->fulldayevent)) if (empty($event->fulldayevent))
{ {
$a = dol_mktime((int) $h, 0, 0, $month, $day, $year, false, 0); $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, 'auto', 0);
$b = dol_mktime((int) $h, 30, 0, $month, $day, $year, false, 0); $b = dol_mktime((int) $h, 30, 0, $month, $day, $year, 'auto', 0);
$c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, false, 0); $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, 'auto', 0);
$dateendtouse = $event->date_end_in_calendar; $dateendtouse = $event->date_end_in_calendar;
if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++; if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++;

View File

@@ -268,7 +268,7 @@ $next_month = $next['month'];
$next_day = $next['day']; $next_day = $next['day'];
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt');
$nb_weeks_to_show = (!empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7; $nb_weeks_to_show = (!empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd');
@@ -276,7 +276,7 @@ $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd');
//print dol_print_date($firstdaytoshow,'dayhour'); //print dol_print_date($firstdaytoshow,'dayhour');
//print dol_print_date($lastdaytoshow,'dayhour'); //print dol_print_date($lastdaytoshow,'dayhour');
$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt'));
$tmpday = $first_day; $tmpday = $first_day;
$picto = 'calendarweek'; $picto = 'calendarweek';
@@ -296,15 +296,6 @@ $param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.
//print 'x'.$param; //print 'x'.$param;
$tabactive = '';
if ($action == 'show_month') $tabactive = 'cardmonth';
if ($action == 'show_week') $tabactive = 'cardweek';
if ($action == 'show_day') $tabactive = 'cardday';
if ($action == 'show_list') $tabactive = 'cardlist';
if ($action == 'show_peruser') $tabactive = 'cardperuser';
if ($action == 'show_pertype') $tabactive = 'cardpertype';
$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param);
$head = calendars_prepare_head($paramnoaction); $head = calendars_prepare_head($paramnoaction);
@@ -605,13 +596,13 @@ if ($resql)
// Add an entry in actionarray for each day // Add an entry in actionarray for each day
$daycursor = $event->date_start_in_calendar; $daycursor = $event->date_start_in_calendar;
$annee = date('Y', $daycursor); $annee = dol_print_date($daycursor, '%Y');
$mois = date('m', $daycursor); $mois = dol_print_date($daycursor, '%m');
$jour = date('d', $daycursor); $jour = dol_print_date($daycursor, '%d');
// Loop on each day covered by action to prepare an index to show on calendar // Loop on each day covered by action to prepare an index to show on calendar
$loop = true; $j = 0; $loop = true; $j = 0;
$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
do { do {
//if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>'; //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>';
@@ -680,7 +671,7 @@ while ($currentdaytoshow < $lastdaytoshow) {
// Filter on hours // Filter on hours
print img_picto('', 'clock', 'class="fawidth30 inline-block paddingleft"'); print img_picto('', 'clock', 'class="fawidth30 inline-block paddingleft"');
print '<span class="hideonsmartphone" title="'.$langs->trans("VisibleTimeRange").'">'.$langs->trans("Hours").'</span>'; print '<span class="hideonsmartphone" title="'.$langs->trans("VisibleTimeRange").'">'.$langs->trans("Hours").'</span>';
print "\n".'<div class="ui-grid-a inline-block"><div class="ui-block-a">'; print "\n".'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">'; print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">';
if (empty($conf->dol_use_jmobile)) print ' - '; if (empty($conf->dol_use_jmobile)) print ' - ';
else print '</div><div class="ui-block-b">'; else print '</div><div class="ui-block-b">';
@@ -852,6 +843,7 @@ while ($currentdaytoshow < $lastdaytoshow) {
$tmpday = $tmparray['mday']; $tmpday = $tmparray['mday'];
$tmpmonth = $tmparray['mon']; $tmpmonth = $tmparray['mon'];
$tmpyear = $tmparray['year']; $tmpyear = $tmparray['year'];
//var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear);
$style = 'cal_current_month'; $style = 'cal_current_month';
if ($iter_day == 6) $style .= ' cal_other_month'; if ($iter_day == 6) $style .= ' cal_other_month';
@@ -859,7 +851,7 @@ while ($currentdaytoshow < $lastdaytoshow) {
if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1;
if ($today) $style = 'cal_today_peruser'; if ($today) $style = 'cal_today_peruser';
show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
$i++; $i++;
} }
@@ -977,8 +969,6 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$cases1 = array(); // Color first half hour $cases1 = array(); // Color first half hour
$cases2 = array(); // Color second half hour $cases2 = array(); // Color second half hour
$curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0);
$i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
$ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
@@ -989,16 +979,16 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
// We are in a particular day for $username, now we scan all events // We are in a particular day for $username, now we scan all events
foreach ($eventarray as $daykey => $notused) foreach ($eventarray as $daykey => $notused)
{ {
$annee = date('Y', $daykey); $annee = dol_print_date($daykey, '%Y', 'gmt');
$mois = date('m', $daykey); $mois = dol_print_date($daykey, '%m', 'gmt');
$jour = date('d', $daykey); $jour = dol_print_date($daykey, '%d', 'gmt');
//print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n";
if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ? if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ?
{ {
// Scan all event for this date // Scan all event for this date
foreach ($eventarray[$daykey] as $index => $event) foreach ($eventarray[$daykey] as $index => $event)
{ {
//print $daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."<br>\n";
//var_dump($event); //var_dump($event);
$keysofuserassigned = array_keys($event->userassigned); $keysofuserassigned = array_keys($event->userassigned);
@@ -1088,9 +1078,9 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$newcolor = ''; //init $newcolor = ''; //init
if (empty($event->fulldayevent)) if (empty($event->fulldayevent))
{ {
$a = dol_mktime((int) $h, 0, 0, $month, $day, $year, false, 0); $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, 'auto', 0);
$b = dol_mktime((int) $h, 30, 0, $month, $day, $year, false, 0); $b = dol_mktime((int) $h, 30, 0, $month, $day, $year, 'auto', 0);
$c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, false, 0); $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, 'auto', 0);
$dateendtouse = $event->date_end_in_calendar; $dateendtouse = $event->date_end_in_calendar;
if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++; if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++;

View File

@@ -638,7 +638,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '</td></tr>'; print '</td></tr>';
} else { } else {
print '<tr><td><label for="socid">'.$langs->trans("ThirdParty").'</label></td><td colspan="3" class="maxwidthonsmartphone">'; print '<tr><td><label for="socid">'.$langs->trans("ThirdParty").'</label></td><td colspan="3" class="maxwidthonsmartphone">';
print $form->select_company($socid, 'socid', '', 'SelectThirdParty'); print img_picto('', 'company').$form->select_company($socid, 'socid', '', 'SelectThirdParty');
print '</td></tr>'; print '</td></tr>';
} }
} }
@@ -818,7 +818,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
print '<tr><td>'.$form->editfieldkey('Categories', 'contcats', '', $object, 0).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey('Categories', 'contcats', '', $object, 0).'</td><td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1); $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1);
print $form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, null, null, '90%'); print img_picto('', 'category').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, null, null, '90%');
print "</td></tr>"; print "</td></tr>";
} }
@@ -965,7 +965,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
{ {
print '<tr><td><label for="socid">'.$langs->trans("ThirdParty").'</label></td>'; print '<tr><td><label for="socid">'.$langs->trans("ThirdParty").'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">'; print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); print img_picto('', 'company').$form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty"));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
@@ -1087,39 +1087,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
} }
} }
} }
// if (! empty($conf->socialnetworks->enabled))
// {
// // Jabber ID
// if (! empty($conf->global->SOCIALNETWORKS_JABBER))
// {
// print '<tr><td><label for="jabberid">'.$form->editfieldkey('Jabber', 'jabberid', '', $object, 0).'</label></td>';
// print '<td><input type="text" name="jabberid" id="jabberid" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("jabberid")?GETPOST("jabberid", 'alpha'):$object->jabberid).'"></td></tr>';
// }
// // Skype
// if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
// {
// print '<tr><td><label for="skype">'.$form->editfieldkey('Skype', 'skype', '', $object, 0).'</label></td>';
// print '<td><input type="text" name="skype" id="skype" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("skype")?GETPOST("skype", 'alpha'):$object->skype).'"></td></tr>';
// }
// // Twitter
// if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
// {
// print '<tr><td><label for="twitter">'.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).'</label></td>';
// print '<td><input type="text" name="twitter" id="twitter" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("twitter")?GETPOST("twitter", 'alpha'):$object->twitter).'"></td></tr>';
// }
// // Facebook
// if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
// {
// print '<tr><td><label for="facebook">'.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).'</label></td>';
// print '<td><input type="text" name="facebook" id="facebook" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOST("facebook")?GETPOST("facebook", 'alpha'):$object->facebook).'"></td></tr>';
// }
// // LinkedIn
// if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN))
// {
// print '<tr><td><label for="linkedin">'.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).'</label></td>';
// print '<td><input type="text" name="linkedin" id="linkedin" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOST("linkedin")?GETPOST("linkedin", 'alpha'):$object->linkedin).'"></td></tr>';
// }
// }
// Visibility // Visibility
print '<tr><td><label for="priv">'.$langs->trans("ContactVisibility").'</label></td><td colspan="3">'; print '<tr><td><label for="priv">'.$langs->trans("ContactVisibility").'</label></td><td colspan="3">';
@@ -1155,7 +1122,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
foreach ($cats as $cat) { foreach ($cats as $cat) {
$arrayselected[] = $cat->id; $arrayselected[] = $cat->id;
} }
print $form->multiselectarray('contcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); print img_picto('', 'category').$form->multiselectarray('contcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
print "</td></tr>"; print "</td></tr>";
} }

View File

@@ -102,6 +102,8 @@ class Conf
public $liste_limit; public $liste_limit;
public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user.
/** /**
* Constructor * Constructor
@@ -693,6 +695,8 @@ class Conf
if (defined('MAIN_ANTIVIRUS_COMMAND')) $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND'); if (defined('MAIN_ANTIVIRUS_COMMAND')) $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
if (defined('MAIN_ANTIVIRUS_PARAM')) $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM'); if (defined('MAIN_ANTIVIRUS_PARAM')) $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
if (!empty($this->global->MAIN_TZUSERINPUTKEY)) $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
// For backward compatibility // For backward compatibility
if (isset($this->product)) $this->produit = $this->product; if (isset($this->product)) $this->produit = $this->product;
if (isset($this->facture)) $this->invoice = $this->facture; if (isset($this->facture)) $this->invoice = $this->facture;

View File

@@ -5531,13 +5531,18 @@ class Form
* @param int $stepminutes Specify step for minutes between 1 and 30 * @param int $stepminutes Specify step for minutes between 1 and 30
* @param string $labeladddateof Label to use for the $adddateof parameter. * @param string $labeladddateof Label to use for the $adddateof parameter.
* @param string $placeholder Placeholder * @param string $placeholder Placeholder
* @param mixed $gm 'auto', 'gmt' or 'tzserver' or 'tzuserrel'
* @return string Html for selectDate * @return string Html for selectDate
* @see form_date(), select_month(), select_year(), select_dayofweek() * @see form_date(), select_month(), select_year(), select_dayofweek()
*/ */
public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '', $placeholder = '') public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '', $placeholder = '', $gm = 'auto')
{ {
global $conf, $langs; global $conf, $langs;
if ($gm == 'auto') {
$gm = $conf->tzuserinputkey;
}
$retstring = ''; $retstring = '';
if ($prefix == '') $prefix = 're'; if ($prefix == '') $prefix = 're';
@@ -5553,7 +5558,11 @@ class Form
if ($set_time === '' && $emptydate == 0) if ($set_time === '' && $emptydate == 0)
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$set_time = dol_now('tzuser') - (getServerTimeZoneInt('now') * 3600); // set_time must be relative to PHP server timezone if ($gm == 'tzuser' || $gm == 'tzuserrel') {
$set_time = dol_now($gm);
} else {
$set_time = dol_now('tzuser') - (getServerTimeZoneInt('now') * 3600); // set_time must be relative to PHP server timezone
}
} }
// Analysis of the pre-selection date // Analysis of the pre-selection date
@@ -5569,14 +5578,14 @@ class Form
} elseif (strval($set_time) != '' && $set_time != -1) } elseif (strval($set_time) != '' && $set_time != -1)
{ {
// set_time est un timestamps (0 possible) // set_time est un timestamps (0 possible)
$syear = dol_print_date($set_time, "%Y"); $syear = dol_print_date($set_time, "%Y", $gm);
$smonth = dol_print_date($set_time, "%m"); $smonth = dol_print_date($set_time, "%m", $gm);
$sday = dol_print_date($set_time, "%d"); $sday = dol_print_date($set_time, "%d", $gm);
if ($orig_set_time != '') if ($orig_set_time != '')
{ {
$shour = dol_print_date($set_time, "%H"); $shour = dol_print_date($set_time, "%H", $gm);
$smin = dol_print_date($set_time, "%M"); $smin = dol_print_date($set_time, "%M", $gm);
$ssec = dol_print_date($set_time, "%S"); $ssec = dol_print_date($set_time, "%S", $gm);
} else { } else {
$shour = ''; $shour = '';
$smin = ''; $smin = '';

View File

@@ -465,9 +465,10 @@ function dol_get_next_week($day, $week, $month, $year)
* *
* @param int $year Year * @param int $year Year
* @param int $month Month * @param int $month Month
* @param mixed $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* Exemple: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, a dol_print_date on it will return 1970-01-01 00:00:00 * True or 1 or 'gmt' to compare with GMT date.
* Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, a dol_print_date on it will return 1970-01-01 00:00:00 * Example: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, a dol_print_date on it will return 1970-01-01 00:00:00
* Example: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, a dol_print_date on it will return 1970-01-01 00:00:00
* @return int Date for first day, '' if error * @return int Date for first day, '' if error
*/ */
function dol_get_first_day($year, $month = 1, $gm = false) function dol_get_first_day($year, $month = 1, $gm = false)
@@ -481,7 +482,8 @@ function dol_get_first_day($year, $month = 1, $gm = false)
* *
* @param int $year Year * @param int $year Year
* @param int $month Month * @param int $month Month
* @param boolean $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @return int Date for first day, '' if error * @return int Date for first day, '' if error
*/ */
function dol_get_last_day($year, $month = 12, $gm = false) function dol_get_last_day($year, $month = 12, $gm = false)
@@ -529,7 +531,8 @@ function dol_get_first_hour($date)
* @param int $day Day * @param int $day Day
* @param int $month Month * @param int $month Month
* @param int $year Year * @param int $year Year
* @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @return array year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year * @return array year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year
*/ */
function dol_get_first_day_week($day, $month, $year, $gm = false) function dol_get_first_day_week($day, $month, $year, $gm = false)

View File

@@ -1971,10 +1971,14 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
* *
* @see dol_mktime(), dol_stringtotime(), dol_getdate() * @see dol_mktime(), dol_stringtotime(), dol_getdate()
*/ */
function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlangs = '', $encodetooutput = false) function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = '', $encodetooutput = false)
{ {
global $conf, $langs; global $conf, $langs;
if ($tzoutput == 'auto') {
$tzoutput = $conf->tzuserinputkey;
}
// Clean parameters // Clean parameters
$to_gmt = false; $to_gmt = false;
$offsettz = $offsetdst = 0; $offsettz = $offsetdst = 0;
@@ -2184,17 +2188,23 @@ function dol_getdate($timestamp, $fast = false, $forcetimezone = '')
* @param int $year Year * @param int $year Year
* @param mixed $gm True or 1 or 'gmt'=Input informations are GMT values * @param mixed $gm True or 1 or 'gmt'=Input informations are GMT values
* False or 0 or 'tzserver' = local to server TZ * False or 0 or 'tzserver' = local to server TZ
* 'tzuser' = local to user TZ * 'auto'
* 'tzuser' = local to user TZ taking dst into account at the current date. Not yet implemented.
* 'tzuserrel' = local to user TZ taking dst into account at the given date. Use this one to convert date input from user.
* 'tz,TimeZone' = use specified timezone * 'tz,TimeZone' = use specified timezone
* @param int $check 0=No check on parameters (Can use day 32, etc...) * @param int $check 0=No check on parameters (Can use day 32, etc...)
* @return int|string Date as a timestamp, '' or false if error * @return int|string Date as a timestamp, '' or false if error
* @see dol_print_date(), dol_stringtotime(), dol_getdate() * @see dol_print_date(), dol_stringtotime(), dol_getdate()
*/ */
function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'tzserver', $check = 1) function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'auto', $check = 1)
{ {
global $conf; global $conf;
//print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
if ($gm == 'auto') {
$gm = $conf->tzuserinputkey;
}
// Clean parameters // Clean parameters
if ($hour == -1 || empty($hour)) $hour = 0; if ($hour == -1 || empty($hour)) $hour = 0;
if ($minute == -1 || empty($minute)) $minute = 0; if ($minute == -1 || empty($minute)) $minute = 0;
@@ -2215,7 +2225,7 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'tzserve
{ {
$default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin' $default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin'
$localtz = new DateTimeZone($default_timezone); $localtz = new DateTimeZone($default_timezone);
} elseif ($gm === 'user' || $gm === 'tzuser') } elseif ($gm === 'user' || $gm === 'tzuser' || $gm === 'tzuserrel')
{ {
// We use dol_tz_string first because it is more reliable. // We use dol_tz_string first because it is more reliable.
$default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin' $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin'
@@ -2254,16 +2264,21 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'tzserve
/** /**
* Return date for now. In most cases, we use this function without parameters (that means GMT time). * Return date for now. In most cases, we use this function without parameters (that means GMT time).
* *
* @param string $mode 'gmt' => we return GMT timestamp, * @param string $mode 'auto'
* 'gmt' => we return GMT timestamp,
* 'tzserver' => we add the PHP server timezone * 'tzserver' => we add the PHP server timezone
* 'tzref' => we add the company timezone * 'tzref' => we add the company timezone. Not implemented.
* 'tzuser' => we add the user timezone * 'tzuser' or 'tzuserrel' => we add the user timezone
* @return int $date Timestamp * @return int $date Timestamp
*/ */
function dol_now($mode = 'gmt') function dol_now($mode = 'auto')
{ {
$ret = 0; $ret = 0;
if ($mode == 'auto') {
$mode = 'tzserver';
}
if ($mode == 'gmt') $ret = time(); // Time for now at greenwich. if ($mode == 'gmt') $ret = time(); // Time for now at greenwich.
elseif ($mode == 'tzserver') // Time for now with PHP server timezone added elseif ($mode == 'tzserver') // Time for now with PHP server timezone added
{ {
@@ -2276,7 +2291,7 @@ function dol_now($mode = 'gmt')
$tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time $tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time
$ret=dol_now('gmt')+($tzsecond*3600); $ret=dol_now('gmt')+($tzsecond*3600);
}*/ }*/
elseif ($mode == 'tzuser') // Time for now with user timezone added elseif ($mode == 'tzuser' || $mode == 'tzuserrel') // Time for now with user timezone added
{ {
//print 'time: '.time(); //print 'time: '.time();
$offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60;

View File

@@ -246,8 +246,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateCreation"); print $langs->trans("DateCreation");
if ($usetable) print '</td><td>'; if ($usetable) print '</td><td>';
else print ': '; else print ': ';
print dol_print_date($object->date_creation, 'dayhour'); print dol_print_date($object->date_creation, 'dayhour', 'tzserver');
if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_creation + ($deltadateforuser * 3600), "dayhour").' &nbsp;'.$langs->trans("ClientHour"); if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_creation, "dayhour", "tzuserrel").' &nbsp;'.$langs->trans("ClientHour");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
} }
@@ -280,8 +280,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateLastModification"); print $langs->trans("DateLastModification");
if ($usetable) print '</td><td>'; if ($usetable) print '</td><td>';
else print ': '; else print ': ';
print dol_print_date($object->date_modification, 'dayhour'); print dol_print_date($object->date_modification, 'dayhour', 'tzserver');
if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_modification + ($deltadateforuser * 3600), "dayhour").' &nbsp;'.$langs->trans("ClientHour"); if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_modification, "dayhour", "tzuserrel").' &nbsp;'.$langs->trans("ClientHour");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
} }
@@ -314,8 +314,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateValidation"); print $langs->trans("DateValidation");
if ($usetable) print '</td><td>'; if ($usetable) print '</td><td>';
else print ': '; else print ': ';
print dol_print_date($object->date_validation, 'dayhour'); print dol_print_date($object->date_validation, 'dayhour', 'tzserver');
if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_validation + ($deltadateforuser * 3600), "dayhour").' &nbsp;'.$langs->trans("ClientHour"); if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_validation, "dayhour", 'tzserver').' &nbsp;'.$langs->trans("ClientHour");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
} }
@@ -348,8 +348,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateApprove"); print $langs->trans("DateApprove");
if ($usetable) print '</td><td>'; if ($usetable) print '</td><td>';
else print ': '; else print ': ';
print dol_print_date($object->date_approve, 'dayhour'); print dol_print_date($object->date_approve, 'dayhour', 'tzserver');
if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_approve + ($deltadateforuser * 3600), "dayhour").' &nbsp;'.$langs->trans("ClientHour"); if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_approve, "dayhour", 'tzserver').' &nbsp;'.$langs->trans("ClientHour");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
} }
@@ -376,8 +376,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateApprove2"); print $langs->trans("DateApprove2");
if ($usetable) print '</td><td>'; if ($usetable) print '</td><td>';
else print ': '; else print ': ';
print dol_print_date($object->date_approve2, 'dayhour'); print dol_print_date($object->date_approve2, 'dayhour', 'tzserver');
if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_approve2 + ($deltadateforuser * 3600), "dayhour").' &nbsp;'.$langs->trans("ClientHour"); if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_approve2, "dayhour", 'tzserver').' &nbsp;'.$langs->trans("ClientHour");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
} }
@@ -412,8 +412,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateClosing"); print $langs->trans("DateClosing");
if ($usetable) print '</td><td>'; if ($usetable) print '</td><td>';
else print ': '; else print ': ';
print dol_print_date($object->date_closing, 'dayhour'); print dol_print_date($object->date_closing, 'dayhour', 'tzserver');
if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_closing + ($deltadateforuser * 3600), "dayhour").' &nbsp;'.$langs->trans("ClientHour"); if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_closing, "dayhour", 'tzserver').' &nbsp;'.$langs->trans("ClientHour");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
} }
@@ -446,8 +446,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateConciliating"); print $langs->trans("DateConciliating");
if ($usetable) print '</td><td>'; if ($usetable) print '</td><td>';
else print ': '; else print ': ';
print dol_print_date($object->date_rappro, 'dayhour'); print dol_print_date($object->date_rappro, 'dayhour', 'tzserver');
if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_rappro + ($deltadateforuser * 3600), "dayhour").' &nbsp;'.$langs->trans("ClientHour"); if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_rappro, "dayhour", 'tzserver').' &nbsp;'.$langs->trans("ClientHour");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
} }
@@ -459,8 +459,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateLastSend"); print $langs->trans("DateLastSend");
if ($usetable) print '</td><td>'; if ($usetable) print '</td><td>';
else print ': '; else print ': ';
print dol_print_date($object->date_envoi, 'dayhour'); print dol_print_date($object->date_envoi, 'dayhour', 'tzserver');
if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_envoi + ($deltadateforuser * 3600), "dayhour").' &nbsp;'.$langs->trans("ClientHour"); if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_envoi, "dayhour", 'tzserver').' &nbsp;'.$langs->trans("ClientHour");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
} }

View File

@@ -35,7 +35,7 @@
--oddevencolor: #202020; --oddevencolor: #202020;
--colorboxstatsborder: #e0e0e0; --colorboxstatsborder: #e0e0e0;
--dolgraphbg: rgba(255,255,255,0); --dolgraphbg: rgba(255,255,255,0);
--fieldrequiredcolor: #700040; --fieldrequiredcolor: #400030;
--colortextbacktab: #<?php print $colortextbacktab; ?>; --colortextbacktab: #<?php print $colortextbacktab; ?>;
--colorboxiconbg: #eee; --colorboxiconbg: #eee;
--refidnocolor:#444; --refidnocolor:#444;