Ajouter une réservation d'un local


<% check_security(1) %>
<% sub validate_time '*******validation des entree************** If not IsNumeric(Cout) and Cout <> "" Then error_list.add "startendtime", "Entrer un numero dans le Coût" b_error = true End If '********valide heures********************** if tm_start = "" or tm_end = "" then error_list.add "startendtime", "Les heures de location et la date sont olbigatoire" b_error = true End If if Request("moisd") = "" or Request("jourd") = "" or Request("anneed") = "" then error_list.add "starttime", "Entrer la date de location ." b_error = true End If ':: requests and validates event start and end time if len(tm_start) > 0 then tm_start = tm_start & " : " & request("minute_start") if len(tm_end) > 0 then tm_end = tm_end & " : " & request("minute_end") if len(tm_end) > 0 then debut = "07 AM" if (TimeValue(tm_start) < TimeValue(debut)) or (TimeValue(tm_end) < TimeValue(debut)) or (TimeValue(tm_start) > TimeValue(tm_end)) then error_list.add "startendtime", "l'heure de réservation doit être entre 7h et 23h." b_error = true end if if (dt_start=dt_end) AND (TimeValue(tm_start) > TimeValue(tm_end)) then error_list.add "startendtime", "Heure de fin (" & tm_end & ") n'est pas aprés l'heure de début (" & tm_start & ")." b_error = true end if end if end sub sub validate_reservation '******************************** blnReservation = false 'b_error = false dTmp = datevalue(dt_start) for j = 1 to 300 if dTmp <= recurring_end then blnReservation=verification(location,tm_start,tm_end,dTmp) if blnReservation = true then error_list.add "startendtime","Le local n'est pas disponible. (" & tm_start & "),(" & tm_end & ")" b_error = true end if else exit for end if if recurring = 0 then dTmp = dateadd("d",1,dTmp) elseif recurring < 30 then dTmp = dateadd("d",recurring,dTmp) elseif recurring = 30 then dTmp = dateadd("m",1,dTmp) else dTmp = dateadd("yyyy",1,dTmp) end if next end sub sub validate_Update '******************************** blnReservation = false 'b_error = false dTmp = datevalue(dt_start) for j = 1 to 300 if dTmp <= recurring_end then blnReservation=verificationUpdate(location,tm_start,tm_end,dTmp,event_id) if blnReservation = true then error_list.add "startendtime","Le local n'est pas disponible. (" & tm_start & "),(" & tm_end & ")" b_error = true end if else exit for end if if recurring = 0 then dTmp = dateadd("d",1,dTmp) elseif recurring < 30 then dTmp = dateadd("d",recurring,dTmp) elseif recurring = 30 then dTmp = dateadd("m",1,dTmp) else dTmp = dateadd("yyyy",1,dTmp) end if next end sub sub add_eventoccurs '******************************* dTmp = datevalue(dt_start) for i = 1 to 300 if dTmp <= recurring_end then cn.Execute("INSERT INTO EventsOccur (event_id, dt_occur, tm_start, tm_end, event_name, description, location,Organisme,NomC,PrenomC,TelC,EmailC,Cout,Tax, b_register) VALUES ("&to_sql(event_id,"number")&","&to_sql(dTmp,"absdate")&","&to_sql(tm_start,"absdate")&","&to_sql(tm_end,"absdate")&","&to_sql(event_name,"text")&","&to_sql(description,"text")&","&to_sql(location,"text")&","&to_sql(Organisme,"text")&","&to_sql(NomC,"text")&","&to_sql(PrenomC,"text")&","&to_sql(TelC,"text")&","&to_sql(EmailC,"text")&","&to_sql(Cout,"text")&","&to_sql(Tax,"text")&","&to_sql(b_register,"number")&")") else exit for if recurring = 0 then dTmp = dateadd("d",1,dTmp) elseif recurring < 30 then dTmp = dateadd("d",recurring,dTmp) elseif recurring = 30 then dTmp = dateadd("m",1,dTmp) else dTmp = dateadd("yyyy",1,dTmp) end if next end sub %> <% dim tm_end dim id dim recurring_end dim event_id dim CodeAdmin dim event_name dim location dim Organisme dim NomC dim PrenomC dim TelC dim EmailC dim Cout dim Tax dim b_register dim description dim dt_start dim tm_start dim b_personal dim recurring dim dt_occur dim recurring_update dim edit_events_sql sub request_edit_events ''' request form inputs from this form tm_end = request("tm_end") id = request("id") 'recurring_end = request("recurring_end") if Request.Form("moisend")<> "" and Request.Form("jourend") <> "" and Request.Form("anneeend")<> "" then recurring_end = Request("moisend") & "/" & Request("jourend") & "/" & Request("anneeend") end if event_id = request("event_id") CodeAdmin = request("CodeAdmin") event_name = request("event_name") location = request("location") Organisme = request("Organisme") NomC = request("NomC") PrenomC = request("PrenomC") TelC = request("TelC") EmailC = request("EmailC") Cout = request("Cout") Tax = request("Tax") b_register = request("b_register") description = request("description") 'dt_start = request("dt_start") if Request.Form("moisd")<> "" and Request.Form("jourd") <> "" and Request.Form("anneed")<> "" then dt_start = Request("moisd") & "/" & Request("jourd") & "/" & Request("anneed") end if tm_start = request("tm_start") b_personal = request("b_personal") recurring = request("recurring") dt_occur = request("dt_occur") recurring_update = request("recurring_update") end sub sub validate_edit_events ''' request and validate data entered from this form tm_end = trim(request("tm_end")) id = trim(request("id")) 'recurring_end = trim(request("recurring_end")) if Request.Form("moisend")<> "" and Request.Form("jourend") <> "" and Request.Form("anneeend")<> "" then recurring_end = trim(Request("moisend") & "/" & Request("jourend") & "/" & Request("anneeend")) end if event_id = trim(request("event_id")) CodeAdmin = trim(request("CodeAdmin")) if CodeAdmin = "" then error_list.add "661037","Le code est obligatoire." b_error = true end if event_name = trim(request("event_name")) if event_name = "" then error_list.add "661038","Le titre est obligatoire." b_error = true end if location = trim(request("location")) Organisme = trim(request("Organisme")) NomC = trim(request("NomC")) PrenomC = trim(request("PrenomC")) TelC = trim(request("TelC")) EmailC = trim(request("EmailC")) Cout = trim(request("Cout")) Tax = trim(request("Tax")) b_register = trim(request("b_register")) description = trim(request("description")) if Request.Form("moisd")<> "" and Request.Form("jourd") <> "" and Request.Form("anneed")<> "" then dt_start = trim(Request("moisd") & "/" & Request("jourd") & "/" & Request("anneed")) end if if dt_start = "" then error_list.add "661040","La date de début est obligatoire.." b_error = true end if tm_start = trim(request("tm_start")) b_personal = trim(request("b_personal")) recurring = trim(request("recurring")) dt_occur = trim(request("dt_occur")) recurring_update = trim(request("recurring_update")) end sub sub get_defaults_edit_events ''' set default values for this form dt_start = "" & request("incDate") & "" b_personal = 0 recurring_update = "0" end sub sub db_select_edit_Events sql = "SELECT " & _ "Events.event_id," & _ "tm_end, " & _ "id, " & _ "recurring_end, " & _ "CodeAdmin, " & _ "event_name, " & _ "location, " & _ "Organisme, " & _ "NomC, " & _ "PrenomC, " & _ "TelC, " & _ "EmailC, " & _ "Cout, " & _ "Tax, " & _ "description," & _ "dt_start, " & _ "tm_start, " & _ "b_personal, " & _ "b_register, " & _ "recurring, " & _ "dt_occur FROM (Events RIGHT JOIN EventsOccur ON Events.event_id = EventsOccur.event_id)" & _ " WHERE " & _ "EventsOccur.id = " & to_sql(id,"number") & "" on error resume next set rs = cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "select_data_edit_Events", "The data selection failed. " & err.description elseif rs.EOF then b_results = false msg_list.add "select_data_edit_Events", "Supprimer." else tm_end = rs("tm_end") id = rs("id") recurring_end = rs("recurring_end") event_id = rs("event_id") CodeAdmin = rs("CodeAdmin") event_name = rs("event_name") location = rs("location") Organisme = rs("Organisme") NomC = rs("NomC") PrenomC = rs("PrenomC") TelC = rs("TelC") EmailC = rs("EmailC") Cout = rs("Cout") Tax = rs("Tax") b_register = rs("b_register") description = rs("description") dt_start = rs("dt_start") tm_start = rs("tm_start") b_personal = rs("b_personal") recurring = rs("recurring") dt_occur = rs("dt_occur") recurring_update = rs("recurring_update") end if rs.Close on error goto 0 end sub sub db_insert_edit_Events sql = "INSERT INTO Events" & _ "(" & _ "CodeAdmin," & _ "dt_start," & _ "dt_end," & _ "recurring," & _ "recurring_end," & _ "b_personal" & _ ") VALUES (" & to_sql(CodeAdmin,"number") & "," & _ "" & to_sql(dt_start,"absdate") & "," & _ "" & to_sql(dt_end,"absdate") & "," & _ "" & to_sql(recurring,"number") & "," & _ "" & to_sql(recurring_end,"absdate") & "," & _ "" & to_sql(b_personal,"number") & ")" & _ "" 'response.write sql on error resume next cn.Execute(sql) if err.Number <> 0 then b_error = true error_list.add "db_insert_edit_Events" & err.Number ,"The database insert failed. " & err.Description else set rs = cn.Execute("SELECT @@IDENTITY") event_id = rs(0) rs.Close msg_list.add "db_insert_edit_Events","Ajouter." end if on error goto 0 end sub sub db_update_edit_Events sql = "UPDATE Events SET " & _ "CodeAdmin = " & to_sql(CodeAdmin,"number") & ", " & _ "dt_start = " & to_sql(dt_start,"absdate") & ", " & _ "dt_end = " & to_sql(dt_end,"absdate") & ", " & _ "recurring = " & to_sql(recurring,"number") & ", " & _ "recurring_end = " & to_sql(recurring_end,"absdate") & ", " & _ "b_personal = " & to_sql(b_personal,"number") & " WHERE " & _ "event_id = " & to_sql(event_id,"number") & "" 'response.write sql on error resume next cn.execute(sql) if err.number <> 0 then b_error = true error_list.add "db_update_edit_Events" & err.Number ,"erreur dans la base de donnée. " & err.Description else end if on error goto 0 end sub sub db_delete_edit_Events sql = "DELETE FROM EventsOccur" & _ " WHERE " & _ "id = " & to_sql(id,"number") & "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "db_delete_edit_Events" & err.Number ,"erreure dans la suppression. " & err.Description else msg_list.add "db_delete_edit_Events","Le champ était supprimé." end if on error goto 0 end sub ''''''''''''''''''''''''''''FIN DES SUBS '********************************************************************************************************** do_search = request("do_search") sortby = request("sortby") ''' request form keys and inputs id = request("id") ':: request action action = lcase(request("action")) ':: handle the action select case action case "select_edit_events" ' select the requested key record from database if id <> "" then db_select_edit_Events else b_error = true error_list.add "edit_edit_Events", "Spécifier l’enregistrement." end if '*****Ajouter **************************** case "insert_edit_events" validate_edit_events validate_time if b_error = true then recurring_end = 0 recurring = 0 error_list.add "invalid", "Vérifier le format des entrées." else if len(recurring_end)=0 or recurring="" then recurring_end = datevalue(dt_start) recurring=0 elseif isDate(recurring_end) then recurring_end = datevalue(recurring_end) end if validate_reservation if not b_error then db_insert_edit_events if not b_error then add_eventoccurs else error_list.add "invalid", "Vérifier le format des entrées." end if end if '******Update******************************* case "update_edit_events" validate_edit_events validate_time if len(recurring_end)=0 or recurring="" then recurring_end=datevalue(dt_start) recurring=0 elseif isDate(recurring_end) then recurring_end=datevalue(recurring_end) end if validate_Update recurring_update=request("recurring_update") if not b_error AND id<>"" then db_update_edit_events if recurring_update=1 then cn.Execute("DELETE FROM EventsOccur WHERE event_id=" & to_sql(event_id,"number")) if not b_error then add_eventoccurs else cn.Execute("UPDATE EventsOccur SET dt_occur=" & to_sql(dt_start,"absdate") & ",tm_start=" & to_sql(tm_start,"absdate") & ", tm_end=" & to_sql(tm_end,"absdate") & ", event_name=" & to_sql(event_name,"text") & ", description=" & to_sql(description,"text") & ", location=" & to_sql(location,"text") & ",Organisme=" & to_sql(Organisme,"text") & ",NomC=" & to_sql(NomC,"text") & ",PrenomC=" & to_sql(PrenomC,"text") & ",TelC=" & to_sql(TelC,"text") & ",EmailC=" & to_sql(EmailC,"text") & ",Cout=" & to_sql(Cout,"text") & ",Tax=" & to_sql(Tax,"text") & ", b_register=" & to_sql(b_register,"number") & ", alert=" & to_sql(alert,"number") & " WHERE id = " & to_sql(id,"number")) msg_list.add "updsingle", "Enregistrement modifié" end if end if case "delete_edit_events" ' delete the requested key database record if id<>"" then recurring_update=request("recurring_update") if recurring_update=1 then event_id=request("event_id") cn.Execute("DELETE FROM EventsOccur WHERE event_id="&to_sql(event_id,"number")) cn.Execute("DELETE FROM Events WHERE event_id="&to_sql(event_id,"number")) else db_delete_edit_events end if response.redirect "upd_events.asp?msg=Enregistrement+supprimer+"&event_id else b_error=true error_list.add "delete","Pas d'enregistrement pour supprimer." end if end select ':: handle the default case(s) (ignores value of action parameter) CodeAdmin = session("CodeAdmin") if id <> "" then ':: check user permission if session("accesslevel") < 3 then set rs = cn.execute("SELECT id, Events.event_id FROM Events, EventsOccur WHERE Events.event_id = EventsOccur.event_id AND id = " & id & " AND CodeAdmin = " & to_sql(session("CodeAdmin"),"number") & "") if rs.EOF then cannot_update = true msg_list.add "noaccess", "Détail." end if b_select_edit_events = true rs.Close else b_select_edit_events = true end if else get_defaults_edit_events end if %> <% display_errs display_msg %> <% if b_select_edit_events then db_select_edit_events %> <% ':: check if hide form var was set if not b_hide_edit_Events then %>
Calendrier
<% if Cout <> "" and Tax = true then %> <%end if%>
update<% else %>insert<%end if %>_edit_Events">
Local
Titre
Organisme
Description
Date début <% if dt_start <> "" then sjourd = day(dt_start) smoisd = month(dt_start) sanneed = year(dt_start) end if %> <% if time_start <> "" then if right(time_start,2) = "PM" then b_pm = true time_start = formatdatetime(time_start,3) time_start = left(time_start,len(time_start)-3) end if %>
Heure début <% if tm_start <> "" then stm_start = hour(tm_start) sminute_start = minute (tm_start) else tm_start="" end if if tm_end <> "" then stm_end = hour(tm_end) sminute_end = minute (tm_end) else tm_end="" end if %> jusqu'à
Répétition <% if not isnull(recurring) then '' if (recurring < 1) AND (not recurring) then recurring = 0 else recurring = 0 end if %> jusqu'à <% if recurring_end <> "" then sjourend = day(recurring_end) smoisend = month(recurring_end) sanneeend = year(recurring_end) end if %> (mm/jj/aaaa)
<% if isNull(recurring_update) then recurring_update = "" %> <% if id <> "" AND recurring > 0 then if recurring_update = "" then recurring_update = 1 %> checked<% end if %> name="recurring_update" value="0">cette date (<% =dt_occur %>) seulement checked<% end if %> name="recurring_update" value="1">toutes les dates <% end if %>

Nom 

Prénom

Courriel

Téléphone

Coût

$
  >Non taxable         >Taxable
Total <% Taxable = int(Cout) * 0.15025 Total = Taxable + Cout if IsNumeric(Total) and Total <> "" then response.write FormatNumber (Total) end if %>
  <% if cout <> "" then %>

Imprimer la facture

<%end if%>
<% if id <> "" then %>'" class="btnfrm"><% end if %> <% if id = "" then %><% end if %> <% if id <> "" then %><% if CodeAdmin = session("CodeAdmin") OR session("accesslevel") > 2 then %><% end if %><% end if %> <% if id <> "" then %><% if CodeAdmin = session("CodeAdmin") OR session("accesslevel") > 2 then %> <% end if %> <% end if %>
<% ':: end hide form if end if %> <% ':: assure that any db resources are freed on error resume next rs.Close set rs = NOTHING cn.Close set cn = NOTHING user_cn.Close set user_cn = NOTHING on error goto 0 %>