86 lines
2.8 KiB
PHP
86 lines
2.8 KiB
PHP
<?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');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
?>
|
|
<br>
|
|
<table width='<?php echo($default_table_width) ?>' cellpadding='5' cellspacing='5' border='0' bgcolor='#eeeeee'>
|
|
<tr>
|
|
<td class='menu-item' align='center'><b>School Revenue</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center' class='menu-item'>
|
|
<?php
|
|
include "schools.options.php";
|
|
|
|
|
|
// Get records to display
|
|
$columnHeaders = array("School Name","Users","Students","Schedules","Orders","Revenue");
|
|
$columnAlign = array('left','center','center','center','center','center','right');
|
|
|
|
$query = "select concat('<a href=http://',url,' target=_blank>',school_name,'</a>') as name,record_num " .
|
|
"from schools " .
|
|
"where status in ('Pending','Trial','Active') " .
|
|
"order by school_name";
|
|
$schools = db_query($query);
|
|
$results = array();
|
|
|
|
|
|
// Setup date range for schedules and orders
|
|
$this_month = date("m",time());
|
|
$this_year = date("Y",time());
|
|
$last_year = $this_year - 1;
|
|
$next_year = $this_year + 1;
|
|
if ($this_month >= '09') {
|
|
$start_date = "{$this_year}-09-01";
|
|
$end_date = "{$next_year}-08-31";
|
|
}
|
|
else {
|
|
$start_date = "{$last_year}-09-01";
|
|
$end_date = "{$this_year}-08-31";
|
|
}
|
|
|
|
$count = 0;
|
|
while ($row = db_fetch_array($schools)) {
|
|
$results[$count][0] = $row['name'];
|
|
$snum = $row['record_num'];
|
|
|
|
$results[$count][1] = db_getVal("select count(*) from users where school_num = $snum");
|
|
$results[$count][2] = db_getVal("select count(*) from people where school_num = $snum and people_type = 'Student'");
|
|
$results[$count][3] = db_getVal("select count(*) from hotlunch_schedules where school_num = $snum and status in ('Pending','Active') and schedule_start_date between '$start_date' and '$end_date'");
|
|
$results[$count][4] = db_getVal("select count(hld.record_num) from hotlunch_menu_dates as hld,hotlunch_schedules as hls " .
|
|
"where hls.school_num = $snum " .
|
|
"and hld.school_num = $snum " .
|
|
"and hls.status in ('Pending','Active') " .
|
|
"and hls.record_num = hld.schedule_num " .
|
|
"and schedule_start_date between '$start_date' and '$end_date'");
|
|
|
|
$count++;
|
|
}
|
|
|
|
|
|
listDataCustom($results,$columnHeaders,'',array(),'N',$columnAlign);
|
|
|
|
echo("<br>\n");
|
|
|
|
include "schools.options.php";
|
|
?>
|
|
</td>
|
|
</tr>
|
|
</table>
|