We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21414
    • 41 Posts
    Hey Guy's,

    I'm working on creating a couple of snippits that is going to allow me to display / edit a work schedule using xpdo with a couple custom db's.

    Right now I have two database tables the first one is basically an event table, with a few extra columns for filtering / sorting later on it looks similar to this:

    id, name, role, group, date, start_time, end_time, total_hours

    There will be one row per "event"/scheduled shift.

    The second is my user table that includes pertinent details about the users/employees there is/will not be any duplicate rows (one row per user). This table looks similar to:

    id, name, avd, rvd, alh, group, role, status, etc, etc ...

    I'm looking to have a schedule table that looks similar to what's below, and am having difficulty today trying to get my head around how to loop through the events and display them how I want.


    |          | Sunday     | Monday     | Tuesday    | Wednesday   | Thursday   | Friday      | Saturday
    | Name     |07/01/12     | 07/02/12    | 07/03/12    | 07/04/12        | 07/05/12   | 07/06/12   | 07/07/12
    | John     | OFF       | 8:30-5:00   | 8:30-5:00   | 8:30-5:00      |  8:30-5:00  |8:30-5:00   |  OFF
    
    



    What I have so far is a snippit that will loop through table 2, and output a list of employees under the name column.

    What I am looking to do is under each day column, check to see if the person who's name is in the first column of the particular row is scheduled to work on that day, and return the start and end times.


    What I am unclear on is how I could have it check what name is in column one of the same row and pass it as a placeholder to the snippit so that it will loop through each person on that day.

    Any ideas? Am I going about this all wrong? Any help would be appreciated.

    [ed. note: nick2687 last edited this post 14 years, 3 months ago.]
      • 3749
      • 24,544 Posts
      First of all, you might consider subclassing the MODX user object and adding your fields rather than having a separate table. That way you'll have access to the other fields of the user object and profile (fullname, email, active, blocked, etc.) if you ever want them.

      Assuming that I understand your setup, you are already getting your user object to check the schedule. The name should be available with $userObject->get('name');


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting