• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need some help converting this class to CI's Calendar class :( willing to pay.

#1
[eluser]Kinsbane[/eluser]
So I have a class that was built for our events - to display them a certain way in a table-based calendar.

Example (with outlines for table cells):
Events Calendar

Now, the major major problem we have using this sytem is that it isn't based on a unique ID - we constantly have issues where ID's and names of Events overlap, causing data issues like disappearing events, or events that happen to reference an older event with the same name's data, and things like that. It's a horrible way of going about things, and we need it fixed. I know CI has the Calendaring class, but it seems limited out-of-the-box for what I need, so I'm hoping we can hack together something as a plugin or a lib and let anyone be able to use it.

If you look at the link above, you'll notice that a bunch of events span multiple days - some even go across weekends (Sat and Sun). You'll also see that the class I'm having trouble with somehow manages to know how to add blank spaces within a day to make room for other events - something I haven't been able to find. Also, the colored boxes are all clickable links which take the user to the event in question.

I would like very much to keep this same functionality and system, as people here have gotten very used to being able to see a specific color span a certain number of days in the month, and then find those days in the color key below the calendar.

The way the system works is this:
We run a mySQL query for all events (even though we should only be getting events for the current month). Looping through each event, the add_event() function is called and those events are assigned to an array in the class, like so:
Code:
if($data['event_date'] > $month_start and $data['event_date'] < $month_end) {
            $cal->add_event($data['event_title'], $data['event_date'], $data['event_length'], "$my_page_url?op=view&id;={$data['event_id']}");
        }

Next, we call the display() function and give it the current month and year and the starting day of the month (in this case, 1) - like so:
Code:
$cal->display(mktime(0,0,0,$month,1,$year));

The data flow from here is easy to follow:
1. Display is called, and the outlying table is setup, which includes the topline containing the month name and prev/next links
2. Header line is setup, which contains the names of the weekdays
3. We while () loop from beginning of month's date to end of month's date, and then call the display_week() function
4. Inside the display_week() function, the get_events_in_week() function is called which brings up those events whose starting dates fall after the beginning of the week's date but before the end of the week's date
5. Once those are brought up, the display_day() function is called
6. display_day() function is called, and this is where I get lost as I can't quite determine how the system makes allowances for the other events around those in a particular day that it needs to add whitespace for

I know a good complement to the Calendaring class would be a sort of events deal, but I don't need this to be an all-out program - I only need this display events for whatever month the user picks, and that's that. All of the event data input and management will be held elsewhere in its own controller.

I am willing to pay a fair, low price for help with this - even though I have to pay for my own wedding. It's just I have been struggling with this for a while and have nothing to show for it. I'd like to be able to get something useable out to the CI community from this if possible.

Is anyone willing to help? Sad

#2
[eluser]wiredesignz[/eluser]
So are we allowed to see the existing code? Can you post it or a link to download it?

#3
[eluser]Kinsbane[/eluser]
Oh shoot! My apologies!

Here's the current class as it stands:
http://www.kinsbane.net/temp/calendarclass.php.txt

And here's an extended version of initializing the class:
Code:
$cal = &new;CALENDAR();

        $cal->show_days = 7;
        $cal->set_table_tags("border=0 cellpadding=0 cellspacing=0 class=\"maincontentnopad\"");
        $cal->set_link_tags("class=\"sidelinks\"");
        $cal->set_cal_url("$my_page_url?op=calendar&month;=$lastmonth&year;=$lastyear", "$my_page_url?op=calendar&month;=$nextmonth&year;=$nextyear");


        $query = "SELECT * FROM event ORDER BY event_date";
        $result = mysql_query($query);
        $data2 = mysql_fetch_array($result, MYSQL_ASSOC);
        while($data = mysql_fetch_array($result, MYSQL_ASSOC)) {
            
        if($data['event_date'] > $month_start and $data['event_date'] < $month_end) {
            $cal->add_event($data['event_title'], $data['event_date'], $data['event_length'], "$my_page_url?op=view&id;={$data['event_id']}");
        }
        }
        $body .= $cal->display(mktime(0,0,0,$month,1,$year));
        $body .= "<br><br>\n";
        $body .= $cal->display_colors();

