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

238 lines
7.8 KiB
PHP

<?php
$ValidAccess = 2010;
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');
if (checkPermission($AllowedUserTypes) != 1) {
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
header('Content-type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hot Lunches - Schools List</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="css/master.css" media="all">
<link rel="stylesheet" type="text/css" href="css/buttons.css" media="all">
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" media="all">
<link rel="stylesheet" type="text/css" href="css/jquery-ui.structure.css" media="all">
<link rel="stylesheet" type="text/css" href="css/jquery-ui.theme.css" media="all">
<link rel="stylesheet" type="text/css" href="css/jquery-ui-timepicker-addon.css" media="all">
<link rel="stylesheet" type="text/css" href="css/custom.css" media="all">
<script language="JavaScript" type="text/javascript" src="include/javascript.js"></script>
<script language="JavaScript" type="text/javascript" src="include/jquery-1.11.1.js"></script>
<script language="JavaScript" type="text/javascript" src="include/jquery-ui-1.11.0.custom/jquery-ui.js"></script>
<script language="JavaScript" type="text/javascript" src="include/jquery.tablednd.js"></script>
<script language="JavaScript" type="text/javascript" src="include/jquery-ui-timepicker-addon.js"></script>
<script language="JavaScript" type="text/javascript">
var today = '2016-02-28';
</script>
<style>
body {
font: 12px Arial, Helvetica, sans-serif;
padding: 0;
}
p {
padding: 0 0 0 15px;
}
h3 {
font: 14px Arial, Helvetica, sans-serif;
font-weight: bold;
}
.country, .country a {
color: #ffffff;
background: #000000;
text-decoration: none;
}
.province, .province a {
color: #000000;
background: #cccccc;
text-decoration: none;
}
a {
color: #000000;
text-decoration: none;
}
.small {
font: 10px Arial, Helvetica, sans-serif;
}
.warning {
background-color: #ffdd33;
}
.error {
background-color: #ff0000;
}
</style>
</head>
<body>
<?php
//
// List of countries and provinces
//
$query = "SELECT country, province, count(*) AS pcount FROM schools WHERE status = 'Active' GROUP BY 1,2";
$results = db_query($query);
$pcountry = "";
while ($row = db_fetch_assoc($results)) {
extract($row);
if ($country != $pcountry) {
if (strlen($pcountry)) echo("</tr></table>\n");
echo("<table cellpadding='2' cellspacing='3'><tr>\n");
echo("<td width='150' align='right' class='country'><b><a href='?country=$country'>$country</a></b></td>\n");
$pcountry = $country;
}
if (strlen($province)) {
$width = 70;
if ($country == 'United Kingdom') $width = '130';
$detail = " <a href='?prov=$province&mode=Detail' title='Details'>+</a>";
echo("<td width='$width' align='center' class='province'><a href='?prov=$province' title='$pcount'>$province <span class='small'>($pcount)</span></a>$detail</td>\n");
}
}
echo("</tr></table>\n");
//
// List of resellers
//
$resellers = db_query("SELECT reseller_code FROM resellers ORDER BY business_name");
$width = 130;
$count = 0;
echo("<br>");
echo("<table width='$width' cellpadding='2' cellspacing='3'><tr>\n");
while ($row = db_fetch_assoc($resellers)) {
$rname = $row['reseller_code'];
// echo("<td width='150' align='right' class='country'><b><a href='?reseller=$rname'>$rname</a></b></td>\n");
$pcount = db_getVal("SELECT count(*) FROM schools WHERE status = 'Active' AND reseller = '$rname'");
$detail = " <a href='?reseller=$rname&mode=Detail' title='Details'>+</a>";
echo("<td width='$width' align='center' class='province'><a href='?reseller=$rname' title='$pcount'>$rname <span class='small'>($pcount)</span></a>$detail</td>\n");
$count++;
if ($count >= 6) {
$count = 0;
echo("</tr><tr>");
}
}
echo("</tr></table>\n");
$rwhere = "";
//
// List of schools
//
if (array_key_exists('reseller',$_GET) && strlen($_GET['reseller'])) {
$reseller = $_GET['reseller'];
$rwhere = "AND reseller = '$reseller' ";
$query = "SELECT * FROM schools WHERE status = 'Active' $rwhere ORDER BY country,province,listing_city,school_name";
}
else {
$pwhere = "AND province = 'BC' ";
if (array_key_exists('prov',$_GET)) $pwhere = "AND province = '$_GET[prov]' ";
if (array_key_exists('country',$_GET)) $pwhere = "AND country = '$_GET[country]' ";
$mode = 'Summary';
$query = "SELECT * FROM schools WHERE status = 'Active' $pwhere ORDER BY country,province,listing_city,school_name";
}
$schools = db_query($query);
$prev_country = "";
$prev_province = "";
$prev_city = "";
if (array_key_exists('mode',$_GET)) $mode = $_GET['mode'];
$output = "";
while ($row = db_fetch_assoc($schools)) {
extract($row);
$city = $listing_city;
$ocity = $city;
$city = trim($city);
if ($city != $ocity) db_query("UPDATE schools SET city = '" . db_escape_string($city) . "' WHERE record_num = $record_num");
if ($prev_province != $province) echo("<h2>$country - $province</h2>");
if ($prev_city != $city) {
$numCity = db_getVal("SELECT count(*) FROM schools WHERE status = 'Active' AND city = '" . db_escape_string($city) . "' $rwhere");
echo("<h3>$city - $numCity</h3>");
}
switch ($mode) {
case 'Detail':
$contacts = "";
$results = db_query("SELECT * FROM school_contact_list WHERE school_num = $record_num ORDER BY sequence");
while ($row = db_fetch_assoc($results)) {
$contacts .= '<br> - ' . $row['contact_name'];
if (strlen($row['contact_phone'])) $contacts .= " - " . $row['contact_phone'];
if (strlen($row['contact_email'])) $contacts .= " - <a href='mailto:" . $row['contact_email'] . "'>" . $row['contact_email'] . "</a>";
}
$edate = $expiry_date;
if (strpos($start_date,'2015-') !== FALSE) {
$start_date = "<span class='warning'>$start_date</span>";
if (strpos($expiry_date,'2016-') !== FALSE) $expiry_date = "<span class='error'>$expiry_date</span>";
}
$expiry_date = "<span id='ed-$record_num' class='expiry-date' snum='$record_num' edate='$edate'>$expiry_date</span>";
echo("<p>");
echo("<b><a href='http://$url'>$school_name</a></b> ($record_num)<br>\n");
echo("$address, $city, $province<br>\nPrincipal: $principal - $phone$contacts<br>");
echo("Start: $start_date - Expiry: $expiry_date");
// Get any linked sites
$results = db_query("SELECT * FROM schools WHERE status = 'Linked' AND linked_site = $record_num ORDER BY link_sequence");
if (db_num_rows($results)) {
while ($row = db_fetch_assoc($results)) {
extract($row);
echo("<br>\n - ($record_num) <a href='http://$url' target='_blank'>$url</a>");
}
}
echo("</p>\n");
break;
case 'Summary':
default:
echo("<p><b><a href='http://$url'>$school_name</a></b> ($record_num)<br>\n$address, $city, $province</p>\n");
break;
}
$prev_country = $country;
$prev_province = $province;
$prev_city = $city;
}
echo(nl2br($output));
$schoolsList = true;
include "include/jquery.hl.php";
include "include/jquery.dialogs.php";
?>
</body>
</html>