Fix: Boucle infinie sur calendrier
This commit is contained in:
parent
1e189b606c
commit
f0f5625398
@ -49,7 +49,7 @@ if (isset($_GET["mode"]) && $_GET["mode"] == 'test')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'."\n";
|
//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'."\n";
|
||||||
print '<html><head></head><body>'."\n";
|
print '<html><head><title>Calendar</title></head><body>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ function xyzToUnixTimestamp($mysqldate){
|
|||||||
$year=substr($mysqldate,0,4);
|
$year=substr($mysqldate,0,4);
|
||||||
$month=substr($mysqldate,4,2);
|
$month=substr($mysqldate,4,2);
|
||||||
$day=substr($mysqldate,6,2);
|
$day=substr($mysqldate,6,2);
|
||||||
$unixtimestamp=dolibarr_mktime(0,0,0,$month,$day,$year);
|
$unixtimestamp=dolibarr_mktime(12,0,0,$month,$day,$year);
|
||||||
return $unixtimestamp;
|
return $unixtimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ function displayBox($selectedDate,$month,$year){
|
|||||||
global $dolibarr_main_url_root,$langs,$conf;
|
global $dolibarr_main_url_root,$langs,$conf;
|
||||||
|
|
||||||
//print "$selectedDate,$month,$year";
|
//print "$selectedDate,$month,$year";
|
||||||
$thedate=dolibarr_mktime(0,0,0,$month,1,$year);
|
$thedate=dolibarr_mktime(12,0,0,$month,1,$year);
|
||||||
//print "thedate=$thedate";
|
//print "thedate=$thedate";
|
||||||
$today=mktime();
|
$today=mktime();
|
||||||
$todayArray=dolibarr_getdate($today);
|
$todayArray=dolibarr_getdate($today);
|
||||||
@ -120,7 +120,7 @@ function displayBox($selectedDate,$month,$year){
|
|||||||
echo $langs->trans($selectMonth).", ".$selectYear;
|
echo $langs->trans($selectMonth).", ".$selectYear;
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<td class="dpHead"><button type="buttton" class="dpInvisibleButtons" id="DPCancel" onClick="closeDPBox();">X</button></td>
|
<td class="dpHead"><button type="button" class="dpInvisibleButtons" id="DPCancel" onClick="closeDPBox();">X</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="dpButtons" onClick="loadMonth('<?php echo $dolibarr_main_url_root.'/lib/' ?>','<?php echo $month?>','<?php echo $year-1?>','<?php echo $xyz ?>')"><<</td>
|
<td class="dpButtons" onClick="loadMonth('<?php echo $dolibarr_main_url_root.'/lib/' ?>','<?php echo $month?>','<?php echo $year-1?>','<?php echo $xyz ?>')"><<</td>
|
||||||
@ -130,30 +130,41 @@ function displayBox($selectedDate,$month,$year){
|
|||||||
<td class="dpButtons" onClick="loadMonth('<?php echo $dolibarr_main_url_root.'/lib/' ?>','<?php echo $month?>','<?php echo $year+1?>','<?php echo $xyz ?>')">>></td>
|
<td class="dpButtons" onClick="loadMonth('<?php echo $dolibarr_main_url_root.'/lib/' ?>','<?php echo $month?>','<?php echo $year+1?>','<?php echo $xyz ?>')">>></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="dpDayNames">
|
<tr class="dpDayNames">
|
||||||
<td width="14.286%"><?php echo $langs->trans("ShortSunday") ?></td>
|
<td width="14%"><?php echo $langs->trans("ShortSunday") ?></td>
|
||||||
<td width="14.286%"><?php echo $langs->trans("ShortMonday") ?></td>
|
<td width="14%"><?php echo $langs->trans("ShortMonday") ?></td>
|
||||||
<td width="14.286%"><?php echo $langs->trans("ShortTuesday") ?></td>
|
<td width="15%"><?php echo $langs->trans("ShortTuesday") ?></td>
|
||||||
<td width="14.286%"><?php echo $langs->trans("ShortWednesday") ?></td>
|
<td width="14%"><?php echo $langs->trans("ShortWednesday") ?></td>
|
||||||
<td width="14.286%"><?php echo $langs->trans("ShortThursday") ?></td>
|
<td width="15%"><?php echo $langs->trans("ShortThursday") ?></td>
|
||||||
<td width="14.286%"><?php echo $langs->trans("ShortFriday") ?></td>
|
<td width="14%"><?php echo $langs->trans("ShortFriday") ?></td>
|
||||||
<td width="14.286%"><?php echo $langs->trans("ShortSaturday") ?></td>
|
<td width="14%"><?php echo $langs->trans("ShortSaturday") ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
//print "x ".$thedate." y";
|
//print "x ".$thedate." y";
|
||||||
$firstdate=dolibarr_getdate($thedate);
|
$firstdate=dolibarr_getdate($thedate);
|
||||||
$mydate=$firstdate;
|
$mydate=$firstdate;
|
||||||
|
|
||||||
// Loop on each day of month
|
// Loop on each day of month
|
||||||
$day=1;
|
$stoploop=0; $day=1; $cols=0;
|
||||||
while($firstdate["month"]==$mydate["month"])
|
while (! $stoploop)
|
||||||
{
|
{
|
||||||
//print_r($mydate);
|
//print_r($mydate);
|
||||||
if($mydate["wday"]==0) echo "<TR class=\"dpWeek\">";
|
if($firstdate==$mydate) // At first run
|
||||||
if($firstdate==$mydate){
|
{
|
||||||
// firstdate, so we may have to put in blanks
|
|
||||||
echo "<TR class=\"dpWeek\">";
|
echo "<TR class=\"dpWeek\">";
|
||||||
for($i=0;$i<$mydate["wday"];$i++)
|
$cols=0;
|
||||||
|
for($i=0;$i< $mydate["wday"];$i++)
|
||||||
|
{
|
||||||
echo "<TD> </TD>";
|
echo "<TD> </TD>";
|
||||||
|
$cols++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($mydate["wday"]==0)
|
||||||
|
{
|
||||||
|
echo "<TR class=\"dpWeek\">";
|
||||||
|
$cols=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dayclass="dpReg";
|
$dayclass="dpReg";
|
||||||
@ -165,18 +176,28 @@ function displayBox($selectedDate,$month,$year){
|
|||||||
echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",".dolibarr_date("n",$thedate).",".$mydate["mday"].",tradMonths)\"";
|
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 " onClick=\"dpClickDay(".$mydate["year"].",".dolibarr_date("n",$thedate).",".$mydate["mday"].",'".$conf->format_date_short_java."')\"";
|
||||||
echo ">".sprintf("%02s",$mydate["mday"])."</TD>";
|
echo ">".sprintf("%02s",$mydate["mday"])."</TD>";
|
||||||
|
$cols++;
|
||||||
|
|
||||||
|
if ($mydate["wday"]==6) echo "</TR>\n";
|
||||||
|
|
||||||
if($mydate["wday"]==6) echo "</tr>";
|
|
||||||
//$thedate=strtotime("tomorrow",$thedate);
|
//$thedate=strtotime("tomorrow",$thedate);
|
||||||
$day++;
|
$day++;
|
||||||
$thedate=dolibarr_mktime(0,0,0,$month,$day,$year);
|
$thedate=dolibarr_mktime(12,0,0,$month,$day,$year);
|
||||||
$mydate=dolibarr_getdate($thedate);
|
if ($thedate == '')
|
||||||
|
{
|
||||||
|
$stoploop=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mydate=dolibarr_getdate($thedate);
|
||||||
|
if ($firstdate["month"] != $mydate["month"]) $stoploop=1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($mydate["wday"]!=0){
|
if ($cols < 7)
|
||||||
for($i=6;$i>=$mydate["wday"];$i--)
|
{
|
||||||
echo "<TD> </TD>";
|
for($i=6; $i>=$cols; $i--) echo "<TD> </TD>";
|
||||||
echo "</TR>";
|
echo "</TR>\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr><td id="dpExp" class="dpExplanation" colspan="7"><?php
|
<tr><td id="dpExp" class="dpExplanation" colspan="7"><?php
|
||||||
|
|||||||
@ -667,19 +667,25 @@ function dolibarr_getdate($timestamp,$fast=false)
|
|||||||
\param month Mois
|
\param month Mois
|
||||||
\param day Jour
|
\param day Jour
|
||||||
\param year Année
|
\param year Année
|
||||||
|
\param gm Time gm
|
||||||
|
\param check No check on parameters (Can use day 32, etc...)
|
||||||
\return timestamp Date en timestamp, '' if error
|
\return timestamp Date en timestamp, '' if error
|
||||||
\remarks PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
|
\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,$gm=0)
|
function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=0,$check=1)
|
||||||
{
|
{
|
||||||
//print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
|
//print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (! $month || ! $day) return '';
|
if ($check)
|
||||||
if ($day > 31) return '';
|
{
|
||||||
if ($month > 12) return '';
|
if (! $month || ! $day) return '';
|
||||||
if ($min < 0 || $min > 60) return '';
|
if ($day > 31) return '';
|
||||||
if ($hour < 0 || $hour > 24) return '';
|
if ($month > 12) return '';
|
||||||
if ($min < 0 || $min > 60) return '';
|
if ($min < 0 || $min > 60) return '';
|
||||||
|
if ($hour < 0 || $hour > 24) return '';
|
||||||
|
if ($min < 0 || $min > 60) return '';
|
||||||
|
}
|
||||||
|
|
||||||
$usealternatemethod=false;
|
$usealternatemethod=false;
|
||||||
if ($year <= 1970) $usealternatemethod=true; // <= 1970
|
if ($year <= 1970) $usealternatemethod=true; // <= 1970
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user