First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = "";
|
||||
$headerArgs = "";
|
||||
|
||||
unset($schedule_num);
|
||||
if (array_key_exists('schedule_num',$_GET) && intval($_GET['schedule_num']) > 0) $schedule_num = intval($_GET['schedule_num']);
|
||||
|
||||
|
||||
// Check if there are any schedules available
|
||||
$vwhere = "AND volunteer_signup = 'Y' ";
|
||||
$today = date("Y-m-d",time() + 60 * 60 * 24 * $school_record['volunteer_signup_days_prior']);
|
||||
if ($school_record['enable_volunteer_signup'] == 'Y') $vwhere = "AND volunteer_signup IN ('Y','D') ";
|
||||
if (isset($schedule_num) && $schedule_num > 0) $vwhere .= "AND record_num = $schedule_num ";
|
||||
|
||||
$query = "select count(*) from hotlunch_schedules " .
|
||||
"where school_num = $school_num " .
|
||||
"and status IN ('Active') " .
|
||||
$vwhere;
|
||||
$num_schedules = db_getVal($query);
|
||||
if ($num_schedules == 0) {
|
||||
$error_message = getLanguageText('TEXT-NO-VOLUNTEER-SCHEDULES');
|
||||
$action = '';
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$naction = "";
|
||||
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
||||
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
||||
|
||||
$school_num = $school_record['record_num'];
|
||||
$user_num = intval($_SESSION['UserInfo']['record_num']);
|
||||
|
||||
$maxVolunteers = $school_record['max_volunteers'];
|
||||
|
||||
|
||||
//
|
||||
// Process any required actions
|
||||
//
|
||||
if (strlen($naction) > 0) {
|
||||
|
||||
switch ($naction) {
|
||||
case 'add':
|
||||
$count = 0;
|
||||
|
||||
// Get set of schedules available for sign up
|
||||
$query = "select * from hotlunch_schedules " .
|
||||
"where school_num = $school_num " .
|
||||
"and status IN ('Active') " .
|
||||
$vwhere .
|
||||
"order by $scheduleSortOrder";
|
||||
$schedules = db_query($query);
|
||||
|
||||
while ($row = db_fetch_array($schedules)) {
|
||||
$schedule_num = $row['record_num'];
|
||||
$schedule_type = $row['schedule_type'];
|
||||
|
||||
// Get the menu dates for this schedule
|
||||
$today = date("Y-m-d",time());
|
||||
$query = "select * from hotlunch_menu_dates " .
|
||||
"where school_num = $school_num " .
|
||||
"and schedule_num = $schedule_num " .
|
||||
"and menu_date > '$today' " .
|
||||
"order by sequence,menu_date";
|
||||
$menu_dates = db_query($query);
|
||||
|
||||
if (db_num_rows($menu_dates) == 0) continue;
|
||||
|
||||
while ($row = db_fetch_array($menu_dates)) {
|
||||
$menu_num = $row['record_num'];
|
||||
$fname = "volunteer_$schedule_num" . "_$menu_num";
|
||||
if (array_key_exists($fname, $_POST) && $_POST[$fname] == 'Y') {
|
||||
db_query("INSERT INTO hotlunch_volunteers (school_num, schedule_num, menu_num, user_num, deleted) VALUES ($school_num,$schedule_num,$menu_num,$user_num,'N')");
|
||||
db_query("UPDATE users SET available_to_volunteer = 'Y' where school_num = $school_num AND record_num = $user_num");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$templatePageTitle = getLanguageText('TEXT-VOLUNTEER-SIGNUP-TITLE');
|
||||
|
||||
include "form.messages.php";
|
||||
|
||||
$datesDisplayed = false;
|
||||
if ($num_schedules > 0) {
|
||||
?>
|
||||
<form method='post' action='/'>
|
||||
<?php
|
||||
// Get set of schedules available for sign up
|
||||
$today = date("Y-m-d",time() + 60 * 60 * 24 * $school_record['volunteer_signup_days_prior']);
|
||||
$now = date("Y-m-d H:i:s",time() + 60 * 60 * 24 * $school_record['volunteer_signup_days_prior']);
|
||||
$query = "select * from hotlunch_schedules " .
|
||||
"where school_num = $school_num " .
|
||||
"and status IN ('Active') " .
|
||||
"and start_order_datetime <= '$now' " .
|
||||
$vwhere .
|
||||
"order by $scheduleSortOrder";
|
||||
$schedules = db_query($query);
|
||||
|
||||
// Display each schedule
|
||||
while ($row = db_fetch_array($schedules)) {
|
||||
extract($row);
|
||||
$schedule_num = $record_num;
|
||||
$schedule_volunteer_signup = $volunteer_signup;
|
||||
$schedule_max_volunteers = $max_volunteers;
|
||||
|
||||
$volunteerMsg = $school_record['default_volunteer_message'];
|
||||
|
||||
// Get the menu dates for this schedule
|
||||
$today = date("Y-m-d",time());
|
||||
$query = "select * from hotlunch_menu_dates " .
|
||||
"where school_num = $school_num " .
|
||||
"and schedule_num = $schedule_num " .
|
||||
"and menu_date > '$today' " .
|
||||
"order by sequence,menu_date";
|
||||
$menu_dates = db_query($query);
|
||||
|
||||
if (db_num_rows($menu_dates) == 0) continue;
|
||||
|
||||
?>
|
||||
<table width='600' cellpadding='5' cellspacing='1' class='content-table'>
|
||||
<tr class='heading'>
|
||||
<td colspan='2' align='center'><?php echo($schedule_name) ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
// Display each menu date
|
||||
$count = 0;
|
||||
while ($row = db_fetch_array($menu_dates)) {
|
||||
extract($row);
|
||||
$menu_num = $record_num;
|
||||
|
||||
$maxVolunteers = $school_record['max_volunteers'];
|
||||
|
||||
$bgclass = 'data-odd';
|
||||
if ($count % 2) $bgclass = 'data-even';
|
||||
$count++;
|
||||
|
||||
$title = $menu_title . date(" - D M jS, Y",strtotime($menu_date) + 60 * 60);
|
||||
|
||||
// Handle schedule level overrides
|
||||
if ($schedule_volunteer_signup == 'Y') {
|
||||
$maxVolunteers = $schedule_max_volunteers;
|
||||
$volunteerMsg = $schedule_volunteer_message;
|
||||
}
|
||||
|
||||
if ($schedule_volunteer_signup == 'N') {
|
||||
$maxVolunteers = 0;
|
||||
}
|
||||
|
||||
|
||||
// Handle the volunteer checkbox field
|
||||
if ($num_volunteer_override == 'Y') {
|
||||
$maxVolunteers = $max_volunteers;
|
||||
$volunteerMsg = $volunteer_msg;
|
||||
}
|
||||
|
||||
if ($num_volunteer_override == 'N') {
|
||||
$maxVolunteers = 0;
|
||||
}
|
||||
|
||||
|
||||
if (isset($menu_code)) $vBox = "volunteer_$menu_code";
|
||||
$vnum = db_getVal("SELECT count(*) FROM hotlunch_volunteers " .
|
||||
"WHERE school_num = $school_num " .
|
||||
"AND schedule_num = $schedule_num " .
|
||||
"AND menu_num = $menu_num " .
|
||||
"AND user_num = $user_num " .
|
||||
"AND deleted != 'Y'");
|
||||
if ($vnum == 1) $vField = "<b>Y</b>";
|
||||
else {
|
||||
$vBox = "volunteer_$schedule_num" . "_$menu_num";
|
||||
$vField = "<input type='checkbox' name='$vBox' value='Y'>";
|
||||
|
||||
// Determine the number of volunteers currently registered
|
||||
$numRegistered = db_getVal("SELECT count(*) FROM hotlunch_volunteers WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num AND deleted != 'Y'");
|
||||
if ($numRegistered >= $maxVolunteers) $vField = "<b>-</b>";
|
||||
}
|
||||
|
||||
?>
|
||||
<tr class='<?php echo($bgclass) ?>'>
|
||||
<td width='570' align='left'><?php echo($title) ?><?php if (strlen($volunteerMsg) > 0) echo("<br><span class='small'>- $volunteerMsg</small>"); ?></td>
|
||||
<td width='30' align='center' valign='top'><?php echo($vField) ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<br>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<input type='hidden' name='action' value='volunteer-signup'>
|
||||
<input type='hidden' name='naction' value='add'>
|
||||
<input type='submit' class='btn btn--primary' value='Sign Up'>
|
||||
</form>
|
||||
<br>
|
||||
<?php
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user