Merge pull request #9527 from frederic34/patch-11

clean datepicker
This commit is contained in:
Laurent Destailleur 2018-09-18 15:00:52 +02:00 committed by GitHub
commit 1a31071a5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,18 +66,19 @@ else
}
// Define tradMonths javascript array (we define this in datapicker AND in parent page to avoid errors with IE8)
$tradTemp=array($langs->trans("January"),
$langs->trans("February"),
$langs->trans("March"),
$langs->trans("April"),
$langs->trans("May"),
$langs->trans("June"),
$langs->trans("July"),
$langs->trans("August"),
$langs->trans("September"),
$langs->trans("October"),
$langs->trans("November"),
$langs->trans("December")
$tradTemp=array(
$langs->trans("January"),
$langs->trans("February"),
$langs->trans("March"),
$langs->trans("April"),
$langs->trans("May"),
$langs->trans("June"),
$langs->trans("July"),
$langs->trans("August"),
$langs->trans("September"),
$langs->trans("October"),
$langs->trans("November"),
$langs->trans("December")
);
print '<script type="text/javascript">';
print 'var tradMonths = [';
@ -96,25 +97,22 @@ $qualified=true;
if (! isset($_GET["sd"])) $_GET["sd"]="00000000";
if (! isset($_GET["m"])) $qualified=false;
if (! isset($_GET["y"])) $qualified=false;
if (! isset($_GET["m"]) || ! isset($_GET["y"])) $qualified=false;
if (isset($_GET["m"]) && isset($_GET["y"]))
{
if ($_GET["m"] < 1) $qualified=false;
if ($_GET["m"] > 12) $qualified=false;
if ($_GET["y"] < 0) $qualified=false;
if ($_GET["y"] > 9999) $qualified=false;
if ($_GET["m"] < 1 || $_GET["m"] > 12) $qualified=false;
if ($_GET["y"] < 0 || $_GET["y"] > 9999) $qualified=false;
}
// If parameters provided, we show calendar
if ($qualified)
{
//print $_GET["cm"].",".$_GET["sd"].",".$_GET["m"].",".$_GET["y"];exit;
displayBox(GETPOST("sd",'alpha'),GETPOST("m",'int'),GETPOST("y",'int'));
displayBox(GETPOST("sd",'alpha'), GETPOST("m",'int'), GETPOST("y",'int'));
}
else
{
dol_print_error('','ErrorBadParameters');
dol_print_error('', 'ErrorBadParameters');
}
@ -195,9 +193,7 @@ function displayBox($selectedDate,$month,$year)
{
echo '<td width="', (int) (($i+1)*100/7) - (int) ($i*100/7), '%">', $langs->trans($day_names[($i + $startday) % 7]), '</td>', "\n";
}
?>
</tr>
<?php
print '</tr>';
//print "x ".$thedate." y"; // $thedate = first day of month
$firstdate=dol_getdate($thedate);
//var_dump($firstdateofweek);
@ -210,7 +206,7 @@ function displayBox($selectedDate,$month,$year)
//print_r($mydate);
if ($mydate < $firstdate) // At first run
{
echo "<TR class=\"dpWeek\">";
echo "<tr class=\"dpWeek\">";
//echo $conf->global->MAIN_START_WEEK.' '.$firstdate["wday"].' '.$startday;
$cols=0;
for ($i = 0; $i < 7; $i++)
@ -221,7 +217,7 @@ function displayBox($selectedDate,$month,$year)
$mydate = $firstdate;
break;
}
echo "<TD>&nbsp;</TD>";
echo "<td>&nbsp;</td>";
$cols++;
}
}
@ -229,7 +225,7 @@ function displayBox($selectedDate,$month,$year)
{
if ($mydate["wday"] == $startday)
{
echo "<TR class=\"dpWeek\">";
echo "<tr class=\"dpWeek\">";
$cols=0;
}
}
@ -245,17 +241,17 @@ function displayBox($selectedDate,$month,$year)
}
// Sur click dans calendrier, appelle fonction dpClickDay
echo "<TD class=\"".$dayclass."\"";
echo "<td class=\"".$dayclass."\"";
echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",tradMonths)\"";
echo " onClick=\"dpClickDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",'".$langs->trans("FormatDateShortJavaInput")."')\"";
echo ">".sprintf("%02s",$mydate["mday"])."</TD>";
echo ">".sprintf("%02s",$mydate["mday"])."</td>";
$cols++;
if (($mydate["wday"] + 1) % 7 == $startday) echo "</TR>\n";
//$thedate=strtotime("tomorrow",$thedate);
$day++;
$thedate=dol_mktime(12,0,0,$month,$day,$year);
$thedate=dol_mktime(12, 0, 0, $month, $day, $year);
if ($thedate == '')
{
$stoploop=1;
@ -269,8 +265,8 @@ function displayBox($selectedDate,$month,$year)
if ($cols < 7)
{
for($i=6; $i>=$cols; $i--) echo "<TD>&nbsp;</TD>";
echo "</TR>\n";
for($i=6; $i>=$cols; $i--) echo "<td>&nbsp;</td>";
echo "</tr>\n";
}
?>
<tr>