Quote Originally Posted by falstaffpac View Post
I'm a little reluctant to post these files because:
1) It is not my work
2) I am not a programmer so I cannot offer support

Unfortunately, this script has not received much support lately and I think its pretty cool when it works. So, I've included the code of the 2 files I formatted below. I hope this is enough to get your calendar working. Beyond this, I don't know that I can be of much help.

/includes/classes/calendar.php
PHP Code:
<?php

/** --------------------------------------------------------------------- */
/** zen-cart Open Source E-commerce                                       */
/** --------------------------------------------------------------------- */
/**  Copyright (c) 2003 The zen-cart developers                           */
/**                                                                 */
/**  http://www.zen-cart.com/index.php                                    */
/**                                                                   */
/** Portions Copyright (c) 2003 osCommerce                               */
/** ----------------------------------------------------------------------   */
/** This source file is subject to version 2.0 of the GPL license,       */
/**  that is bundled with this package in the file LICENSE, and is       */
/** available through the world-wide-web at the following url:           */
/**  http://www.zen-cart.com/license/2_0.txt.                             */
/**  If you did not receive a copy of the zen-cart license and are unable */
/** to obtain it through the world-wide-web, please send a note to       */
/** [email protected] so we can mail you a copy immediately.          */
/** ----------------------------------------------------------------------  */
/** $Id: events_manager.php 2007-07-10 [email protected]  */

class Calendar
    
{
    function 
Calendar()
    {
    }
    function 
getDayNames()
    {
        return 
$this->dayNames;
    }
    function 
setDayNames($names)
    {        
        
$this->dayNames $names;
    }
    function 
getMonthNames()
    {
        
$this->monthNames;
    }
    function 
setMonthNames($names)
    {
    
$this->monthNames $names;
    }
    function 
getStartDay()
    {
        return 
$this->startDay;
    }
    function 
setStartDay($day)
    {
        
$this->startDay $day;
    }
    function 
getStartMonth()
    {
        return 
$this->startMonth;
    }
    function 
setStartMonth($month)
    {
        
$this->startMonth $month;
    }
    function 
getCalendarLink($month$year)
    {
         return 
"&_month=$month&_year=$year";
    }
    function 
pad($s$n)
    {
        
$r $s;    while (strlen($r) < $n)
    {    
           
$r "0".$r;
    }
        return 
$r;
    }
    
    function 
getFileName($day$month$year)
    {
        return 
$this->pad($year4) ."-"$this->pad($month2) ."-"$this->pad($day2);
    }
    
    function 
getDbLink($day$month$year)
    {    
        global 
$db
            
$dateString $this->getFileName($day$month$year);    
        
$event $db->Execute("select start_date from " TABLE_EVENTS_CALENDAR " where '" $dateString "' between start_date and end_date");
        if(
$event->RecordCount() > 0)
        {
    while (!
$event->EOF)
           {    
            
/* get the first event for this day's start date for the link */

    
list($year_start$month_start$day_start) = split ('[/.-]'$event->fields['start_date']);
                    break; 
$event->MoveNext();
             }   
            
        
$bname FILENAME_EVENTS_CALENDAR;
            return 
"index.php?main_page=".$bname."&_day=".$day_start."&_month=".$month_start."&_year=".$year_start."";
              }
    }
        
    function 
getCurrentMonthView()
    {
        
$d getdate(time());
        return 
$this->getMonthView($d["mon"], $d["year"]);
    }
        function 
getCurrentYearView()
    {
        
$d getdate(time());
        return 
$this->getYearView($d["year"]);
    }
        function 
getMonthView($month$year)
    {
        return 
$this->getMonthHTML($month$year);
    }
    function 
getYearView($year)
    {
        return 
$this->getYearHTML($year);
    }
    function 
getDaysInMonth($month$year)
    {
        if (
$month || $month 12)
        {
            return 
0;
        }
        
$d $this->daysInMonth[$month 1];
        if (
$month == 2)
        {
            if (
$year%== 0)
            {
                if (
$year%100 == 0)
                {
                    if (
$year%400 == 0)
                    {
                        
$d 29;
                    }
                }
                else
                {
                    
$d 29;
                }
            }
        }
        return 
$d;
    }

