First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$CurrentTable = "hotlunch_menu_dates";
|
||||
$DeleteField = "menu_title,menu_date";
|
||||
$dSeparator = "<br>";
|
||||
$FormFile = "hotlunch_menu_dates.form.php";
|
||||
$TitleText = getLanguageText('TEXT-MENU');
|
||||
$OrderBy = "sequence,menu_date asc";
|
||||
$Sequence = 'Y';
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = getLanguageText('TEXT-MANAGE-FORM');
|
||||
|
||||
$moduleName = "hotlunch_menu_dates.edit.php";
|
||||
// startLog($moduleName);
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Schedule Team','Application Administrator');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
include "form.messages.php";
|
||||
include "hotlunch_reports.menu.php";
|
||||
endTemplate();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (array_key_exists('schedule_num',$_GET)) $schedule_num = intval($_GET['schedule_num']);
|
||||
if (array_key_exists('schedule_num',$_POST)) $schedule_num = intval($_POST['schedule_num']);
|
||||
|
||||
if (!isset($schedule_num) || intval($schedule_num) == 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE');
|
||||
include "form.messages.php";
|
||||
include "hotlunch_reports.menu.php";
|
||||
endTemplate();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// Check if this is a valid schedule
|
||||
$swhere = "";
|
||||
if ($_SESSION['UserInfo']['type'] == 'Supplier') $swhere = " and supplier_num = " . $_SESSION['UserInfo']['supplier_num'];
|
||||
$query = "select * from hotlunch_schedules " .
|
||||
"where record_num = $schedule_num " .
|
||||
"and school_num = $school_num $swhere";
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) == 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE-NUM');
|
||||
include "form.messages.php";
|
||||
include "hotlunch_reports.menu.php";
|
||||
endTemplate();
|
||||
exit;
|
||||
}
|
||||
|
||||
$hotlunch_schedule = db_fetch_array($results);
|
||||
$templatePageTitle .= " - " . $hotlunch_schedule['schedule_name'];
|
||||
|
||||
|
||||
// If this is a ScheduleTeam user check if they have permission to access this schedule
|
||||
if ($_SESSION['UserInfo']['type'] == 'Schedule Team') {
|
||||
$userNum = $_SESSION['UserInfo']['record_num'];
|
||||
$access = db_getVal("SELECT count(*) FROM hotlunch_schedules_people WHERE school_num = $school_num AND schedule_num = $schedule_num AND user_num = $userNum");
|
||||
|
||||
if (!$access || $access == 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-NO-SCHEDULE-ACCESS');
|
||||
include "form.messages.php";
|
||||
include "hotlunch_reports.menu.php";
|
||||
endTemplate();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$scriptName = str_replace("/m/data1/hotlunches.net/admin/","",__FILE__);
|
||||
|
||||
// Main buttons
|
||||
include "hotlunch_reports.menu.php";
|
||||
|
||||
$naction = 'manage';
|
||||
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
||||
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
||||
|
||||
|
||||
|
||||
switch (strtolower($naction)) {
|
||||
case "manage":
|
||||
include "hotlunch_menu_dates.manage.php";
|
||||
break;
|
||||
|
||||
case "manage-update":
|
||||
// Get set of menu dates to process
|
||||
$results = db_query("SELECT * FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num ORDER BY sequence,menu_date");
|
||||
while ($row = db_fetch_array($results)) {
|
||||
$record_num = $row['record_num'];
|
||||
if (array_key_exists('title_'.$record_num, $_POST)) $menu_title = db_escape_string(trim($_POST["title_$record_num"]));
|
||||
if (array_key_exists('date_'.$record_num, $_POST)) $menu_date = $_POST["date_$record_num"];
|
||||
if (array_key_exists('end_date_'.$record_num, $_POST)) $end_order = $_POST["end_date_$record_num"];
|
||||
if (array_key_exists('min__'.$record_num, $_POST)) $min_vol = number_format($_POST["min_$record_num"],0);
|
||||
if (array_key_exists('max_'.$record_num, $_POST)) $max_vol = number_format($_POST["max_$record_num"],0);
|
||||
|
||||
if (!isset($end_order)) $end_order = $menu_date;
|
||||
|
||||
$query = "UPDATE hotlunch_menu_dates " .
|
||||
"SET menu_title = '$menu_title', " .
|
||||
"menu_date = '$menu_date', " .
|
||||
"menu_end_order_datetime = '$end_order', " .
|
||||
"max_volunteers = $max_vol " .
|
||||
"WHERE school_num = $school_num AND record_num = $record_num";
|
||||
db_query($query);
|
||||
}
|
||||
|
||||
$form_message = getLanguageText('MSG-MENUS-UPDATED');
|
||||
header("Location: ?action=menu-dates&schedule_num=$schedule_num&form_message=" . urlencode($form_message));
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
include "hotlunch_orders.print_buttons.php";
|
||||
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user