Exemplo n.º 1
0
 public static function selectID($stationId)
 {
     $stationJob = new StationJob();
     // note that StationJob has a unique stationid for each jobid (which is where the UI needs to catch up)
     $station = Station::selectID($stationId);
     $stationJob->setStation($station);
     $jobs = Job::selectStation($station->expoid, $station->stationid);
     $stationJob->setJob($jobs[0]);
     return $stationJob;
 }
Exemplo n.º 2
0
function setShiftPreferences($workerId, $expoId, $locations)
{
    $timePrefs = NewTimePreference::selectID($workerId, $expoId);
    $locationPrefs = JobPreference::selectID($workerId, $expoId);
    $jobs = Job::selectExpo($expoId);
    foreach ($jobs as $job) {
        $sp = new ShiftPreference();
        $sp->workerid = $workerId;
        $sp->jobid = $job->jobid;
        $sp->stationid = $job->stationid;
        $sp->expoid = $expoId;
        $station = Station::selectID($job->stationid);
        //time preference
        $timeZone = swwat_format_timezone($station->startTime);
        $startTime = swwat_format_epoch($station->startTime);
        $stopTime = swwat_format_epoch($station->stopTime);
        $zeroFlag = FALSE;
        $tdesire = 0;
        $count = 0;
        foreach ($timePrefs as $timePref) {
            $epoch = date_format(new DateTime($timePref->day, new DateTimeZone($timeZone)), 'U');
            for ($i = 0; $i < 24; $i++) {
                $startHour = $epoch;
                $endHour = strtotime("+1 hours", $epoch);
                if ($startHour >= $startTime && $endHour <= $stopTime) {
                    $field = 'hour' . ($i + 1);
                    $value = $timePref->{$field};
                    if ($value == 0) {
                        $zeroFlag = TRUE;
                    }
                    $tdesire += $value;
                    $count++;
                }
                $epoch = strtotime("+1 hours", $epoch);
            }
        }
        if ($zeroFlag || $count == 0) {
            $tdesire = 0;
        } else {
            $tdesire = $tdesire / $count;
        }
        // location preference
        $index = array_search($station->location, $locations);
        $field = 'job' . ($index + 1);
        $ldesire = $locationPrefs->{$field};
        $desire = 0;
        if ($tdesire != 0 && $ldesire != 0) {
            $desire = ($tdesire + $ldesire) / 2;
        }
        $sp->desirePercent = $desire;
        $sp->update();
    }
}
Exemplo n.º 3
0
function reviewPageContent()
{
    echo "<form method=\"POST\" name=\"preferencereview_form\" action=\"PreferenceReviewAction.php\">\n";
    echo "\n";
    echo "<div id=\"content\" style=\"clear:both\">\n";
    echo "Below are all the sessions you&apos;ve shown interest in. You&apos;re welcome to trim down the list. You MUST set a maximum number of hours at the bottom of the page (it is defaulted to 20), and we&apos;ll schedule you for where we need you the most!\n";
    echo "<p />\n";
    echo "Note: Our system won&apos;t allow us to double book you, so if you have two sessions at the same time, you&apos;ll only be scheduled for one.  Also know that if you requested more shifts than the maximum amount of hours you can commit, you will not be booked to all of the events you selected.\n";
    echo "<p />\n";
    echo "Click next at the bottom of the page once you are comfortable with your selections.\n";
    echo "<p />\n";
    $jobIncludeList = array();
    $jobIncludeList[] = "Volunteer";
    $jobList = Job::selectExpo($expo->expoid);
    usort($jobList, "JobCompare");
    $date = array();
    $max_job_size = 0;
    $max_time_size = 0;
    $max_location_size = 0;
    $max_title_size = 0;
    foreach ($jobList as $j) {
        $stationDateTime = swwat_format_shift($j->startTime, $j->stopTime);
        list($stationDate, $stationTime, $start) = explode(';', $stationDateTime);
        $date[] = $stationDate;
        $job = $j->jobTitle;
        if (strlen($job) > $max_job_size) {
            $max_job_size = strlen($job);
        }
        if (strlen($stationTime) > $max_time_size) {
            $max_time_size = strlen($stationTime);
        }
        $location = $j->location;
        if (strlen($location) > $max_location_size) {
            $max_location_size = strlen($location);
        }
        $title = $j->stationTitle;
        if (strlen($title) > $max_title_size) {
            $max_title_size = strlen($title);
        }
    }
    $date = array_values(array_unique($date));
    $max_radio_size = "10%";
    $max_percent_size = "5%";
    //$max_job_size = 12*($max_job_size);
    $max_time_size = "12%";
    $max_hours_size = "5%";
    $max_location_size = "15%";
    $max_title_size = "53%";
    $table_size = "95%";
    $numColumns = 6;
    echo "<table width=\"" . $table_size . "\" align=\"center\" class=\"research\">\n";
    echo "<tr class=\"accordion\">\n";
    echo "<th width=\"120\" class=\"rowTitle\"></th>";
    echo "<th width=\"" . $max_percent_size . "\" class=\"rowTitle\">Percent Filled</th>";
    //echo "<th width=\"".$max_job_size."\" class=\"rowTitle\">Job</th>";
    echo "<th width=\"" . $max_time_size . "\" class=\"rowTitle\">Time</th>";
    echo "<th width=\"" . $max_hours_size . "\" class=\"rowTitle\">Hours</th>";
    echo "<th width=\"" . $max_location_size . "\" class=\"rowTitle\">Location</th>";
    echo "<th width=\"" . $max_title_size . "\" class=\"rowTitle\">Title</th>";
    echo "</tr>\n";
    // kludge to remove empty dates
    for ($k = 0; $k < count($date); $k++) {
        $count[$k] = 0;
        for ($l = 0; $l < count($jobList); $l++) {
            $sp = ShiftPreference::selectID($author->workerid, $jobList[$l]->jobid);
            if (!is_null($sp)) {
                $desire = $sp->desirePercent;
            } else {
                $desire = 0;
            }
            $stationDateTime = swwat_format_shift($jobList[$l]->startTime, $jobList[$l]->stopTime);
            list($stationDate, $stationTime, $start) = explode(';', $stationDateTime);
            if (!strcmp($date[$k], $stationDate) && in_array($jobList[$l]->jobTitle, $jobIncludeList) && $desire != 0) {
                $count[$k]++;
            }
        }
    }
    for ($k = 0; $k < count($date); $k++) {
        $dow = date('l', strtotime($date[$k]));
        if ($count[$k] != 0) {
            echo "<tr class=\"accordion\">\n";
            echo "<th colspan=\"" . $numColumns . "\" class=\"rowTitle\">";
            echo "<div style=\"float:left\">" . htmlspecialchars($date[$k] . ", " . $dow) . "</div>\n";
            echo "<div style=\"float:right\"><img id=\"icon1\" src=\"" . PARAM_COLLAPSE_ICON . "\"/></div>\n";
            echo "</th>\n";
            echo "</tr>\n";
        }
        for ($l = 0; $l < count($jobList); $l++) {
            //$optionArray = array(array($jobList[$l]->jobid.":0", "No"), array($jobList[$l]->jobid.":1", "Yes"));
            $param_station = PARAM_TITLE . $l;
            if (!isset($_POST[$param_station])) {
                $_POST[$param_station] = NULL;
            }
            $sp = ShiftPreference::selectID($author->workerid, $jobList[$l]->jobid);
            if (!is_null($sp)) {
                $desire = $sp->desirePercent;
            } else {
                $desire = 0;
            }
            $stationDateTime = swwat_format_shift($jobList[$l]->startTime, $jobList[$l]->stopTime);
            list($stationDate, $stationTime, $start) = explode(';', $stationDateTime);
            $start = $jobList[$l]->startTime;
            $stop = $jobList[$l]->stopTime;
            $diff = $start->diff($stop);
            $hours = $diff->d * 24 + $diff->h + $diff->i / 60 + $diff->s / 360;
            if ($jobList[$l]->minCrew != 0) {
                $percent = intval(100 * ($jobList[$l]->assignedCrew / $jobList[$l]->minCrew)) . "%";
            } else {
                $percent = "-";
            }
            $s = Station::selectID($jobList[$l]->stationid);
            $dclass = preg_replace('/\\s/', '_', $date[$k]);
            if (!strcmp($date[$k], $stationDate) && in_array($jobList[$l]->jobTitle, $jobIncludeList) && $desire != 0) {
                echo "<tr class=\"" . $dclass . "\">\n";
                echo "<td class=\"fieldValue\">";
                //swwat_createRadioSelect($param_station, $optionArray, "radio", $jobList[$l]->jobid.":".$desire);
                echo "<input id=\"" . $param_station . "n\" name=\"" . $param_station . "\" type=\"radio\" value=\"" . $jobList[$l]->jobid . ":0" . "\" ";
                if ($desire == 0) {
                    echo "checked=\"checked\" ";
                }
                echo "/>";
                echo "<label for=\"" . $param_station . "n\">No&nbsp;&nbsp;</label>\n";
                echo "<input id=\"" . $param_station . "y\" name=\"" . $param_station . "\" type=\"radio\" value=\"" . $jobList[$l]->jobid . ":100" . "\" ";
                if ($desire != 0) {
                    echo "checked=\"checked\" ";
                }
                echo "/>";
                echo "<label for=\"" . $param_station . "y\">Yes</label>\n";
                echo "</td>\n";
                echo "<td class=\"fieldValue\">" . htmlspecialchars($percent) . "</td>\n";
                //echo "<td class=\"fieldValue\">".htmlspecialchars($jobList[$l]->jobTitle)."</td>\n";
                echo "<td class=\"fieldValue\">" . htmlspecialchars($stationTime) . "</td>\n";
                echo "<td class=\"fieldValue\">" . htmlspecialchars($hours) . "</td>\n";
                echo "<td class=\"fieldValue\">" . htmlspecialchars($jobList[$l]->location) . "</td>\n";
                echo "<td class=\"fieldValue\">";
                echo "<div style=\"float:left\">" . htmlspecialchars($jobList[$l]->stationTitle) . "</div>\n";
                echo "<div style=\"float:right\"><img id=\"icon2\" src=\"" . PARAM_EXPAND_ICON . "\"/></div>\n";
                echo "</td>\n";
                echo "</tr>\n";
                echo "<tr class=\"description " . $param_station . " " . $dclass . "\">\n";
                echo "<td class=\"fieldValue\" style=\"text-align: center\" colspan=\"" . $numColumns . "\">";
                echo htmlspecialchars($s->description) . "<br><a href=\"" . htmlspecialchars($s->URL) . "\">" . htmlspecialchars($s->URL) . "</a></td>\n";
                echo "</td>\n";
                echo "</tr>\n";
            }
        }
    }
    echo "</table>\n";
    echo "<p />";
    $_POST[PARAM_MAXHOURS] = $author->selectMaxHours($expo->expoid);
    echo "The MAXIMUM number of hours I am available to work is ";
    swwat_createInputValidateInteger(PARAM_MAXHOURS, "content", 2);
    echo "<p />";
    echo "</div><!-- content -->\n";
}