    function 
getMonthHTML($m$y$show 1)
    {
        
$s "";
        
$a $this->adjustDate($m$y);
        
$month $a[0];
        
$year  $a[1];
        
$daysInMonth $this->getDaysInMonth($month$year);
        
$date getdate(mktime(1200$month1$year));
           
$first $date["wday"];
        
$monthName $this->monthNames[$month 1];
        
$prev $this->adjustDate($month 1$year);
        
$next $this->adjustDate($month 1$year);
        
$this_month date('m');
        
$this_year date('Y');
        
$header $monthName . (($show 0) ? " " $year "");
        
$D $this->monthNames[11].'&nbsp;';
        
$J $this->monthNames[0].'&nbsp;';
             if (
$show == 1)
         {
         
$prevMonth '<a href=index.php?main_page='FILENAME_EVENTS_CALENDAR_INCLUDE '&eventmode=eventframe' .$this->getCalendarLink($prev[0], $prev[1]).' target=calendar title='$this->monthNames[$month 2] . (($month-1) ? $D.($year-1) : '&nbsp;'$year) .' >&lt;</a>';
         
         
$nextMonth '<a href=index.php?main_page='FILENAME_EVENTS_CALENDAR_INCLUDE '&eventmode=eventframe' $this->getCalendarLink($next[0], $next[1]).' target=calendar title='$this->monthNames[$month 0] . (($month+11) ? $J.($year+1) : '&nbsp;'$year) .' >&gt;</a>';
        }
        else
        {
            
$prevMonth "";
            
$nextMonth "";
        }
        
$s .= "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
        
$s .= "<tr class=\"calendarHeader\">\n";
        
$linkHeader zen_href_link(FILENAME_EVENTS_CALENDAR"_month=$month&_year=$year");
        
$s .= "<td align=\"left\"><a href=\"$linkHeader\" target=\"_parent\">$header</a></td>\n";
        
$s .= "<td align=\"center\" class=\"yearHeader\">\n";

      if(
mktime (0,0,0,$month ,0,$year) > mktime (0,0,0,$this_month ,0,$this_year))
    {
            
$s .= $prevMonth;
        }
        else
    {
        
$s .= $prevMonth;
        }
            
$s .= "</td>\n";
            
$s .= "<td align=\"center\" class=\"yearHeader\">$nextMonth</td></tr>\n";
            
$s .= "<tr><td colspan=\"3\">\n";
            
$s .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"calendarMonth\"><tr class=\"calendarHeader\">\n";
            
$s .= "<td align=\"center\" valign=\"middle\">" $this->dayNames[($this->startDay)%7] . "</td>\n";
            
$s .= "<td align=\"center\" valign=\"middle\">" $this->dayNames[($this->startDay+1)%7] . "</td>\n";
            
$s .= "<td align=\"center\" valign=\"middle\">" $this->dayNames[($this->startDay+2)%7] . "</td>\n";
            
$s .= "<td align=\"center\" valign=\"middle\">" $this->dayNames[($this->startDay+3)%7] . "</td>\n";
            
$s .= "<td align=\"center\" valign=\"middle\">" $this->dayNames[($this->startDay+4)%7] . "</td>\n";
            
$s .= "<td align=\"center\" valign=\"middle\">" $this->dayNames[($this->startDay+5)%7] . "</td>\n";
            
$s .= "<td align=\"center\" valign=\"middle\">" $this->dayNames[($this->startDay+6)%7] . "</td>\n";
            
$s .= "</tr>\n";$d $this->startDay $first;
        
        while (
$d 1)
        {
            
$d -= 7;
        }
            
$today getdate(time());
            
$start_day $this->getStartDay();
            
$click BOX_CLICK_LINK;
            
        while (
$d <= $daysInMonth)
        {
            
$s .= "<tr>\n";
            for (
$i 0$i 7$i++)
            {
$class = (($i < (6-$start_day) &! $i <= $start_day) ? (($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" "calendar" ) : (($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" "calendarWeekend"));
              if (
$d && $d <= $daysInMonth)
                {
                 
$link $this->getDbLink($d$month$year);
                 
$s .= (($link == "") ? "<td class=\"$class\" align=\"left\" valign=\"bottom\">" "<td class=\"$class\" onclick=top.window.location=\"$link\">" );
                
                 if(
$show == 1)
        {
                 
$s .= (($link == "") ? $d "<a href=\"$link\" target=\"_parent\" title=\"$click\">$d</a>");
                }
            else
            {
                     
$s .= (($link == "") ? $d "<a href=\"$link\" title=\"$click\">$d</a>");
            }
        }
                else
                {
                    
$s .= "<td class=\"empty\">&nbsp;";
                }
                      
$s .= "</td>\n";
                          
$d++;
             }
            
$s .= "</tr>\n";
            }
                
$s .= "</table>\n";
                
$s .= "</td></tr></table>\n";
        
                return 
$s;
          }
          
    function 
getYearHTML($year)
    {
        
$year_view 1;
        
$s "";
        
$prev 'index.php?main_page='.FILENAME_EVENTS_CALENDAR $this->getCalendarLink(1$year 1) .'&year_view=1';
        
$next 'index.php?main_page='.FILENAME_EVENTS_CALENDAR $this->getCalendarLink(1$year 1) .'&year_view=1';
        
$this_year date('Y');
        
$s .= "<table align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" >\n";
        
$s .= "<tr>";
               if(
$year $this_year)
        {
        
$s .= "<td class=\"yearHeader\" align=\"center\" align=\"left\">" . (($prev == "") ? "&nbsp;" "<a href=\"$prev\">&lt;&lt;</a>")  . "</td>\n";
        }
        else
        {
        
$s .= "<td class=\"yearHeader\" align=\"center\" align=\"left\">&nbsp;</td>\n";
        }
        
$s .= "<td height=\"20\" class=\"yearHeader\" align=\"center\">" . (($this->startMonth 1) ? $year " - " . ($year 1) : $year) ."</td>\n";
            
$s .= "<td class=\"yearHeader\" align=\"center\" align=\"right\">" . (($next == "") ? "&nbsp;" "<a href=\"$next\">&gt;&gt;</a>")  . "</td>\n";
            
$s .= "</tr>\n";        $s .= "<tr>";        $s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "</tr>\n";
                
$s .= "<tr>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "</tr>\n";
                
$s .= "<tr>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "</tr>\n";
                
$s .= "<tr>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML(10 $this->startMonth$year0) ."</td>\n";
                
$s .= "<td valign=\"top\">" $this->getMonthHTML(11 $this->startMonth$year0) ."</td>\n";
                
$s .= "</tr>\n";
                
$s .= "</table>\n";
                return 
$s;
            }
    function 
adjustDate($month$year)
    {
        
$a = array();
        
$a[0] = $month;
        
$a[1] = $year;
        while (
$a[0] > 12)
        {
            
$a[0] -= 12;
            
$a[1]++;
        }
        while (
$a[0] <= 0)
        {
            
$a[0] += 12;
            
$a[1]--;
        }
        return 
$a;
    }
    
    
/* 
        The start day of the week. This is the day that appears in the first column
        of the calendar. Sunday = 0.
    */
    
var $startDay 0;

    
/* 
        The start month of the year. This is the month that appears in the first slot
        of the calendar in the year view. January = 1.
    */
    
var $startMonth 1;

    
/*
        The labels to display for the days of the week. The first entry in this array
        represents Sunday.
    */
    
var $dayNames = array("S""M""T""W""T""F""S");
    
    
/*
        The labels to display for the months of the year. The first entry in this array
        represents January.
    */
    
var $monthNames = array("January""February""March""April""May""June",
                            
"July""August""September""October""November""December");
                            
                            
    
/*
        The number of days in each month. You're unlikely to want to change this...
        The first entry in this array represents January.
    */
    
var $daysInMonth = array(312831303130313130313031);
    }
?>
/modules/events_calendar_listing.php
PHP Code:
<?php

/** --------------------------------------------------------------------- */
/** zen-cart Open Source E-commerce                                       */
/** --------------------------------------------------------------------- */
/**  Copyright (c) 2003 The zen-cart developers     */
/**                                                                 */
/**  [url]http://www.zen-cart.com/index.php[/url]           */
/**                                                                   */
/** Portions Copyright (c) 2003 osCommerce                               */
/** ----------------------------------------------------------------------   */
/** This source file is subject to version 2.0 of the GPL license,       */
/**  that is bundled with this package in the file LICENSE, and is       */
/** available through the world-wide-web at the following url:           */
/**  [url]http://www.zen-cart.com/license/2_0.txt[/url].                             */
/**  If you did not receive a copy of the zen-cart license and are unable */
/** to obtain it through the world-wide-web, please send a note to       */
/** [email protected] so we can mail you a copy immediately.          */
/** ----------------------------------------------------------------------  */
/** $Id: events_manager.php 2007-07-10 [email protected]  */




if(isset($listingTitle))
{
    echo 
'<H2>' $listingTitle '</H2>';
}
    
$events_split = new splitPageResults($events_query_rawMAX_DISPLAY_NUMBER_EVENTS'DAYOFMONTH(start_date)');
    
$events_query $db->Execute($events_query_raw);
    
    
/** Show Paging Header ? */
    
if (($events_split->number_of_rows 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) 
 {
 
?>
        </td>
    </tr>

<tr>
        <td>
            <table border="0" width="100%" cellspacing="0" cellpadding="2">
                <tr>
                    <td class="smallText">
                        <?php
                             
if(isset($displayPagingSuffix))
                            {
                                
$displayPagingSuffix ' : ' $displayPagingSuffix;
                            }
                            echo 
$events_split->display_count(TEXT_DISPLAY_NUMBER_OF_PAGES $displayPagingSuffix);
                         
?>
                    </td>
                    <td align="right" class="smallText">
                    <?php
                     
echo TEXT_RESULT_PAGE ' ' $events_split->display_links(MAX_DISPLAY_PAGE_LINKSzen_get_all_get_params(array('page''info''x''y')));
                    
?>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>

    <?php
}
      
$row 0;
      
$list_box_contents = array();
      
      
/** Add headings ... */
      
      
$list_box_contents[$row][] = array('align' => 'left',
                                
'params' => 'class="event_header"',
                                
'text' => '&nbsp;' TEXT_EVENT_TITLE '&nbsp;');
      
      
$list_box_contents[$row][] = array('align' => 'center',
                                
'params' => 'class="event_header"',
                                
'text' => '&nbsp;Start ' TEXT_EVENT_DATE '&nbsp;');
     
$list_box_contents[$row][] = array('align' => 'center',
                                
'params' => 'class="event_header"',
                                
'text' => '&nbsp;End ' TEXT_EVENT_DATE '&nbsp;');

                                
    
/** Add listing rows ... */
             
$events $db->Execute($events_split->sql_query);
         
    
/** while($events = zen_db_fetch_array($events_query)) */
    
        
while (!$events->EOF)
        {
            
$row++;
            
$list_box_contents[$row][] = array('align' =>     'left',
                                                               
'params' => 'class="event_description"',
                                                        
'text'  =>  '<a href="index.php?main_page='
                                           
FILENAME_EVENTS_CALENDAR '&select_event=' $events->fields['event_id'] . '">' $events->fields['title'] . '</a>');
                   
$events->MoveNext();
            list(
$year$month$day) = split '[/.-]'$events->fields['start_date']);
                
$list_box_contents[$row][] = array( 'align'  => 'center',
                                    
'params' => 'class="event_description"',
                                    
'text'   => date("F j, Y"mktime(000$month$day$year)));
                
$endDate '-';
                if(isset(
$events->fields['end_date']) && trim($events->fields['end_date']) != '')
                {
                    list(
$year$month$day) = split ('[/.-]'$events->fields['end_date']);
                        
$endDate date("F j, Y"mktime(000$month$day$year));
                        }
                        
$list_box_contents[$row][] = array('align'  => 'center',
                                       
'params' => 'class="event_description"',
                                       
'text'   => $endDate);
                            
                       }
                       
     
/** Show listing */
              
require($template->get_template_dir('tpl_tabular_display.php',DIR_WS_TEMPLATE$current_page_base,'common'). '/tpl_tabular_display.php');
     
     
/** new productListingBox($list_box_contents); */
             
if (($events_split->number_of_rows 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')))
     {
     
?>
        </td>
    </tr>
    <tr>
        <td>
            <table border="0" width="100%" cellspacing="0" cellpadding="2">
                <tr>
                    <td class="smallText">
                        <?php
                             
if(isset($displayPagingSuffix))
                            {
                                
$displayPagingSuffix ' : ' $displayPagingSuffix;
                            }
                            echo 
$events_split->display_count(TEXT_DISPLAY_NUMBER_OF_PAGES $displayPagingSuffix);
                         
?>
                    </td>
                    <td align="right" class="smallText">
                        <?php echo TEXT_RESULT_PAGE ' ' $events_split->display_links(MAX_DISPLAY_PAGE_LINKSzen_get_all_get_params(array('page''info''x''y'))); ?>                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td><?php
    
}
 else
{
?>
    <table border=0 width="100%" cellspacing="0" cellpadding="4">
        <tr>
                    <td class="main"><br><?php echo TEXT_NO_EVENTS?></td>
                </tr>
            </table>
<?php
}
?>
Thanks for this help but I am facing this problem. The sidebox that should display the calendar is now displaying the homepage. Why is this happening?! PLEASE HELP!