1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
| <?
/* Init variables */
$resabutton = "";
$holiday = "";
$idresa = array_fill (0,48,0);
$begresa = array_fill (0,48,0);
$nextline = 0;
$begrange = 7; /* hour begin range to */
$endrange = 20; /* end for daily planning */
/* Right date format */
$curtime = sprintf("%02d",$curday)."-".sprintf("%02d",$curmonth)."-".$curyear;
/* Right to make a reservation */
if ( $resark==1 ) {
$resabutton = "<A HREF=\"javascript:Popup('resanew.php?idroom=".
$idroom."&seek=".$curtime.
"&begh=%6\$s&begm=%7\$s',450,500,'resanew');\"><IMG ".
"SRC='images/resanew.gif' BORDER=0 ".
"TITLE='".$txt[9]."'></A>";
}
$viewbutton = "<CENTER><A HREF=\"javascript:Popup('resaopen.php?idresa=".
"%1\$s',450,500,'resaopen');\"><IMG SRC='images/view.gif' ".
"BORDER=0 TITLE='".$txt[30]."'></A>";
$lineOK = "<TR>
<TD WIDTH=5%% VALIGN=TOP BGCOLOR=\"%2\$s\">
<FONT FACE=\"%5\$s\" COLOR=\"%3\$s\" SIZE=2>%1\$s
</TD>
<TD WIDTH=90%% BGCOLOR=\"%4\$s\">
<P><FONT FACE=\"%5\$s\" SIZE=2>%6\$s
</TD>
<TD WIDTH=5%% VALIGN=TOP>
<P>%7\$s</P>".
"</TD></TR>";
$lineNO = "<TR>
<TD WIDTH=5%% VALIGN=TOP BGCOLOR=\"%2\$s\">
<FONT FACE=\"%5\$s\" COLOR=\"%3\$s\" SIZE=2>%1\$s
</TD>
<TD WIDTH=90%% BGCOLOR=\"%4\$s\">
<P ALIGN=CENTER>$resabutton </P>
</TD>
<TD WIDTH=5%% VALIGN=TOP>
<P> </P>".
"</TD></TR>";
?>
<TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=3>
<THEAD>
<TR>
<?
/* Is it a public day? */
$qry = "SELECT IdHd, YearHd FROM ".HOLI." ".
"WHERE DayHd = '".$curday."' ".
"AND MonthHd = '".$curmonth."' ";
$ret = mysql_query($qry, $cnx) ;
$hd = mysql_fetch_row($ret) ;
if ( $hd[0]!=0 && ($hd[1]==NULL || $hd[1]==$curyear) ) $holiday = $txt[8];
/* Requête pour afficher tous les ateliers */
$req = "select IdRm, NameRm, BkcolRm, FtcolRm FROM rp_room ORDER BY IdRm";
if (!$res = mysql_query($req)) exit("Erreur : ".mysql_error());
while ($col = mysql_fetch_row($res))
/* Room name and date (mise en commentaire pour infos)*/
/* $qry = "SELECT IdRm, NameRm, BkcolRm, FtcolRm FROM ".ROOM; */
/* $ret = mysql_query($qry, $cnx) ; */
/* while($col = mysql_fetch_row($ret))*/
{
$idroom = $col[0];
$nameroom = $col[1];
$bkcolorroom = $col[2];
$ftcolorroom = $col[3];
echo'<TH COLSPAN="3" WIDTH="100%" VALIGN="TOP" BGCOLOR="'.$bkcolorroom.'">'
.'<P><FONT FACE="'.$font.'" COLOR="'.$ftcolorroom.'">'
.$nameroom.' - '.sprintf('%02d', $curday).'/'
.sprintf('%02d', $curmonth).'/'.$curyear.'<BR>'.$holiday.'</P></TH>';
}
?>
</TR>
</THEAD>
<TBODY>
<?
/* Requête pour extraire toutes les réservations */
/* $qry = "select IdRs, TitleRs, BegRs, EndRs FROM rp_resa ORDER BY BegRs"; */
/* if (!$res = mysql_query($qry)) exit("Erreur : ".mysql_error()); */
/* while ($col = mysql_fetch_row($res)) */
/* { */
/* Extract reservation (code original)*/
$qry = "select IdRs, TitleRs, BegRs, EndRs FROM rp_resa ORDER BY BegRs";
if (!$ret = mysql_query($qry, $cnx)) exit("Erreur : ".mysql_error());
$c=0;
while ( $col = mysql_fetch_row($ret) )
{
$idresa[$c] = $col[0] ;
$titleresa[$c] = $col[1] ;
// extract and formate begin time from 07:00 to 0730
$begh = substr($col[2],0,2);
if (intval(substr($col[2],3,2))==30) $begm="30"; else $begm="00";
$begresa[$c] = $begh.$begm;
// extract and formate end time from 07:00 to 0730
$endh = substr($col[3],0,2);
if (intval(substr($col[3],3,2))==30) $endm="30"; else $endm="00";
// Formula to calculate number of boxes to set
$begtmp = intval($begh.$begm);
$endtmp = intval($endh.$endm);
$ecart = ($endtmp - $begtmp)/100;
$intpart = intval($ecart);
$decpart = ($ecart - $intpart)*10;
$boxresa[$c] = $intpart *2-1; # <------- Modify in 1.4
if ( $decpart!=0 ) $boxresa[$c]++;
$c++;
}
$c = 0; $odd=1;
for ( $t=$begrange ; $t<$endrange ; $t++)
{
$view = sprintf ( $viewbutton, $idresa[$c]);
/* Full hour */
$curtime = $t *100 ;
$num="<BIG>".$t.":00</BIG>";
if ( $begresa[$c]==strval($curtime) ) {
printf ($lineOK, $num, $bkcolorroom, $ftcolorroom,
$style ['reserved'.$odd], $font, $titleresa [$c], $view);
$nextline = 1 ;
if ( $boxresa[$c]==0 ) {
$c++;
$nextline=0;
if ( $odd ) $odd=0; else $odd=1;
}
}
elseif ( $nextline && $boxresa[$c]!=0 ) {
$boxresa[$c]--;
printf ($lineOK, $num, $bkcolorroom, $ftcolorroom,
$style ['reserved'.$odd], $font," "," ");
if ( $boxresa[$c]==0 ) {
$c++;
$nextline=0;
if ( $odd ) $odd=0; else $odd=1;
}
}
else printf ($lineNO, $num, $bkcolorroom, $ftcolorroom,
$style ['notreserved'], $font, $t, "00");
$view = sprintf ( $viewbutton, $idresa[$c]);
/* Half hour */
$curtime = $curtime+30;
$num="<SMALL>".$t.":30</SMALL>";
if ( $begresa[$c]==strval($curtime) ) {
printf ($lineOK, $num, $bkcolorroom, $ftcolorroom,
$style ['reserved'.$odd], $font, $titleresa [$c], $view);
$nextline = 1 ;
if ( $boxresa[$c]==0 ) {
$c++;
$nextline=0;
if ( $odd ) $odd=0; else $odd=1;
}
}
elseif ( $nextline && $boxresa[$c]!=0 ) {
$boxresa[$c]--;
printf ($lineOK, $num, $bkcolorroom, $ftcolorroom,
$style ['reserved'.$odd], $font, " ", " ");
if ( $boxresa[$c]==0 ) {
$c++;
$nextline=0;
if ( $odd ) $odd=0; else $odd=1;
}
}
else printf ($lineNO, $num, $bkcolorroom, $ftcolorroom,
$style ['notreserved'], $font, $t, "30");
}
?>
</TBODY>
</TABLE> |
Partager