//echo "jobid = ".$job_id;
     schedule_a_person($schedule_ID, $temp_template_id, $job_id, $emp_id, $emp_shift, $job_facility, $job_station);
 } elseif ($PP_DS == 0 && $PP_NS == 0 && $SP == 0) {
     //echo "SIXTH CASE: ".$emp_first_name . " ".$emp_last_name;;
     //This case happens when their Posted Position are all taken, and their shift prefence is all taken as well.
     //So they will get scheduled onto (day or night) as a sorter. ****IF there is a spot available, else the schedule is full at this point****
     //Give SP as a sorter if there is a spot on the schedule
     //check if sorters PP is full.
     if (!isSortersFull($link, $db, $temp_template_id, $schedule_ID)) {
         $emp_posted_position = "18";
         //18 is sorter
         $job_id = findAvailablePP_withShiftPreference($emp_id, $emp_posted_position, $emp_shift_num_opposite, $temp_template_id, $schedule_ID);
         $job_facility = findFacility($job_id);
         $job_station = findStation($job_id);
         //echo "jobid = ".$job_id;
         schedule_a_person($schedule_ID, $temp_template_id, $job_id, $emp_id, $emp_shift, $job_facility, $job_station);
     } else {
         //echo "The schedule is now typically FULL at this point, or the schedule is looking for the non rotational and or a specific persons posted position to fill the remaining jobs.";
         //Ex: No sorters spots left, but schedule needs to find a PP that hasn't been filled yet. Can mean a lower senority person with a PP.
         //echo "Sorry!  No more sorters allowed on the schedule";
     }
 } else {
     //fail..what just happened?.  The code should never reach this else, but if it does, it shouldn't do anything to how the schedule is created.  I have yet to see this echo appear.
     //I can't think of a scenario where code will get to this spot.
     echo "SEVENTH CASE: OMG!!! ITS HAPPENING!!!! CALL ALAN!!!!!";
     //go to the next person in the list.
     //The schedule probably had very little amount of positions and specific
     //posted position requirement.
 }
 //echo "JobID=".$job_id;
 //echo "<br>";
function addUnfilledPositionsToSchedule($link, $db, $schedule_ID, $template_ID)
{
    //Identify All the Positions that are not filled.
    $sql_unfilled_positions = "\n\tSELECT *\n\tFROM `" . $db . "`.`schedule_template_position_list_auto`\n\tWHERE \n\tid_template = " . $template_ID . "\n\tAND scheduled = 0\n\t";
    $result_unfilled_positions = $link->query($sql_unfilled_positions);
    //If there is any positions that are unfilled.  Add them to the scheudle with an employee id as 0.
    //echo "results from addingpositios....".mysqli_num_rows($result_unfilled_positions);
    if (mysqli_num_rows($result_unfilled_positions) > 0) {
        //Loop through the list of unfilled positions and then add them to the schedule with an employee id = 0.
        while ($row = $result_unfilled_positions->fetch_assoc()) {
            $job_id = $row['ID'];
            $ID_schedule_position = $row['ID_schedule_position'];
            //echo "Unfilled positions job id=".$job_id;
            //echo "Unfilled positions ID_schedule_position=".$ID_schedule_position;
            $emp_id = 0;
            $emp_shift = $row['shift'];
            $job_facility = $row['facility'];
            $job_station = $row['station'];
            schedule_a_person($schedule_ID, $template_ID, $job_id, $emp_id, $emp_shift, $job_facility, $job_station);
        }
    }
    //end if
}