Exemple #1
0
function expoListWorkerRow(Expo $expo, $position, $isOrganizer, Worker $worker, array $docList)
{
    expoListStartRow($expo, $position, $isOrganizer);
    if ($expo->isPast() || $expo->isRunning()) {
        $hours = ShiftStatus::WorkerHours($worker->workerid, $expo->expoid);
    } else {
        $hours = "-";
    }
    echo "  <td class='fieldValue'>" . htmlspecialchars($hours) . "</td>\n";
    if ($isOrganizer || !$expo->isPast()) {
        echo "  <td class='fieldValue'><a href='WorkerDocumentUploadPage.php?" . PARAM_LIST_INDEX . "=" . $position . "'>Upload</a></td>\n";
    } else {
        echo "  <td class='fieldValue'>Upload</td>\n";
    }
    echo "</tr>\n";
    // insert a non-expo row in the expo table!
    if (($isOrganizer || !$expo->isPast()) && !is_null($docList)) {
        if (count($docList) > 0) {
            makeDocumentListHTMLHeader(FALSE);
            for ($d = 0; $d < count($docList); $d++) {
                $document = $docList[$d];
                if ($document->expoid == $expo->expoid) {
                    makeDocumentListHTMLRow($document, $d, !$expo->isPast(), $isOrganizer, NULL);
                }
            }
            // $d
        }
    }
}
function makeWorkerScheduleListHTMLRows(ShiftAssignmentView $s, $position)
{
    echo '<tr>' . "\n";
    echo '<td class="fieldValueFirst"><a href="StationViewPage.php?';
    echo PARAM_LIST2_INDEX, '=', $position, '">';
    echo htmlspecialchars($s->stationTitle), "</a></td>\n";
    echo '<td class="fieldValue">' . htmlspecialchars($s->location) . '</td>' . "\n";
    $stationDateTime = swwat_format_shift($s->startTime, $s->stopTime);
    list($stationDate, $stationTime, $start) = explode(';', $stationDateTime);
    echo '<td class="fieldValue">' . htmlspecialchars($stationDate) . '</td>' . "\n";
    echo '<td class="fieldValue">' . htmlspecialchars($stationTime) . '</td>' . "\n";
    echo '<td class="fieldValue">' . htmlspecialchars($s->instruction) . '</td>' . "\n";
    $expo = Expo::selectID($s->expoid);
    if ($expo->isPast() || $expo->isRunning()) {
        $hours = ShiftStatus::WorkerStationHours($s->workerid, $s->stationid, $s->expoid);
    } else {
        $hours = "-";
    }
    echo "<td class=\"fieldValue\"><a href=\"ShiftStatusViewPage.php?";
    echo PARAM_LIST_INDEX, '=S:', $s->stationid, '">';
    echo htmlspecialchars($hours);
    echo "</a></td>\n";
    if ($s->URL != NULL) {
        echo '<td><iframe src="https://www.facebook.com/plugins/like.php?href=' . $s->URL . '&amp;send=false&amp;layout=button_count&amp;width=80&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe></td>' . "\n";
    }
    echo '</tr>' . "\n";
}
function createShiftCheckInHTMLList($expoid, $stationid)
{
    echo "<div id=\"workerlist_table\">\n";
    echo "<form method=\"POST\" name=\"ShiftCheckIn_form\" action=\"ShiftCheckInAction.php?" . PARAM_LIST_INDEX . "=" . $stationid . "\">\n";
    echo "<table>\n";
    $shiftAssignmentList = ShiftAssignmentView::selectStation($expoid, $stationid);
    $c = count($shiftAssignmentList);
    $workerList = array();
    for ($k = 0; $k < $c; $k++) {
        $workerList[$k] = Worker::selectID($shiftAssignmentList[$k]->workerid);
    }
    usort($workerList, "WorkerCompare");
    echo "<tr><td class=\"rowTitle\" colspan=\"4\">Supervisors</td></tr>\n";
    $supervisors = 0;
    for ($k = 0; $k < $c; $k++) {
        if ($workerList[$k]->isSupervisor() && !$workerList[$k]->isDisabled) {
            $ss = ShiftStatus::mostRecentStatus($workerList[$k]->workerid, $stationid, $expoid);
            if (count($ss) > 0) {
                $statusType = $ss->statusType;
            } else {
                $statusType = NULL;
            }
            makeShiftCheckInListHTMLRows($workerList[$k], $statusType);
            $supervisors++;
        }
    }
    if ($supervisors == 0) {
        echo "<tr><td class=\"fieldError\" colspan=\"4\">There are currently no Supervisors assigned to this station.</td></tr>\n";
    }
    echo "<tr><td class=\"rowTitle\" colspan=\"4\">Crew</td></tr>\n";
    $crew = 0;
    for ($k = 0; $k < $c; $k++) {
        if ($workerList[$k]->isCrewMember() && !$workerList[$k]->isDisabled) {
            $ss = ShiftStatus::mostRecentStatus($workerList[$k]->workerid, $stationid, $expoid);
            if (count($ss) > 0) {
                $statusType = $ss->statusType;
            } else {
                $statusType = NULL;
            }
            makeShiftCheckInListHTMLRows($workerList[$k], $statusType);
            $crew++;
        }
    }
    // $k
    if ($crew == 0) {
        echo "<tr><td class=\"fieldError\" colspan=\"4\">There are currently no Crew assigned to this station.</td></tr>\n";
    }
    echo "</table></form></div><!-- workerlist_table -->\n";
}
function makeCheckInWorkerDashboardListHTMLRows2(Worker $w, $expoid)
{
    echo "<tr>\n";
    echo "<td class=\"fieldValueFirst\">" . htmlspecialchars($w->nameString()) . "</td>\n";
    echo "<td class=\"fieldValue\">" . htmlspecialchars($w->email) . "</td>\n";
    echo "<td class=\"fieldValue\">" . swwat_format_phone($w->phone) . "</td>\n";
    $ss = ShiftStatus::mostRecentStatusWorker($w->workerid, $expoid);
    echo "<td class=\"fieldValue\">";
    if (!is_null($ss)) {
        $s = StationJob::selectID($ss->stationid);
        echo $s->location . " (" . $s->title . ")";
    } else {
        echo "-";
    }
    echo "</td>\n";
    echo "<td class=\"fieldValue\">";
    if (!is_null($ss)) {
        if ($ss->statusType == "CHECK_IN") {
            echo "<div style=\"color: red\">Checked In</div>";
        } else {
            if ($ss->statusType == "CHECK_OUT") {
                echo "<div style=\"color: green\">Checked Out</div>";
            }
        }
    } else {
        echo "Never checked in";
    }
    echo "</td>\n";
    echo "<td class=\"fieldValue\">";
    if (!is_null($ss)) {
        $hours = ShiftStatus::WorkerHours($w->workerid, $expoid);
        if (is_int($hours)) {
            echo $hours;
        } else {
            echo sprintf('%.2f', $hours);
        }
    } else {
        echo "-";
    }
    echo "</td>\n";
    echo "</tr>\n";
}
    $expoid = $expo->expoid;
}
$stationid = NULL;
if (isset($_REQUEST[PARAM_LIST_INDEX])) {
    $stationid = swwat_parse_number(html_entity_decode($_REQUEST[PARAM_LIST_INDEX]), FALSE);
}
$workerid = NULL;
$statusType = NULL;
if (isset($_POST) && $_POST != NULL) {
    $keys = array_keys($_POST);
    $workerid = $keys[0];
    $values = array_values($_POST);
    if (!strcmp($values[0], 'Check In')) {
        $statusType = 'CHECK_IN';
    } else {
        if (!strcmp($values[0], 'Check Out')) {
            $statusType = 'CHECK_OUT';
        }
    }
}
if ($workerid != NULL && $stationid != NULL && $expoid != NULL && $statusType != NULL) {
    $shiftstatus = new ShiftStatus();
    $shiftstatus->workerid = $workerid;
    $shiftstatus->stationid = $stationid;
    $shiftstatus->expoid = $expoid;
    $shiftstatus->statusType = $statusType;
    $shiftstatus->statusTime = NULL;
    $shiftstatus->insert();
}
header('Location: ShiftCheckInPage.php?' . PARAM_LIST_INDEX . '=' . $stationid);
include 'ShiftCheckInPage.php';
function createShiftStatusDataHTMLList($expoid, $stationid, $workerid, $type, $isDisabledFlag = TRUE)
{
    echo "<tr><td class=\"rowTitle\">Check In</td><td class=\"rowTitle\">Check Out</td></tr>\n";
    $shiftstatus = ShiftStatus::selectStatus($workerid, $stationid, $expoid);
    $c = count($shiftstatus);
    $n = 0;
    if ($c > 0) {
        for ($k = 0; $k < $c; $k++) {
            if (isset($shiftstatus[$k + 1])) {
                if ($shiftstatus[$k]->statusType == "CHECK_IN" && $shiftstatus[$k + 1]->statusType == "CHECK_OUT") {
                    $shiftstatus_matrix[$n][0] = $shiftstatus[$k];
                    $shiftstatus_matrix[$n][1] = $shiftstatus[$k + 1];
                    $k++;
                    $n++;
                } else {
                    if ($shiftstatus[$k]->statusType == "CHECK_IN" && $shiftstatus[$k + 1]->statusType == "CHECK_IN") {
                        $shiftstatus_matrix[$n][0] = $shiftstatus[$k];
                        $shiftstatus_matrix[$n][1] = NULL;
                        $n++;
                    } else {
                        if ($shiftstatus[$k]->statusType == "CHECK_OUT" && $shiftstatus[$k + 1]->statusType == "CHECK_OUT") {
                            $shiftstatus_matrix[$n][0] = NULL;
                            $shiftstatus_matrix[$n][1] = $shiftstatus[$k];
                            $n++;
                        }
                    }
                }
            } else {
                if ($shiftstatus[$k]->statusType == "CHECK_IN") {
                    $shiftstatus_matrix[$n][0] = $shiftstatus[$k];
                    $shiftstatus_matrix[$n][1] = NULL;
                    $n++;
                } else {
                    if ($shiftstatus[$k]->statusType == "CHECK_OUT") {
                        $shiftstatus_matrix[$n][0] = NULL;
                        $shiftstatus_matrix[$n][1] = $shiftstatus[$k];
                        $n++;
                    }
                }
            }
        }
    }
    if (isset($shiftstatus_matrix)) {
        $c = count($shiftstatus_matrix);
        if ($c > 0) {
            for ($k = 0; $k < $c; $k++) {
                for ($l = 0; $l < 2; $l++) {
                    makeShiftStatusDataHTMLRows($shiftstatus_matrix[$k][$l], $k, $l, "shiftstatuseditpage_shiftstatusdata", $isDisabledFlag);
                }
            }
        }
        echo "<tr>";
        echo "<td><input class=\"fieldValue\" type=\"Submit\" value=\"" . $type . "\"/>";
        if (!strcmp($type, 'Save')) {
            $_POST[PARAM_SAVE] = htmlspecialchars($type);
            echo "<input type=\"hidden\" name=\"" . PARAM_SAVE . "\" value=\"" . $_POST[PARAM_SAVE] . "\"/>";
        }
        echo "</td>";
        echo "</tr>\n";
    } else {
        echo "<tr><td colspan=\"2\" class=\"fieldError\">There are no check-ins or check-outs</td></tr>\n";
        echo "<tr>";
        echo "<td><input class=\"fieldValue\" type=\"Submit\" value=\"" . $type . "\" disabled=\"disabled\"/></td>";
        echo "</tr>\n";
    }
}
function makeCheckInStationDashboardStationListHTMLRows(Job $job, $k, $expoid, $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";
    $assignedWorkerList = ShiftAssignmentView::selectStation($expoid, $job->stationid);
    $c = count($assignedWorkerList);
    $nsupervisor = 0;
    $ncrew = 0;
    if ($c > 0) {
        for ($k = 0; $k < $c; $k++) {
            $w = Worker::selectID($assignedWorkerList[$k]->workerid);
            if ($w->isSupervisor()) {
                $nsupervisor++;
            }
            if ($w->isCrewMember()) {
                $ncrew++;
            }
        }
    }
    $supervisor = 'Supervisors: ' . $nsupervisor . ' (' . $job->minSupervisor . ' - ' . $job->maxSupervisor . ')';
    echo "<tr class=\"accordion Supervisors sectionTitle\">\n";
    echo "<td colspan=\"5\" class=\"fieldValue\">\n";
    echo "<div style=\"float:left\">" . htmlspecialchars($supervisor) . "</div>\n";
    echo "<div style=\"float:right\"><img id=\"icon\" src=\"" . PARAM_EXPAND_ICON . "\"/></div>\n";
    echo "</td>\n";
    echo "<tr>\n";
    if ($nsupervisor > 0) {
        for ($k = 0; $k < $c; $k++) {
            $w = Worker::selectID($assignedWorkerList[$k]->workerid);
            if ($w->isSupervisor()) {
                $ss = ShiftStatus::mostRecentStatus($assignedWorkerList[$k]->workerid, $job->stationid, $expoid);
                makeCheckInStationDashboardWorkerListHTMLRows($w, $ss, $max_name_size, $max_email_size);
            }
        }
    } else {
        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";
    $crew = 'Crew: ' . $ncrew . ' (' . $job->minCrew . ' - ' . $job->maxCrew . ')';
    echo "<tr class=\"accordion Crew sectionTitle\">\n";
    echo "<td colspan=\"5\" class=\"fieldValue\">\n";
    echo "<div style=\"float:left\">" . $crew . "</div>\n";
    echo "<div style=\"float:right\"><img id=\"icon\" src=\"" . PARAM_EXPAND_ICON . "\"/></div>\n";
    echo "</td>\n";
    echo "<tr>\n";
    if ($ncrew > 0) {
        for ($k = 0; $k < $c; $k++) {
            $w = Worker::selectID($assignedWorkerList[$k]->workerid);
            if ($w->isCrewMember()) {
                $ss = ShiftStatus::mostRecentStatus($assignedWorkerList[$k]->workerid, $job->stationid, $expoid);
                makeCheckInStationDashboardWorkerListHTMLRows($w, $ss, $max_name_size, $max_email_size);
            }
        }
    } else {
        echo "<tr><td class=\"fieldError\" colspan=\"5\">There are currently no crew assigned to this station.</td></tr>\n";
    }
    echo "</table>";
    echo "</td>\n</tr>\n";
}
                        $shiftstatus_new[$k]->statusTime = swwat_parse_date(html_entity_decode($_POST[PARAM_STATUSDATE][$k - 1] . " " . $_POST[PARAM_STATUSHOUR][$k]), true);
                    }
                }
            } else {
                $shiftstatus_new[$k]->shiftstatusid = NULL;
                $shiftstatus_new[$k]->workerid = NULL;
                $shiftstatus_new[$k]->stationid = NULL;
                $shiftstatus_new[$k]->expoid = NULL;
                $shiftstatus_new[$k]->statusType = NULL;
                $shiftstatus_new[$k]->statusTime = NULL;
            }
        }
    }
    for ($k = 0; $k < $c; $k++) {
        if (!is_null($shiftstatus_new[$k]->shiftstatusid)) {
            $shiftstatus_old = ShiftStatus::selectID($shiftstatus_new[$k]->shiftstatusid);
            if ($shiftstatus_new[$k]->workerid != $shiftstatus_old->workerid || $shiftstatus_new[$k]->stationid != $shiftstatus_old->stationid || $shiftstatus_new[$k]->expoid != $shiftstatus_old->expoid || $shiftstatus_new[$k]->statusType != $shiftstatus_old->statusType || swwat_format_isodatetime($shiftstatus_new[$k]->statusTime) != swwat_format_isodatetime($shiftstatus_old->statusTime)) {
                $shiftstatus_new[$k]->update();
            }
        } else {
            if (!is_null($shiftstatus_new[$k]->statusType)) {
                $shiftstatus_new[$k]->insert();
            }
        }
    }
    header("Location: ShiftStatusViewPage.php?" . PARAM_LIST_INDEX . "=" . $type . ":" . $index);
    include "ShiftStatusViewPage.php";
    return;
}
header('Location: ShiftCheckInPage.php');
include 'ShiftCheckInPage.php';