307 lines
13 KiB
PHP
307 lines
13 KiB
PHP
<?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";
|
|
$FormFile = "hotlunch_menu_dates.dialog.php";
|
|
$JQueryFile = "hotlunch_menu_dates.js.php";
|
|
$DialogWidth = 750;
|
|
$DialogHeight = 450;
|
|
$TitleText = getLanguageText('TEXT-MENU');
|
|
$SequenceFlag = 'Y';
|
|
$tableAction = "menu-dates-list";
|
|
$RequiredFields = array('menu_title');
|
|
|
|
$CustomDialogFields = array(
|
|
array('field_name' => 'schedule_num', 'default' => $schedule_num, 'ftype' => 'form-data'),
|
|
array('field_name' => 'select_classes', 'default' => "'AllClasses'", 'ftype' => 'form-data'),
|
|
array('field_name' => 'selected_classes', 'default' => '[]', 'ftype' => 'form-data'),
|
|
);
|
|
|
|
// 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();
|
|
}
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = getLanguageText('TEXT-MANAGE-FORM');
|
|
|
|
$moduleName = "hotlunch_menu_dates.php";
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') startLog($moduleName);
|
|
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
|
|
$CustomData = "&schedule_num=$schedule_num";
|
|
$numOrders = db_getVal("SELECT count(*) FROM hotlunch_order_items WHERE school_num = $school_num AND schedule_num = $schedule_num AND active = 'Y'");
|
|
|
|
$query = "SELECT count(*) FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_link != 'No'";
|
|
$numLinks = db_getVal($query);
|
|
|
|
if ($numLinks > 0) {
|
|
$JSeditValidation = "
|
|
var mlink = $(\"#menu-date-link-\"+record_num).val();
|
|
if (mlink != 'No') {
|
|
alert(\"".getLanguageText('TEXT-UNABLE-TO-EDIT-LINKED-MENUS')."\");
|
|
return;
|
|
}
|
|
";
|
|
}
|
|
|
|
$query = "SELECT count(*) FROM hotlunch_menu_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND menu_num IN (SELECT record_num FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num)";
|
|
$numItems = db_getVal($query);
|
|
|
|
|
|
?>
|
|
<style>
|
|
#data-dialog-body {
|
|
max-height: 550px;
|
|
overflow: auto;
|
|
}
|
|
</style>
|
|
|
|
<input type='hidden' id='current_schedule_num' value='<?php echo($schedule_num) ?>'>
|
|
<input type='hidden' id='current_menu_num'>
|
|
<input type='hidden' id='current_supplier_num'>
|
|
|
|
<?php
|
|
|
|
// Update revenue and supplier costs for each menu in schedule
|
|
include "hotlunch_schedule_post.php";
|
|
|
|
// Main buttons
|
|
include "hotlunch_reports.menu.php";
|
|
|
|
include "form.js.php";
|
|
|
|
include "hotlunch_menu_dates.options.php";
|
|
|
|
include "hotlunch_orders.print_buttons.php";
|
|
|
|
?>
|
|
<div id='modify-menu-links-dialog' title="<?php displayLanguageText('TEXT-CHANGE-MENU-LINKING'); ?>">
|
|
<center>
|
|
<p><b><?php displayLanguageText('TEXT-UPDATE-ALL-MENU-DATES') ?></b></p>
|
|
<p><button class='modify-links btn btn--outline btn--xsmall btn--200' new='Admin'> <?php displayLanguageText('TEXT-SWITCH-LINKS-TO-ADMIN'); ?> </button></p>
|
|
<p><button class='modify-links btn btn--outline btn--xsmall btn--200' new='Paper'> <?php displayLanguageText('TEXT-SWITCH-LINKS-TO-PAPER'); ?> </button></p>
|
|
<p><button class='modify-links btn btn--outline btn--xsmall btn--200' new='All'> <?php displayLanguageText('TEXT-SWITCH-LINKS-TO-ALL'); ?> </button></p>
|
|
<p><button class='modify-links btn btn--outline btn--xsmall btn--200' new='No'> <?php displayLanguageText('TEXT-REMOVE-MENU-LINKS'); ?> </button></p>
|
|
</center>
|
|
</div>
|
|
|
|
<div id='modify-menu-link-dialog' title="<?php displayLanguageText('TEXT-CHANGE-MENU-LINKING'); ?>">
|
|
<center>
|
|
<p><button class='modify-link btn btn--outline btn--xsmall btn--200' new='Admin'> <?php displayLanguageText('TEXT-LINKED-FOR-ADMIN'); ?> </button></p>
|
|
<p><button class='modify-link btn btn--outline btn--xsmall btn--200' new='Paper'> <?php displayLanguageText('TEXT-LINKED-FOR-PAPER-ORDERS'); ?> </button></p>
|
|
<p><button class='modify-link btn btn--outline btn--xsmall btn--200' new='All'> <?php displayLanguageText('TEXT-LINKED-FOR-ALL-ORDERS'); ?> </button></p>
|
|
<p><button class='modify-link btn btn--outline btn--xsmall btn--200' new='No'> <?php displayLanguageText('TEXT-NOT-LINKED'); ?> </button></p>
|
|
<input type='hidden' id='current-menu-num'>
|
|
</center>
|
|
</div>
|
|
|
|
<div id='generate-menu-dialog' title="<?php displayLanguageText('TEXT-GENERATE-MENU-ENTRIES'); ?>">
|
|
<center>
|
|
<table width='550'>
|
|
<tr>
|
|
<td align='left'>
|
|
<span id='generate-menu-title'></span>
|
|
<p><b><?php displayLanguageText('TEXT-SUPPLIER-SELECT-MSG'); ?></b></p>
|
|
<p class='align-left'><b><label for='supplier-search'><?php displayLanguageText('TEXT-SUPPLIER-SEARCH'); ?></label>:</b><br>
|
|
<input type='text' id='supplier-search' size='40' class="form-field text ui-widget-content ui-corner-all"></p>
|
|
<p class='align-left'><b><label for='supplier-select'><?php displayLanguageText('TEXT-SELECT-SUPPLIER'); ?></label>:</b><br>
|
|
<select name='supplier_selet' id='supplier-select' class='select-width300 form-field ui-widget-content ui-corner-all'>
|
|
<option value=''><?php displayLanguageText('TEXT-SELECT-SUPPLIER'); ?></option>
|
|
<?php
|
|
$swhere = "";
|
|
if ($_SESSION['UserInfo']['type'] == 'Supplier') {
|
|
$snum = intval($_SESSION['UserInfo']['supplier_num']);
|
|
$swhere = " and record_num = $snum ";
|
|
}
|
|
|
|
$query = "SELECT s.supplier_name,s.record_num,count(sp.record_num) as products " .
|
|
"FROM suppliers as s LEFT JOIN supplier_products as sp ON sp.school_num = $supplier_school_num AND sp.supplier_num = s.record_num AND sp.status = 'Active' AND product_type = 'Product' " .
|
|
"WHERE s.school_num = $supplier_school_num " .
|
|
"AND s.status = 'Active' $swhere " .
|
|
"GROUP BY 1,2 " .
|
|
"ORDER BY supplier_name";
|
|
$results = db_query($query);
|
|
while ($row = db_fetch_array($results)) {
|
|
$supplier_name = $row['supplier_name'];
|
|
$products = $row['products'];
|
|
$rnum = $row['record_num'];
|
|
|
|
$selected = "";
|
|
if (isset($selected_supplier) && $selected_supplier == $rnum) $selected = " selected='selected'";
|
|
echo(" <option value='$rnum'$selected>$supplier_name ($products products)</option>\n");
|
|
}
|
|
?>
|
|
</select></p>
|
|
<br>
|
|
<span id='top-generate-buttons'>
|
|
<center>
|
|
<button class='generate-menu-btn btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-GENERATE-MENU-ENTRIES'); ?> </button>
|
|
</center>
|
|
</span>
|
|
<br>
|
|
<div id='supplier-products-div'></div>
|
|
<br>
|
|
<div id='generate-menu-dates-div'></div>
|
|
<br>
|
|
<center>
|
|
<button id='clear-generate-btn' class='btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-CLEAR'); ?> </button>
|
|
<button class='generate-menu-btn btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-GENERATE-MENU-ENTRIES'); ?> </button>
|
|
<button id='cancel-generate-btn' class='btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button>
|
|
</center>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</div>
|
|
|
|
<div id='copy-menu-dialog' title="<?php displayLanguageText('TEXT-COPY-MENU'); ?>">
|
|
<div id='copy-menu-tabs'>
|
|
<a class='dialog-top' href='#'></a>
|
|
<ul>
|
|
<li id='copy-menu-tab'><a href='#copy-menu-div'><?php displayLanguageText('TEXT-CURRENT-MENU-SCHEDULE'); ?></a></li>
|
|
<li id='other-schedule-tab'><a href='#other-schedule-div'><?php displayLanguageText('TEXT-OTHER-SCHEDULE-MENU'); ?></a></li>
|
|
</ul>
|
|
<div id='copy-menu-div'>
|
|
<center>
|
|
<table width='550'>
|
|
<tr>
|
|
<td align='left'>
|
|
<span id='copy-menu-title'></span>
|
|
<br>
|
|
<p class='align-left'><b><label for='copy-menu-title'><?php displayLanguageText('TEXT-COPY-MENU-TITLE'); ?></label>:</b><br>
|
|
<select name='copy_menu_title' id='copy_menu_title' class='select-width100 form-field ui-widget-content ui-corner-all'>
|
|
<?php BuildFileList("yn.txt") ?>
|
|
</select>
|
|
<p class='align-left'><b><label for='copy-menu-link'><?php displayLanguageText('TEXT-MENU-LINK'); ?></label>:</b><br>
|
|
<select name='menu_link' id='copy-menu-link' class='select-width200 form-field ui-widget-content ui-corner-all'>
|
|
<?php BuildFileList("menu_linking.txt") ?>
|
|
</select>
|
|
<div id='copy-menu-dates-div'></div>
|
|
<br>
|
|
<center>
|
|
<button id='copy-menu-btn' class='btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-COPY-MENU'); ?> </button>
|
|
<button class='cancel-copy-menu-btn btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button>
|
|
</center>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</div>
|
|
<div id='other-schedule-div'>
|
|
<center>
|
|
<table width='550'>
|
|
<tr>
|
|
<td align='left'>
|
|
<span id='copy-menu-header'><?php displayLanguageText('TEXT-SOURCE-MENU'); ?></span>
|
|
<br>
|
|
<p class='align-left'><b><label for='copy-source-schedule'><?php displayLanguageText('TEXT-SCHEDULE'); ?></label>:</b><br>
|
|
<select name='copy-source-schedule' id='copy-source-schedule' class='select-width300 form-field ui-widget-content ui-corner-all'>
|
|
<option value=''><?php displayLanguageText('TEXT-SELECT-A-SCHEDULE'); ?></option>
|
|
<?php
|
|
$query = "SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND status != 'Deleted' ORDER BY schedule_start_date DESC";
|
|
$schedules = db_query($query);
|
|
while ($row = db_fetch_assoc($schedules)) {
|
|
$snum = $row['record_num'];
|
|
$stitle = $row['schedule_name'];
|
|
$numMenus = db_getVal("SELECT count(*) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $snum");
|
|
echo(" <option value='$snum'>$stitle ($numMenus)</option>\n");
|
|
}
|
|
?>
|
|
</select></p>
|
|
<p class='align-left'><b><label for='copy-source-menu'><?php displayLanguageText('TEXT-MENU'); ?></label>:</b><br>
|
|
<select name='copy-source-menu' id='copy-source-menu' class='select-width300 form-field ui-widget-content ui-corner-all'>
|
|
</select></p>
|
|
<br>
|
|
<span id='source-menu-title'></span>
|
|
<span id='target-menu-title'></span>
|
|
<br>
|
|
<center>
|
|
<button id='copy-other-menu-btn' class='btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-COPY-MENU'); ?> </button>
|
|
<button class='cancel-copy-menu-btn btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button>
|
|
<input type='hidden' id='target-title'>
|
|
<input type='hidden' id='copy-mode'>
|
|
</center>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
endTemplate();
|
|
?>
|