First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
// header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// 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) {
|
||||
echo("<br>\n");
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
|
||||
$menu_num = 0;
|
||||
if (array_key_exists('menu_num',$_GET)) $menu_num = intval($_GET['menu_num']);
|
||||
if (array_key_exists('menu_num',$_POST)) $menu_num = intval($_POST['menu_num']);
|
||||
|
||||
if (array_key_exists('selected_menus',$_GET)) $selected_menus = $_GET['selected_menus'];
|
||||
if (array_key_exists('selected_menus',$_POST)) $selected_menus = $_POST['selected_menus'];
|
||||
|
||||
|
||||
$numSuppliers = db_getVal("SELECT count(*) FROM suppliers WHERE school_num = $school_num AND status = 'Active'");
|
||||
|
||||
if ($naction == 'View Products' || $numSuppliers == 1) {
|
||||
$selected_supplier = $_POST['selected_supplier'];
|
||||
if ($numSuppliers == 1) $selected_supplier = db_getVal("SELECT record_num FROM suppliers WHERE school_num = $school_num AND status = 'Active'");
|
||||
|
||||
// Check that a supplier has been selected
|
||||
if (strlen($selected_supplier) == 0) {
|
||||
$error_message = "Error: No Supplier Has Been Selected";
|
||||
}
|
||||
else {
|
||||
$num_products = db_getVal("SELECT count(*) FROM supplier_products WHERE school_num = $supplier_school_num AND supplier_num = $selected_supplier AND status = 'Active'");
|
||||
if ($num_products == 0) {
|
||||
$error_message = "Error: Supplier Has No Products";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get menu info
|
||||
if (isset($menu_num) && $menu_num > 0) {
|
||||
$results = db_query("SELECT * FROM hotlunch_menu_dates WHERE school_num = $school_num AND record_num = $menu_num");
|
||||
$row = db_fetch_array($results);
|
||||
$menu_title = $row['menu_title'];
|
||||
$menu_date = date("D M jS Y",strtotime($row['menu_date']));
|
||||
}
|
||||
|
||||
$scriptName = str_replace("/m/data1/app.hotlunches.net/","",__FILE__);
|
||||
include "help.docs.php";
|
||||
|
||||
|
||||
?>
|
||||
<br>
|
||||
<br>
|
||||
<form method='post' action='/'>
|
||||
<?php
|
||||
$message_width = $default_form_width;
|
||||
include "form.messages.php";
|
||||
?>
|
||||
<table width='<?php echo($default_form_width) ?>' class='content-table'>
|
||||
<tr>
|
||||
<td colspan='2' align='center' class='heading'>Generate a Menu from Supplier Products</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' align='center'> </td>
|
||||
</tr>
|
||||
<?php if (isset($menu_num) && $menu_num > 0) { ?>
|
||||
<tr>
|
||||
<td colspan='2' align='center'>
|
||||
<p>Title: <b><?php echo($menu_title) ?></b><br>
|
||||
Date: <b><?php echo($menu_date) ?></b></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td width='35%' align='right' valign='top'>Supplier: </td>
|
||||
<td width='65%' align='left' valign='top'>
|
||||
<select name='selected_supplier'>
|
||||
<option value=''>Select a Supplier to Generate the Menu</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 = $school_num AND sp.supplier_num = s.record_num AND sp.status = 'Active' " .
|
||||
"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>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (($naction == 'View Products' || $numSuppliers == 1) && $num_products > 0) { ?>
|
||||
<tr>
|
||||
<td colspan='2' align='center'>
|
||||
<br>
|
||||
<table width='700' cellpadding='2' cellspacing='2' class='content-table'>
|
||||
<tr class='heading'>
|
||||
<td align='left'>Product Name</td>
|
||||
<td align='center'> </td>
|
||||
</tr>
|
||||
<?php
|
||||
$products = db_query("SELECT * FROM supplier_products WHERE school_num = $supplier_school_num AND supplier_num = $selected_supplier AND status = 'Active' ORDER BY sequence,product_name");
|
||||
$count = 0;
|
||||
while ($row = db_fetch_array($products)) {
|
||||
extract($row);
|
||||
|
||||
$bgclass = 'data-odd';
|
||||
if ($count % 2) $bgclass = 'data-even';
|
||||
$count++;
|
||||
|
||||
$price = $currencySymbol . number_format($standard_online_price,2);
|
||||
|
||||
if (strlen($product_description)) $product_description = " - <span class='small'>$product_description - $price</span>";
|
||||
?>
|
||||
<tr class='<?php echo($bgclass) ?>'>
|
||||
<td align='left' valign='top'>
|
||||
<b><?php echo($product_name) ?></b><br>
|
||||
<?php echo($product_description) ?>
|
||||
</td>
|
||||
<td width='50' align='center' valign='top'><input type='checkbox' name='selected_products[]' value='<?php echo($record_num) ?>'></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
$bgclass = 'data-odd';
|
||||
if ($count % 2) $bgclass = 'data-even';
|
||||
$count++;
|
||||
|
||||
?>
|
||||
</table>
|
||||
<br>
|
||||
<table width='700' cellpadding='2' cellspacing='2' class='content-table'>
|
||||
<tr class='<?php echo($bgclass) ?>'>
|
||||
<td width='60%' align='left' valign='top'><b>New Items Generated To:</b></td>
|
||||
<td align='left'>
|
||||
<?php BuildFileRadio("menu_items_generate.txt","item_location","End") ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if (isset($menu_num) && $menu_num == 0) { ?>
|
||||
<tr>
|
||||
<td colspan='2' align='center'> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align='right' valign='top'>Selected Menu Dates: </td>
|
||||
<td align='left' valign='top'>
|
||||
<select name='selected_menus[]' multiple size='10' class='select-width400'>
|
||||
<?php
|
||||
$query = "select distinct hlmd.*,hs.schedule_name,hs.schedule_start_date " .
|
||||
"from hotlunch_menu_dates as hlmd, hotlunch_schedules as hs " .
|
||||
"where hlmd.school_num = $school_num " .
|
||||
"and hs.school_num = $school_num " .
|
||||
"and hs.status != 'Deleted' " .
|
||||
"and hlmd.schedule_num = hs.record_num " .
|
||||
"and hlmd.schedule_num = $schedule_num " .
|
||||
$swhere .
|
||||
"order by hs.schedule_start_date desc,hs.schedule_name,hlmd.sequence,menu_date";
|
||||
$results = db_query($query);
|
||||
$prev_schedule = "";
|
||||
$count = 0;
|
||||
while ($row = db_fetch_array($results)) {
|
||||
$name = $row['menu_title'];
|
||||
$date = date("l F jS, Y",strtotime($row['menu_date']));
|
||||
$rnum = $row['record_num'];
|
||||
|
||||
if ($hotlunch_schedule['display_menu_date'] == 'Y') $name .= " - $date";
|
||||
|
||||
// Check if this date is a source date for other menus
|
||||
$num_menus = db_getVal("SELECT count(*) FROM hotlunch_menu_dates WHERE school_num = $school_num AND source_menu = $rnum");
|
||||
if ($num_menus > 0) continue;
|
||||
|
||||
$schedule_name = $row['schedule_name'];
|
||||
if ($schedule_name != $prev_schedule) {
|
||||
if ($prev_schedule != "") echo(" </optgroup>\n");
|
||||
echo(" <optgroup label='$schedule_name'>\n");
|
||||
$prev_schedule = $schedule_name;
|
||||
}
|
||||
|
||||
$selected = "";
|
||||
if (isset($selected_menus) && is_array($selected_menus)) if (in_array($rnum,$selected_menus)) $selected = " selected='selected'";
|
||||
|
||||
echo(" <option value='$rnum'$selected>$name</option>\n");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if ($count == 0) {
|
||||
echo(" <option value='0'>There are no defined menu dates to copy to</option>\n");
|
||||
}
|
||||
else {
|
||||
echo(" </optgroup>\n");
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td colspan='2' align='center'>
|
||||
<br>
|
||||
<table cellpadding='2' cellspacing='2'>
|
||||
<tr>
|
||||
<?php if ($numSuppliers > 1) { ?>
|
||||
<td align='center'><input type='submit' class='btn btn--primary' id='view-products' value="<?php displayLanguageText('TEXT-VIEW-PRODUCTS'); ?>"></td>
|
||||
<?php } ?>
|
||||
<td align='center'><input type='submit' class='btn btn--primary' id='generate-menu' value="<?php displayLanguageText('TEXT-GENERATE-MENU'); ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='hidden' name='action' value='menu-dates'>
|
||||
<input type='hidden' name='naction' id='naction' value='generate-multi-menu'>
|
||||
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
|
||||
<input type='hidden' name='menu_num' value='<?php echo($menu_num) ?>'>
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#generate-menu").click(function() {
|
||||
$("#naction").val('Generate Menu');
|
||||
});
|
||||
|
||||
$("#view-products").click(function() {
|
||||
$("#naction").val('View Products');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in new issue
Block a user