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; }
} if (!is_null($algorithm)) { $aas = NULL; if (0 == strcmp(ASSIGNANDSUBTRACT, $algorithm)) { $aas = new AssignAndSubtract($expo->expoid, $stationList, $workerList, $assignmentList, $keepFlag); } else { if (0 == strcmp(FIRSTCOMEFIRSTSERVE, $algorithm)) { $aas = new FirstComeFirstServed($expo->expoid, $stationList, $workerList, $assignmentList, $keepFlag); } else { if (0 == strcmp(FIRSTCOMELOCATIONLOCKED, $algorithm)) { $aas = new FirstComeLocationLocked($expo->expoid, $stationList, $workerList, $assignmentList, $keepFlag); } else { if (0 == strcmp(FIRSTCOMESOFTLOCATIONLOCKED, $algorithm)) { $aas = new FirstComeSoftLocationLocked($expo->expoid, $stationList, $workerList, $assignmentList, $keepFlag); } else { $aas = new FirstComeFirstServed($expo->expoid, $stationList, $workerList, $assignmentList, $keepFlag); } } } } $workerList = NULL; $stationList = NULL; $assignmentList = NULL; $d1 = new DateTime(); logMessage("ScheduleExpoAction", "**** {$algorithm} - assignSchedule(" . $expo->expoid . ") ****", $d1->format('H:i'), "\n"); $aas->assignSchedule($expo->expoid); $d2 = new DateTime(); logMessage("ScheduleExpoAction", "**** {$algorithm} - assignSchedule(" . $expo->expoid . ") ****", $d2->format('H:i'), " elapsed: ", $d2->getTimestamp() - $d1->getTimestamp(), "\n"); $aas->logJobListState($algorithm, "jobs after assignment"); $aas->logWorkerListState($algorithm, "workers after assignment"); // $_SESSION[PARAM_SCHEDULE_PUBLISH] = $aas; - this will not work due to the recursion
function reviewActionContent($author, $expo) { if (isset($_POST[PARAM_MAXHOURS]) && !is_null($_POST[PARAM_MAXHOURS])) { $author->updateMaxHours($expo->expoid, swwat_parse_string(html_entity_decode($_POST[PARAM_MAXHOURS]))); } $jobList = Job::selectExpo($expo->expoid); usort($jobList, "JobCompare"); $prefJobidList = array(); $prefDesireList = array(); if (count($_POST) > 0) { $keys = array_keys($_POST); $values = array_values($_POST); for ($k = 0; $k < count($_POST); $k++) { if (strpos($keys[$k], 'title') !== false) { list($prefJobidList[], $prefDesireList[]) = explode(':', $values[$k]); } } } $shiftpreference = new ShiftPreference(); foreach ($jobList as $j) { $shiftpreference->workerid = $author->workerid; $shiftpreference->jobid = $j->jobid; $shiftpreference->stationid = $j->stationid; $shiftpreference->expoid = $j->expoid; $pos = array_search($j->jobid, $prefJobidList); if ($pos === false) { $shiftpreference->desirePercent = NULL; } else { $shiftpreference->desirePercent = $prefDesireList[$pos]; if ($shiftpreference->desirePercent == 0) { $shiftpreference->desirePercent = NULL; } } $shiftpreference->update(); } // note post $shiftpreference save if ($expo->scheduleAssignAsYouGo) { if ($expo->scheduleWorkerReset) { $shifts = ShiftAssignment::selectWorker($expo->expoid, $author->workerid); ShiftAssignment::deleteList($shifts); } FirstComeFirstServed::assignAsYouGo($expo, $author); if ($expo->scheduleVisible) { mailSchedule($expo, $author); header('Location: WorkerSchedulePage.php'); include 'WorkerSchedulePage.php'; return; } } // assignAsYouGo }