Jump to content

Shift System


Recommended Posts

I'm creating a shift system where it stores into database which shift is the user in. However sometimes their shift extends over the other shift. How can I implement it better

I'm currently using the time to get which shift they are on. There are two shift.

1) morning: 0800 - 1930hrs

2) night: 1930 - 0800hrs

 

Sometimes the shift will overrun. How do I maintain on which shift they were.

 


  $whatshift = (int) date("Hi");
  if ($whatshift > "0800" && $whatshift < "1800") {
    $shift = 1;
  } else {
    $shift = 2;
  }

 

Link to comment
Share on other sites

Currently the code is run and the shift value is added into the database with other data.

However sometimes the night shift overruns the morning shift time and thus the shift value will change to 1 instead.

 

I was think of setting a cookie when the user logged in and store the session for 12hours. However I cannot confirm the time of their login this the 12hours cookie will overrun into the next shift.

Link to comment
Share on other sites

Can you not just check which user logged in and what day it is then check the schedule for their shift?

If you just try and check a persons shift when the log in and they may login many times than that won't really work by itself.  You need to either have a defined schedule or some sort of clock in/clock out feature to that they use at the start and end of their shift.

 

Link to comment
Share on other sites

If I worked morning shift, its shift 1.

If I worked night shift, it's shift 2.

 

There is no fixed schedule thus when they key in their entry, it checks if the time is after 1800hrs. But sometimes their shift extends to the next morning which is shift 1 but I want the shift to remain as shift 2.

Link to comment
Share on other sites

You won't be able to get determine their shift at any given moment by checking the current time.  There's not enough information to do that.

If it's a system the login to and stay logged into through out the day then you could determine it at login and store it in a session variable.  So long as they stay logged in that'd be fine.  Even that however could fail if they end  up logging out but then have to login again after their shift technically ended for some last minute stuff before going home.

So the only ideal solutions are to either

  1. Let your users select the shift when making their entries.   Perhaps have a supervisor review the entries for accuracy
  2. Have a defined schedule you can use to look up their shift.

This is less of a technical problem and more of a business process problem.  First, determine how their shift is determined in the business process.  Many places just use a clock-in/clock-out process where at the start of their shift the employee completes a clock-in process and at the end they complete a clock-out process.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.