Hi Everyone,
I am currently still on version 10.5 but this could easily apply to version 11. I was looking for a way to show a basic "day" calendar view for my application. Basically I wanted a simple day calendar broken out by hours that was easy to read and looked like a calendar. I know in version 10.5 and 11 there are calendar options available and they are very nice, but I needed something that was easy to customize and used standard grid technology.
So using a standard read only grid and events I was able to build something very nice I think. Basically I wrote a lot of Xbasic code that uses the OnExistingRowRender and the OnAfterExistingRowRender to build the calendar look and feel. I have included the code and an image of the result below.
New_Display_Calendar.jpg
To implement it yourself here are some key points...
1) Use a read only grid.
2) You need a date and time field in the grid of course.
3) The color coding you see in the image where just conditional formatting I added to some fields.
4) Add a search field on the read only grid and set hide grid when no search is active.
5) You will probably need to modify the code a bit to suit your needs. I make absolutely no warranty to its use and you can use it on your application as you see fit. It could probably be cleaned up a bit and made more flexible but I will leave that to someone else if they want to work on it.
6) I was able to get the concept of how the OnExistingRowRender works from some comments on the forum so thanks to the forum for help.
Let me know what you think or any ideas to improve it. (Code below)
Cheers,
Scott
Here is the code for the OnExistingRowRender:
dim date_new as c
dim date_old as c
dim time_new as c
dim time_old as c
dim date_display_loop as c
'HTML Formatting...
dim date_format as c
dim row_format as c
dim break_after_date as c
dim break_after_time as c
dim early_description as c
date_format = "<div style=\"width:980px;background-color: #e1dfdf;height: 25px;\"><SPAN STYLE=\"color: black; font-size: 12pt;\">"
row_format = "<SPAN STYLE=\"color: #969696; font-size: 10pt\">"
break_after_date = "<br>"
break_after_time = ""
break_before_time = "<br><hr>"
early_description = "<hr>12:00 am to 7:00 am and services with no time assigned</span>"
if eval_valid("e.rtc.date")=.f. 'if e.rtc.Grupo hasnt been set (eg. first row)
e.rtc.date = "$nada$" 'set to a dummy value
e.rtc.time = "$nada$"
end if
Date_old = e.rtc.date 'The Grouping field value from the previous record
Time_old = e.rtc.time
Date_new = e.rowData.data("Date") 'The Grouping field value from the current record
time_new = e.rowData.data("Time") 'Time field
date_new = REMSPECIAL(date_new)
time_new = REMSPECIAL(time_new)
time_hour = substr(time_new,1,2)
'debug(1)
time_am_pm = substr(time_new,9,2)
if val(time_hour) != 12
if time_am_pm = "pm"
time_hour = val(time_hour) + 12
end if
end if
if val(time_hour) = 12
if time_am_pm = "am"
time_hour = 01
end if
end if
if date_new <> date_old
if date_old = "$nada$"
date_display = e.rowData.data("Date")
date_display2 = format_data(date_display,"4")
'Ok, so we know its the first occurence, but that doesnt stop us needing to create the initial date line and 7:00 am to 12:00 pm line, because no matter
'what that is coming. So lets set that up first!
date_display_loop = date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description
'Now - what time is it? FIgure that out and generate the entries...
if val(time_hour) < 7 'do nothing, we alredy created the early morning entry...
else if time_hour = "" 'blank time, do nothing.
else if val(time_hour) >= 18 'in this case create all the hours plus the final evening notation
dim loop as n
dim next as n
dim time_counter as c
time_counter = 6
time_check = 17
loop_counter = 6
next = 100
for loop = loop_counter to next
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
time_counter = val(time_counter) + 1
if loop = 16
date_display_loop = date_display_loop + break_before_time + row_format + "6:00 pm to 12:00 am" + "</span>"
exit for
end if
next loop
else ' ok we have a time value, create the entry.
dim loop as n
dim next as n
dim time_counter as c
time_counter = 6
time_check = val(time_hour) - 1
loop_counter = 6
next = 100
for loop = loop_counter to next
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
time_counter = val(time_counter) + 1
if loop >= time_check
exit for
end if
next loop
end if ' this end if is for checking what time it was.
date_format = <<%html%
<tr bgcolor="#ffffff">
<td colspan="30">
<font color="#000000" size=3 >%html% + date_display_loop + <<%html%
</font>
</td>
</tr>
%html%
e.htmlPrefix = date_format
' e.htmlPrefix = <<%html%
' <tr bgcolor="#ffffc0">
' <td colspan="10">
' <font color=#CC0000 size=3 >%html% + date_display_loop + <<%html%
' </font>
' </td>
' </tr>
' %html%
end if 'end of is it $nada$
end if 'end of is it not the same date.
if date_new <> date_old
if date_old != "$nada$"
date_display = e.rowData.data("Date")
date_display2 = format_data(date_display,"4")
'Its not the first occurence of a date
'So before the new date, we need to build up the previous time entries.!!
'First lets check to see if theere were entries late in the day...so we don't need to do anythin.
if val(time_old) >= 18
'So we know that the time old is no there. We just need to get todays date and figure out the time.
date_display_loop = "<br>" + date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description
else
'What was the previous time...
if time_old = "" 'so there were entries that had no times and nothing after that..
'create the 7:00 am row and the enter the normal loop....
time_old = "06"
end if 'End if there was no times in the previous run.
if val(time_old) <= 6
time_old = 6
end if
'ok, so here we are still working on the previous day. If there wasn't any values with a time then they have been handled in the previous if
'clause. So
'no we need to create the previous working hours.
'We need to build the html. So take the last time value, add 1, add it to the variab.e
dim loop as n
dim next as n
loop_counter = time_old
next = 16
for loop = loop_counter to next
'Dont need this if the previous day was 5 pm.
if val(time_old) != 17
if val(time_old) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format +(val(time_old) + 1) + " am" + "</span>" + break_after_time
else if val(time_old) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
end if
time_old = val(time_old) + 1
next loop
date_display_loop = date_display_loop + break_before_time + row_format + "6:00pm to 12:00am<br><br>"+ "</span>" + date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description
end if ' there were entries late in the day so no need to generate a previous view.
'Now we have the previous day taken care of! Now figure out today!
if val(time_hour) < 7 'do nothing, we alredy created the early morning entry...
else if time_hour = "" 'blank time, do nothing.
else if val(time_hour) >= 18
dim loop as n
dim next as n
dim time_counter as c
time_counter = 6
time_check = 17
loop_counter = 6
next = 100
for loop = loop_counter to next
'We dont need to enter this if its 17
if val(time_old) != 17
if val(time_counter + 1) < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
end if
time_counter = val(time_counter) + 1
if loop = time_check
date_display_loop = date_display_loop + "<br><br> 6:00 pm to 12:00 am"
exit for
end if
next loop
else ' ok we have a time value, create the entry.
dim loop as n
dim next as n
dim time_counter as c
time_counter = 6
time_check = val(time_hour) - 1
loop_counter = 6
next = 100
for loop = loop_counter to next
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
time_counter = val(time_counter) + 1
if loop = time_check
exit for
end if
next loop
end if ' this end if is for checking what time it was.
date_format = <<%html%
<tr bgcolor="#ffffff">
<td colspan="30">
<font color="#000000" size=3 >%html% + date_display_loop + <<%html%
</font>
</td>
</tr>
%html%
e.htmlPrefix = date_format
end if 'Is it the first occurence?
end if 'Is it a new date?
'debug(1)
if date_new = date_old
if time_hour != time_old 'only do something if the time is different....
if time_hour != "" 'we don't want to do this unless its a real time, the previous time might have been 12;00 am to 7:00 am
if val(time_hour) >= 7
'debug(1)
'Now - what time is it? FIgure that out and generate the entries...
if val(time_hour) >= 18 'in this case create all the hours plus the final evening notation
if val(time_old) < 18 'if we had a previous value dont create the data again!
dim loop as n
dim next as n
dim time_counter as c
if time_old = ""
time_old = 6
end if
time_counter = time_old
time_check = val(time_old) - 1
loop_counter = time_old
next = 100
for loop = loop_counter to next
'For the 5 pm ones just exit...we dont need an entry
if val(time_old) != 17
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
end if
time_counter = val(time_counter) + 1
if loop >= 16
date_display_loop = date_display_loop + row_format + "<br><br><hr> 6:00 pm to 12:00 am" "</span>"
exit for
end if
next loop
end if ' end if was the previous on less than 16
else ' ok we have a time value, create the entry.
dim loop as n
dim next as n
dim time_counter as c
if time_old = ""
time_old = 6
end if
if val(time_old) <= 6
time_old = 6
end if
time_counter = time_old
time_check = val(time_hour) - 1
loop_counter = time_old
next = 100
for loop = loop_counter to next
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
time_counter = val(time_counter) + 1
if loop = time_check
exit for
end if
next loop
end if ' this end if is for checking what time it was.
date_format = <<%html%
<tr bgcolor="#ffffff">
<td colspan="30">
<font color="#000000" size=3 >%html% + date_display_loop + <<%html%
</font>
</td>
</tr>
%html%
e.htmlPrefix = date_format
end if 'old time is greater than 7
end if 'end of time old.
end if 'end of is it $nada$
end if 'end of is it not the same date.
e.rtc.date = date_new
e.rtc.time = time_hour
Here is the code for the OnAfterExistingRowRender
'HTML Formatting...
dim date_format as c
dim row_format as c
dim break_after_date as c
dim break_after_time as c
dim early_description as c
date_format = "<div style=\"width:970px;background-color: #e1dfdf;height: 25px;\"><SPAN STYLE=\"color: black; font-size: 12pt;\">"
row_format = "<SPAN STYLE=\"color: #969696; font-size: 10pt\">"
break_after_date = "<br>"
break_after_time = ""
break_before_time = "<br><hr>"
dim date_display_loop as c
Time_old = e.rtc.time
if val(time_old) >= 18
'So we know that the time old is no there. We just need to get todays date and figure out the time.
' do nothing! we hav everyhthing we need
else
'What was the previous time...
if time_old = "" 'so there were entries that had no times and nothing after that..
'create the 7:00 am row and the enter the normal loop....
time_old = "06"
end if 'End if there was no times in the previous run.
if val(time_old) <= 6
time_old = 6
end if
'ok, so here we are still working on the previous day. If there wasn't any values with a time then they have been handled in the previous if
'clause. So
'no we need to create the previous working hours.
'We need to build the html. So take the last time value, add 1, add it to the variab.e
dim loop as n
dim next as n
loop_counter = time_old
next = 16
for loop = loop_counter to next
'Dont need this if the previous day was 5 pm.
if val(time_old) != 17
if val(time_old) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format +(val(time_old) + 1) + " am" + "</span>" + break_after_time
else if val(time_old) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
end if
time_old = val(time_old) + 1
next loop
date_display_loop = date_display_loop + row_format + "<br><br><hr> 6:00 pm to 12:00 am" "</span>"
end if ' there were entries late in the day so no need to generate a previous view.
e.rtc.date = "$nada$" 'set to a dummy value
e.rtc.time = "$nada$"
'
'
' e.html = <<%html%
' <tr bgcolor="#ffffc0">
' <td colspan="10">
' <font color=#CC0000 size=3 >%html% + date_display_loop + <<%html%
' </font>
' </td>
' </tr>
' %html%
date_format = <<%html%
<tr bgcolor="#ffffff">
<td colspan="30">
<font color="#000000" size=3 >%html% + date_display_loop + <<%html%
</font>
</td>
</tr>
%html%
e.html = date_format
I am currently still on version 10.5 but this could easily apply to version 11. I was looking for a way to show a basic "day" calendar view for my application. Basically I wanted a simple day calendar broken out by hours that was easy to read and looked like a calendar. I know in version 10.5 and 11 there are calendar options available and they are very nice, but I needed something that was easy to customize and used standard grid technology.
So using a standard read only grid and events I was able to build something very nice I think. Basically I wrote a lot of Xbasic code that uses the OnExistingRowRender and the OnAfterExistingRowRender to build the calendar look and feel. I have included the code and an image of the result below.
New_Display_Calendar.jpg
To implement it yourself here are some key points...
1) Use a read only grid.
2) You need a date and time field in the grid of course.
3) The color coding you see in the image where just conditional formatting I added to some fields.
4) Add a search field on the read only grid and set hide grid when no search is active.
5) You will probably need to modify the code a bit to suit your needs. I make absolutely no warranty to its use and you can use it on your application as you see fit. It could probably be cleaned up a bit and made more flexible but I will leave that to someone else if they want to work on it.
6) I was able to get the concept of how the OnExistingRowRender works from some comments on the forum so thanks to the forum for help.
Let me know what you think or any ideas to improve it. (Code below)
Cheers,
Scott
Here is the code for the OnExistingRowRender:
dim date_new as c
dim date_old as c
dim time_new as c
dim time_old as c
dim date_display_loop as c
'HTML Formatting...
dim date_format as c
dim row_format as c
dim break_after_date as c
dim break_after_time as c
dim early_description as c
date_format = "<div style=\"width:980px;background-color: #e1dfdf;height: 25px;\"><SPAN STYLE=\"color: black; font-size: 12pt;\">"
row_format = "<SPAN STYLE=\"color: #969696; font-size: 10pt\">"
break_after_date = "<br>"
break_after_time = ""
break_before_time = "<br><hr>"
early_description = "<hr>12:00 am to 7:00 am and services with no time assigned</span>"
if eval_valid("e.rtc.date")=.f. 'if e.rtc.Grupo hasnt been set (eg. first row)
e.rtc.date = "$nada$" 'set to a dummy value
e.rtc.time = "$nada$"
end if
Date_old = e.rtc.date 'The Grouping field value from the previous record
Time_old = e.rtc.time
Date_new = e.rowData.data("Date") 'The Grouping field value from the current record
time_new = e.rowData.data("Time") 'Time field
date_new = REMSPECIAL(date_new)
time_new = REMSPECIAL(time_new)
time_hour = substr(time_new,1,2)
'debug(1)
time_am_pm = substr(time_new,9,2)
if val(time_hour) != 12
if time_am_pm = "pm"
time_hour = val(time_hour) + 12
end if
end if
if val(time_hour) = 12
if time_am_pm = "am"
time_hour = 01
end if
end if
if date_new <> date_old
if date_old = "$nada$"
date_display = e.rowData.data("Date")
date_display2 = format_data(date_display,"4")
'Ok, so we know its the first occurence, but that doesnt stop us needing to create the initial date line and 7:00 am to 12:00 pm line, because no matter
'what that is coming. So lets set that up first!
date_display_loop = date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description
'Now - what time is it? FIgure that out and generate the entries...
if val(time_hour) < 7 'do nothing, we alredy created the early morning entry...
else if time_hour = "" 'blank time, do nothing.
else if val(time_hour) >= 18 'in this case create all the hours plus the final evening notation
dim loop as n
dim next as n
dim time_counter as c
time_counter = 6
time_check = 17
loop_counter = 6
next = 100
for loop = loop_counter to next
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
time_counter = val(time_counter) + 1
if loop = 16
date_display_loop = date_display_loop + break_before_time + row_format + "6:00 pm to 12:00 am" + "</span>"
exit for
end if
next loop
else ' ok we have a time value, create the entry.
dim loop as n
dim next as n
dim time_counter as c
time_counter = 6
time_check = val(time_hour) - 1
loop_counter = 6
next = 100
for loop = loop_counter to next
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
time_counter = val(time_counter) + 1
if loop >= time_check
exit for
end if
next loop
end if ' this end if is for checking what time it was.
date_format = <<%html%
<tr bgcolor="#ffffff">
<td colspan="30">
<font color="#000000" size=3 >%html% + date_display_loop + <<%html%
</font>
</td>
</tr>
%html%
e.htmlPrefix = date_format
' e.htmlPrefix = <<%html%
' <tr bgcolor="#ffffc0">
' <td colspan="10">
' <font color=#CC0000 size=3 >%html% + date_display_loop + <<%html%
' </font>
' </td>
' </tr>
' %html%
end if 'end of is it $nada$
end if 'end of is it not the same date.
if date_new <> date_old
if date_old != "$nada$"
date_display = e.rowData.data("Date")
date_display2 = format_data(date_display,"4")
'Its not the first occurence of a date
'So before the new date, we need to build up the previous time entries.!!
'First lets check to see if theere were entries late in the day...so we don't need to do anythin.
if val(time_old) >= 18
'So we know that the time old is no there. We just need to get todays date and figure out the time.
date_display_loop = "<br>" + date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description
else
'What was the previous time...
if time_old = "" 'so there were entries that had no times and nothing after that..
'create the 7:00 am row and the enter the normal loop....
time_old = "06"
end if 'End if there was no times in the previous run.
if val(time_old) <= 6
time_old = 6
end if
'ok, so here we are still working on the previous day. If there wasn't any values with a time then they have been handled in the previous if
'clause. So
'no we need to create the previous working hours.
'We need to build the html. So take the last time value, add 1, add it to the variab.e
dim loop as n
dim next as n
loop_counter = time_old
next = 16
for loop = loop_counter to next
'Dont need this if the previous day was 5 pm.
if val(time_old) != 17
if val(time_old) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format +(val(time_old) + 1) + " am" + "</span>" + break_after_time
else if val(time_old) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
end if
time_old = val(time_old) + 1
next loop
date_display_loop = date_display_loop + break_before_time + row_format + "6:00pm to 12:00am<br><br>"+ "</span>" + date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description
end if ' there were entries late in the day so no need to generate a previous view.
'Now we have the previous day taken care of! Now figure out today!
if val(time_hour) < 7 'do nothing, we alredy created the early morning entry...
else if time_hour = "" 'blank time, do nothing.
else if val(time_hour) >= 18
dim loop as n
dim next as n
dim time_counter as c
time_counter = 6
time_check = 17
loop_counter = 6
next = 100
for loop = loop_counter to next
'We dont need to enter this if its 17
if val(time_old) != 17
if val(time_counter + 1) < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
end if
time_counter = val(time_counter) + 1
if loop = time_check
date_display_loop = date_display_loop + "<br><br> 6:00 pm to 12:00 am"
exit for
end if
next loop
else ' ok we have a time value, create the entry.
dim loop as n
dim next as n
dim time_counter as c
time_counter = 6
time_check = val(time_hour) - 1
loop_counter = 6
next = 100
for loop = loop_counter to next
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
time_counter = val(time_counter) + 1
if loop = time_check
exit for
end if
next loop
end if ' this end if is for checking what time it was.
date_format = <<%html%
<tr bgcolor="#ffffff">
<td colspan="30">
<font color="#000000" size=3 >%html% + date_display_loop + <<%html%
</font>
</td>
</tr>
%html%
e.htmlPrefix = date_format
end if 'Is it the first occurence?
end if 'Is it a new date?
'debug(1)
if date_new = date_old
if time_hour != time_old 'only do something if the time is different....
if time_hour != "" 'we don't want to do this unless its a real time, the previous time might have been 12;00 am to 7:00 am
if val(time_hour) >= 7
'debug(1)
'Now - what time is it? FIgure that out and generate the entries...
if val(time_hour) >= 18 'in this case create all the hours plus the final evening notation
if val(time_old) < 18 'if we had a previous value dont create the data again!
dim loop as n
dim next as n
dim time_counter as c
if time_old = ""
time_old = 6
end if
time_counter = time_old
time_check = val(time_old) - 1
loop_counter = time_old
next = 100
for loop = loop_counter to next
'For the 5 pm ones just exit...we dont need an entry
if val(time_old) != 17
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
end if
time_counter = val(time_counter) + 1
if loop >= 16
date_display_loop = date_display_loop + row_format + "<br><br><hr> 6:00 pm to 12:00 am" "</span>"
exit for
end if
next loop
end if ' end if was the previous on less than 16
else ' ok we have a time value, create the entry.
dim loop as n
dim next as n
dim time_counter as c
if time_old = ""
time_old = 6
end if
if val(time_old) <= 6
time_old = 6
end if
time_counter = time_old
time_check = val(time_hour) - 1
loop_counter = time_old
next = 100
for loop = loop_counter to next
if val(time_counter) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time
else if val(time_counter) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
time_counter = val(time_counter) + 1
if loop = time_check
exit for
end if
next loop
end if ' this end if is for checking what time it was.
date_format = <<%html%
<tr bgcolor="#ffffff">
<td colspan="30">
<font color="#000000" size=3 >%html% + date_display_loop + <<%html%
</font>
</td>
</tr>
%html%
e.htmlPrefix = date_format
end if 'old time is greater than 7
end if 'end of time old.
end if 'end of is it $nada$
end if 'end of is it not the same date.
e.rtc.date = date_new
e.rtc.time = time_hour
Here is the code for the OnAfterExistingRowRender
'HTML Formatting...
dim date_format as c
dim row_format as c
dim break_after_date as c
dim break_after_time as c
dim early_description as c
date_format = "<div style=\"width:970px;background-color: #e1dfdf;height: 25px;\"><SPAN STYLE=\"color: black; font-size: 12pt;\">"
row_format = "<SPAN STYLE=\"color: #969696; font-size: 10pt\">"
break_after_date = "<br>"
break_after_time = ""
break_before_time = "<br><hr>"
dim date_display_loop as c
Time_old = e.rtc.time
if val(time_old) >= 18
'So we know that the time old is no there. We just need to get todays date and figure out the time.
' do nothing! we hav everyhthing we need
else
'What was the previous time...
if time_old = "" 'so there were entries that had no times and nothing after that..
'create the 7:00 am row and the enter the normal loop....
time_old = "06"
end if 'End if there was no times in the previous run.
if val(time_old) <= 6
time_old = 6
end if
'ok, so here we are still working on the previous day. If there wasn't any values with a time then they have been handled in the previous if
'clause. So
'no we need to create the previous working hours.
'We need to build the html. So take the last time value, add 1, add it to the variab.e
dim loop as n
dim next as n
loop_counter = time_old
next = 16
for loop = loop_counter to next
'Dont need this if the previous day was 5 pm.
if val(time_old) != 17
if val(time_old) + 1 < 12
date_display_loop = date_display_loop + break_before_time + row_format +(val(time_old) + 1) + " am" + "</span>" + break_after_time
else if val(time_old) + 1 = 12
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1) + " pm" + "</span>" + break_after_time
else
date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1 - 12) + " pm" + "</span>" + break_after_time
end if
end if
time_old = val(time_old) + 1
next loop
date_display_loop = date_display_loop + row_format + "<br><br><hr> 6:00 pm to 12:00 am" "</span>"
end if ' there were entries late in the day so no need to generate a previous view.
e.rtc.date = "$nada$" 'set to a dummy value
e.rtc.time = "$nada$"
'
'
' e.html = <<%html%
' <tr bgcolor="#ffffc0">
' <td colspan="10">
' <font color=#CC0000 size=3 >%html% + date_display_loop + <<%html%
' </font>
' </td>
' </tr>
' %html%
date_format = <<%html%
<tr bgcolor="#ffffff">
<td colspan="30">
<font color="#000000" size=3 >%html% + date_display_loop + <<%html%
</font>
</td>
</tr>
%html%
e.html = date_format