PHP - Staff 4 On 4 Off Rota
Hi Everyone!
Really stuck with this one.. Im midway through creating a "rota" for staff at work.. and it shows whos working that day, and who isnt. For a "base" rota (unedited with no holidays/sickness etc) i need to populate the calendar i made with staff names on a 4 on 4 off basis. I was hoping php could loop round and pop the names in for me. Here's whats i have so far: Code: [Select] $shifts1 = array("Day", "Night"); $shifts2 = array("Night", "Day"); $staffPair1 = array("Adam", "Ashley"); $staffPair2 = array("Dave", "Terry"); $thisMonth = date("F"); $daysThisMonth = date("t"); for ($i = 1; $i <= $daysThisMonth; $i++) { $calGen .= "<div id=\"calendarDays\"><div>$i</div><div>$STAFF_ON_SHIFT</div></div>"; } Pair1 work together, one is on DAYS, one is on NIGHTS for 4 days/nights then both are off for 4 days, Pair2 then steps in and works the same for 4 days/nights, then off for 4 days etc etc. I need to echo $STAFF_ON_SHIFT which is who is on what shift on what date. So for example a month would be like this: Adam (D) Ashley (N) Terry (OFF) Dave (OFF) above x4 days - then Adam (OFF) Ashley (OFF) Terry (D) Dave (N) above x4 days - then Adam (N) Ashley (D) Terry (OFF) Dave (OFF) above x4 days - then Adam (OFF) Ashley (OFF) Terry (N) Dave (D) First pair switches shifts round every other 4 so Adam is on nights and Ashley on Days then off for 4 days, then Adam is on days and Ashley on nights, same for pair2 (shift switch around).. I know thats a lot to ask, but breaking it down looks "simple" lol. Assign a shift to pair1 for 4 days Pair 2 off for 4 days Assign a shift to pair2 for 4 days Pair 1 off for 4 days Repeat above but swap shifts round for each pair (nights, days) Any help? MANY MANY THANKS!!!!!! Similar TutorialsHello! Hello: I am building a Staff list, that I want to use to allow the owner of a company to upload a photo, name, phone, and email of each person on his staff. I am using this approach from a tutorial I found online: Database: Code: [Select] CREATE TABLE employees (id int(5), name VARCHAR(30), email VARCHAR(30), phone VARCHAR(30), photo VARCHAR(30)) Form: Code: [Select] <form enctype="multipart/form-data" action="Add.php" method="POST"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name = "email"><br> Phone: <input type="text" name = "phone"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form> Add.php Code: [Select] <?php include('include/myConn.php'); ?> ... <?php $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ; if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { echo "Sorry, there was a problem uploading your file."; } ?> Display.php Code: [Select] <?php include('include/myConn.php'); ?> ... <?php $data = mysql_query("SELECT * FROM employees") or die(mysql_error()); while($info = mysql_fetch_array($data)); { echo "<img src=images/".$info['photo'] ."> <br>"; echo "<b>Name:</b> ".$info['name'] . "<br> "; echo "<b>Email:</b> ".$info['email'] . " <br>"; echo "<b>Phone:</b> ".$info['phone'] . " <hr>"; } ?> I am not getting any errors and the photo is uploaded to the "images" folder, but none of the data displays ... I do not see why .. Any ideas? Also, if any one has done something like this before and has a better approach to doing this, I am all ears. I do want to allow the owner to edit and delete the profiles as well. Thanks.
I have 3 staff members that need to pick vacation in a certain order.
~~~~~~First round of picking~~~~~~
Staff 1 takes 2 Weeks
~~~~~~Second round of picking~~~~~~
Staff 1 takes 1 Weeks
~~~~~~Third round of picking~~~~~~
Staff 1 Skipped
~~~~~~~~~~~~ --calendar.php-- $year=2020; $sql = "SELECT * FROM vac_admin WHERE pick_year='$year'; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { $row_admin = mysqli_fetch_assoc($result); } $current_pick_staff = $row_admin['current_pick_staff']; $sql = "SELECT * FROM vac_pick_order WHERE pick_year='$year' && pick_order = '$current_pick_staff'"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_assoc($result); if($row['vac_c_counter'] < 0){ $emp_num = $row['emp_num']; }ELSE{ ?????????????????? goto next staff with weeks > 0 ?????Somthing like if ($current_pick_staff == 3){ $current_pick_staff = 1; }ELSE{ $current_pick_staff++; } ?????????????????? } ~<FORM>~~~~~~~~~~~~~~~~~~~~~ Staff with $emp_num can now pick ~~~~~~ $_POST -> $date = XXXX-XX-XX; $num_weeks = X; $emp_num; ~</FORM>~~~~~~~~~~~~~~~~~~~~~ --process.php-- $year = 2020; $date = $_POST['date']; $num_weeks = $_POST['num_weeks']; $emp_num = $_POST['emp_num']; $sql = "INSERT INTO vac_picks (pick_year,emp_num,date) VALUES ($year,$emp_num,$date)"; $sql = "UPDATE vac_pick_order SET vac_c_counter=vac_c_counter - $num_weeks WHERE emp_num='$emp_num'; $sql = "UPDATE vac_admin SET pick_order=pick_order +1 WHERE pick_year='$year' ; Then back to calendar.php until all weeks gone.
|