Solved

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

Posted on 2003-11-04
5
1,073 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

9 Experts available now in Live!

Get 1:1 Help Now