#4
[eluser]bradym[/eluser]
Is there a reason you don't want to just continue using the same code? There's no reason you can't use outside classes within CodeIgniter.

I usually create a helper or plugin that just has include('class.php') then I build functions for the tasks I'm using the class for.

In your case, build a function that takes the appropriate parameters to display the calendar and returns the html for the calendar. Then in your view just call the helper function.

Does that help any? Or is it clear as mud?

Brady

#5
[eluser]wiredesignz[/eluser]
@kinsbane,
This looks fairly easy to port to CI. Can you also post the `Event` database table structure please.

#6
[eluser]Kinsbane[/eluser]
Sure! Here it is:
Code:
CREATE TABLE `event` (
  `event_id` int(10) unsigned NOT NULL auto_increment,
  `event_date` int(10) unsigned NOT NULL default '0',
  `event_length` int(2) NOT NULL default '0',
  `event_title` varchar(128) default NULL,
  `event_location` varchar(128) default NULL,
  `event_status` enum('on schedule','rescheduled','cancelled','over','hidden') NOT NULL default 'on schedule',
  `event_shown` enum('yes','no') NOT NULL default 'yes',
  `event_description` mediumtext,
  `event_type` enum('','Tradeshow','Conference','Seminar/Webinar','Road Show') NOT NULL default 'Tradeshow',
  `date_created` int(10) unsigned NOT NULL default '0',
  `created_by` varchar(16) NOT NULL default '',
  `date_modified` int(10) unsigned NOT NULL default '0',
  `modified_by` varchar(16) NOT NULL default '',
  `booth` varchar(255) NOT NULL default '',
  `attendance` enum('','1','2','3','4') NOT NULL default '',
  `feedback_sent` enum('','Y','N') NOT NULL default 'N',
  `partner_event` enum('','yes','no') NOT NULL default 'no',
  PRIMARY KEY  (`event_id`)
) TYPE=MyISAM PACK_KEYS=0 AUTO_INCREMENT=1110 ;

Thank you, wiredesignz!

#7
[eluser]Kinsbane[/eluser]
[quote author="bradym" date="1207438185"]Is there a reason you don't want to just continue using the same code? There's no reason you can't use outside classes within CodeIgniter.

I usually create a helper or plugin that just has include('class.php') then I build functions for the tasks I'm using the class for.

In your case, build a function that takes the appropriate parameters to display the calendar and returns the html for the calendar. Then in your view just call the helper function.

Does that help any? Or is it clear as mud?

Brady[/quote]

I don't want to because there's a second part of the calendar class that I didn't include (because I want to get rid of it) that involves handling forms, and manages the actual data input.

I don't want to do that anymore. I'd much rather have the calendar display stuff integrated into CI's calendar and then build the management side of it (insert, update, delete events) into a separate controller/model.

A lot of the events are also driven by requests, which the event gets added to the database once the event is approved by upper management. Which will also be a separate system, but will all tie into the same database and tables.

#8
[eluser]Kinsbane[/eluser]
Oh shoot!

I also forgot to mention earlier that I don't want the number of possible colors that an event can have to be limited to 16 per month.

I would like to use a random color for each event, and found this function for generating random HTML color hex codes. I'm hoping to interpret this into the Calendar somehow..

Code:
function random_color()
    {
        mt_srand((double)microtime()*1000000);
        $c = '';
        while(strlen($c)<6){
            $c .= sprintf("#X", mt_rand(0, 255));
        }
        return $c;
    }

#9
[eluser]Kinsbane[/eluser]
I'm bumping this to see if any other members would like to try their hand at helping out with this project Smile

#10
[eluser]Kinsbane[/eluser]
Been a little while, hoping maybe I can get some assistance. Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.