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;
 }
    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 {
        if (0 == strcmp(FIRSTCOMEFIRSTSERVE, $algorithm)) {
            $aas = new FirstComeFirstServed($expo->expoid, $stationList, $workerList, $assignmentList, $keepFlag);
        } else {
<?php

// $Id: ScheduleExpoDeleteAction.php 2297 2012-09-30 15:04:17Z ecgero $ Copyright (c) ConSked, LLC. All Rights Reserved.
include 'util/authenticateOrganizer.php';
require_once 'properties/constants.php';
require_once 'db/Expo.php';
require_once 'db/ShiftAssignment.php';
require_once 'util/log.php';
require_once 'util/session.php';
require_once 'swwat/gizmos/parse.php';
$expo = getExpoCurrent();
if ($expo != NULL) {
    ShiftAssignment::deleteExpo($expo->expoid);
    $_SESSION[PARAM_DELETE] = true;
}
session_write_close();
header('Location: ScheduleExpoPage.php');
include 'ScheduleExpoPage.php';
$firstTimeThrough = !(isset($_REQUEST["add"]) || isset($_REQUEST["remove"]) || isset($_REQUEST["save"]));
$job = getStationCurrent();
// note this only works (StationJob not Station) for CIW where station:job == 1:1
if ($firstTimeThrough) {
    // now go get the workers
    $workerList = Worker::selectStation($job->stationid);
    // now go to the non-workers!
    $workerOutList = Worker::selectNotStation($expo->expoid, $job->stationid);
    $oddWorkerList = array();
    // but unfilled
} else {
    $workerList = getSelectList();
    $oddWorkerList = $job->oddWorkerList($workerList);
    // use REQUEST as may be a GET
    if (isset($_REQUEST["save"])) {
        $assignment = new ShiftAssignment();
        // can re-use several times
        $assignment->expoid = $expo->expoid;
        $assignment->stationid = $job->stationid;
        $assignment->jobid = $job->jobid;
        foreach ($workerList as $worker) {
            // save the new worker list
            // logMessage("save", $worker->lastName);
            $assignment->workerid = $worker->workerid;
            $assignment->insert();
        }
        foreach ($oddWorkerList as $worker) {
            // save the new worker list
            // logMessage("delete", $worker->lastName);
            $assignment->workerid = $worker->workerid;
            $assignment->delete();
 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 makeSchedulingReportStationListHTMLRows(Job $job, array $workerList, $k, $max_name_size, $max_email_size)
{
    $stationDateTime = swwat_format_shift($job->startTime, $job->stopTime);
    list($stationDate, $stationTime, $start) = explode(';', $stationDateTime);
    $dclass = preg_replace('/\\s/', '_', $stationDate);
    echo "<tr class='mainTitle All " . $dclass . "'>\n";
    echo "<td class='fieldValue'><a href='StationViewPage.php?";
    echo PARAM_LIST2_INDEX, "=", $k, "'>";
    echo htmlspecialchars($job->stationTitle);
    echo "</a></td>\n";
    echo "<td class='fieldValue'>" . htmlspecialchars($job->jobTitle) . "</td>\n";
    echo "<td class='fieldValue'>" . htmlspecialchars($job->location) . "</td>\n";
    echo "<td class='fieldValue'>" . htmlspecialchars($stationDate) . "</td>\n";
    echo "<td class='fieldValue'>" . htmlspecialchars($stationTime) . "</td>\n";
    echo "</tr>\n";
    echo "<tr class='All " . $dclass . "'>\n";
    echo "<td colspan='5' style='padding-left: 15px'>\n";
    echo "<table class='research' width='100%'>\n";
    if ($job->assignedSupervisor == 0 && $job->minSupervisor == 0 && $job->maxSupervisor == 0) {
        $color = 'unstaffed';
    } else {
        if ($job->assignedSupervisor < $job->minSupervisor) {
            $color = 'understaffed';
        } else {
            if ($job->assignedSupervisor > $job->maxSupervisor) {
                $color = 'overstaffed';
            } else {
                $color = 'rightstaffed';
            }
        }
    }
    $supervisor = 'Supervisors: ' . $job->assignedSupervisor . ' (' . $job->minSupervisor . ' - ' . $job->maxSupervisor . ')';
    echo "<tr class='accordion Supervisors'>\n";
    echo "<td colspan='5' class='fieldValue " . $color . "'>\n";
    echo "<div style='float:left'>" . htmlspecialchars($supervisor) . "</div>\n";
    echo "<div style='float:right'>" . ucfirst($color) . "&nbsp;&nbsp;<img id='icon' src='" . PARAM_EXPAND_ICON . "'/></div>\n";
    echo "</td>\n";
    echo "</tr>\n";
    $assignedList = ShiftAssignment::selectJob($job->expoid, $job->jobid);
    $warnFlag = $job->assignedSupervisor < $job->minSupervisor;
    // if low, then maybe none - note false if 0 == 0
    if ($job->assignedSupervisor > 0) {
        foreach ($assignedList as $assigned) {
            $index = findWorker($assigned->workerid, $workerList);
            $w = $workerList[$index];
            if (!is_null($w) && $w->isSupervisor()) {
                makeSchedulingReportWorkerListHTMLRows($w, $index, $max_name_size, $max_email_size);
                $warnFlag = FALSE;
            }
        }
    }
    if ($warnFlag) {
        echo "<tr><td class='fieldError' colspan='5'>There are currently no supervisors assigned to this station.</td></tr>\n";
    }
    echo "</table>\n";
    echo "<table class='research' width='100%'>\n";
    if ($job->assignedCrew == 0 && $job->minCrew == 0 && $job->maxCrew == 0) {
        $color = 'unstaffed';
    } else {
        if ($job->assignedCrew < $job->minCrew) {
            $color = 'understaffed';
        } else {
            if ($job->assignedCrew > $job->maxCrew) {
                $color = 'overstaffed';
            } else {
                $color = 'rightstaffed';
            }
        }
    }
    $crew = 'Crew: ' . $job->assignedCrew . ' (' . $job->minCrew . ' - ' . $job->maxCrew . ')';
    echo "<tr class='accordion Crew'>\n";
    echo "<td colspan='5' class='fieldValue " . $color . "'>\n";
    echo "<div style='float:left'>" . htmlspecialchars($crew) . "</div>\n";
    echo "<div style='float:right'>" . ucfirst($color) . "&nbsp;&nbsp;<img id='icon' src='" . PARAM_EXPAND_ICON . "'/></div>\n";
    echo "</td>\n";
    echo "</tr>\n";
    $warnFlag = $job->assignedCrew < $job->minCrew;
    // if low, then maybe none - note false if 0 == 0
    if ($job->assignedCrew > 0) {
        foreach ($assignedList as $assigned) {
            $index = findWorker($assigned->workerid, $workerList);
            $w = $workerList[$index];
            if (!is_null($w) && $w->isCrewMember()) {
                makeSchedulingReportWorkerListHTMLRows($w, $index, $max_name_size, $max_email_size);
                $warnFlag = FALSE;
            }
        }
    }
    if ($warnFlag) {
        echo "<tr><td class='fieldError' colspan='5'>There are currently no crew assigned to this station.</td></tr>\n";
    }
    echo "</table>\n";
    echo "</td>\n</tr>\n";
}
Exemple #7
0
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
}