public static function commitSchedule($expoId, $keepAssignmentsFlag, array $assignmentList) { // should probably combine these as single DB transaction if (!$keepAssignmentsFlag) { $oldAssignmentList = ShiftAssignment::selectExpo($expoId); // actively get rid of old list ShiftAssignment::deleteList($oldAssignmentList); } // create new list ShiftAssignment::insertList($assignmentList); return; }
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 }