204 lines
7.9 KiB
PHP
204 lines
7.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-SUPPLIER-INFORMATION');
|
|
$headerArgs = "";
|
|
|
|
// startLog("supplier_dashboard.php");
|
|
// writeLog(print_r($_SESSION, true));
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Supplier');
|
|
if (!in_array($_SESSION['UserInfo']['type'],$AllowedUserTypes)) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED').' - '.$_SESSION['UserInfo']['type'];
|
|
include "form.messages.php";
|
|
endTemplate();
|
|
exit();
|
|
}
|
|
|
|
if ($_SESSION['UserInfo']['type'] == 'Supplier') $supplier_num = intval($_SESSION['UserInfo']['supplier_num']);
|
|
writeLog("supplier_num: $supplier_num");
|
|
if (!isset($supplier_num) || intval($supplier_num) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
endTemplate();
|
|
exit();
|
|
}
|
|
|
|
|
|
$school_name = $school_record['school_name'];
|
|
|
|
// Get set of active schedules
|
|
$today = date("Y-m-d",time());
|
|
$now = date("Y-m-d H:i:00",time());
|
|
$cutoff_date = date("Y-m-d",time() - 60 * 60 * 24 * 14);
|
|
$query = "select hls.* " .
|
|
"from hotlunch_schedules as hls " .
|
|
"where hls.school_num = $school_num " .
|
|
"and hls.status != 'Deleted' " .
|
|
"and (hls.schedule_end_date >= '$today' OR hls.end_order_datetime >= '$now') " .
|
|
"order by $scheduleSortOrder";
|
|
$schedules = db_query($query);
|
|
|
|
if (db_num_rows($schedules) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-NO-SCHEDULES');
|
|
include "form.messages.php";
|
|
endTemplate();
|
|
exit();
|
|
}
|
|
|
|
?>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$(".supplier-link").click(function(e) {
|
|
var num_orders = $(this).attr('norders');
|
|
if (num_orders == 0) {
|
|
alert("<?php displayLanguageText('TEXT-THERE-ARE-NO-ORDERS'); ?>");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<br>
|
|
<table width='90%' class='content-table'>
|
|
<tr class='heading'>
|
|
<td align='center'><?php displayLanguageText('TEXT-CURRENT-SCHEDULES'); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<?php
|
|
while ($row = db_fetch_array($schedules)) {
|
|
|
|
$schedule_name = $row['schedule_name'];
|
|
$schedule_num = $row['record_num'];
|
|
$schedule_type = $row['schedule_type'];
|
|
|
|
$date_where = "";
|
|
if ($schedule_type == 'Hot Lunch') $date_where = "AND hlmd.menu_date >= '$cutoff_date' ";
|
|
|
|
$query = "SELECT DISTINCT hlmd.* FROM hotlunch_menu_dates AS hlmd, hotlunch_menu_items AS hlmi, hotlunch_menu_products AS hlmp, supplier_products AS sp " .
|
|
"WHERE hlmd.school_num = $school_num " .
|
|
"AND hlmd.schedule_num = $schedule_num " .
|
|
$date_where .
|
|
"AND hlmi.school_num = $school_num " .
|
|
"AND hlmi.menu_num = hlmd.record_num " .
|
|
"AND hlmp.school_num = $school_num " .
|
|
"AND hlmp.menu_item_num = hlmi.record_num " .
|
|
"AND sp.school_num = $supplier_school_num " .
|
|
"AND sp.record_num = hlmp.supplier_product_num " .
|
|
"AND sp.supplier_num = $supplier_num " .
|
|
"ORDER BY sequence,menu_date";
|
|
$menu_dates = db_query($query);
|
|
if (db_num_rows($menu_dates) == 0) continue;
|
|
|
|
$numOrders = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num AND ordered_by_type != 'Concession'");
|
|
// if ($numOrders == 0) continue;
|
|
|
|
?>
|
|
<br>
|
|
<table width='95%' class='content-table'>
|
|
<tr class='heading'>
|
|
<td align='left' width='50%'><?php echo($schedule_name) ?></td>
|
|
<td align='center' width='20%'><?php displayLanguageText('TEXT-DATE'); ?></td>
|
|
<td align='center' width='10%'><?php displayLanguageText('TEXT-ORDERS'); ?></td>
|
|
<td align='center' width='10%'><?php displayLanguageText('TEXT-ITEMS'); ?></td>
|
|
<td align='center'> </td>
|
|
</tr>
|
|
<?php
|
|
$results = db_query("SELECT * FROM suppliers WHERE school_num = $school_num AND record_num = $supplier_num");
|
|
$row = db_fetch_assoc($results);
|
|
$printItemLabels = $row['print_item_labels'];
|
|
$printMealLabels = $row['print_meal_labels'];
|
|
$orderDetailsRpt = $row['order_details_report'];
|
|
|
|
$count = 0;
|
|
while ($row = db_fetch_array($menu_dates)) {
|
|
|
|
$bgclass = "data-even";
|
|
if (($count % 2) == 0) $bgclass = "data-odd";
|
|
$count++;
|
|
|
|
$menu_title = $row['menu_title'];
|
|
$menu_date = $row['menu_date'];
|
|
$menu_num = $row['record_num'];
|
|
|
|
if ($menu_date < $today) $bgclass = 'warning';
|
|
|
|
$numOrders = db_getVal("SELECT count(distinct order_num) FROM hotlunch_order_items WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num");
|
|
$results = db_query("SELECT count(distinct order_num) AS orders, count(*) AS items " .
|
|
"FROM hotlunch_order_items AS hloi, hotlunch_menu_products AS hlmp, supplier_products AS sp " .
|
|
"WHERE hloi.school_num = $school_num " .
|
|
"AND hlmp.school_num = $school_num " .
|
|
"AND sp.school_num = $supplier_school_num " .
|
|
"AND hloi.schedule_num = $schedule_num " .
|
|
"AND hloi.menu_num = $menu_num " .
|
|
"AND hloi.menu_item_num = hlmp.menu_item_num " .
|
|
"AND hlmp.supplier_product_num = sp.record_num " .
|
|
"AND sp.supplier_num = $supplier_num");
|
|
$r = db_fetch_assoc($results);
|
|
$numSupplierOrders = $r['orders'];
|
|
$numSupplierItems = $r['items'];
|
|
|
|
$supplier_order_print = "<a href='/?action=supplier-orders-print&schedule_num=$schedule_num&menu_num=$menu_num' norders='$numOrders' class='supplier-link' title='Print Order'>$print_icon</a>";
|
|
$supplier_order_download = "<a href='/?action=supplier-orders-csv&schedule_num=$schedule_num&menu_num=$menu_num' norders='$numOrders' class='supplier-link' title='Download Spreadsheet'>$filedownload_icon</a>";
|
|
|
|
$item_labels = "";
|
|
if ($printItemLabels == 'Y') {
|
|
$item_labels = " <a href='/?action=item-labels&schedule_num=$schedule_num&menu_num=$menu_num' norders='$numOrders' class='supplier-link' title='Item Labels'>$labels_icon</a>";
|
|
}
|
|
|
|
$meal_labels = "";
|
|
if ($printMealLabels == 'Y') {
|
|
$meal_labels = " <a href='/?action=meal-labels&schedule_num=$schedule_num&menu_num=$menu_num' norders='$numOrders' class='supplier-link' title='Meal Labels'>$labels_icon</a>";
|
|
}
|
|
|
|
$order_details = "$orderDetailsRpt";
|
|
if ($orderDetailsRpt == 'Y') {
|
|
$order_details = " <a href='/?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num' norders='$numOrders' class='supplier-link' title='Order Details'>$print_icon</a>";
|
|
}
|
|
|
|
?>
|
|
<tr class='<?php echo($bgclass) ?>'>
|
|
<td align='left'><?php echo($menu_title) ?></td>
|
|
<td align='center'><?php echo(date($school_record['date_format'],strtotime($menu_date))) ?></td>
|
|
<td align='center'><?php echo($numSupplierOrders) ?></td>
|
|
<td align='center'><?php echo($numSupplierItems) ?></td>
|
|
<td align='center'>
|
|
<nobr>
|
|
<?php echo($supplier_order_print) ?>
|
|
|
|
<?php echo($supplier_order_download) ?>
|
|
<?php echo($item_labels) ?>
|
|
<?php echo($meal_labels) ?>
|
|
<?php echo($order_details) ?>
|
|
</nobr>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</table>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
endTemplate();
|
|
?>
|