Files
HotLunches/hotlunch_menu.price_update.php
T
2026-10-19 15:22:52 -07:00

123 lines
3.9 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = getLanguageText('TEXT-MENU-UPDATE');
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier');
if (checkPermission($AllowedUserTypes) != 1) {
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
include "form.messages.php";
endTemplate();
exit();
}
// Get schedule_num
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']);
// Get menu
unset($selected_menu_num);
if (array_key_exists('selected_menu_num',$_GET)) $selected_menu_num = intval($_GET['selected_menu_num']);
if (array_key_exists('selected_menu_num',$_POST)) $selected_menu_num = intval($_POST['selected_menu_num']);
if (!isset($schedule_num)) {
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE-NUM');
include "form.messages.php";
endTemplate();
exit();
}
// Check if this is a valid schedule
$today = date("Y-m-d",time());
$query = "select * from hotlunch_schedules " .
"where record_num = $schedule_num " .
"and school_num = $school_num";
$results = db_query($query);
if (db_num_rows($results) == 0) {
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE');
include "form.messages.php";
return;
}
$hotlunch_schedule = db_fetch_array($results);
// If this is a ScheduleTeam user check if they have permission to access this schedule
if (in_array($_SESSION['UserInfo']['type'],array('Schedule Team','Schedule Volunteer'))) {
$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";
endTemplate();
exit();
}
}
// Check that this schedule date has lunch dates specified
$query = "select count(*) num from hotlunch_menu_dates " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num";
$results = db_query($query);
$row = db_fetch_array($results);
if ($row['num'] == 0) {
$error_message = getLanguageText('ERRORMSG-NO-MENU-DATES');
include "form.messages.php";
endTemplate();
exit();
}
// Check that this schedule date has lunch items specified
$query = "select count(hotlunch_menu_items.record_num) num from hotlunch_menu_items,hotlunch_menu_dates " .
"WHERE hotlunch_menu_items.school_num = $school_num " .
"AND hotlunch_menu_dates.school_num = $school_num " .
"AND hotlunch_menu_dates.record_num = hotlunch_menu_items.menu_num " .
"AND hotlunch_menu_dates.schedule_num = $schedule_num";
$results = db_query($query);
$row = db_fetch_array($results);
if ($row['num'] == 0) {
$error_message = getLanguageText('ERRORMSG-NO-MENU-ITEMS');
include "form.messages.php";
endTemplate();
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'];
// Display the selected menu form
if ($action == "menu-price-update") include "hotlunch_menu.price_update.form.php";
if ($action == "menu-price-update-special") include "hotlunch_menu.price_update.special.form.php";
endTemplate();
?>