예제 #1
0
 public function assignWorker(WorkerSchedule $worker, $expoId)
 {
     if (0 == count($this->jobList)) {
         return;
     }
     // jobs in preference order
     $myJobList = $worker->sortJobPreference($this->jobList, FALSE);
     // first get locations in preference order
     $locations = array();
     foreach ($myJobList as $job) {
         if (!in_array($job->location, $locations)) {
             $locations[] = $job->location;
         }
     }
     // $job
     // next reorder jobs ... order by preference group by location!
     $groupByLocation = array();
     foreach ($locations as $location) {
         foreach ($myJobList as $job) {
             if (0 == strcmp($job->location, $location)) {
                 $groupByLocation[] = $job;
             }
         }
         // $job
     }
     // $location
     $myJobList = NULL;
     $locations = NULL;
     $lockLocation = NULL;
     logMessage("LocationLock", "assigning workerid:" . $worker->workerid . "  count(gbl):" . count($groupByLocation));
     foreach ($groupByLocation as $job) {
         try {
             logMessage("LocationLock - isnull?", "jobid:" . $job->jobid . " in try  ");
             if (!is_null($lockLocation)) {
                 logMessage("LocationLock - strcmp", "lockLocation:" . $lockLocation . " after is_null  " . $job->location);
                 if (0 != strcmp($lockLocation, $job->location)) {
                     logMessage("LocationLock - break", "jobid:" . $job->jobid . "  lockLocation:" . $lockLocation . " before break  ");
                     break;
                     // leave loop
                 }
             }
             logMessage("LocationLock - addwprler", "jobid:" . $job->jobid . "  worker:" . $worker->workerid);
             $job->addWorker($worker, $expoId);
             // exception leaves $lockLocation NULL
             logMessage("LocationLock - set lockLocation", "job->location:" . $job->location);
             $lockLocation = $job->location;
         } catch (ScheduleException $se) {
             logMessage("LocationLock failure", $job->jobid . "  " . $se->getMessage());
             continue;
             // do not force
         }
     }
     // $job
     $groupByLocation = NULL;
 }
 public function assignWorker(WorkerSchedule $worker, $expoId)
 {
     if (0 == count($this->jobList)) {
         return;
     }
     // jobs in preference order
     $myJobList = $worker->sortJobPreference($this->jobList, FALSE);
     // first get locations in preference order
     $locations = array();
     foreach ($myJobList as $job) {
         if (!in_array($job->location, $locations)) {
             $locations[] = $job->location;
         }
     }
     // $job
     // next reorder jobs ... order by preference group by location!
     $groupByLocation = array();
     foreach ($locations as $location) {
         foreach ($myJobList as $job) {
             if (0 == strcmp($job->location, $location)) {
                 $groupByLocation[] = $job;
             }
         }
         // $job
     }
     // $location
     $myJobList = NULL;
     $locations = NULL;
     foreach ($groupByLocation as $job) {
         try {
             $job->addWorker($worker, $expoId);
         } catch (ScheduleException $se) {
             // logMessage("failure", $job->jobid . "  " . $se->getMessage());
             continue;
             // do not force
         }
     }
     // $job
     $groupByLocation = NULL;
 }
