diff --git a/htdocs/lib/datepicker.php b/htdocs/lib/datepicker.php index 28c3a651bd3..fbc79b65e4d 100644 --- a/htdocs/lib/datepicker.php +++ b/htdocs/lib/datepicker.php @@ -1,8 +1,9 @@ + * Copyright (C) 2005-2007 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin - * This file is a modified version of datepicker.php from phpBSM + * This file is a modified version of datepicker.php from phpBSM to fix some + * bugs, to add new features and to dramatically increase speed. * * 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 @@ -37,6 +38,15 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); require_once("../master.inc.php"); +// URL http://mydolibarr/lib/datepicker.php?mode=test&cm=shw&m=10&y=2038 can be used for tests +if (isset($_GET["mode"]) && $_GET["mode"] == 'test') +{ + print ''; + print ''."\n"; + print ''; +} + + $langs->trans("main"); if(!isset($_GET["cm"])) $_GET["cm"]="shw"; @@ -55,7 +65,7 @@ function xyzToUnixTimestamp($mysqldate){ $year=substr($mysqldate,0,4); $month=substr($mysqldate,4,2); $day=substr($mysqldate,6,2); - $unixtimestamp=mktime(0,0,0,$month,$day,$year); + $unixtimestamp=dolibarr_mktime(0,0,0,$month,$day,$year); return $unixtimestamp; } @@ -64,13 +74,14 @@ function displayBox($selectedDate,$month,$year){ $langs->load("main"); //print "$selectedDate,$month,$year"; - $thedate=mktime(0,0,0,$month,1,$year); - $today=mktime(0,0,0); - $todayArray=getdate($today); + $thedate=dolibarr_mktime(0,0,0,$month,1,$year); + //print "thedate=$thedate"; + $today=mktime(); + $todayArray=dolibarr_getdate($today); if($selectedDate != "00000000") { $selDate=xyzToUnixTimestamp($selectedDate); - $xyz=date("Ymd",$selDate); + $xyz=dolibarr_date("Ymd",$selDate); } else { @@ -82,8 +93,8 @@ function displayBox($selectedDate,$month,$year){ trans($selectMonth).", ".$selectYear; ?> @@ -92,7 +103,7 @@ function displayBox($selectedDate,$month,$year){ << ','','')">< - ','')">trans("Today") ?> + ','')">trans("Today") ?> ','','')">> >> @@ -106,7 +117,8 @@ function displayBox($selectedDate,$month,$year){ trans("ShortSaturday") ?> trans("January"), $langs->trans("February"), @@ -122,12 +134,15 @@ function displayBox($selectedDate,$month,$year){ $langs->trans("December") ); - print ''; + print ''; + // Loop on each day of month + $day=1; while($firstdate["month"]==$mydate["month"]) { + //print_r($mydate); if($mydate["wday"]==0) echo ""; if($firstdate==$mydate){ // firstdate, so we may have to put in blanks @@ -142,13 +157,15 @@ function displayBox($selectedDate,$month,$year){ // Sur click dans calendrier, appelle fonction dpClickDay echo "format_date_short_java."')\""; + echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",".dolibarr_date("n",$thedate).",".$mydate["mday"].",tradMonths)\""; + echo " onClick=\"dpClickDay(".$mydate["year"].",".dolibarr_date("n",$thedate).",".$mydate["mday"].",'".$conf->format_date_short_java."')\""; echo ">".sprintf("%02s",$mydate["mday"]).""; if($mydate["wday"]==6) echo ""; - $thedate=strtotime("tomorrow",$thedate); - $mydate=getdate($thedate); + //$thedate=strtotime("tomorrow",$thedate); + $day++; + $thedate=dolibarr_mktime(0,0,0,$month,$day,$year); + $mydate=dolibarr_getdate($thedate); } if($mydate["wday"]!=0){ @@ -160,7 +177,7 @@ function displayBox($selectedDate,$month,$year){ trans($tempDate["month"])." "; print sprintf("%02s",$tempDate["mday"]); print ", ".$tempDate["year"]; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 023db4dbeb2..2fa17b8520a 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -39,6 +39,8 @@ Ensemble de fonctions de base de dolibarr sous forme d'include */ +include_once(DOL_DOCUMENT_ROOT ."/includes/adodbtime/adodb-time.inc.php"); + /** \brief Renvoi une version en chaine depuis une version en tableau @@ -557,6 +559,54 @@ function dolibarr_stringtotime($string) } +/** + \brief Return an array with date info + \param timestamp Timestamp + \param fast Fast mode + \return array Array of informations + If no fast mode: + 'seconds' => $secs, + 'minutes' => $min, + 'hours' => $hour, + 'mday' => $day, + 'wday' => $dow, + 'mon' => $month, + 'year' => $year, + 'yday' => floor($secsInYear/$_day_power), + 'weekday' => gmdate('l',$_day_power*(3+$dow)), + 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)), + 0 => $origd + If fast mode: + 'seconds' => $secs, + 'minutes' => $min, + 'hours' => $hour, + 'mday' => $day, + 'mon' => $month, + 'year' => $year, + 'yday' => floor($secsInYear/$_day_power), + 'leap' => $leaf, + 'ndays' => $ndays + \remarks PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows +*/ +function dolibarr_getdate($timestamp,$fast=false) +{ + $usealternatemethod=false; + if ($year <= 1901) $usealternatemethod=true; + if ($year >= 2038) $usealternatemethod=true; + if ($year <= 1970 && $_SERVER["WINDIR"]) $usealternatemethod=true; + + if ($usealternatemethod) + { + $arrayinfo=adodb_getdate($timestamp,$fast); + } + else + { + $arrayinfo=getdate($timestamp); + } + + return $arrayinfo; +} + /** \brief Retourne une date fabriquée depuis infos. Remplace la fonction mktime non implémentée sous Windows si année < 1970 @@ -567,26 +617,61 @@ function dolibarr_stringtotime($string) \param day Jour \param year Année \return date Date + \remarks PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows */ function dolibarr_mktime($hour,$minute,$second,$month,$day,$year) { - $montharray=array(1=>'january',2=>'february',3=>'march',4=>'april',5=>'may',6=>'june', - 7=>'july',8=>'august',9=>'september',10=>'october',11=>'november',12=>'december'); - - if ($year <= 1970 && $_SERVER["WINDIR"]) + //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; + + $usealternatemethod=false; + if ($year <= 1901) $usealternatemethod=true; + if ($year >= 2038) $usealternatemethod=true; + if ($year <= 1970 && $_SERVER["WINDIR"]) $usealternatemethod=true; + + if ($usealternatemethod) { - // Sous Windows, mktime ne fonctionne pas quand année < 1970. - // On utilise strtotime pour obtenir la traduction. - $string=$day." ".$montharray[0+$month]." ".$year; + /* + // On peut utiliser strtotime pour obtenir la traduction. + // strtotime is ok for range: Vendredi 13 Décembre 1901 20:45:54 GMT au Mardi 19 Janvier 2038 03:14:07 GMT. + $montharray=array(1=>'january',2=>'february',3=>'march',4=>'april',5=>'may',6=>'june', + 7=>'july',8=>'august',9=>'september',10=>'october',11=>'november',12=>'december'); + $string=$day." ".$montharray[0+$month]." ".$year." ".$hour.":".$minute.":".$second." GMT"; $date=strtotime($string); - //print "x".($month)."y".(0+$month)." ".$string." ".$date."e"; - //print "eee".$db->idate($date); - return $date; + print "- ".$string." ".$date." -"; + */ + $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,0,1); } else { - return mktime($hour,$minute,$second,$month,$day,$year); - } + $date=gmmktime($hour,$minute,$second,$month,$day,$year); + } + return $date; +} + + +/** + \brief Returna formated date + \param fmt Format + \param timestamp Date + \return string Formated date +*/ +function dolibarr_date($fmt,$timestamp) +{ + $usealternatemethod=false; + if ($year <= 1901) $usealternatemethod=true; + if ($year >= 2038) $usealternatemethod=true; + if ($year <= 1970 && $_SERVER["WINDIR"]) $usealternatemethod=true; + + if ($usealternatemethod) + { + $string=adodb_date($fmt,$timestamp,1); + } + else + { + $string=date($fmt,$timestamp); + } + + return $string; } diff --git a/htdocs/theme/eldy/eldy.css.php b/htdocs/theme/eldy/eldy.css.php index 261e17a2ca6..a3cfc7450ad 100644 --- a/htdocs/theme/eldy/eldy.css.php +++ b/htdocs/theme/eldy/eldy.css.php @@ -1398,14 +1398,14 @@ div.menuFleche .table_data { border-style:ridge; - border-width:1; + border: 1px; } .tab_base { background:#C5D0DD; font-weight:bold; border-style:ridge; - border-width:1; + border: 1px; cursor:pointer; } .table_sub_heading @@ -1413,16 +1413,15 @@ div.menuFleche background:#CCCCCC; font-weight:bold; border-style:ridge; - border-width:1; + border: 1px; } .table_body { background:#F0F0F0; - font-wieght:normal; - font-size:12; + font-weight:normal; font-family:sans-serif; border-style:ridge; - border-width:1; + border: 1px; border-spacing: 0px; border-collapse: collapse; } @@ -1432,6 +1431,6 @@ div.menuFleche color:white; font-weight:bold; border-style:groove; - border-width:1; + border: 1px; cursor:pointer; } \ No newline at end of file