Ejemplo n.º 1
0
                $shift = select_dbShifts($shiftid);
            } else {
                if (process_add_slot($_POST, $shift, $venue)) {
                    $shift = select_dbShifts($shiftid);
                } else {
                    if (process_clear_shift($_POST, $shift, $venue)) {
                        $shift = select_dbShifts($shiftid);
                    } else {
                        if (process_ignore_slot($_POST, $shift, $venue)) {
                            $shift = select_dbShifts($shiftid);
                        }
                    }
                }
            }
            $persons = $shift->get_persons();
            echo "<br><br><table align=\"center\" border=\"1px\"><tr><td align=\"center\" colspan=\"2\"><b>" . get_shift_name_from_id($shiftid) . "</b></td></tr>";
            if ($_SESSION['access_level'] >= 2) {
                echo "<tr><td valign=\"top\"><br>&nbsp;" . do_slot_num($persons, $shift->num_vacancies()) . "</td><td>";
                echo "<form method=\"POST\" style=\"margin-bottom:0;\">\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"_submit_add_slot\" value=\"1\"><br>\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"Add Slot\" style=\"width: 150px\"\n\t\t\t\t\t\t\t\t\t\t\tname=\"submit\" >\n\t\t\t\t\t\t\t\t\t\t\t</form>";
                echo "<form method=\"POST\" style=\"margin-bottom:0;\">\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"_submit_clear_shift\" value=\"1\">\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"Clear Entire Shift\" style=\"width: 150px\"\n\t\t\t\t\t\t\t\t\t\t\tname=\"submit\" >\n\t\t\t\t\t\t\t\t\t\t\t</form>";
                echo "<form method=\"POST\" style=\"margin-bottom:0;\">\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"_submit_move_shift\" value=\"1\">\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"Move Shift\" style=\"width: 150px\"\n\t\t\t\t\t\t\t\t\t\t\tname=\"submit\" >\n\t\t\t\t\t\t\t\t\t\t\t</form>";
                echo "<br></td></tr>";
            }
            echo display_filled_slots($persons);
            echo display_vacant_slots($shift->num_vacancies());
            echo "</td></tr></table>";
            echo "<p align=\"center\"><a href=\"calendar.php?id=" . substr($shiftid, 0, 8) . "&edit=true&venue=house" . "\">\n\t\t\t\t\t\t\t\t\tBack to Calendar</a>";
        }
    }
}
?>
function process_edit_scl($post)
{
    $id = $post['_shiftid'];
    $shift = select_dbShifts($id);
    $venue = substr($id, 9);
    $venue = substr($venue, strlen($venue) - 3);
    $scl = select_dbSCL($id);
    $persons_old = $scl->get_persons();
    $vacancies = $shift->num_vacancies();
    $new_acceptances = 0;
    for ($i = 0; $i < count($persons_old); ++$i) {
        $p_new = [$persons_old[$i][0], $persons_old[$i][1], $persons_old[$i][2], $persons_old[$i][3], $persons_old[$i][4], trim(str_replace(',', '&#44;', str_replace('+', '&#43;', str_replace('\'', '\\\'', htmlentities($post['datecalled_' . $i]))))), trim(str_replace(',', '&#44;', str_replace('+', '&#43;', str_replace('\'', '\\\'', htmlentities($post['notes_' . $i]))))), $post['accepted_' . $i]];
        $persons_new[] = $p_new;
        if ($post['accepted_' . $i] == "Yes" && $persons_old[$i][7] != "Yes") {
            ++$new_acceptances;
            $accepted_people[] = $i;
        }
    }
    if ($new_acceptances > $vacancies) {
        for ($j = 0; $j < count($accepted_people); ++$j) {
            if ($j == 0) {
                $s = $persons_new[$accepted_people[$j]][1] . " " . $persons_new[$accepted_people[$j]][2];
            } else {
                if ($j == count($accepted_people) - 1) {
                    $s = $s . " and " . $persons_new[$accepted_people[$j]][1] . " " . $persons_new[$accepted_people[$j]][2];
                } else {
                    $s = $s . ", " . $persons_new[$accepted_people[$j]][1] . " " . $persons_new[$accepted_people[$j]][2];
                }
            }
            $persons_new[$accepted_people[$j]][7] = "?";
        }
        if ($vacancies == 1) {
            echo "You assigned <b>" . $s . "</b> to this shift, but there is only " . $vacancies . " open slot.<br>\n\t\t\t\t\tPlease assign volunteers again.</p>";
        } else {
            echo "You assigned <b>" . $s . "</b> to this shift, but there are only " . $vacancies . " open slots.<br>\n\t\t\t\t\tPlease assign volunteers again.</p>";
        }
        update_sub_call_list($scl, $persons_new, $vacancies, "open");
        return $id;
    } else {
        $p = $shift->get_persons();
        for ($j = 0; $j < count($accepted_people); ++$j) {
            $s = $persons_new[$accepted_people[$j]][0] . "+" . $persons_new[$accepted_people[$j]][1] . "+" . $persons_new[$accepted_people[$j]][2];
            $p[] = $s;
            --$vacancies;
            $shift->ignore_vacancy();
        }
        $shift->assign_persons($p);
        update_dbShifts($shift);
        for ($j = 0; $j < count($accepted_people); ++$j) {
            add_log_entry('<a href=\\"personEdit.php?id=' . $_SESSION['_id'] . '\\">' . $_SESSION['f_name'] . ' ' . $_SESSION['l_name'] . '</a> assigned <a href=\\"personEdit.php?id=' . $persons_new[$accepted_people[$j]][0] . '\\">' . $persons_new[$accepted_people[$j]][1] . ' ' . $persons_new[$accepted_people[$j]][2] . '</a> to the shift: <a href=\\"editShift.php?shift=' . $shift->get_id() . '&venue=' . $venue . '\\">' . get_shift_name_from_id($shift->get_id()) . '</a>.');
        }
        //print_r($shift);
        if ($vacancies == 0) {
            $status = "closed";
        } else {
            $status = "open";
        }
        update_sub_call_list($scl, $persons_new, $vacancies, $status);
    }
}
Ejemplo n.º 3
0
 $vacancy_query = "SELECT SHIFTID,VACANCIES FROM SHIFT " . "WHERE VACANCIES > 0 ORDER BY SHIFTID;";
 error_log("in index.php, will retrieve shift vacancies with this query: " . $vacancy_query);
 $vacancy_list = mysql_query($vacancy_query);
 if (!$vacancy_list) {
     error_log('sql error while retrieving shifts with vacancies ' . mysql_error());
     echo mysql_error();
 }
 //upcoming vacancies
 if (mysql_num_rows($vacancy_list) > 0) {
     error_log("will display vacancies");
     echo '<div class="vacancyBox">';
     echo '<p><strong>Upcoming Vacancies:</strong><ul>';
     while ($thisRow = mysql_fetch_array($vacancy_list, MYSQL_ASSOC)) {
         $shift_date = mktime(0, 0, 0, substr($thisRow['SHIFTID'], 0, 2), substr($thisRow['SHIFTID'], 3, 2), substr($thisRow['SHIFTID'], 6, 2));
         if ($shift_date > $today && $shift_date < $two_weeks) {
             echo '<li type="circle"><a href="' . $path . 'editShift.php?shift=' . $thisRow['SHIFTID'] . '">' . get_shift_name_from_id($thisRow['SHIFTID']) . '</a></li>';
         }
     }
     echo '</ul></p></div><br>';
 }
 //active applicants
 //     connect();
 //Checks all of the volunteers to see if they are within 7 days old, if so add them to $array_New_Volunteers
 $one_Week = 7;
 $array_New_Volunteers;
 $volunteers_within_week = getall_persons();
 foreach ($volunteers_within_week as $temp_Week_Volunteer) {
     $daysAsVolunteer = check_Days_As_Volunteer($temp_Week_Volunteer->get_date_added());
     if ($daysAsVolunteer <= $one_Week) {
         #array_push($array_New_Volunteers, $temp_Week_Volunteer);
         $array_New_Volunteers[] = $temp_Week_Volunteer;