Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
6a93439902
@ -44,15 +44,13 @@ if((isset($_GET['field']) && ! empty($_GET['field']))
|
|||||||
&& (isset($_GET['table_element']) && ! empty($_GET['table_element']))
|
&& (isset($_GET['table_element']) && ! empty($_GET['table_element']))
|
||||||
&& (isset($_GET['fk_element']) && ! empty($_GET['fk_element'])))
|
&& (isset($_GET['fk_element']) && ! empty($_GET['fk_element'])))
|
||||||
{
|
{
|
||||||
$element = GETPOST('element');
|
$element = GETPOST('element','alpha');
|
||||||
$table_element = GETPOST('table_element');
|
$table_element = GETPOST('table_element','alpha');
|
||||||
$fk_element = GETPOST('fk_element');
|
$fk_element = GETPOST('fk_element','alpha');
|
||||||
$ext_element = GETPOST('ext_element');
|
$ext_element = GETPOST('ext_element','alpha');
|
||||||
//$ext_table_element = GETPOST('ext_table_element');
|
$field = substr(GETPOST('field','alpha'), 8); // remove prefix val_
|
||||||
//$ext_fk_element = GETPOST('ext_fk_element');
|
$type = GETPOST('type','alpha');
|
||||||
$field = substr(GETPOST('field'), 8); // remove prefix val_
|
$loadmethod = (GETPOST('loadmethod','alpha') ? GETPOST('loadmethod','alpha') : 'getValueFrom');
|
||||||
$type = GETPOST('type');
|
|
||||||
$loadmethod = (GETPOST('loadmethod') ? GETPOST('loadmethod') : 'getValueFrom');
|
|
||||||
|
|
||||||
if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
|
if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -45,16 +45,15 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
|||||||
&& (isset($_POST['table_element']) && ! empty($_POST['table_element']))
|
&& (isset($_POST['table_element']) && ! empty($_POST['table_element']))
|
||||||
&& (isset($_POST['fk_element']) && ! empty($_POST['fk_element'])))
|
&& (isset($_POST['fk_element']) && ! empty($_POST['fk_element'])))
|
||||||
{
|
{
|
||||||
$element = GETPOST('element');
|
$element = GETPOST('element','alpha');
|
||||||
$table_element = GETPOST('table_element');
|
$table_element = GETPOST('table_element','alpha');
|
||||||
$fk_element = GETPOST('fk_element');
|
$fk_element = GETPOST('fk_element','alpha');
|
||||||
$ext_element = GETPOST('ext_element');
|
$ext_element = GETPOST('ext_element','alpha');
|
||||||
//$ext_table_element = GETPOST('ext_table_element');
|
$field = substr(GETPOST('field','alpha'), 8); // remove prefix val_
|
||||||
//$ext_fk_element = GETPOST('ext_fk_element');
|
$value = GETPOST('value','alpha');
|
||||||
$field = substr(GETPOST('field'), 8); // remove prefix val_
|
$type = GETPOST('type','alpha');
|
||||||
$value = GETPOST('value');
|
$savemethod = GETPOST('savemethod','alpha');
|
||||||
$type = GETPOST('type');
|
$savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom');
|
||||||
$savemethodname = (GETPOST('savemethod') ? GETPOST('savemethod') : 'setValueFrom');
|
|
||||||
|
|
||||||
$view='';
|
$view='';
|
||||||
$format='text';
|
$format='text';
|
||||||
@ -158,7 +157,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
if (! is_object($object)) $object = new GenericObject($db);
|
if (! is_object($object) || empty($savemethod)) $object = new GenericObject($db);
|
||||||
|
|
||||||
// Specific for add_object_linked()
|
// Specific for add_object_linked()
|
||||||
// TODO add a function for variable treatment
|
// TODO add a function for variable treatment
|
||||||
|
|||||||
@ -77,7 +77,6 @@ class HookManager
|
|||||||
|
|
||||||
$this->contextarray=array_merge($arraycontext,$this->contextarray); // All contexts are concatenated
|
$this->contextarray=array_merge($arraycontext,$this->contextarray); // All contexts are concatenated
|
||||||
|
|
||||||
$i=0;
|
|
||||||
foreach($conf->hooks_modules as $module => $hooks)
|
foreach($conf->hooks_modules as $module => $hooks)
|
||||||
{
|
{
|
||||||
if ($conf->$module->enabled)
|
if ($conf->$module->enabled)
|
||||||
@ -93,29 +92,14 @@ class HookManager
|
|||||||
$actionfile = 'actions_'.$module.'.class.php';
|
$actionfile = 'actions_'.$module.'.class.php';
|
||||||
$pathroot = '';
|
$pathroot = '';
|
||||||
|
|
||||||
$this->hooks[$i]['type']=$context;
|
|
||||||
|
|
||||||
// Include actions class overwriting hooks
|
// Include actions class overwriting hooks
|
||||||
$resaction=dol_include_once($path.$actionfile);
|
$resaction=dol_include_once($path.$actionfile);
|
||||||
if ($resaction)
|
if ($resaction)
|
||||||
{
|
{
|
||||||
$controlclassname = 'Actions'.ucfirst($module);
|
$controlclassname = 'Actions'.ucfirst($module);
|
||||||
$actionInstance = new $controlclassname($this->db);
|
$actionInstance = new $controlclassname($this->db);
|
||||||
$this->hooks[$i]['modules'][$module] = $actionInstance;
|
$this->hooks[$context][$module] = $actionInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include dataservice class (model)
|
|
||||||
// TODO storing dao is useless here. It's goal of controller to known which dao to manage
|
|
||||||
$daofile = 'dao_'.$module.'.class.php';
|
|
||||||
$resdao=dol_include_once($path.$daofile);
|
|
||||||
if ($resdao)
|
|
||||||
{
|
|
||||||
// Instantiate dataservice class (model)
|
|
||||||
$daoInstance = 'Dao'.ucfirst($module);
|
|
||||||
$this->hooks[$i]['modules'][$module]->object = new $daoInstance($this->db);
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,11 +129,11 @@ class HookManager
|
|||||||
|
|
||||||
// Loop on each hook
|
// Loop on each hook
|
||||||
$resaction=0; $resprint='';
|
$resaction=0; $resprint='';
|
||||||
foreach($this->hooks as $hook)
|
foreach($this->hooks as $modules)
|
||||||
{
|
{
|
||||||
if (! empty($hook['modules']))
|
if (! empty($modules))
|
||||||
{
|
{
|
||||||
foreach($hook['modules'] as $module => $actioninstance)
|
foreach($modules as $actioninstance)
|
||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
|
|||||||
156
htdocs/core/js/dst.js
Normal file
156
htdocs/core/js/dst.js
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
// Copyright (C) 2011-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
// Copyright (C) 2011-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
// or see http://www.gnu.org/
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// \file htdocs/core/js/dst.js
|
||||||
|
// \brief File that include javascript functions for detect user tz, dst_observed, dst_first, dst_second
|
||||||
|
//
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
// Detect and save TZ and DST
|
||||||
|
var rightNow = new Date();
|
||||||
|
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
|
||||||
|
var temp = jan1.toGMTString();
|
||||||
|
var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
|
||||||
|
var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);
|
||||||
|
var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
|
||||||
|
temp = june1.toGMTString();
|
||||||
|
var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
|
||||||
|
var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);
|
||||||
|
var dst;
|
||||||
|
if (std_time_offset == daylight_time_offset) {
|
||||||
|
dst = "0"; // daylight savings time is NOT observed
|
||||||
|
} else {
|
||||||
|
dst = "1"; // daylight savings time is observed
|
||||||
|
}
|
||||||
|
var dst_first=DisplayDstSwitchDates('first');
|
||||||
|
var dst_second=DisplayDstSwitchDates('second');
|
||||||
|
//alert(dst);
|
||||||
|
$('#tz').val(std_time_offset); // returns TZ
|
||||||
|
$('#dst_observed').val(dst); // returns if DST is observed on summer
|
||||||
|
$('#dst_first').val(dst_first); // returns DST first switch in year
|
||||||
|
$('#dst_second').val(dst_second); // returns DST second switch in year
|
||||||
|
// Detect and save screen resolution
|
||||||
|
$('#screenwidth').val($(window).width()); // returns width of browser viewport
|
||||||
|
$('#screenheight').val($(window).height()); // returns width of browser viewport
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1005,13 +1005,13 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanage
|
|||||||
*/
|
*/
|
||||||
function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
|
function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
|
||||||
{
|
{
|
||||||
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
|
if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
|
||||||
{
|
{
|
||||||
$special_code = $object->lines[$i]->special_code;
|
$special_code = $object->lines[$i]->special_code;
|
||||||
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
|
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
|
||||||
foreach($object->hooks as $hook)
|
foreach($object->hooks as $modules)
|
||||||
{
|
{
|
||||||
if (method_exists($hook['modules'][$special_code],'pdf_getlineupwithtax')) return $hook['modules'][$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails);
|
if (method_exists($modules[$special_code],'pdf_getlineupwithtax')) return $modules[$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1222,13 +1222,13 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
|
if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
|
||||||
{
|
{
|
||||||
$special_code = $object->lines[$i]->special_code;
|
$special_code = $object->lines[$i]->special_code;
|
||||||
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
|
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
|
||||||
foreach($object->hooks as $hook)
|
foreach($object->hooks as $modules)
|
||||||
{
|
{
|
||||||
if (method_exists($hook['modules'][$special_code],'pdf_getlinetotalwithtax')) return $hook['modules'][$special_code]->pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails);
|
if (method_exists($modules[$special_code],'pdf_getlinetotalwithtax')) return $modules[$special_code]->pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -35,9 +35,12 @@ print '<!-- Includes for JQuery (Ajax library) -->'."\n";
|
|||||||
if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
|
if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
|
||||||
else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" />'."\n"; // JQuery
|
else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" />'."\n"; // JQuery
|
||||||
// JQuery. Must be before other includes
|
// JQuery. Must be before other includes
|
||||||
|
$ext='.js';
|
||||||
|
if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) $ext='.jgz';
|
||||||
print '<!-- Includes JS for JQuery -->'."\n";
|
print '<!-- Includes JS for JQuery -->'."\n";
|
||||||
if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n";
|
if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n";
|
||||||
else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-latest.min'.$ext.'"></script>'."\n";
|
else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-latest.min'.$ext.'"></script>'."\n";
|
||||||
|
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/dst.js"></script>'."\n";
|
||||||
print '<link rel="stylesheet" type="text/css" href="'.$conf_css.'" />
|
print '<link rel="stylesheet" type="text/css" href="'.$conf_css.'" />
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
<!--
|
<!--
|
||||||
@ -62,140 +65,9 @@ print '<!-- HTTP_USER_AGENT = '.$_SERVER['HTTP_USER_AGENT'].' -->
|
|||||||
|
|
||||||
<!-- Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second -->
|
<!-- 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)
|
$(document).ready(function () {
|
||||||
{
|
|
||||||
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 () {
|
|
||||||
// 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) { ?>$('#<?php echo $focus_element; ?>').focus(); <?php } ?> // Warning to use this only on visible element
|
||||||
// Detect and save TZ and DST
|
|
||||||
var rightNow = new Date();
|
|
||||||
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
|
|
||||||
var temp = jan1.toGMTString();
|
|
||||||
var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
|
|
||||||
var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);
|
|
||||||
var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
|
|
||||||
temp = june1.toGMTString();
|
|
||||||
var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
|
|
||||||
var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);
|
|
||||||
var dst;
|
|
||||||
if (std_time_offset == daylight_time_offset) {
|
|
||||||
dst = "0"; // daylight savings time is NOT observed
|
|
||||||
} else {
|
|
||||||
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('#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
|
|
||||||
jQuery('#screenwidth').val(jQuery(window).width()); // returns width of browser viewport
|
|
||||||
jQuery('#screenheight').val(jQuery(window).height()); // returns width of browser viewport
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -40,9 +41,10 @@ if ($conf->agenda->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/action/cl
|
|||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
$langs->load("suppliers");
|
$langs->load("suppliers");
|
||||||
if ($conf->facture->enabled) $langs->load("bills");
|
if ($conf->facture->enabled) $langs->load("bills");
|
||||||
if ($conf->commande->enabled) $langs->load("orders");
|
if ($conf->commande->enabled) $langs->load("orders");
|
||||||
if ($conf->propal->enabled) $langs->load("propal");
|
if ($conf->propal->enabled) $langs->load("propal");
|
||||||
|
if ($conf->ficheinter->enabled) $langs->load("interventions");
|
||||||
|
|
||||||
$projectid='';
|
$projectid='';
|
||||||
$ref='';
|
$ref='';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user