[Resolvido] Calendário somente com dias úteis
Encontrei esse código para gerar um calendário (funciona).
Mas quero "configurar" para exibir apenas os dias úteis.
Anexei um print para ilustrar o problema.
Agradeço desde já.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Option Explicit%>
<%
Session.LCID=1046
%>
<%
Function FormatStr(String)
on Error resume next
String = Replace(String, CHR(13), "")
String = Replace(String, CHR(10) & CHR(10), "</P><P>")
String = Replace(String, CHR(10), "<BR>")
FormatStr = StringEnd Function
Dim dtToday
dtToday = Date()
Dim dtCurViewMonth ' First day of the currently viewed month
Dim dtCurViewDay ' Current day of the currently viewed month
Dim frmDate ' Date submitted by form
' if the GO button was used, build the date from the month and year
If InStr(1, Request.Form, "subGO", 1) > 0 then
if Request.Form("CURDATE_month") = "" then
tmpMonth = month(now())
else
tmpMonth = Request.Form("CURDATE_month")
End If
if Request.Form("CURDATE_year") = "" then
tmpyear = year(now())
else
tmpyear = Request.Form("CURDATE_year")
End If
tmpDate = "1 " & tmpMonth & " 1999"
mnth = Month(tmpDate)
frmDate = DateSerial(tmpyear, mnth, 1)
Else
frmDate = Request.Form("CURDATE")
end if
if Request("view_date") <> "" then
frmDate= DateSerial(year(Request("view_date")), month(Request("view_date")), 1)
end if
%>
<%
'--------------------------------------------------
Function DtPrevSunday(ByVal dt)
Do While WeekDay(dt) > vbMOnday
dt = DateAdd("d", -1, dt)
Loop
DtPrevSunday = dt
End Function
'--------------------------------------------------
%>
<%REM Set current view month from posted CURDATE, or
' the current date as appropriate.
' if posted from the form
' if prev button was hit on the form
If InStr(1, Request.Form, "subPrev", 1) > 0 Then
dtCurViewMonth = DateAdd("m", -1, frmDate)
' if next button was hit on the form
ElseIf InStr(1, Request.Form, "subNext", 1) > 0 Then
dtCurViewMonth = DateAdd("m", 1, frmDate)
' anyother time
Else
' date add in text box
If InStr(1, Request.Form, "subGO", 1) > 0 then
dtCurViewMonth = frmDate
Else
if Request("view_date") <> "" then
dtCurviewMonth = frmDate
else
dtCurViewMonth = DateSerial(Year(dtToday), Month(dtToday), 1)
End If
End If
End If
%>
<% REM --------BEGINNING OF DRAW CALENDAR SECTION-------- %>
<% REM This section executes the event query and draws a matching calendar. %>
<%
Dim iDay, iWeek, sFontColor, dictDte(31,2), intCount
strSql = "SELECT * FROM DATAS WHERE month(DatasDataInicio)= " & month(dtCurViewMonth) & " and year(DatasDataInicio) = " & year(dtCurViewMonth) & ""
set rs = conn.Execute (StrSql)
intCount= 0
' populate array with days of month
on Error resume next
do until rs.EOF
if intCount > 31 then exit do
if Day(rs("DatasDataInicio")) = intCount + 1 then
dictDte(intCount, 1) = left(rs("DatasDescricao"),15)&"..."
rs.Movenext
Else
dictDte(intCount, 1) = " "
End If
dictDte(intCount, 2) = intCount + 1
intCount = intCount + 1
loop
%> <table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr align="center" height="25" valign="middle">
<% For iDay = vbMonday To vbFriday %>
<th width="14%" align="left"><%=WeekDayName(iDay)%></th>
<%Next %>
</tr>
<%
dtCurViewDay = DtPrevSunday(dtCurViewMonth)
For iWeek = 0 To 6
Response.Write "<TR VALIGN=TOP>" & vbCrLf
Dim sBGCOLOR
sBGCOLOR = "#FFFFFF"
For iDay = 0 To 6
sBGCOLOR = "#FFFFFF"
If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
'Marca dia atual
If dtCurViewDay = dtToday Then sBGCOLOR = "#EFB4CF"
else
sBGCOLOR = "#F5F5F5"
End If
Response.Write "<TD HEIGHT=75 bgcolor='" & sBGCOLOR & "' align=left class=gridCal >"
If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
If dtCurViewDay = dtToday Then
sFontColor = "#ff0000"
Else
sFontColor = "#00000"
End If
'---- Write day of month
Response.Write "<a href=rhCalendarioDetalhes.asp?" & "view_date=" & day(dtCurViewday) & "-" & monthname(month(dtCurViewday)) & "-" & year(dtCurViewday) & " span class=data>" & Day(dtCurViewDay) & "</a><span class=txt3>"& formatStr(dictDte(Day(dtCurViewDay)- 1, 1)) & "</span>"
'---Else
'---Response.Write " "
End If
Response.Write "</TD>" & vbCrLf
dtCurViewDay = DateAdd("d", 1, dtCurViewDay)
Next
Response.Write "</TR>" & vbCrLf
Next%>
</table>
</td>
</tr>
</table>
Discussão (8)
Carregando comentários...