Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

(OT) designing a "per event, resource schedule" manager

by leocharre (Priest)
on Aug 03, 2006 at 15:41 UTC ( [id://565477]=perlquestion: print w/replies, xml ) Need Help??

leocharre has asked for the wisdom of the Perl Monks concerning the following question:

I'm making a project to help manage a "schedule for events taking place occupying a finite resource".. For example if a client is managing hotel rooms and rentals.
They will need to enter via http, and reports must be generated to present online to anybody enquiring to hold an envent (rent a room, throw a party in a church.. etc)

Calendar::Schedule is fab, but how would I stop overlapping?

Solution 1..

I have a simple module to interact with a timeslots table in an open dbi handle.

In the timeslots section is recorded the id of the timeslot, the id of the event(who what, beyond scope here), the start time, and end time.

I've been thinking that I'd use unix time for defining a "time bloc", start and end.
With funny leap year etc situations.. will time xxxxxxxxxx always translate to a specific date?

Maybe managing a schedule via start and end times is not the most sensible approach, what about start time and duration?

Solution 2?

My other thought is interfacing with an application that already tracks a calendar schedule type of organization.. Like mozilla sunbird? What else could I look into interfacing to?

update:

Actually, I could use Calendar::Schedule simply to render, and I could enter in the data from a sql csv, etc table, and have time conflict managed on the side.
I would have to convert unix time or something else to register events with Calendar::Schedule

  • Comment on (OT) designing a "per event, resource schedule" manager

Replies are listed 'Best First'.
Re: (OT) designing a "per event, resource schedule" manager
by jdtoronto (Prior) on Aug 03, 2006 at 18:58 UTC
    Well, if nobody else wants to take a stab at this one.

    A couple of years ago I wrote a Webapp, using CGI::Application and a bundle of other tings including Time::Piece to run golf course tee-off time scheduling. Slots lengths were configurable (based on preferences) because some courses tee-off from only one hole, others run dual tee-off and tighten the slot timing depending on the day of week. You don't need to use a fancy calendar module. As I recall I used a simple HTML calendar created dynamically to select the day (there are some nice JavaScript ones as well) and then created a table where each timeslot was a clickable area using HTML::Template already booked timeslots were in red and could not be clicked! Pretty simple really. Class::DBI and its family, as well the the plug-ins for CGI::Application made it a lot easier. As of now it manages 37 golf course for 28 clubs. It has been adapted for beauty salon booking and on the golf version it also handles lesson bookings for the pro's at the clubs. It isn't trivial, but I wrote it on my own over a period of about 6 months, so it wasn't a nightmare either!

    jdtoronto

      We have this one client who is presently managing bookings for event spaces with an excel spreadsheet. This poor man highlights by hand the hours he needs and names them by day, etc. Every time someone wants to book, he looks it up click click click click and hopes that his paper version, computer version, or whatever... is recent. I could export all with some level of error, into a sensitively formatted data set.

      A lot of people have already existing calendars. The only stability I have seen is the ical standard .. Mozilla Sunbird is coming out.

      With a method that uses the ical standard.. Your gold client, this events organizer.. a beauty salon manager.. would all be able to (if they want) enter the changes in their laptop, and a script could regulalry update the website ical file or records- from their data.

      I am thinking my problem separates into two things that could be re-used. One is a table layout for mysql for the ical standard (which I can't see an example of).
      The other is a time collission detector.

      The tie collission detector could simply be.. if we have unix time 23 through 32 (excuse me).. and an inquiry for time 31-34 was made.. we can simply detect that $requested_start < $last_registered_end Thus a collission is present.

      I am using CGI::Application, HTML::Template, and CGI::Session. I was hoping to use Calendar::Schedule, but it's kinda buggy- or super duper unfriendly to develop with.

      I'm gonna offer the project up for grabs when done, so nobody has to do this again!!! :) </p

        if we have unix time 23 through 32 (excuse me).. and an inquiry for time 31-34 was made.. we can simply detect that $requested_start < $last_registered_end Thus a collission is present.

        Ah, but how about back-to-back appts., where you start before one, and end before the other? Or a new appt. that "embeds", i.e. it has a start time after, and an end time before, another pre-existing appt?

        My feeling is that scheduling is a pretty complex set of rules...but I'd be thrilled to be proven wrong.

        ----Asim, known to some as Woodrow.

Re: (OT) designing a "per event, resource schedule" manager
by Asim (Hermit) on Aug 03, 2006 at 19:58 UTC

    These are just thoughts; it's a project I plan to be working on soon, but have yet to work through the date collision details. However my thought is "use a range of numbers". Figure out your increments, and store the start and end times, along with an array of numbers that represent the times, likely in 24-hour format. For example --  my @hours = (13, 13.25, 13.5, 13.75, 14, 14.25, 14.5, 14.75, 15). Store the array in the DB in some fashion – I admit nothing excellent comes to mind, as a (var)char would have to be parsed, and a cross-reference table might just be overkill. Update2: Of course, it should be possible to auto-generate the numbers in Perl, each time you make the query I talk about next...benchmarking would help tell which approach is best.

    At any rate, in Perl, do a SQL query that grabs that array, and also queries for any events whose end time is after your start time, or who's start time is before your end time. Iterate each row from the table against the New Event's array of times, and use something to figure out the Intersection of the two sets -- maybe Array::Compare? The Perl Cookbook also has a solution for this. Whatever matches, is a collision you’ll need to deal with.

    This is a very naive solution, so I hope others can improve on it, or offer a different, more refined algorithm for this process. I do hope it helps, though, and if I do the project in question, I'll try to remember to come back and report on it!

    Update: Upon relection, there's a module to interface to Google Calendar; it can do a lot of the scheduling for you, although I doubt I'll be able to use it for mine. I did some early work, prior to this module's release, on interfacing with GCal, and I found it rough, but do-able -- and it's been improved, I'm told, since those early days quite a bit.

    ----Asim, known to some as Woodrow.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://565477]
Approved by Tanktalus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2025-02-14 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found