Solved

calendar application - more than one event at at time in table (date) cell

Posted on 2003-11-04
5
1,071 Views
Last Modified: 2013-12-24
the link to my calendar app:

http://www.redcatweb2.org/calendar/index.cfm

i need to be able to show more than one event in a table cell. currently if i add an event to a date already being used by another event, the new event takes over the spot of the old event and the old event isn't displayed anymore.

my code:

<cfquery name="craigcal" datasource="calartscalendar">
SELECT * FROM calendar
</cfquery>

<CFPARAM name="Curr_Date" default="#now()#">

<CFIF isdefined("MonthChange")>
                     
                        <CFIF monthchange is 'forward'>
                       
            <CFSET curntdate = createodbcdate(dateadd("m", 1, lastdate))>
      <CFELSE>
            <CFSET curntdate = createodbcdate(dateadd("m", -1, lastdate))>
      </CFIF>
</CFIF>
<CFPARAM name="YearSet" default="#year(Curr_Date)#">
<CFPARAM name="MonthSet" default="#month(Curr_Date)#">

<!--- Create the date variables to search the Database by. --->
<CFSET monthstart = createdatetime(#yearset#, #monthset#, 1, 0, 0, 0)>
<CFSET monthend = createdatetime(#yearset#, #monthset#, #daysinmonth(monthstart)#, 23, 59, 59)>
        <CFQUERY datasource="calartscalendar" name="SearchResults">
              Select Eventname, EventDescription, Calendar_ID, CalendarDate From calendar Where CalendarDate >= #CreateODBCDate(monthstart)# and CalendarDate <= #CreateODBCDate(monthend)# <cfif #len(eventtype)#>and EventType = '#eventtype#'</cfif>
          </CFQUERY>
          <CFSET Lst_Eventname = Replace(ValueList(SearchResults.Eventname,'~'),'~~','~ ~','All')>
          <CFSET Lst_EventDescription = Replace(ValueList(SearchResults.EventDescription,'~'),'~~','~ ~','All')>
          <CFSET Lst_Calendar_ID = ValueList(SearchResults.Calendar_ID,'~')>
          <CFSET Lst_CalendarDate = ValueList(SearchResults.CalendarDate,'~')>
          <CFPARAM NAME="curr_date" DEFAULT="#CreateDate(Year(Now()), Month(Now()), Day(Now()))#">
                    <CFSET Lst_CalendarDay = "">
          <CFLOOP FROM="1" TO="#ListLen(Lst_CalendarDate,'~')#" INDEX="day_index">
               <CFSET Lst_CalendarDay = ListAppend(Lst_CalendarDay,day(dateformat(ListGetAt(Lst_CalendarDate,day_index,'~'),'mm/dd/yyyy')),'~')>
          </CFLOOP>

         
          <TABLE width="722" border="0" cellspacing="0" cellpadding="0"> <TR>
                    <TD align="left" valign="top" width="41">&nbsp;</TD>
                    <TD align="left" valign="top" width="630"><BR>
                    <TABLE width="558" border="0" cellspacing="0" cellpadding="2">
                         <TR>
                              <TD align="left">
                              <SPAN class="calendarbold_big"><CFOUTPUT>#DATEFORMAT(CURR_DATE, "mmmm yyyy")#</CFOUTPUT></SPAN></TD>
                              <TD align="right">
                              <SPAN class="calendarbold_big"><A HREF="index.cfm?Curr_Date=<CFOUTPUT>#DateAdd('m',-1,CURR_DATE)#</CFOUTPUT>"><span class="calendarbold_arrows"><font size="6">&#8249;&#8249;</font></span></A>  <A HREF="index.cfm?Curr_Date=<CFOUTPUT>#DateAdd('m',1,CURR_DATE)#</CFOUTPUT>"><span class="calendarbold_arrows"><font size="6">&#8250;&#8250;</font></span></A></SPAN></TD>
                         </TR>
                    </TABLE><BR>
                  <TABLE width="600" border="0" cellspacing="0" cellpadding="6">
              <TR align="left">
                              <TD valign="top" width="80" height=""><SPAN class="calendarbold"><FONT color="#000000">S</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">M</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">T</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">W</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">T</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">F</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">S</SPAN></TD>
                         </TR>
                         <TR bgcolor="#FFFFFF">
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>
                         </TR>
                         <TR>
                              <!--- just change curr_date value as per date passed --->
                              <CFSET I_ROWCNT = 1>
                              <CFSET I_ROWNO     = 1><!--- WILL HOLD THE N0 0F ROWS DISPLAYED IN CALENDAR. --->                                                  
                              <CFLOOP FROM="1" TO="#Evaluate(DayOfWeek(CreateDate(Year(Curr_Date), Month(Curr_Date), 1))-1)#" INDEX="i_empty"><!--- put empty spaces till the first day of month comes eg. in case of May..there would be four empty spaces. --->
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                             </CFLOOP>
                              <CFSET I_ROWCNT = I_EMPTY>                              
                              <CFLOOP FROM="1" TO="#DaysInMonth(Curr_Date)#" INDEX="i_day">                                                                                          
                                   <CFIF ListFindNoCase(Lst_CalendarDay,i_day,'~') NEQ 0>
                                        <TD bgcolor="#F1E39E" align="left" valign="top" width="80" height="80"><SPAN class="calendarbold"><CFOUTPUT>#i_day#</CFOUTPUT></SPAN><BR>                                  
                                        <SPAN class="frontcopy"><cfset myUrl = urlencodedformat(#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#)>
<cfoutput>
<a href="event.cfm?Eventname=#myUrl#">#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#</a> </cfoutput></A><BR></TD>    
                                   <CFELSE>                                        
                                        <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold"><CFOUTPUT>#i_day#</CFOUTPUT></SPAN><BR></TD>
                                   </CFIF>                                  
                                   <CFIF I_ROWCNT MOD 7 EQ 0>
                                        </TR>
                                        <TR bgcolor="#FFFFFF">
                                             <TD align="left" valign="top" colspan="13" height="2"></TD>
                                        </TR>
                                        <TR>
                                        <CFSET I_ROWNO = IncrementValue(I_ROWNO)>
                                   </CFIF>
                                   <CFSET I_ROWCNT = IncrementValue(I_ROWCNT)>
                              </CFLOOP>
                         </TR>
                         <CFIF I_ROWNO LT 6><!--- hide this row in no. of rows is 6 --->
                              <TR>
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>
                              </TR>
                         </CFIF>                        
                    </TABLE></TD>
               </TR>
          </TABLE>
     <CENTER><IMG src="http://calarts.edu/images/redcat/buildings/seasondarkgray.gif" width="640" height="359" alt="" border="0"></CENTER></TD>
     </TR>
</TABLE>
</BODY>
</HTML>
0
Comment
Question by:phillystyle123
5 Comments
 
LVL 17

Assisted Solution

by:anandkp
anandkp earned 100 total points
ID: 9684292
show me how ur list "Lst_eventname" looks when u have 2 events on the same day ....

u'll just have to loop over the events & display them inside the TD - so as to be able to show multiple events on the same day.

K'Rgds
Anand
0
 
LVL 11

Accepted Solution

by:
hart earned 100 total points
ID: 9684387
Anands right :-)
since he doesn't have the code, i have just pasted what he means by looping over events

change this part in your code

<SPAN class="frontcopy"><cfset myUrl = urlencodedformat(#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#)>
<cfoutput>
<a href="event.cfm?Eventname=#myUrl#">#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#</a> </cfoutput></A><BR>


to this

                        <CFIF ListValueCount(Lst_CalendarDay,i_day,'~') GT 1>
                                                                  <CFLOOP FROM="1" TO="#ListLen(Lst_CalendarDay,'~')#" INDEX="event_index">
                                                                        <CFIF ListGetAt(Lst_CalendarDay,event_index,'~') Eq i_day>
                                                                              <cfset myUrl = urlencodedformat(ListGetAt(Lst_EventName,event_index,'~'))>                                                                              
                                                                              <SPAN class="frontcopy"><cfoutput><a href="event.cfm?Eventname=#myUrl#">#ListGetAt(Lst_EventName,event_index,'~')#</a></cfoutput><BR>
                                                                        </CFIF>                                                                        
                                                                  </CFLOOP>
                                                            <CFELSE>
                                                                  <cfset myUrl = urlencodedformat(ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~'))>
                                                                  <SPAN class="frontcopy"><cfoutput><a href="event.cfm?Eventname=#myUrl#">#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#</a></cfoutput><BR>
                                                            </CFIF>


Regards
Hart


0
 

Author Comment

by:phillystyle123
ID: 9685677
thanks experts!  works perfectly!!!!!!
0
 

Expert Comment

by:mattimeikalainen
ID: 10029153
I have also quite similar calendar application, but i have problems with event.cfm page. It also passes urlencodedformat url parameter to the action page (event.cfm) , but it doesn't work!

Here is my calendar page code where It  passes url parameter:

<cfset minunUrl = urlencodedformat(ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~'))>
<cfoutput><a href="event.cfm?eventName=#minunUrl#">#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#</a></cfoutput><BR>
 </CFIF>


Here is event.cfm code:
<CFQUERY NAME="SearchResults" DATASOURCE="galleryesim">
SELECT *
FROM kalenteri
WHERE eventName = #url.eventName#
</CFQUERY>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<cfoutput query="SearchResults">
<table border="0" cellpadding="0">
  <tr>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>#eventDescription#,#eventName#</td>
    <td></td>
    <td></td>
  </tr>
</table>
</cfoutput>



</body>
</html>


0
 
LVL 17

Expert Comment

by:anandkp
ID: 10033120
mattimeikalainen : put up a seperate q's for urself !
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now