<?require "msg_french.inc.php3";?>
<HTML>
<HEAD>
<TITLE> Calendrier - <? echo $msgCalendar ?></TITLE>
<style type="text/css">
<!--
body {  font-family: Arial, Helvetica, sans-serif; font-size: 9pt}
input {  font-family: Arial, Helvetica, sans-serif; font-size: 8pt; background-color: #CCCCCC}
select {  font-family: Arial, Helvetica, sans-serif; font-size: 8pt; background-color: #CCCCCC}
a {  font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color: #666666; text-decoration: none}

-->
</style>
</HEAD>
<BODY>
<?
    // get all the info
if (!$HTTP_POST_VARS) {
    $theDate = getdate();
    $mon = $theDate["mon"];     // numeric month (1-12)
    $month = $theDate["month"]; // display month january, feb..
    $year = $theDate["year"];   // 4 digit year (y2k compliant)
}
if ($action = "findDate") {
    $theDate = getdate(mktime(0,0,0,$mon,1,$year));
    $month = $theDate["month"];
}

    // get what weekday the first is on
    $tempDate = getdate(mktime(0,0,0,$mon,1,$year));
    $firstwday= $tempDate["wday"];

    // get the last day of the month
    $cont = true;
    $tday = 27;
    while (($tday <= 32) && ($cont)) {
        $tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
        if ($tdate["mon"] != $mon) {
            $lastday = $tday - 1;
            $cont = false;
        }
        $tday++;
    }

?>
<table border="0" cellspacing=0 cellpadding=2 width="250" align="center">
  <tr>
    <td colspan="7">
      <table border="0" align="center">
        <tr valign="middle">
          <td align="center" >
            <FORM METHOD="POST" ACTION="<? echo basename($PHP_SELF)."?table=$table&period=$period"; ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="findDate">
<INPUT TYPE="HIDDEN" NAME="mon" VALUE="<?
if (($mon-1)<1) { echo "12"; }
else { echo $mon-1; } ?>">
<INPUT TYPE="HIDDEN" NAME="year" VALUE="<?
if (($mon-1)<1) { echo $year-1; }
else { echo $year; } ?>">

              <input type="image" border="0" name="imageField2" src="./image/left_btn.gif" width="32" height="22" align="middle">
            </FORM>
</TD>
          <TD ALIGN="CENTER" valign="top"><? echo $msgMonthsArray[$mon-1]."  ".$year ?></TD>
          <TD align="center" height="19">
            <FORM METHOD="POST" ACTION="<? echo basename($PHP_SELF)."?table=$table&period=$period"; ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="findDate">
<INPUT TYPE="HIDDEN" NAME="mon" VALUE="<?
if (($mon+1)>12) { echo "1"; }
else { echo $mon+1; } ?>">
<INPUT TYPE="HIDDEN" NAME="year" VALUE="<?
if (($mon+1)>12) { echo $year+1; }
else { echo $year; } ?>">
              <input type="image" border="0" name="imageField" src="./image/right_btn.gif" width="32" height="22" align="middle">
            </FORM></td></tr></table>
</td></tr>
  <tr bgcolor="#CCCCCC">
    <th><? echo $msgDaysShortArray[0] ?></th>
    <th><? echo $msgDaysShortArray[1] ?></th>
    <th><? echo $msgDaysShortArray[2] ?></th>
    <th><? echo $msgDaysShortArray[3] ?></th>
    <th><? echo $msgDaysShortArray[4] ?></th>
    <th><? echo $msgDaysShortArray[5] ?></th>
    <th><? echo $msgDaysShortArray[6] ?></th>
  </tr>
<?  $d = 1;
    $thisDay = date('d');
    $thisMon = date('n');
    $thisMon = date('n');
         # $thisMonth = date('F');
    $thisYear = date('Y');
    $wday = $firstwday;
    $firstweek = true;

    // loop through all the days of the month
    while ( $d <= $lastday) {

        // set up blank days for first week
        if ($firstweek) {
            echo "<TR>";
            for ($i=1; $i<=$firstwday; $i++) {
                echo "<TD>  </td>";
            }
            $firstweek = false;
        }

        if ($wday==0) {
            // Sunday start week with <tr>
            echo "<tr>";
        }
            // print cell
            //
//             $lnk_f = "index2.php3?table=".$table."&reqdate=".strtotime("$year-$mon-$d")."&reset=0&period=$period";
             $lnk_f = "index2.php3?table=".$table."&reqdate=".mktime(0,0,0,$mon,$d,$year)."&reset=0&period=$period";
             $lnk = "<a href=\"#\" onClick=\"window.open('$lnk_f','original','')\">".$d."</a>";
            echo "<td";
            if (($d == $thisDay) && ($mon == $thisMon)) { echo " BGCOLOR=\"#FFFFCC\""; }
            #echo "> $d </td>";
            echo " ><div align=\"center\"> $lnk </div></td>";

        if ($wday==6) {
            // Saturday end week with </tr>
            echo "</tr>\n";
        }

        $wday++;
        $wday = $wday % 7;
        $d++;
    }
    ?>
  <TR bgcolor="#CECFCE">
    <TD COLSPAN="7" ALIGN="CENTER"><? echo $msgToday ?> :<b>
<?
  echo $msgDaysArray[date("w")] ." ";
  echo date("j").(date("j") == 1 ? "er " : " ");
  echo $msgMonthsArray[date("n")-1]." ".date("Y");

?></b>
</TD>
  </TR>
  <TR>
<TD COLSPAN="7" ALIGN="CENTER"><FORM METHOD="POST" ACTION="<? echo basename($PHP_SELF)."?table=$table&period=$period"; ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="findDate">
        <br>
        <SELECT NAME="mon">
<OPTION VALUE="<? echo $thisMon; ?>"><? echo $msgMonthsArray[$thisMon-1]; ?></OPTION>
<OPTION VALUE="<? echo $thisMon; ?>">--------------</OPTION>
<OPTION VALUE="1"><? echo $msgMonthsArray[0] ?></OPTION>
<OPTION VALUE="2"><? echo $msgMonthsArray[1] ?></OPTION>
<OPTION VALUE="3"><? echo $msgMonthsArray[2] ?></OPTION>
<OPTION VALUE="4"><? echo $msgMonthsArray[3] ?></OPTION>
<OPTION VALUE="5"><? echo $msgMonthsArray[4] ?></OPTION>
<OPTION VALUE="6"><? echo $msgMonthsArray[5] ?></OPTION>
<OPTION VALUE="7"><? echo $msgMonthsArray[6] ?></OPTION>
<OPTION VALUE="8"><? echo $msgMonthsArray[7] ?></OPTION>
<OPTION VALUE="9"><? echo $msgMonthsArray[8] ?></OPTION>
<OPTION VALUE="10"><? echo $msgMonthsArray[9] ?></OPTION>
<OPTION VALUE="11"><? echo $msgMonthsArray[10] ?></OPTION>
<OPTION VALUE="12"><? echo $msgMonthsArray[11] ?></OPTION>
</SELECT>
<SELECT NAME="year">
<OPTION VALUE="<? echo $thisYear; ?>"><? echo $thisYear; ?></OPTION>
<OPTION VALUE="<? echo $thisYear; ?>">--------</OPTION>
<OPTION VALUE="2000">2000</OPTION>
<OPTION VALUE="2001">2001</OPTION>
<OPTION VALUE="2002">2002</OPTION>
<OPTION VALUE="2003">2003</OPTION>
<OPTION VALUE="2004">2004</OPTION>
<OPTION VALUE="2005">2005</OPTION>
<OPTION VALUE="2006">2006</OPTION>
<OPTION VALUE="2007">2007</OPTION>
<OPTION VALUE="2008">2008</OPTION>
<OPTION VALUE="2009">2009</OPTION>
<OPTION VALUE="2010">2010</OPTION>
<OPTION VALUE="2011">2011</OPTION>
<OPTION VALUE="2012">2012</OPTION>
<OPTION VALUE="2013">2013</OPTION>
<OPTION VALUE="2014">2014</OPTION>
<OPTION VALUE="2015">2015</OPTION>
<OPTION VALUE="2016">2016</OPTION>
<OPTION VALUE="2017">2017</OPTION>
<OPTION VALUE="2018">2018</OPTION>
<OPTION VALUE="2019">2019</OPTION>
<OPTION VALUE="2020">2020</OPTION>
<OPTION VALUE="2021">2021</OPTION>
<OPTION VALUE="2022">2022</OPTION>
<OPTION VALUE="2023">2023</OPTION>
<OPTION VALUE="2024">2024</OPTION>
<OPTION VALUE="2025">2025</OPTION>
</SELECT>
        <input type="image" border="0" name="imageField3" src="./image/ok_btn.gif" width="59" height="18">
      </FORM></TD></TR>
</table>

</body>
</html>