コード例 #1
0
ファイル: NYCCPreferences.php プロジェクト: ConSked/scheduler
function wizardActionContent($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])));
    }
    $dateSpanList = $_SESSION[PARAM_DATETIME];
    $locationList = $_SESSION[PARAM_LOCATION];
    // Location Preference
    $k = 0;
    while (isset($_POST[PARAM_LOCATION . $k])) {
        $desire = parsePreferenceNumber(PARAM_LOCATION, $k);
        $locationDesires[$locationList[$k]] = 0 == $desire ? NULL : $desire;
        $locationTest[$k] = parsePreferenceNumber(PARAM_LOCATION, $k);
        $k += 1;
    }
    $jp = new JobPreference();
    $jp->workerid = $author->workerid;
    $jp->expoid = $expo->expoid;
    $count_jobs = $jp->number_jobs;
    for ($k = 0; $k < $count_jobs; $k++) {
        $field = 'job' . ($k + 1);
        if (isset($locationTest[$k])) {
            $jp->{$field} = $locationTest[$k];
        } else {
            $jp->{$field} = 0;
        }
    }
    $test = JobPreference::selectID($author->workerid, $expo->expoid);
    if (!is_null($test)) {
        $jp->update();
    } else {
        $jp->insert();
    }
    // Time Preference
    $k = 0;
    while (isset($_POST[PARAM_DATETIME . $k])) {
        $desire = parsePreferenceNumber(PARAM_DATETIME, $k);
        $dateSpanDesires[$dateSpanList[$k]] = 0 == $desire ? NULL : $desire;
        $dateSpanTest[$k] = parsePreferenceNumber(PARAM_DATETIME, $k);
        $k += 1;
    }
    $tp = new TimePreference();
    $tp->workerid = $author->workerid;
    $tp->expoid = $expo->expoid;
    $count_shifts = $tp->number_shifts;
    for ($k = 0; $k < $count_shifts; $k++) {
        $field = 'shift' . ($k + 1);
        if (isset($dateSpanTest[$k])) {
            $tp->{$field} = $dateSpanTest[$k];
        } else {
            $tp->{$field} = 0;
        }
    }
    $test = TimePreference::selectID($author->workerid, $expo->expoid);
    if (!is_null($test)) {
        $tp->update();
    } else {
        $tp->insert();
    }
    //exit;
    $gp = GrossPreference::updateHelper_Location_DateSpan($expo->expoid, $author->workerid, $locationDesires, $dateSpanDesires);
}
コード例 #2
0
ファイル: NewPreferences.php プロジェクト: ConSked/scheduler
function locationPreferences($step, $author, $expo)
{
    $locationList = GrossPreference::selectLocation($expo->expoid);
    if (count($locationList) > 1) {
        echo "<div class=\"center\"><b>" . $step . "</b>. Select your location preferences.</div>\n";
        echo "<div class=\"center\">(0 = absolutely not, 10 = absolutely yes)</div>\n";
        echo "<br>\n";
        $jp_old = JobPreference::selectID($author->workerid, $expo->expoid);
        $default = array();
        for ($i = 0; $i < count($locationList); $i++) {
            echo "<input type=\"hidden\" name=\"" . PARAM_LOCATION . $i . "\" value=\"" . $locationList[$i] . "\">\n";
            if (count($jp_old) != 0) {
                $arg = 'job' . ($i + 1);
                $default[$i] = $jp_old->{$arg} / 10;
            } else {
                $default[$i] = 5;
            }
        }
        echo "<table class=\"prefs\">\n";
        swwat_spaces(2);
        echo "<tbody>\n";
        for ($i = 0; $i < count($locationList); $i++) {
            swwat_spaces(4);
            echo "<tr>\n";
            swwat_spaces(6);
            echo "<th class=\"blue\">" . $locationList[$i] . "</th>\n";
            swwat_spaces(6);
            echo "<td>\n";
            swwat_spaces(8);
            echo "<select name=\"" . PARAM_LPREFS . $i . "\">\n";
            for ($j = 0; $j < 11; $j++) {
                $checked = $default[$i] == $j ? ' selected' : '';
                swwat_spaces(10);
                echo "<option value=\"" . $j . "\"" . $checked . ">" . $j . "</option>\n";
            }
            swwat_spaces(8);
            echo "</select>\n";
            swwat_spaces(6);
            echo "</td>\n";
            swwat_spaces(4);
            echo "</tr>\n";
        }
        swwat_spaces(2);
        echo "</tbody>\n";
        echo "</table>\n";
        echo "<br><br>\n";
        $step++;
    } else {
        if (count($locationList) == 1) {
            $i = 0;
            echo "<input type=\"hidden\" name=\"" . PARAM_LOCATION . $i . "\" value=\"" . $locationList[$i] . "\">\n";
            echo "<input type=\"hidden\" name=\"" . PARAM_LPREFS . $i . "\" value=\"10\">\n";
        }
    }
    return $step;
}