<%
/*******************************************************************************
***************************déclaration de variables globales *******************
*******************************************************************************/
var today = new Date();
function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11){
this[0] = m0;
this[1] = m1;
this[2] = m2;
this[3] = m3;
this[4] = m4;
this[5] = m5;
this[6] = m6;
this[7] = m7;
this[8] = m8;
this[9] = m9;
this[10] = m10;
this[11] = m11;
}
var monthNames = "Janvier Février Mars Avril Mai Juin Juillet Août SeptembreOctobre Novembre Décembre Janvier Février Mars Avril Mai Juin Juillet ";
var monthNamesAng = "January February March April May June July August SeptemberOctober November December January February March April May June July ";
var today = new Date();
var thisDay;
var moisLettre
//gère les années bisextiles
year = today.getYear();
if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
// p2p-dv 2003-12-16 Changed following statement since it did not work in its original state.
// To be tested again in 2005
// p2p-dv 2004-01-09 Problem with November through December of year before Leap year.
// Must revise code in the future to correct.
// Problem is that since calendars are evalutated before all 3 months are posted, the
// current year of the first month is evaluated, but not the remaining months.
function nDays(year){
if (year % 4 == 0)
var monthDays = new montharr(31, 29, 31, 30, 31, 30, 31, 31, 30,31, 30, 31)
else
var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30,31, 30, 31);
return monthDays[moisPresent];
}
thisDay = today.getDate();
//nDays = monthDays[today.getMonth()];
firstDay = today;
firstDay.setDate(1);
testMe = firstDay.getDate();
if (testMe == 2)
firstDay.setDate(0);
startDay = firstDay.getDay();
moisPresent = today.getMonth();
moisPresentBD = moisPresent+1;
if (varLangue=="ang") {%>Today : <%
//écrire la date d'aujourd'hui
Response.write(monthNamesAng.substring(moisPresent * 9, (moisPresent + 1) * 9)); //aller chercher et écrire le mois
%> <%
Response.write(thisDay);%> <%
Response.write(year);
}
%>
<%
if (varLangue=="fr") {%>Date d'aujourd'hui : <%
//écrire la date d'aujourd'hui
Response.write(thisDay);%> <%
Response.write(monthNames.substring(moisPresent * 9, (moisPresent + 1) * 9)); //aller chercher et écrire le mois
%> <%
Response.write(year);
}%>
<%
//connexion à la BD
var oConn;
var filePath;
var oRs;
var oRs2;
var moisCourant;
var monSQL;
var monSQL2;
filePath = Session("Chalets");
//response.write("file" + filePath);
oConn = Server.CreateObject("ADODB.Connection");
oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+filePath);
%>
|
<%if (varLangue=="ang") {%>Availability for Chalet <%}
if (varLangue=="fr") {%>Disponibilités du Chalet
<%}Response.write(nomChalet)%>
|
<%if (varLangue=="fr") {%>Réserver<%}%>
<%if (varLangue=="ang") {%>Reserve<%}%>
<%if (varLangue=="fr") {%>
Légende du calendrier et modalités de réservation<%}%>
<%if (varLangue=="ang") {%>
Calender legend and reservation condition<%}%>
<%
/******************************** Début du mois **************************************
********************************* Début du mois **************************************
********************************* Début du mois *************************************/
var confirm=0; //vérifie si la fin est d'une réservation est le début d'une autre. c'est une variable booléenne
//var qui dit si on est entre la date d'arrivée et de départ si =0, en noir, si =1, en rouge, si =2 en jaune
var y=5 //valeur inutile
//requête qui regarde s'il y a un enregistrement qui débute avant le moisPrésent et termine pendant ou après celui-ci.
monSQL4 = "SELECT LocationApprouve FROM tblLocation T1, tblChalet T2 WHERE MoisArrive < "+moisPresentBD+" AND MoisDepart >= "+moisPresentBD+" AND AnneeDepart="+year+" AND T1.ChaletID = T2.ChaletID AND T2.ChaletID="+varChaletID+" AND LocationApprouve<>'3';"
oRs4 = oConn.Execute(monSQL4);
if (oRs4.Bof == true && oRs4.Eof == true) {y=0;}
else {if (oRs4.fields(0).value==0) {y=2;
confirm=confirm+1;}
if (oRs4.fields(0).value==1 || oRs4.fields(0).value==2) {y=1;
confirm=confirm+1;}
}
//boucle qui génère chacun des mois
var app=0; //si app==1 on écrit le AM à cet endroit, sinon, on l'écrit ailleur. Ça
//gère les cases où il faut écrire AM et PM au même endroit.
var coul=0; //variable qui garde e mémoire pendant un tour si la location est approuvée.
//boucle qui dit de générer 7 mois
for (var j = 1; j <= 7; ++j) {
%>
| <%
//Affichage du nom du mois et de l'année
%><%
if (varLangue=="fr") {
Response.write(monthNames.substring(moisPresent * 9, (moisPresent + 1) * 9));
Response.write(year);%> |
| Dimanche | Lundi |
Mardi |
Mercredi | Jeudi |
Vendredi | Samedi |
<%}
if (varLangue=="ang") {
Response.write(monthNamesAng.substring(moisPresent * 9, (moisPresent + 1) * 9));
Response.write(year);%>
| Sunday | Monday |
Tuesday |
Wednesday | Thursday |
Friday | Saturday |
<%}
column = 0;
//gère l'affichage de colonne en fonction de la journée de la semain actuelle (lundi, mardi,mercredi, ...
//ajoute les rangées après le jour de la semaine actuelle
for (i=0; i| | <%
column++;}
//une boucle pour chaque jour jusqu'au nombre de jour dans le mois
for (i=1; i<=nDays(year); i++) {
%><%
// monSQL = "SELECT JourArrive, MoisArrive, AnneeArrive FROM tblLocation T1, tblChalet T2 WHERE JourArrive="+i+" AND AnneeArrive="+year+" AND MoisArrive="+moisPresentBD+" AND T1.ChaletID = T2.ChaletID AND T2.ChaletID="+varChaletID;""
// monSQL2 = "SELECT JourDepart, MoisDepart, AnneeDepart FROM tblLocation T1, tblChalet T2 WHERE JourDepart="+i+" AND AnneeDepart="+year+" AND MoisDepart="+moisPresentBD+" AND T1.ChaletID = T2.ChaletID AND T2.ChaletID="+varChaletID;""
// monSQL3 = "SELECT LocationApprouve FROM tblLocation T1, tblChalet T2 WHERE JourArrive="+i+" AND AnneeArrive="+year+" AND MoisArrive="+moisPresentBD+" AND T1.ChaletID = T2.ChaletID AND T2.ChaletID="+varChaletID;""
// monSQL5 = "SELECT LocationApprouve FROM tblLocation T1, tblChalet T2 WHERE JourDepart="+i+" AND AnneeDepart="+year+" AND MoisDepart="+moisPresentBD+" AND T1.ChaletID = T2.ChaletID AND T2.ChaletID="+varChaletID;""
// oRs = oConn.Execute(monSQL);
// oRs2 = oConn.Execute(monSQL2);
// oRs3 = oConn.Execute(monSQL3);
// oRs5 = oConn.Execute(monSQL5);
function Chalet() {
this.tot = 0;
this.LocationApprouve = -1;
this.Reset = function() { this.LocationApprouve = -1 };
}
var tabChalets = new Array();
tabChalets[1] = new Chalet();
monSQL = 'SELECT tblLocation.ChaletID, tblLocation.LocationApprouve, DateDiff("d",[DateDepart],"'+ year +'/'+ moisPresentBD +'/'+ i +'") AS dep, DateDiff("d",[DateArrivee],"'+ year +'/'+ moisPresentBD +'/'+ i +'") AS arr FROM tblLocation WHERE IsDate([AnneeArrive] & "/" & [MoisArrive] & "/" & [JourArrive]) AND IsDate([AnneeDepart] & "/" & [MoisDepart] & "/" & [JourDepart]) AND CVDate("'+ year +'/'+ moisPresentBD +'/'+ i +'") Between CVDate([AnneeArrive] & "/" & [MoisArrive] & "/" & [JourArrive]) And CVDate([AnneeDepart] & "/" & [MoisDepart] & "/" & [JourDepart]) AND tblLocation.ChaletID='+varChaletID+';';
oRs = oConn.Execute(monSQL);
var k = 0;
var dep = 0;
var arr = 0;
while(!oRs.Eof) {
if(oRs("LocationApprouve").Value >= 1) tabChalets[1].LocationApprouve = oRs("LocationApprouve").Value;
if(oRs("dep").Value == 0) dep = 1;
if(oRs("arr").Value == 0) arr = 1;
k = k + 1;
oRs.MoveNext();
}
tabChalets[1].tot = k;
//tableau ci-dessous pour mettre à gauche le chiffre et à droite le AM-PM%>
<%
Response.Write('');
var cols = 0;
Response.Write("");
if(cols % 2 == 0) Response.Write("");
Response.Write("");
var couleur = "";
if(tabChalets[1].tot == 0) couleur = "339933";
else couleur = "red";
if(dep == 1) Response.Write("AM ");
if(arr == 1) Response.Write("PM ");
Response.Write("");
Response.Write(i);
Response.Write("");
Response.Write(" | ");
if(cols % 2 == 1) Response.Write(" ");
cols++;
if(cols % 2 == 1) Response.Write(" | ");
else Response.Write("");
Response.Write(" ");
Response.Write(' | ');
%>
|
<%
column++;
if (column == 7) {%> <%
column = 0;}
}
%>
<%
/********************************* Fin du mois ********************************
********************************** Fin du mois ********************************
********************************** Fin du mois *******************************/
//Changement du startDay pour le prochain mois
// p2p-dv 2003-12-19 Ajouter cas pour le 29 du mois
if (nDays(year) == 31) {startDay = startDay + 3;}
else if (nDays(year) == 30) {startDay = startDay + 2;}
else if (nDays(year) == 29) {startDay = startDay + 1;}
else if (nDays(year) == 28) {startDay = startDay;}
else {startDay == startDay + 1;}
if (startDay == 7) {startDay = 0;}
else if (startDay == 8) {startDay = 1;}
else if (startDay == 9) {startDay = 2;}
else if (startDay == 10) {startDay = 3;}
else if (startDay == 11) {startDay = 4;}
else if (startDay == 12) {startDay = 5;}
else {startDay = startDay;}
//incrémentation
moisPresent = moisPresent + 1; //on change de mois
moisPresentBD = moisPresentBD + 1;
if (moisPresent == 12) {
moisPresent = 0; //si on est rendu au mois de décembre, le mois prochain est janvier
year = year + 1;} //si le mois prochain est janvier, on augmente l'année de un
//nDays = monthDays[moisPresent]; //nombre de jour du prochain mois
if (moisPresentBD == 13) {
moisPresentBD = 1;}
%>
<%if (varLangue=="fr") {%>Réserver<%}%>
<%if (varLangue=="ang") {%>Reserve<%}%>
<%
}//fin de la boucle de génération du mois<
//fermer la connexion
oRs.close();
// oRs2.close();
// oRs3.close();
oConn.close();
%>
<%if (varLangue=="fr") {%> |
|
|