Development Projects: Mileage Trackers

So, at work we have to track our trips to various sites via a mileage tracker Excel sheet. It’s all very 1990’s and kind of silly to me.  The thought was: what if I could build a website that could do it for us.

Well, I’ve started figuring it out conceptually and now I’m sort of stuck.  I find when I’m stuck it’s best to write things out and figure out where I’m getting tripped up.  That’s where you come in, blog-o-sphere (can we still use that word? Is it ok? Hip? And what not? IDGAF).  Help me out.

So the idea is: User logs in to site, and is presented with a selection for year and month.  Selecting the year and month brings up the calendar for the selection.  The calendar should show trips to sites on specific days.  They have the option to print out a copy for submission (because paper copies are still tops, apparently because reasons).  Ideally I’d like the page to output data to a pre-formatted Excel sheet and convert that to a PDF for printing.  That part shouldn’t be difficult. The part that has me scratching my head is, oddly enough, the login system and the display of a calendar system.

Upon login, I’d like to have it check for an existing user profile in the database.  If it doesn’t (say as on first login) I’d like it to prompt a dialog for entering a full name (used to sign off on the form).  The login is handled by PHP LDAP authentication on a SSL enabled site, so getting a username is done via SERVER[‘REMOTE_USER’] which is trivial.  Where I’m getting caught up is in the logic of the page itself.  I sort of see it going like this:

  1. User navigates to page.
  2. User login.
  3. Page detects user account, queries db to check if has registered in the system before.
    1. If they have: proceed to main page and show calendar selections.
    2. If they have not: force them to register.  Then redirect them to main page and show calendar selections.

I’m trying to keep it as one simple page with calls to different functions, and doing some sort of AJAX magic – I think that’s where it’s fouling me up.  I don’t want them to feel like they’re submitting forms all day long.

Generating the calendar shouldn’t be too bad.  It’s going to be a big CSS formatted table I think (oh shush, Calendars are big sets of tabular data and using tables is not a sin when it’s appropriate).

It should be something as trivial as the following bits of pseudo-ish-code:

IF(isset($_SESSION['username']) AND isset($_SESSION['fullname']) AND isset($_SESSION['userid'])){
    // Show the dashboard
    // Can we condense this into some sort of session placeholder? like $_SESSION['active'] set
    // as part of login below? Probably.
        // Check for login details
        // SQL magic to see if there is a username matching the $_SERVER['REMOTE_USER']
        if(REMOTE_USER in the Database with all account details){
            // Set $_SESSION Variables
            // Show the registration page
        // Error Message, if there is no session user and no remote user there
        // is a big problem, we should never end up here.

Just seem to be getting lost in the logic of it and having a hard time concentrating on where it all should be going.

I tried re-writing the code out a few times before Christmas and New Years breaks but got stone walled each time.   I’m going to give it another try today or tomorrow because I’d like to demo this at the end of the month or in February.

Once I get past this step the rest should be fairly easy-going.  I’m just not 100% certain where it’s all headed in the grand scheme of things.  I eventually want to include an API that will allow you to submit requests via simple HTTP calls instead of having to use the website.   I could then convert it into an applet or app in general to log your trips.  That would be kind of cool.

-M, out.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.