forked from Wavyzz/dolibarr
Fix: DST is correctly detected
This commit is contained in:
@@ -141,17 +141,17 @@ $dec=$langs->trans("SeparatorDecimal");
|
|||||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentValueSeparatorDecimal").'</td><td>'.$dec.'</td></tr>'."\n";
|
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentValueSeparatorDecimal").'</td><td>'.$dec.'</td></tr>'."\n";
|
||||||
// Show results of functions to see if everything works
|
// Show results of functions to see if everything works
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> price2num(1233.56+1)</td><td>'.price2num(1233.56+1,'2').'</td></tr>';
|
print '<tr '.$bc[$var].'><td width="300"> => price2num(1233.56+1)</td><td>'.price2num(1233.56+1,'2').'</td></tr>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr ".$bc[$var].'><td width=\"300\">=> price2num('."'1".$thousand."234".$dec."56')</td><td>".price2num("1".$thousand."234".$dec."56",'2')."</td>";
|
print "<tr ".$bc[$var].'><td width=\"300\"> => price2num('."'1".$thousand."234".$dec."56')</td><td>".price2num("1".$thousand."234".$dec."56",'2')."</td>";
|
||||||
if (($thousand != ',' && $thousand != '.') || ($thousand != ' '))
|
if (($thousand != ',' && $thousand != '.') || ($thousand != ' '))
|
||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr ".$bc[$var].'><td width=\"300\">=> price2num('."'1 234.56')</td><td>".price2num("1 234.56",'2')."</td>";
|
print "<tr ".$bc[$var].'><td width=\"300\"> => price2num('."'1 234.56')</td><td>".price2num("1 234.56",'2')."</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> price(1234.56)</td><td>'.price(1234.56).'</td>';
|
print '<tr '.$bc[$var].'><td width="300"> => price(1234.56)</td><td>'.price(1234.56).'</td>';
|
||||||
// Timezone
|
// Timezone
|
||||||
$txt =$langs->trans("OSTZ").' (variable system TZ): '.($_ENV["TZ"]?$_ENV["TZ"]:$langs->trans("NotDefined")).'<br>'."\n";
|
$txt =$langs->trans("OSTZ").' (variable system TZ): '.($_ENV["TZ"]?$_ENV["TZ"]:$langs->trans("NotDefined")).'<br>'."\n";
|
||||||
$txt.=$langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone")?ini_get("date.timezone"):$langs->trans("NotDefined")).''."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
|
$txt.=$langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone")?ini_get("date.timezone"):$langs->trans("NotDefined")).''."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
|
||||||
@@ -160,6 +160,7 @@ if (function_exists('date_default_timezone_get'))
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentTimeZone").'</td><td>'; // Timezone server PHP
|
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentTimeZone").'</td><td>'; // Timezone server PHP
|
||||||
$a=date_default_timezone_get();
|
$a=date_default_timezone_get();
|
||||||
|
$a.=' '.getCurrentTimeZone();
|
||||||
$a.=' ('.(-dol_mktime(0,0,0,1,1,1970)>0?'+':'').(-dol_mktime(0,0,0,1,1,1970)).')';
|
$a.=' ('.(-dol_mktime(0,0,0,1,1,1970)>0?'+':'').(-dol_mktime(0,0,0,1,1,1970)).')';
|
||||||
print $form->textwithtooltip($a,$txt,2,1,img_info(''));
|
print $form->textwithtooltip($a,$txt,2,1,img_info(''));
|
||||||
print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php
|
print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php
|
||||||
@@ -173,27 +174,34 @@ else
|
|||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
}
|
}
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> '.$langs->trans("CurrentHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzserver').'</td></tr>'."\n";
|
print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("CurrentHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzserver').'</td></tr>'."\n";
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> dol_print_date(0,"dayhourtext")</td><td>'.dol_print_date(0,"dayhourtext").'</td>';
|
print '<tr '.$bc[$var].'><td width="300"> => dol_print_date(0,"dayhourtext")</td><td>'.dol_print_date(0,"dayhourtext").'</td>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> dol_get_first_day(1970,1,false)</td><td>'.dol_get_first_day(1970,1,false).' (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,false),'dayhour').')</td>';
|
print '<tr '.$bc[$var].'><td width="300"> => dol_get_first_day(1970,1,false)</td><td>'.dol_get_first_day(1970,1,false).' (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,false),'dayhour').')</td>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> dol_get_first_day(1970,1,true)</td><td>'.dol_get_first_day(1970,1,true).' (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,true),'dayhour').')</td>';
|
print '<tr '.$bc[$var].'><td width="300"> => dol_get_first_day(1970,1,true)</td><td>'.dol_get_first_day(1970,1,true).' (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,true),'dayhour').')</td>';
|
||||||
// Parent company
|
// Parent company
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CompanyTZ").'</td><td>'.$langs->trans("FeatureNotYetAvailable").'</td></tr>'."\n";
|
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CompanyTZ").'</td><td>'.$langs->trans("FeatureNotYetAvailable").'</td></tr>'."\n";
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> '.$langs->trans("CompanyHour").'</td><td>'.$langs->trans("FeatureNotYetAvailable").'</td></tr>'."\n";
|
print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("CompanyHour").'</td><td>'.$langs->trans("FeatureNotYetAvailable").'</td></tr>'."\n";
|
||||||
// Client
|
// Client
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("ClientTZ").'</td><td>'.($_SESSION['dol_tz']!=''?($_SESSION['dol_tz']>=0?'+':'').$_SESSION['dol_tz']:'').' ('.($_SESSION['dol_tz']>=0?'+':'').($_SESSION['dol_tz']*60*60).')</td></tr>'."\n";
|
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("ClientTZ").'</td><td>'.($_SESSION['dol_tz']!=''?($_SESSION['dol_tz']>=0?'+':'').$_SESSION['dol_tz']:'').' ('.($_SESSION['dol_tz']>=0?'+':'').($_SESSION['dol_tz']*60*60).')</td></tr>'."\n";
|
||||||
//$var=!$var;
|
//$var=!$var;
|
||||||
//print '<tr '.$bc[$var].'><td width="300">=> '.$langs->trans("ClientOffsetWithGreenwich").'</td><td>'..'</td></tr>'."\n";
|
//print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("ClientOffsetWithGreenwich").'</td><td>'..'</td></tr>'."\n";
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("DaylingSavingTime").'</td><td>'.($_SESSION['dol_dst']>=0?yn(1):yn(0)).' ('.($_SESSION['dol_dst']>=0?'+':'').($_SESSION['dol_dst']*60*60).')</td></tr>'."\n";
|
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("DaylingSavingTime").'</td><td>';
|
||||||
|
if ($_SESSION['dol_dst']>0)
|
||||||
|
{
|
||||||
|
print ($_SESSION['dol_dst']>0?'+':'').($_SESSION['dol_dst']).' ('.($_SESSION['dol_dst']>0?'+':'').($_SESSION['dol_dst']*60*60).')';
|
||||||
|
}
|
||||||
|
else print yn(0);
|
||||||
|
if (isset($_SESSION['dol_dst_first'])) print ' ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']),'dayhour','gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']),'dayhour','gmt').')';
|
||||||
|
print '</td></tr>'."\n";
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> '.$langs->trans("ClientHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzuser').'</td></tr>'."\n";
|
print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("ClientHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzuser').'</td></tr>'."\n";
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$filesystemencoding=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
|
$filesystemencoding=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
|
||||||
@@ -204,7 +212,7 @@ $tmp=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
|
|||||||
if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1'; // By default for windows
|
if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1'; // By default for windows
|
||||||
if (empty($tmp)) $tmp='utf-8'; // By default for other
|
if (empty($tmp)) $tmp='utf-8'; // By default for other
|
||||||
if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING;
|
if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING;
|
||||||
print '<tr '.$bc[$var].'><td width="300">=> '.$langs->trans("File encoding").'</td><td>'.$tmp.'</td></tr>'."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
|
print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("File encoding").'</td><td>'.$tmp.'</td></tr>'."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|||||||
@@ -553,16 +553,15 @@ if (count($listofextcals))
|
|||||||
$event->id=$icalevent['UID'];
|
$event->id=$icalevent['UID'];
|
||||||
$event->icalname=$namecal;
|
$event->icalname=$namecal;
|
||||||
$event->icalcolor=$colorcal;
|
$event->icalcolor=$colorcal;
|
||||||
//$usertime=($_SESSION['dol_tz']*60*60)+($_SESSION['dol_dst']*60*60);
|
|
||||||
$usertime=0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output.
|
$usertime=0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output.
|
||||||
$event->datep=$datestart+$usertime;
|
$event->datep=$datestart+$usertime;
|
||||||
$event->datef=$dateend+$usertime;
|
$event->datef=$dateend+$usertime;
|
||||||
$event->type_code="ICALEVENT";
|
$event->type_code="ICALEVENT";
|
||||||
|
|
||||||
if($icalevent['SUMMARY']) $event->libelle=$icalevent['SUMMARY'];
|
if($icalevent['SUMMARY']) $event->libelle=$icalevent['SUMMARY'];
|
||||||
elseif($icalevent['DESCRIPTION']) $event->libelle=dol_nl2br($icalevent['DESCRIPTION'],1);
|
elseif($icalevent['DESCRIPTION']) $event->libelle=dol_nl2br($icalevent['DESCRIPTION'],1);
|
||||||
else $event->libelle = $langs->trans("ExtSiteNoLabel");
|
else $event->libelle = $langs->trans("ExtSiteNoLabel");
|
||||||
|
|
||||||
$event->date_start_in_calendar=$event->datep;
|
$event->date_start_in_calendar=$event->datep;
|
||||||
|
|
||||||
if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef;
|
if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class Form
|
|||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output edit in place form
|
* Output edit in place form
|
||||||
*
|
*
|
||||||
@@ -156,14 +156,14 @@ class Form
|
|||||||
function editInPlace($value, $htmlname, $condition, $inputType='textarea', $inputOption='')
|
function editInPlace($value, $htmlname, $condition, $inputType='textarea', $inputOption='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$out='';
|
$out='';
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if ($inputType == 'textarea') $value = dol_nl2br($value);
|
if ($inputType == 'textarea') $value = dol_nl2br($value);
|
||||||
else if ($inputType == 'numeric') $value = price($value);
|
else if ($inputType == 'numeric') $value = price($value);
|
||||||
else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day');
|
else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day');
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition)
|
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition)
|
||||||
{
|
{
|
||||||
if ($inputType == 'datepicker')
|
if ($inputType == 'datepicker')
|
||||||
@@ -185,7 +185,7 @@ class Form
|
|||||||
$inputType = 'textarea';
|
$inputType = 'textarea';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$out.= '<div class="edit_'.$inputType.'" id="'.$htmlname.'">';
|
$out.= '<div class="edit_'.$inputType.'" id="'.$htmlname.'">';
|
||||||
$out.= $value;
|
$out.= $value;
|
||||||
$out.= '</div>';
|
$out.= '</div>';
|
||||||
@@ -194,7 +194,7 @@ class Form
|
|||||||
{
|
{
|
||||||
$out = $value;
|
$out = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,11 +355,11 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
array_multisort($label, SORT_ASC, $countryArray);
|
array_multisort($label, SORT_ASC, $countryArray);
|
||||||
|
|
||||||
foreach ($countryArray as $row)
|
foreach ($countryArray as $row)
|
||||||
{
|
{
|
||||||
//print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'<br>';
|
//print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'<br>';
|
||||||
if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) )
|
if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) )
|
||||||
{
|
{
|
||||||
$foundselected=true;
|
$foundselected=true;
|
||||||
$out.= '<option value="'.$row['rowid'].'" selected="selected">';
|
$out.= '<option value="'.$row['rowid'].'" selected="selected">';
|
||||||
@@ -537,7 +537,7 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load into cache cache_types_fees, array of types of fees
|
* Load into cache cache_types_fees, array of types of fees
|
||||||
*
|
*
|
||||||
@@ -547,26 +547,26 @@ class Form
|
|||||||
function load_cache_types_fees()
|
function load_cache_types_fees()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$langs->load("trips");
|
$langs->load("trips");
|
||||||
|
|
||||||
if (count($this->cache_types_fees)) return 0; // Cache already load
|
if (count($this->cache_types_fees)) return 0; // Cache already load
|
||||||
|
|
||||||
$sql = "SELECT c.code, c.libelle as label";
|
$sql = "SELECT c.code, c.libelle as label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees as c";
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees as c";
|
||||||
$sql.= " ORDER BY lower(c.libelle) ASC";
|
$sql.= " ORDER BY lower(c.libelle) ASC";
|
||||||
|
|
||||||
dol_syslog(get_class($this).'::load_cache_types_fees sql='.$sql, LOG_DEBUG);
|
dol_syslog(get_class($this).'::load_cache_types_fees sql='.$sql, LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
||||||
$label=($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
|
$label=($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
|
||||||
$this->cache_types_fees[$obj->code] = $label;
|
$this->cache_types_fees[$obj->code] = $label;
|
||||||
@@ -592,9 +592,9 @@ class Form
|
|||||||
function select_type_fees($selected='',$htmlname='type',$showempty=0)
|
function select_type_fees($selected='',$htmlname='type',$showempty=0)
|
||||||
{
|
{
|
||||||
global $user, $langs;
|
global $user, $langs;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::select_type_fees ".$selected.", ".$htmlname, LOG_DEBUG);
|
dol_syslog(get_class($this)."::select_type_fees ".$selected.", ".$htmlname, LOG_DEBUG);
|
||||||
|
|
||||||
$this->load_cache_types_fees();
|
$this->load_cache_types_fees();
|
||||||
|
|
||||||
print '<select class="flat" name="'.$htmlname.'">';
|
print '<select class="flat" name="'.$htmlname.'">';
|
||||||
@@ -604,7 +604,7 @@ class Form
|
|||||||
if ($selected == -1) print ' selected="selected"';
|
if ($selected == -1) print ' selected="selected"';
|
||||||
print '> </option>';
|
print '> </option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->cache_types_fees as $key => $value)
|
foreach($this->cache_types_fees as $key => $value)
|
||||||
{
|
{
|
||||||
print '<option value="'.$key.'"';
|
print '<option value="'.$key.'"';
|
||||||
|
|||||||
@@ -61,6 +61,23 @@ function get_tz_array()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return server timezone
|
||||||
|
*
|
||||||
|
* @return string TimeZone
|
||||||
|
*/
|
||||||
|
function getCurrentTimeZone()
|
||||||
|
{
|
||||||
|
// Method 1
|
||||||
|
//$tzstring=date_default_timezone_get(); // Then convert into tz
|
||||||
|
|
||||||
|
// Method 2
|
||||||
|
$tmp=dol_mktime(0,0,0,1,1,1970);
|
||||||
|
$tz=($tmp<0?'+':'-').sprintf("%02d",abs($tmp/3600));
|
||||||
|
return $tz;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a delay to a date
|
* Add a delay to a date
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -828,11 +828,11 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
|||||||
* YYYY-MM-DDTHH:MM:SSZ (RFC3339)
|
* YYYY-MM-DDTHH:MM:SSZ (RFC3339)
|
||||||
* DD/MM/YY or DD/MM/YYYY (this format should not be used anymore)
|
* DD/MM/YY or DD/MM/YYYY (this format should not be used anymore)
|
||||||
* DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (this format should not be used anymore)
|
* DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (this format should not be used anymore)
|
||||||
* 19700101020000 -> 7200
|
|
||||||
* @param int $gm 1=Input date is GM date, 0=Input date is local date
|
* @param int $gm 1=Input date is GM date, 0=Input date is local date
|
||||||
|
* 19700101020000 -> 7200 with gm=1
|
||||||
* @return date Date
|
* @return date Date
|
||||||
*
|
*
|
||||||
* @see dol_print_date, dol_mktime, dol_getdate
|
* @see dol_print_date, dol_mktime, dol_getdate
|
||||||
*/
|
*/
|
||||||
function dol_stringtotime($string, $gm=1)
|
function dol_stringtotime($string, $gm=1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,7 +55,113 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
|||||||
|
|
||||||
<body class="body">
|
<body class="body">
|
||||||
|
|
||||||
|
<!-- Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
function DisplayDstSwitchDates(firstsecond)
|
||||||
|
{
|
||||||
|
var year = new Date().getYear();
|
||||||
|
if (year < 1000) year += 1900;
|
||||||
|
|
||||||
|
var firstSwitch = 0;
|
||||||
|
var secondSwitch = 0;
|
||||||
|
var lastOffset = 99;
|
||||||
|
|
||||||
|
// Loop through every month of the current year
|
||||||
|
for (i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
// Fetch the timezone value for the month
|
||||||
|
var newDate = new Date(Date.UTC(year, i, 0, 0, 0, 0, 0));
|
||||||
|
var tz = -1 * newDate.getTimezoneOffset() / 60;
|
||||||
|
|
||||||
|
// Capture when a timzezone change occurs
|
||||||
|
if (tz > lastOffset)
|
||||||
|
firstSwitch = i-1;
|
||||||
|
else if (tz < lastOffset)
|
||||||
|
secondSwitch = i-1;
|
||||||
|
|
||||||
|
lastOffset = tz;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go figure out date/time occurences a minute before
|
||||||
|
// a DST adjustment occurs
|
||||||
|
var secondDstDate = FindDstSwitchDate(year, secondSwitch);
|
||||||
|
var firstDstDate = FindDstSwitchDate(year, firstSwitch);
|
||||||
|
|
||||||
|
if (firstsecond == 'first') return firstDstDate;
|
||||||
|
if (firstsecond == 'second') return secondDstDate;
|
||||||
|
|
||||||
|
if (firstDstDate == null && secondDstDate == null)
|
||||||
|
return 'Daylight Savings is not observed in your timezone.';
|
||||||
|
else
|
||||||
|
return 'Last minute before DST change occurs in ' +
|
||||||
|
year + ': ' + firstDstDate + ' and ' + secondDstDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
function FindDstSwitchDate(year, month)
|
||||||
|
{
|
||||||
|
// Set the starting date
|
||||||
|
var baseDate = new Date(Date.UTC(year, month, 0, 0, 0, 0, 0));
|
||||||
|
var changeDay = 0;
|
||||||
|
var changeMinute = -1;
|
||||||
|
var baseOffset = -1 * baseDate.getTimezoneOffset() / 60;
|
||||||
|
var dstDate;
|
||||||
|
|
||||||
|
// Loop to find the exact day a timezone adjust occurs
|
||||||
|
for (day = 0; day < 50; day++)
|
||||||
|
{
|
||||||
|
var tmpDate = new Date(Date.UTC(year, month, day, 0, 0, 0, 0));
|
||||||
|
var tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
|
||||||
|
|
||||||
|
// Check if the timezone changed from one day to the next
|
||||||
|
if (tmpOffset != baseOffset)
|
||||||
|
{
|
||||||
|
var minutes = 0;
|
||||||
|
changeDay = day;
|
||||||
|
|
||||||
|
// Back-up one day and grap the offset
|
||||||
|
tmpDate = new Date(Date.UTC(year, month, day-1, 0, 0, 0, 0));
|
||||||
|
tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
|
||||||
|
|
||||||
|
// Count the minutes until a timezone chnage occurs
|
||||||
|
while (changeMinute == -1)
|
||||||
|
{
|
||||||
|
tmpDate = new Date(Date.UTC(year, month, day-1, 0, minutes, 0, 0));
|
||||||
|
tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
|
||||||
|
|
||||||
|
// Determine the exact minute a timezone change
|
||||||
|
// occurs
|
||||||
|
if (tmpOffset != baseOffset)
|
||||||
|
{
|
||||||
|
// Back-up a minute to get the date/time just
|
||||||
|
// before a timezone change occurs
|
||||||
|
tmpOffset = new Date(Date.UTC(year, month,
|
||||||
|
day-1, 0, minutes-1, 0, 0));
|
||||||
|
changeMinute = minutes;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
minutes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a month (for display) since JavaScript counts
|
||||||
|
// months from 0 to 11
|
||||||
|
dstDate = tmpOffset.getMonth() + 1;
|
||||||
|
|
||||||
|
// Pad the month as needed
|
||||||
|
if (dstDate < 10) dstDate = "0" + dstDate;
|
||||||
|
|
||||||
|
// Add the day and year
|
||||||
|
dstDate = year + '-' + dstDate + '-' + tmpOffset.getDate() + 'T';
|
||||||
|
|
||||||
|
// Capture the time stamp
|
||||||
|
tmpDate = new Date(Date.UTC(year, month,
|
||||||
|
day-1, 0, minutes-1, 0, 0));
|
||||||
|
dstDate += tmpDate.toTimeString().split(' ')[0] + 'Z';
|
||||||
|
return dstDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jQuery(document).ready(function () {
|
jQuery(document).ready(function () {
|
||||||
// Set focus on correct field
|
// Set focus on correct field
|
||||||
<?php if ($focus_element) { ?>jQuery('#<?php echo $focus_element; ?>').focus(); <?php } ?> // Warning to use this only on visible element
|
<?php if ($focus_element) { ?>jQuery('#<?php echo $focus_element; ?>').focus(); <?php } ?> // Warning to use this only on visible element
|
||||||
@@ -75,8 +181,13 @@ jQuery(document).ready(function () {
|
|||||||
} else {
|
} else {
|
||||||
dst = "1"; // daylight savings time is observed
|
dst = "1"; // daylight savings time is observed
|
||||||
}
|
}
|
||||||
|
var dst_first=DisplayDstSwitchDates('first');
|
||||||
|
var dst_second=DisplayDstSwitchDates('second');
|
||||||
|
//alert(dst);
|
||||||
jQuery('#tz').val(std_time_offset); // returns TZ
|
jQuery('#tz').val(std_time_offset); // returns TZ
|
||||||
jQuery('#dst').val(dst); // returns DST
|
jQuery('#dst_observed').val(dst); // returns if DST is observed on summer
|
||||||
|
jQuery('#dst_first').val(dst_first); // returns DST first switch in year
|
||||||
|
jQuery('#dst_second').val(dst_second); // returns DST second switch in year
|
||||||
// Detect and save screen resolution
|
// Detect and save screen resolution
|
||||||
jQuery('#screenwidth').val(jQuery(window).width()); // returns width of browser viewport
|
jQuery('#screenwidth').val(jQuery(window).width()); // returns width of browser viewport
|
||||||
jQuery('#screenheight').val(jQuery(window).height()); // returns width of browser viewport
|
jQuery('#screenheight').val(jQuery(window).height()); // returns width of browser viewport
|
||||||
@@ -88,7 +199,9 @@ jQuery(document).ready(function () {
|
|||||||
<input type="hidden" name="loginfunction" value="loginfunction" />
|
<input type="hidden" name="loginfunction" value="loginfunction" />
|
||||||
<!-- Add fields to send local user information -->
|
<!-- Add fields to send local user information -->
|
||||||
<input type="hidden" name="tz" id="tz" value="" />
|
<input type="hidden" name="tz" id="tz" value="" />
|
||||||
<input type="hidden" name="dst" id="dst" value="" />
|
<input type="hidden" name="dst_observed" id="dst_observed" value="" />
|
||||||
|
<input type="hidden" name="dst_first" id="dst_first" value="" />
|
||||||
|
<input type="hidden" name="dst_second" id="dst_second" value="" />
|
||||||
<input type="hidden" name="screenwidth" id="screenwidth" value="" />
|
<input type="hidden" name="screenwidth" id="screenwidth" value="" />
|
||||||
<input type="hidden" name="screenheight" id="screenheight" value="" />
|
<input type="hidden" name="screenheight" id="screenheight" value="" />
|
||||||
|
|
||||||
|
|||||||
@@ -381,7 +381,18 @@ if (! defined('NOLOGIN'))
|
|||||||
{
|
{
|
||||||
$dol_authmode=$conf->authmode; // This properties is defined only when logged to say what mode was successfully used
|
$dol_authmode=$conf->authmode; // This properties is defined only when logged to say what mode was successfully used
|
||||||
$dol_tz=$_POST["tz"];
|
$dol_tz=$_POST["tz"];
|
||||||
$dol_dst=$_POST["dst"];
|
$dol_dst=0;
|
||||||
|
if (isset($_POST["dst_first"]) && isset($_POST["dst_second"]))
|
||||||
|
{
|
||||||
|
$datenow=dol_now();
|
||||||
|
$datefirst=dol_stringtotime($_POST["dst_first"]);
|
||||||
|
$datesecond=dol_stringtotime($_POST["dst_second"]);
|
||||||
|
if ($datenow >= $datefirst && $datenow < $datesecond) $dol_dst=1;
|
||||||
|
}
|
||||||
|
//print $datefirst.'-'.$datesecond.'-'.$datenow; exit;
|
||||||
|
$dol_dst_observed=$_POST["dst_observed"];
|
||||||
|
$dol_dst_first=$_POST["dst_first"];
|
||||||
|
$dol_dst_second=$_POST["dst_second"];
|
||||||
$dol_screenwidth=$_POST["screenwidth"];
|
$dol_screenwidth=$_POST["screenwidth"];
|
||||||
$dol_screenheight=$_POST["screenheight"];
|
$dol_screenheight=$_POST["screenheight"];
|
||||||
}
|
}
|
||||||
@@ -515,6 +526,9 @@ if (! defined('NOLOGIN'))
|
|||||||
$_SESSION["dol_authmode"]=isset($dol_authmode)?$dol_authmode:'';
|
$_SESSION["dol_authmode"]=isset($dol_authmode)?$dol_authmode:'';
|
||||||
$_SESSION["dol_tz"]=isset($dol_tz)?$dol_tz:'';
|
$_SESSION["dol_tz"]=isset($dol_tz)?$dol_tz:'';
|
||||||
$_SESSION["dol_dst"]=isset($dol_dst)?$dol_dst:'';
|
$_SESSION["dol_dst"]=isset($dol_dst)?$dol_dst:'';
|
||||||
|
$_SESSION["dol_dst_observed"]=isset($dol_dst_observed)?$dol_dst_observed:'';
|
||||||
|
$_SESSION["dol_dst_first"]=isset($dol_dst_first)?$dol_dst_first:'';
|
||||||
|
$_SESSION["dol_dst_second"]=isset($dol_dst_second)?$dol_dst_second:'';
|
||||||
$_SESSION["dol_screenwidth"]=isset($dol_screenwidth)?$dol_screenwidth:'';
|
$_SESSION["dol_screenwidth"]=isset($dol_screenwidth)?$dol_screenwidth:'';
|
||||||
$_SESSION["dol_screenheight"]=isset($dol_screenheight)?$dol_screenheight:'';
|
$_SESSION["dol_screenheight"]=isset($dol_screenheight)?$dol_screenheight:'';
|
||||||
$_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM;
|
$_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||||
@@ -978,14 +992,14 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
|
|||||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/ColVis/js/ColVis.min'.$ext.'"></script>'."\n";
|
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/ColVis/js/ColVis.min'.$ext.'"></script>'."\n";
|
||||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/TableTools/js/TableTools.min'.$ext.'"></script>'."\n";
|
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/TableTools/js/TableTools.min'.$ext.'"></script>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global js function
|
// Global js function
|
||||||
print '<!-- Includes JS of Dolibarr -->'."\n";
|
print '<!-- Includes JS of Dolibarr -->'."\n";
|
||||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js"></script>'."\n";
|
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js"></script>'."\n";
|
||||||
|
|
||||||
// Add datepicker default options
|
// Add datepicker default options
|
||||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
|
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
|
||||||
|
|
||||||
// Output module javascript
|
// Output module javascript
|
||||||
if (is_array($arrayofjs))
|
if (is_array($arrayofjs))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user