예제 #3
0
 public static function assignAsYouGo(Expo $expo, Worker $worker)
 {
     if ($expo->scheduleAssignAsYouGo) {
         $workerList = NULL;
         $stationList = NULL;
         $assignmentList = NULL;
         try {
             // needed for all
             $workerList = WorkerSchedule::selectExpo($expo->expoid);
             $stationList = JobSchedule::selectExpo($expo->expoid);
             $assignmentList = ShiftAssignment::selectExpo($expo->expoid);
         } catch (PDOException $ex) {
             logMessage("FirstComeFirstServed", "assignAsYouGo(" . $expo->titleString() . ", " . $worker->email . ") - " . $ex->getMessage());
             return;
         }
         foreach ($workerList as $w) {
             if ($w->workerid == $worker->workerid) {
                 $worker = $w;
                 break;
             }
         }
         // $w
         $aas = new FirstComeFirstServed($expo->expoid, $stationList, $workerList, $assignmentList, TRUE);
         $stationList = NULL;
         $assignmentList = NULL;
         $workerList = NULL;
         $d1 = new DateTime();
         logMessage("FirstComeFirstServed", "**** assignSchedule(" . $expoId . ") ****", $d1->format('H:i'), "\n");
         $aas->assignWorker($worker, $expoId);
         $d2 = new DateTime();
         logMessage("FirstComeFirstServed", "****assignSchedule(" . $expoId . ") ****", $d2->format('H:i'), "  elapsed: ", $d2->getTimestamp() - $d1->getTimestamp(), "\n");
         // $aas->logJobListState("FirstComeFirstServed", "jobs after assignment");
         // $aas->logWorkerListState("FirstComeFirstServed", "workers after assignment");
         AbstractScheduler::commitSchedule($expo->expoid, TRUE, $aas->getSchedule());
     }
     return;
 }
예제 #4
0
 private function replaceOverMaxWorkerTime($worker, $expoId)
 {
     $changed = FALSE;
     // birds of a feather
     $roleList = WorkerSchedule::filter($this->workerList, $worker->authrole());
     unset($roleList[$worker->workerid]);
     // remove $loopWorker
     $loopWorkerUnhappyJob = $worker->sortJobPreference($this->jobList, TRUE);
     foreach ($loopWorkerUnhappyJob as $loopJob) {
         $preferredSwapOrder = WorkerSchedule::sortTimeLeft($loopJob, $roleList, FALSE);
         foreach ($preferredSwapOrder as $swapWorker) {
             if ($loopJob->swapTime($loopWorker, $swapWorker, $expoId)) {
                 $changed = TRUE;
                 break;
                 // goto $loopJob loop
             }
         }
         // $swapWorker
         if (!$worker->overMaxHours()) {
             break;
         }
         // onto next worker
     }
     // $loopJob
     return $changed;
 }
예제 #5
0
try {
    $algorithm = swwat_parse_enum($algorithm, ScheduleEnum::$ENUM_ARRAY, FALSE);
} catch (ParseSWWATException $ex) {
    header('Location: WorkerLoginPage.php');
    include 'WorkerLoginPage.php';
    return;
}
$keepFlag = isset($_POST[PARAM_SCHEDULE_KEEP]);
$_SESSION[PARAM_SCHEDULE_ALGO] = $_POST[PARAM_SCHEDULE_ALGO];
$_SESSION[PARAM_SCHEDULE_KEEP] = $_POST[PARAM_SCHEDULE_KEEP];
$workerList = NULL;
$stationList = NULL;
$assignmentList = NULL;
try {
    // needed for all
    $workerList = WorkerSchedule::selectExpo($expo->expoid);
    // needed for all excepting PREFERENCEASSIGN
    $stationList = JobSchedule::selectExpo($expo->expoid);
    $assignmentList = ShiftAssignment::selectExpo($expo->expoid);
} catch (PDOException $ex) {
    $_POST[PARAM_PAGE_MESSAGE] = "Please try to schedule at a later time.";
    logMessage("ScheduleExpoAction", "Database screwup" . $ex->getMessage());
    header('Location: ScheduleExpoPage.php');
    include 'ScheduleExpoPage.php';
    return;
}
if (!is_null($algorithm)) {
    $aas = NULL;
    if (0 == strcmp(ASSIGNANDSUBTRACT, $algorithm)) {
        $aas = new AssignAndSubtract($expo->expoid, $stationList, $workerList, $assignmentList, $keepFlag);
    } else {
예제 #6
0
 public function filter($authrole)
 {
     return WorkerSchedule::filter($this->workerList, $authrole);
 }
예제 #7
0
 public function getSchedule()
 {
     return WorkerSchedule::createShiftAssignmentList($this->expoid, $this->workerList);
 }