6548 lines
305 KiB
PHP
6548 lines
305 KiB
PHP
<?php
|
|
|
|
$ValidAccess = 2010;
|
|
require_once("include/globals.php");
|
|
|
|
|
|
if (isset($action) && $action != 'trx-receipt' && (SessionActive() != 1 || ! UserLoggedIn())) {
|
|
logExit("Session is not active\n");
|
|
exit();
|
|
}
|
|
|
|
// CSRF token validation
|
|
include "include/ajax.csrfToken.php";
|
|
|
|
|
|
|
|
// Set default timezone
|
|
// date_default_timezone_set("Canada/Pacific");
|
|
$now = date("Y-m-d H:i:s",time());
|
|
|
|
$moduleName = "ajax.DataTable.Fetch.php";
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') startLog($moduleName);
|
|
// startLog($moduleName);
|
|
|
|
|
|
// Get parameters
|
|
if (array_key_exists('table_name', $_GET)) $table_name = db_escape_string($_GET['table_name']);
|
|
if (array_key_exists('sequence_flag', $_GET)) $sequence_flag = db_escape_string($_GET['sequence_flag']);
|
|
if (array_key_exists('sequence', $_GET)) $sequence_flag = db_escape_string($_GET['sequence']);
|
|
if (array_key_exists('action', $_GET)) $action = db_escape_string($_GET['action']);
|
|
if (array_key_exists('table_id', $_GET)) $table_id = db_escape_string($_GET['table_id']);
|
|
if (array_key_exists('action_name', $_GET)) $action_name = db_escape_string($_GET['action_name']);
|
|
|
|
|
|
writeLog("$action");
|
|
|
|
// Set userType
|
|
$userType = "Parent";
|
|
if (array_key_exists('type', $_SESSION['UserInfo']) && in_array($_SESSION['UserInfo']['type'],$AllAdminUserTypes)) $userType = "Admin";
|
|
|
|
|
|
// Validate parameters
|
|
if (strstr($table_name,' ') !== FALSE) logExit("Invalid table name\n");
|
|
|
|
|
|
|
|
// sequence data if required
|
|
writeLog("sequence_flag: $sequence_flag");
|
|
if (isset($sequence_flag) && $sequence_flag == 'Y') {
|
|
|
|
$stable = $table_name;
|
|
|
|
switch ($table_name) {
|
|
case 'form-fields':
|
|
case '_form_fields':
|
|
$stable = "_form_fields";
|
|
$query = "select * from _form_fields " .
|
|
"order by sequence";
|
|
break;
|
|
|
|
case '_form_actions':
|
|
$query = "select * from _form_actions " .
|
|
"order by sequence";
|
|
break;
|
|
|
|
default:
|
|
$query = "select * from $table_name " .
|
|
"where school_num = $school_num " .
|
|
"order by sequence";
|
|
break;
|
|
}
|
|
|
|
// // Resequence the records
|
|
// writeLog("$query\n");
|
|
// $results = db_query($query);
|
|
// if (db_num_rows($results)) {
|
|
// $count = 1;
|
|
// while ($row = db_fetch_array($results)) {
|
|
// $rnum = $row['record_num'];
|
|
// $query = "update $stable set sequence = $count where record_num = $rnum";
|
|
// db_query($query);
|
|
// $count++;
|
|
// }
|
|
// }
|
|
}
|
|
|
|
|
|
// Return data parameters
|
|
$return_data = array();
|
|
$return_data['content'] = "";
|
|
$return_data['num_records'] = 0;
|
|
$localContent = "";
|
|
$content = "";
|
|
$data = array();
|
|
|
|
|
|
// Default commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
|
|
//
|
|
// Get data based on $action value
|
|
//
|
|
switch ($action) {
|
|
|
|
case 'generic-table-list':
|
|
|
|
// startLog("generic-table-list");
|
|
|
|
if (array_key_exists('table_name', $_GET)) $TableName = $_GET['table_name'];
|
|
if (array_key_exists('actual_table_name', $_GET)) $ActualTableName = $_GET['actual_table_name'];
|
|
if (array_key_exists('action-name', $_GET)) $action_name = db_escape_string($_GET['action-name']);
|
|
if (!isset($TableName)) logExit("$TableName is not set");
|
|
if (isset($TableName)) writeLog("TableName: $TableName");
|
|
if (isset($action_name)) {
|
|
writeLog("action_name: $action_name");
|
|
|
|
$query = "SELECT * FROM _form_actions WHERE action_name = '$action_name'";
|
|
writeLog($query);
|
|
$results = db_query($query);
|
|
$ActionRecord = db_fetch_assoc($results);
|
|
}
|
|
|
|
unset($query);
|
|
|
|
$commands = array();
|
|
$commands[] = "<a href='#' rnum='%d' class='edit-current-record' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='#' rnum='%d' class='delete-current-record' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
$orderBy = "1";
|
|
|
|
writeLog("Generic: $TableName");
|
|
|
|
switch ($TableName) {
|
|
case 'form-actions':
|
|
$columnFields = array('action_name',
|
|
'action_table_name',
|
|
'action_table_load_name',
|
|
'action_sortable_flag',
|
|
'action_searchable_flag',
|
|
'action_default_commands_flag');
|
|
$columnHeaders = array('Action Name',
|
|
'DB Table',
|
|
'DataTable Name',
|
|
'Sortable',
|
|
'Seach Field',
|
|
'Default Commands');
|
|
$columnAlign = array('left',
|
|
'left',
|
|
'left',
|
|
'center',
|
|
'center',
|
|
'center');
|
|
|
|
$cwhere = "";
|
|
$orderBy = "action_name";
|
|
|
|
$commands[] = "<a href='#' class='edit-form-fields' rnum='%d' title='Edit Form Fields'>$file_icon_small</a>";
|
|
$commands[] = "<a href='#' class='edit-form-permissions' rnum='%d' title='Edit Form Permissions'>$users_icon_small</a>";
|
|
$commands[] = "<a href='#' class='execute-action' rnum='%d' title='View Action in Action'>$web_icon_small</a>";
|
|
|
|
$query = "SELECT * FROM _form_actions ORDER BY action_name";
|
|
break;
|
|
|
|
case 'form-fields':
|
|
if (array_key_exists('current_form_action', $_GET)) $action_name = db_escape_string($_GET['current_form_action']);
|
|
if (!isset($action_name)) {
|
|
logExit("action_name is not set");
|
|
}
|
|
|
|
// Validate the sction_name
|
|
$query = "SELECT * FROM _form_actions WHERE action_name = '$action_name'";
|
|
writeLog($query);
|
|
$action_record = db_getVal($query);
|
|
if (!is_array($action_record)) {
|
|
logExit("action_name is invalid: $action_name");
|
|
}
|
|
|
|
$query = "SELECT count(*) FROM _form_fields WHERE action_name = '$action_name'";
|
|
$num = db_getVal($query);
|
|
writeLog("Num Fields Found: $num");
|
|
|
|
if ($num == 0) {
|
|
writeLog("action_table_name: ".$action_record['action_table_name']);
|
|
$table = new Table($action_record['action_table_name']);
|
|
$form_fields = new Table('_form_fields');
|
|
|
|
for ($i = 0; $i < count($table->column_names); $i++) {
|
|
$fname = $table->column_names[$i];
|
|
$ftype = $table->column_types[$i];
|
|
$fvalues = $table->column_values[$i];
|
|
$fdefault = $table->column_defaults[$i];
|
|
$flength = 0;
|
|
|
|
if ($fname == 'school_num') continue;
|
|
if ($fname == 'record_num') continue;
|
|
|
|
switch ($ftype) {
|
|
case 'text':
|
|
$ftype = 'textbox';
|
|
$flength = 60;
|
|
break;
|
|
|
|
case 'varchar':
|
|
case 'int':
|
|
case 'smallint':
|
|
case 'decimal':
|
|
$ftype = 'text';
|
|
$flength = 20;
|
|
break;
|
|
|
|
case 'enum':
|
|
$ftype = 'select';
|
|
if ($fvalues == "'Y','N'") $fvalues = 'YN';
|
|
break;
|
|
}
|
|
|
|
if ($fname == 'sequence') $ftype = 'hidden';
|
|
|
|
$entry = array();
|
|
|
|
$entry['action_name'] = $action_name;
|
|
$entry['action_fields_column_name'] = $fname;
|
|
$entry['action_fields_screen_field_type'] = $ftype;
|
|
$entry['action_fields_field_prompt'] = "TEXT-".strtoupper(str_replace('_','-',$fname));
|
|
$entry['action_fields_text_length'] = $flength;
|
|
$entry['action_fields_insert_active_flag'] = 'Y';
|
|
$entry['action_fields_update_active_flag'] = 'Y';
|
|
$entry['action_fields_required_field_flag'] = 'N';
|
|
$entry['action_fields_default_field_value'] = $fdefault;
|
|
$entry['action_fields_select_options'] = $fvalues;
|
|
$entry['action_fields_report_alignment'] = 'left';
|
|
$entry['sequence'] = $i;
|
|
|
|
$query = $form_fields->BuildInsert($entry);
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
|
|
$columnFields = array('action_fields_column_name','action_fields_screen_field_type','action_fields_report_sequence',
|
|
'action_fields_insert_active_flag','action_fields_update_active_flag','action_fields_required_field_flag');
|
|
$columnHeaders = array('Column Name','Type','Report','Insert Active','Update Active','Required');
|
|
$columnAlign = array('left','left','center','center','center','center');
|
|
|
|
$cwhere = "";
|
|
$orderBy = "sequence, action_name";
|
|
|
|
$query = "SELECT * FROM _form_fields WHERE action_name = '$action_name' ORDER BY sequence, action_name, action_fields_column_name";
|
|
break;
|
|
|
|
case 'form-permissions':
|
|
if (array_key_exists('current_form_action', $_GET)) $action_name = db_escape_string($_GET['current_form_action']);
|
|
|
|
$query = "SELECT * FROM _form_permission WHERE action_name = '$action_name' ORDER BY record_num";
|
|
writeLog($query);
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
$table = new Table('_form_permission');
|
|
$options = GetFileListArray("user_types.txt", "", "");
|
|
|
|
$entry = array();
|
|
$entry['action_name'] = $action_name;
|
|
foreach ($options AS $value => $option) {
|
|
$utype = $option;
|
|
$entry['action_permission_user_type'] = $utype;
|
|
$entry['action_permission_allowed'] = 'N';
|
|
|
|
switch ($utype) {
|
|
case 'System Administrator':
|
|
case 'Application Administrator':
|
|
$entry['action_permission_allowed'] = 'Y';
|
|
break;
|
|
}
|
|
|
|
$query = $table->BuildInsert($entry);
|
|
writeLog($query);
|
|
db_query($query);
|
|
}
|
|
|
|
$query = "SELECT * FROM _form_permission WHERE action_name = '$action_name' ORDER BY record_num";
|
|
writeLog($query);
|
|
$results = db_query($query);
|
|
}
|
|
|
|
$columnFields = array('action_name','action_permission_user_type','action_permission_allowed');
|
|
$columnHeaders = array('Action Name','User Type','Access Allowed');
|
|
$columnAlign = array('left','left','center');
|
|
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$entry = array();
|
|
|
|
$entry[] = $row['action_name'];
|
|
$entry[] = $row['action_permission_user_type'];
|
|
$entry[] = $row['action_permission_allowed'];
|
|
$entry['record_num'] = $row['record_num'];
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
$action = '';
|
|
$totals = array();
|
|
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
echo(json_encode($return_data));
|
|
exit();
|
|
break;
|
|
|
|
case 'staff-people':
|
|
$columnFields = array('first_name','last_name','user_num','staff_category','class_num');
|
|
$columnHeaders = array(getLanguageText('TEXT-FIRST-NAME'),
|
|
getLanguageText('TEXT-LAST-NAME'),
|
|
getLanguageText('TEXT-USER-ID'),
|
|
getLanguageText('TEXT-CATEGORY'),
|
|
$GlobalText['Class'],
|
|
);
|
|
$columnAlign = array('left','left','left','left','center');
|
|
|
|
if ($school_record['special_item_prices'] != 'N') {
|
|
$columnFields[] = 'menu_price_category';
|
|
$columnHeaders[] = getLanguageText('TEXT-MENU-PRICE-CATEGORY');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
if ($school_record['implement_multiple_item_prices'] != 'N') {
|
|
$columnFields[] = 'access_to_multiple_item_prices';
|
|
$columnHeaders[] = getLanguageText('TEXT-ACCESS-TO-FLEX-PRICES');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
$cwhere = " AND people_type = 'Staff' ";
|
|
$orderBy = "last_name,first_name";
|
|
if (array_key_exists('sort-field', $_GET)) $orderBy = db_escape_string($_GET['sort-field']);
|
|
if (array_key_exists('sort-order', $_GET)) $orderBy .= ' '.db_escape_string($_GET['sort-order']);
|
|
|
|
unset($query);
|
|
break;
|
|
|
|
case 'classes':
|
|
$columnFields = array();
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
|
|
if ($school_record['p_display_division'] != 'N' || $school_record['i_display_division'] != 'N') {
|
|
$columnFields[] = 'division';
|
|
$columnHeaders[] = $school_record['division_class_num_text'];
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
if ($school_record['p_display_grade'] != 'N' || $school_record['i_display_grade'] != 'N') {
|
|
$columnFields[] = 'grade';
|
|
$columnHeaders[] = getLanguageText('TEXT-GRADE');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
if ($school_record['p_display_program'] != 'N' || $school_record['i_display_program'] != 'N') {
|
|
$columnFields[] = 'class_program';
|
|
$columnHeaders[] = getLanguageText('TEXT-PROGRAM');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
$columnFields[] = 'description';
|
|
$columnHeaders[] = getLanguageText('TEXT-DESCRIPTION');
|
|
$columnAlign[] = 'left';
|
|
|
|
$columnFields[] = 'label_description';
|
|
$columnHeaders[] = getLanguageText('TEXT-LABEL-DESCRIPTION');
|
|
$columnAlign[] = 'left';
|
|
|
|
$columnFields[] = 'default_price_category';
|
|
$columnHeaders[] = getLanguageText('TEXT-DEFAULT-PRICE-CATEGORY');
|
|
$columnAlign[] = 'center';
|
|
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
writeLog($fname);
|
|
}
|
|
|
|
$orderBy = "sequence";
|
|
$cwhere = "";
|
|
if (array_key_exists('custom-where', $_GET)) $cwhere .= $_GET['custom-where'];
|
|
writeLog("cwhere: $cwhere");
|
|
if (array_key_exists('cwhere', $_GET)) $cwhere .= $_GET['cwhere'];
|
|
writeLog("cwhere: $cwhere");
|
|
|
|
unset($query);
|
|
break;
|
|
|
|
default:
|
|
if (array_key_exists('action-name', $_GET)) $action_name = db_escape_string($_GET['action-name']);
|
|
|
|
$query = "SELECT * FROM _form_fields " .
|
|
"WHERE action_name = '$action_name' " .
|
|
"AND action_fields_report_sequence > 0 " .
|
|
"ORDER BY action_fields_report_sequence, sequence";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
$return_data['content'] = "No Report Fields Defined for : $action_name";
|
|
echo(json_encode($return_data));
|
|
exit();
|
|
}
|
|
|
|
$columnFields = array();
|
|
$columnTypes = array();
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
unset($orderBy);
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$fname = $row['action_fields_column_name'];
|
|
|
|
$skip = false;
|
|
switch ($fname) {
|
|
case 'menu_price_category':
|
|
if ($school_record['special_item_prices'] == 'N') $skip = true;
|
|
break;
|
|
}
|
|
|
|
if ($skip) continue;
|
|
writeLog("school_record['special_item_prices']: ".$school_record['special_item_prices']);
|
|
writeLog("Default: $fname");
|
|
|
|
$columnFields[] = $fname;
|
|
$columnTypes[] = $row['action_fields_screen_field_type'];
|
|
$columnAlign[] = $row['action_fields_report_alignment'];
|
|
$header = $row['action_fields_field_prompt'];
|
|
if (strpos($header, 'TEXT-') === 0) $header = getLanguageText($header);
|
|
if (strpos($header, 'GlobalText.') === 0) {
|
|
$pindex = str_replace('GlobalText.','',$header);
|
|
$header = $GlobalText[$pindex];
|
|
}
|
|
$columnHeaders[] = $header;
|
|
|
|
if (!isset($orderBy)) $orderBy = $row['action_fields_column_name'];
|
|
}
|
|
|
|
writeLog("ActionRecord['action_sort_fields']: ".$ActionRecord['action_sort_fields']);
|
|
if (strlen($ActionRecord['action_sort_fields'])) $orderBy = $ActionRecord['action_sort_fields'];
|
|
|
|
if (array_key_exists('sort-field', $_GET)) $orderBy = db_escape_string($_GET['sort-field']);
|
|
if (array_key_exists('sort-order', $_GET)) $orderBy .= ' '.db_escape_string($_GET['sort-order']);
|
|
if ($sequence_flag == 'Y') $orderBy = "sequence";
|
|
|
|
$cwhere = "";
|
|
if (array_key_exists('custom-where', $_GET)) $cwhere .= $_GET['custom-where'];
|
|
writeLog("cwhere: $cwhere");
|
|
if (array_key_exists('cwhere', $_GET)) $cwhere .= $_GET['cwhere'];
|
|
writeLog("cwhere: $cwhere");
|
|
$cwhere = str_ireplace('where','',$cwhere);
|
|
$cwhere = str_ireplace(';','',$cwhere);
|
|
writeLog("cwhere: $cwhere");
|
|
|
|
unset($query);
|
|
break;
|
|
|
|
}
|
|
|
|
if (!isset($ActualTableName)) $ActualTableName = $TableName;
|
|
if (!isset($cwhere)) $cwhere = "";
|
|
|
|
if (!isset($query)) {
|
|
$table = new Table($ActualTableName);
|
|
writeLog("orderBy: $orderBy");
|
|
if ($table->school_num_flag == 'Y') $query = "SELECT * FROM $ActualTableName WHERE school_num = $school_num $cwhere ORDER BY $orderBy";
|
|
else $query = "SELECT * FROM $ActualTableName WHERE 1 = 1 $cwhere ORDER BY $orderBy";
|
|
}
|
|
writeLog("$TableName query: $query");
|
|
$results = db_query($query);
|
|
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
if ($return_data['num_records'] > 0) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
|
|
$entry = array();
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
$ftype = $columnTypes[$i];
|
|
if (! array_key_exists($fname, $row)) {
|
|
writeLog("fname error: $ActualTableName - $fname");
|
|
continue;
|
|
}
|
|
$fdata = $row[$fname];
|
|
|
|
$fkey = $action_name.'.'.$fname;
|
|
unset($odata);
|
|
if (isset($LookupArrays) && array_key_exists($fkey, $LookupArrays)) {
|
|
$odata = $fdata;
|
|
if (array_key_exists($fdata, $LookupArrays[$fkey])) $fdata = $LookupArrays[$fkey][$fdata];
|
|
else $fdata = "";
|
|
}
|
|
|
|
if (strlen($fdata) && $ftype == 'money') {
|
|
$fdata = '$'.number_format(floatval($fdata), 2);
|
|
}
|
|
|
|
if (array_key_exists('record_num',$row)) {
|
|
$rnum = $row['record_num'];
|
|
if ($i == 0) $fdata = "<span class='edit-current-record' rnum='$rnum'>$fdata</span>";
|
|
else {
|
|
$span_name = str_replace('_','-',$fname).'-data-span';
|
|
$id = str_replace('_','-',$fname).'-data-span-id-'.$rnum;
|
|
$stext = "";
|
|
if (isset($odata)) $stext = " ref-num='$odata'";
|
|
$fdata = "<span id='$id' fname='$fname' rnum='$rnum' class='$span_name'$stext>$fdata</span>";
|
|
}
|
|
}
|
|
$entry[] = $fdata;
|
|
}
|
|
|
|
if (array_key_exists('record_num',$row)) $entry['record_num'] = $row['record_num'];
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
$action = '';
|
|
if (!isset($totals)) $totals = array();
|
|
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
}
|
|
else {
|
|
writeLog("No Records");
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
echo(json_encode($return_data));
|
|
exit();
|
|
}
|
|
|
|
// writeLog($return_data['content']);
|
|
writeLog("end of generic-table-list");
|
|
break;
|
|
|
|
|
|
case 'polls':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-TITLE'),
|
|
getLanguageText('TEXT-QUESTIONS'),
|
|
getLanguageText('TEXT-ANSWERS'),
|
|
);
|
|
$columnAlign = array('left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "SELECT * FROM polls WHERE school_num = $school_num ORDER BY sequence";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
if (strlen(trim($description))) $description = "<br><span class='small'>".trim($description)."</span>";
|
|
$numQuestions = db_getVal("SELECT count(*) FROM poll_questions WHERE school_num = $school_num AND poll_num = $record_num");
|
|
$numAnswers = db_getVal("SELECT count(distinct user_num) FROM poll_answers WHERE school_num = $school_num AND poll_num = $record_num");
|
|
|
|
// Format for admin display
|
|
$data[] = array("<span class='edit-poll' rnum='$record_num' onClick=''><b>$poll_title</b></span>$description",
|
|
"<span class='poll-questions' rnum='$record_num' onClick=''>$numQuestions</span>",
|
|
"<span class='poll-questions' rnum='$record_num' onClick=''>$numAnswers</span>",
|
|
"record_num" => $record_num,
|
|
"delete_flag" => 'Y');
|
|
|
|
}
|
|
|
|
$commands = array();
|
|
$commands[] = "<a href='?action=$action&naction=edit&record_num=%d' class='edit-poll' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?action=$action&naction=delete-confirmed&record_num=%d' class='delete-poll' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
$commands[] = "<a href='?action=$action&naction=view-details&record_num=%d' class='poll-answers' rnum='%d' title='View Questions'>$view_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'delivery-groups':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-GROUP'),
|
|
getLanguageText('TEXT-TITLE'),
|
|
getLanguageText('TEXT-CLASSES'),
|
|
);
|
|
$columnAlign = array('center','center','center');
|
|
|
|
// Get records to display
|
|
$query = "SELECT * FROM delivery_groups WHERE school_num = $school_num ORDER BY sequence,group_id";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
$numEntries = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND delivery_group = '$group_id'");
|
|
if ($numEntries) $delete_flag = 'N';
|
|
|
|
$data[] = array($group_id,
|
|
$group_title,
|
|
$numEntries,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 450;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'student-categories':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-CATEGORY'),
|
|
getLanguageText('TEXT-NUMBER'),
|
|
);
|
|
$columnAlign = array('left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "SELECT * FROM student_categories WHERE school_num = $school_num ORDER BY sequence";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
$warnings = "";
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$numEntries = db_getVal("SELECT count(*) FROM people_categories WHERE school_num = $school_num AND category_num = $record_num");
|
|
$warnings .= "<input type='hidden' id='warning-msg-$record_num' value='".getLanguageText('TEXT-GROUP-DELETE-WARNING-MESSAGE')."'>\n";
|
|
|
|
if (!isset($delete_flag)) $delete_flag = 'Y';
|
|
if ($numEntries > 0) $delete_flag = 'N';
|
|
$data[] = array($category,
|
|
$numEntries,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
$commands[] = "<a href='#' class='view-student-list' rnum='%d' dflag='%s' gname='category_num' title='View Class List'>$students_icon_small</a>";
|
|
// $commands[] = "<a href='?record_num=%d' class='view-details' rnum='%d' title='View Details'>$view_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 450;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
$return_data['content'] .= $warnings;
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'staff-categories':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-CATEGORY'),
|
|
getLanguageText('TEXT-NUMBER'),
|
|
getLanguageText('TEXT-DEFAULT'),
|
|
);
|
|
$columnAlign = array('left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "SELECT * FROM staff_categories WHERE school_num = $school_num ORDER BY sequence";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
$numEntries = db_getVal("SELECT count(*) FROM people WHERE school_num = $base_school_num AND people_type = 'Staff' AND staff_category = $record_num");
|
|
if ($numEntries) $delete_flag = 'N';
|
|
|
|
if (!isset($is_default)) $is_default = '';
|
|
|
|
$data[] = array($category_title,
|
|
$numEntries,
|
|
"<span class='is-default' rnum='$record_num'>$is_default</span>",
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 450;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'staff-list':
|
|
// Are staff categories in use
|
|
$nCategories = db_getVal("SELECT count(*) FROM people WHERE school_num = $school_num AND people_type = 'Staff' AND staff_category > 0");
|
|
|
|
// Setup format
|
|
$columnHeaders = array();
|
|
$columnHeaders[] = getLanguageText('TEXT-NAME');
|
|
if ($nCategories > 0) $columnHeaders[] = getLanguageText('TEXT-CATEGORY');
|
|
$columnHeaders[] = getLanguageText('TEXT-USER-ID');
|
|
$columnHeaders[] = getLanguageText('TEXT-CLASS');
|
|
|
|
$columnAlign = array();
|
|
$columnAlign[] = 'left';
|
|
if ($nCategories > 0) $columnAlign[] = 'center';
|
|
$columnAlign[] = 'left';
|
|
$columnAlign[] = 'left';
|
|
|
|
if ($school_record['special_item_prices'] != 'N') {
|
|
$columnHeaders[] = getLanguageText('TEXT-MENU-PRICE-CATEGORY');
|
|
$columnAlign[] = "center";
|
|
}
|
|
|
|
$div_text = $school_record['division_class_num_text'];
|
|
$query = "SELECT p.*,category_title " .
|
|
"FROM people AS p LEFT JOIN staff_categories AS sc ON (sc.school_num = $school_num AND sc.record_num = p.staff_category) " .
|
|
"WHERE p.school_num = $base_school_num " .
|
|
"AND people_type = 'Staff' " .
|
|
"ORDER BY last_name,first_name";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
// Format the name
|
|
if (strlen($title)) $name = "$title $first_name $last_name";
|
|
else $name = "$first_name $last_name";
|
|
|
|
// Get and format userid
|
|
$userid = '';
|
|
|
|
$ruser = db_query("SELECT * FROM users WHERE school_num = $base_school_num AND record_num = $user_num");
|
|
if (db_num_rows($ruser)) {
|
|
$user = db_fetch_assoc($ruser);
|
|
$userid = $user['userid'];
|
|
$userid = "<a href='/?action=users&naction=lookup&userid=$userid'>$userid</a>";
|
|
|
|
// If there is an email address create a link for the name field
|
|
if (strlen($user['email']) && strstr($user['email'],'@')) {
|
|
$name = "<a href='mailto:" . $user['email'] . "'>$name</a>";
|
|
}
|
|
}
|
|
|
|
$numOrders = 0;
|
|
$numOrders = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $record_num");
|
|
if ($numOrders > 0) $name .= " ($numOrders)";
|
|
|
|
if ($school_record['implement_meal_locations'] == 'Y') {
|
|
$location = "";
|
|
if ($meal_location > 0) {
|
|
if ($meal_location != $class_num) {
|
|
$location = "<span class='small warning'>" . db_getVal("SELECT description FROM classes WHERE school_num = $base_school_num AND record_num = $meal_location") . "</span>";
|
|
}
|
|
else {
|
|
$location = "<span class='small'>" . getLanguageText('TEXT-CLASSROOM') . "</span>";
|
|
}
|
|
}
|
|
if (strlen($location)) $name .= "<br>$location";
|
|
}
|
|
|
|
$class_num = db_getVal("SELECT record_num FROM classes WHERE teacher1 = $record_num ORDER BY sequence LIMIT 1");
|
|
$classinfo = '';
|
|
if (isset($class_num) && $class_num > 3) {
|
|
$classinfo = getClassInfo($class_num, 'internal');
|
|
db_query("UPDATE people SET class_num = $class_num WHERE school_num = $school_num AND people_type = 'Staff' AND record_num = $record_num");
|
|
}
|
|
else $classinfo = getLanguageText('TEXT-'.strtoupper($people_type));
|
|
|
|
$entry = array();
|
|
$entry[] = $name;
|
|
if ($nCategories > 0)$entry[] = $category_title;
|
|
$entry[] = $userid;
|
|
if (strlen($classinfo) > 50) $classinfo = substr($classinfo, 0, 45)."...";
|
|
$entry[] = $classinfo;
|
|
|
|
if ($school_record['special_item_prices'] == 'Y') {
|
|
$mcat = strtolower(str_replace(' ','',$menu_price_category));
|
|
$mclass = '';
|
|
$menu_price_category_text = getLanguageText('TEXT-'.$menu_price_category);
|
|
if ($menu_price_category != 'Regular') {
|
|
$mclass = 'warning';
|
|
switch ($menu_price_category) {
|
|
case 'Special 1':
|
|
if (strlen($school_record['special1_text'])) $menu_price_category_text = $school_record['special1_text'];
|
|
break;
|
|
case 'Special 2':
|
|
if (strlen($school_record['special2_text'])) $menu_price_category_text = $school_record['special2_text'];
|
|
break;
|
|
case 'Special 3':
|
|
if (strlen($school_record['special3_text'])) $menu_price_category_text = $school_record['special3_text'];
|
|
break;
|
|
}
|
|
}
|
|
|
|
$menu_price_category = "<span class='price-category' snum='$record_num' mcat='$mcat'><span class='$mclass'>" . $menu_price_category_text . "</span></span>";
|
|
$entry[] = $menu_price_category;
|
|
}
|
|
|
|
$entry['record_num'] = $record_num;
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 900;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'application-contacts':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-NAME'),
|
|
getLanguageText('TEXT-EMAIL'),
|
|
getLanguageText('TEXT-PHONE'),
|
|
getLanguageText('TEXT-CELL-PHONE'),
|
|
getLanguageText('TEXT-POSITION'),
|
|
);
|
|
$columnAlign = array('left','left','left','left','left');
|
|
|
|
// Get records to display
|
|
$query = "SELECT contact_name,contact_email,contact_phone,contact_cell,contact_position,sequence,record_num " .
|
|
"FROM school_contact_list " .
|
|
"WHERE school_num = $school_num " .
|
|
"ORDER BY sequence";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
$num = db_num_rows($results);
|
|
|
|
if ($num > 0) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
|
|
$delete_flag = 'Y';
|
|
if ($num == 1) $delete_flag = 'N';
|
|
|
|
$email = $row['contact_email'];
|
|
$data[] = array(
|
|
$row['contact_name'],
|
|
"<a href='mailto:$email'>$email</a>",
|
|
$row['contact_phone'],
|
|
$row['contact_cell'],
|
|
$row['contact_position'],
|
|
$row['sequence'],
|
|
"record_num" => $row['record_num'],
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 650;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'user-account-trx-codes':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-TRANSACTION-CODE'),
|
|
getLanguageText('TEXT-CATEGORY'),
|
|
getLanguageText('TEXT-COUNT')
|
|
);
|
|
$columnAlign = array('left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "select transaction_type_code,trx_category,sequence,record_num " .
|
|
"from user_account_trx_codes " .
|
|
"where school_num = $school_num " .
|
|
"order by trx_category,sequence";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$count = db_getVal("SELECT count(*) FROM user_account WHERE school_num = $school_num AND transaction_type = '$transaction_type_code'");
|
|
$delete_flag = 'Y';
|
|
if ($count > 0) $delete_flag = 'N';
|
|
|
|
$trxCat = getLanguageText('TEXT-'.$trx_category);
|
|
$data[] = array($transaction_type_code,
|
|
$trxCat,
|
|
$count,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 650;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'admin-user-access-list':
|
|
|
|
// Get records to display
|
|
$query = "SELECT userid, record_num FROM users " .
|
|
"WHERE school_num = $base_school_num " .
|
|
"AND type NOT IN ('Parent','Staff','Guest','Application Volunteer','Schedule Volunteer')";
|
|
$users = db_query($query);
|
|
|
|
$content = "";
|
|
$schoolName = $school_record['school_name'];
|
|
|
|
if (db_num_rows($users) > 0) {
|
|
$content = "<h2>$schoolName</h2>\n";
|
|
$content .= "<table width='400' cellpadding='2' cellspacing='2' class='content-table'>";
|
|
$content .= "<tr class='heading'>";
|
|
$content .= "<td width='80%' >".getLanguageText('TEXT-USER-ID')."</td>";
|
|
$content .= "<td align='center'>".getLanguageText('TEXT-ACCESS')."</td>";
|
|
$content .= "</tr>";
|
|
|
|
$class = 'data-odd';
|
|
while ($row = db_fetch_assoc($users)) {
|
|
extract($row);
|
|
|
|
$access = 'N';
|
|
$query = "SELECT * FROM admin_user_access WHERE school_num = $school_num AND user_num = $record_num";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$r = db_fetch_assoc($results);
|
|
$access = $r['access'];
|
|
$rnum = $r['record_num'];
|
|
}
|
|
else {
|
|
$query = "INSERT INTO admin_user_access (school_num,user_num,access) VALUES ($school_num, $record_num, 'N')";
|
|
db_query($query);
|
|
$rnum = db_insert_id();
|
|
}
|
|
|
|
if ($class == 'data-odd') $class = 'data-even';
|
|
else $class = 'data-odd';
|
|
|
|
$content .= "<tr class='$class'>";
|
|
$content .= "<td>$userid</td>";
|
|
$content .= "<td align='center'><span class='admin-access' rnum='$rnum'>$access</span></td>";
|
|
$content .= "</tr>";
|
|
}
|
|
|
|
$content .= "</table>";
|
|
}
|
|
$return_data['content'] = $content;
|
|
break;
|
|
|
|
case 'class-programs':
|
|
// Setup format
|
|
$columnHeaders = array($GlobalText['ClassProgram'],
|
|
getLanguageText('TEXT-NUMBER'),
|
|
);
|
|
$columnAlign = array('left','center');
|
|
|
|
// Get records to display
|
|
$query = "SELECT program_name,count(c.record_num) AS count,cp.sequence,cp.record_num " .
|
|
"FROM class_programs as cp left join classes as c on c.class_program = cp.record_num " .
|
|
"WHERE cp.school_num = $school_num " .
|
|
"GROUP BY 1,3,4 " .
|
|
"ORDER BY sequence,program_name";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
if ($count > 0) $delete_flag = 'N';
|
|
|
|
$data[] = array($program_name,
|
|
$count,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 450;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'deposit-amounts':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-AMOUNT'));
|
|
$columnAlign = array('center');
|
|
|
|
// Get records to display
|
|
$query = "select amount,record_num " .
|
|
"from account_deposit_amounts " .
|
|
"where school_num = $school_num " .
|
|
"order by amount";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
|
|
$data[] = array($currencySymbol.number_format($amount,2),
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 350;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'organization-contacts':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-POSITION'),
|
|
getLanguageText('TEXT-NAME'),
|
|
getLanguageText('TEXT-EMAIL'),
|
|
);
|
|
$columnAlign = array('left','left','left');
|
|
|
|
// Get records to display
|
|
$query = "select position,person,email,sequence,record_num " .
|
|
"from organization_contacts " .
|
|
"where school_num = $school_num " .
|
|
"order by sequence,position";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
|
|
$data[] = array($position,
|
|
$person,
|
|
$email,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 650;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'payment-discounts':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-TYPE'),
|
|
getLanguageText('TEXT-AMOUNT'),
|
|
getLanguageText('TEXT-START-DATE'),
|
|
getLanguageText('TEXT-END-DATE')
|
|
);
|
|
$columnAlign = array('left','center','center','center');
|
|
|
|
// Get records to display
|
|
$query = "select discount_type,discount,start_date,end_date,record_num " .
|
|
"from payment_discounts " .
|
|
"where school_num = $school_num " .
|
|
"order by start_date,end_date";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
|
|
$data[] = array($discount_type,
|
|
$currencySymbol.number_format($discount,2),
|
|
$start_date,
|
|
$end_date,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 600;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'document-categories':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-TITLE'),
|
|
getLanguageText('TEXT-DOCUMENTS'),
|
|
);
|
|
$columnAlign = array('left','center');
|
|
|
|
// Get records to display
|
|
$query = "select dc.category,count(d.record_num) as number,dc.sequence,dc.record_num " .
|
|
"from document_categories as dc left join documents as d on d.school_num = $school_num and d.category_num = dc.record_num " .
|
|
"where dc.school_num = $base_school_num " .
|
|
"group by 1,3,4 " .
|
|
"order by sequence,category";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
if ($number > 0) $delete_flag = 'N';
|
|
|
|
$data[] = array($category,
|
|
$number,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 450;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'documents':
|
|
// Set document path
|
|
$documentPath = "files/" . sprintf("%08d",$school_num) . "/uploads/";
|
|
|
|
// Get set of documents in system
|
|
$columnHeaders = array(getLanguageText('TEXT-FILE'),
|
|
getLanguageText('TEXT-TITLE'),
|
|
getLanguageText('TEXT-DATE'),
|
|
getLanguageText('TEXT-STATUS'));
|
|
$columnAlign = array("left","left","center","center");
|
|
$query = "SELECT document_name,document_title,notes,added_datetime,status,record_num FROM school_documents " .
|
|
"WHERE school_num = $school_num " .
|
|
"ORDER BY added_datetime DESC";
|
|
writeLog("query: $query");
|
|
$documents = db_query($query);
|
|
|
|
$cutoff = date("Y-m-d 00:00:00",time() - 60 * 60 * 24 * 30);
|
|
$data = array();
|
|
if (db_num_rows($documents)) {
|
|
while ($row = db_fetch_assoc($documents)) {
|
|
extract($row);
|
|
$entry = array();
|
|
|
|
if (!file_exists("$documentPath$document_name")) {
|
|
if ($status == 'Uploaded') db_query("UPDATE school_documents SET status = 'Deleted' WHERE school_num = $school_num AND record_num = $record_num");
|
|
$status = 'Deleted';
|
|
}
|
|
|
|
if ($status == 'Deleted' && $added_datetime < $cutoff) {
|
|
db_query("DELETE FROM school_documents WHERE school_num = $school_num AND record_num = $record_num");
|
|
continue;
|
|
}
|
|
|
|
if (!isset($notes)) $notes = '';
|
|
$note = str_replace("'","'",$notes);
|
|
$entry[] = "<a href='$documentPath$document_name' title='$note' target='_blank'>$document_name</a>";
|
|
$entry[] = $document_title;
|
|
$entry[] = $added_datetime;
|
|
$entry[] = $status;
|
|
$entry['record_num'] = $record_num;
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
$commands = array();
|
|
$commands[] = "<a href='#' class='delete-document command-icon' rnum='%d' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
writeLog("table_id: $table_id\n");
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,array());
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- " . getLanguageText('ERRORMSG-NO-RECORDS') . " --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'content-tabs':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-TITLE'),
|
|
getLanguageText('TEXT-VISIBLE-TO-PARENTS'),
|
|
getLanguageText('TEXT-PAGES'),
|
|
);
|
|
$columnAlign = array('left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "select ct.tab_title,ct.visible_to_parents,count(fc.record_num) as number,ct.sequence,ct.record_num " .
|
|
"from content_tabs as ct left join formatted_content as fc on fc.tab_num = ct.record_num " .
|
|
"where ct.school_num = $school_num " .
|
|
"group by 1,2,4,5 " .
|
|
"order by 4,1";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
if ($number > 0) $delete_flag = 'N';
|
|
|
|
$data[] = array($tab_title,
|
|
$visible_to_parents,
|
|
$number,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 550;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'page-content':
|
|
// startLog('page-content');
|
|
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-PAGE-NAME'),
|
|
getLanguageText('TEXT-DATE-MODIFIED'),
|
|
);
|
|
$columnAlign = array('left','center');
|
|
|
|
// Get records to display
|
|
$query = "select content_id,date_modified,record_num " .
|
|
"from formatted_content " .
|
|
"where school_num = $school_num " .
|
|
"and content_type = 'C' " .
|
|
"order by content_id";
|
|
writeLog("query: $query");
|
|
$results = db_query($query);
|
|
$numPages = db_num_rows($results);
|
|
writeLog("Pages: $numPages");
|
|
$return_data['num_records'] = $numPages;
|
|
|
|
if ($numPages == 0) {
|
|
$today = date("Y-m-d",time());
|
|
$pQuery = $query;
|
|
|
|
$query = "INSERT INTO formatted_content (school_num,content_id,content_title,content_type,tab_num,date_added,date_modified) " .
|
|
"VALUES($school_num,'Login Page','','C',0,'$today','$today')";
|
|
writeLog("query: $query");
|
|
db_query($query);
|
|
|
|
$query = "INSERT INTO formatted_content (school_num,content_id,content_title,content_type,tab_num,date_added,date_modified) " .
|
|
"VALUES($school_num,'Welcome Page','','C',0,'$today','$today')";
|
|
writeLog("query: $query");
|
|
db_query($query);
|
|
|
|
$results = db_query($pQuery);
|
|
$numPages = db_num_rows($results);
|
|
}
|
|
|
|
if ($numPages > 0) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
$content_id = getLanguageText('ID-'.$content_id);
|
|
$content_id .= "<input type='hidden' id='content_id_$record_num' value='$content_id'>";
|
|
|
|
$data[] = array($content_id,
|
|
$date_modified,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$reset_icon = "<img src='images/icons/refresh24.png' alt='Refresh Page Content' border='0'>";
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='reset-content' rnum='%d' title='Reset Page Content'>$reset_icon</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 650;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'additional-pages':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-MENU-TAB'),
|
|
getLanguageText('TEXT-PAGE-NAME'),
|
|
getLanguageText('TEXT-DATE-MODIFIED'),
|
|
getLanguageText('TEXT-PUBLIC'),
|
|
);
|
|
$columnAlign = array('left','left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "select ct.tab_title,content_id,date_modified,public_page,fc.record_num,ct.sequence as tab_sequence,fc.sequence " .
|
|
"from formatted_content as fc left join content_tabs as ct on ct.record_num = fc.tab_num " .
|
|
"where fc.school_num = $school_num " .
|
|
"and fc.content_type = 'A' " .
|
|
"order by tab_sequence,sequence,content_id";
|
|
writeLog("query: $query");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
|
|
if (strlen($tab_title) == 0) $tab_title = "-- ".getLanguageText('MENUTAB-HOME')." --";
|
|
|
|
$flag = 'Y';
|
|
if ($public_page == 'Y') $flag = 'N';
|
|
$public_page = "<span class='public-flag' flag='$flag' rnum='$record_num'> $public_page </span>";
|
|
|
|
$data[] = array($tab_title,
|
|
$content_id,
|
|
$date_modified,
|
|
$public_page,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 650;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'delivery-classes':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-CLASS'),
|
|
getLanguageText('TEXT-DELIVERY-GROUP'),
|
|
);
|
|
$columnAlign = array('left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "SELECT * FROM classes WHERE school_num = $base_school_num ORDER BY sequence";
|
|
writeLog("query: $query");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
// Get delivery groups
|
|
$query = "SELECT * FROM delivery_groups WHERE school_num = $school_num ORDER BY sequence";
|
|
writeLog("query: $query");
|
|
$groups = db_query($query);
|
|
if (db_num_rows($groups)) {
|
|
$groupEntries = array();
|
|
while ($row = db_fetch_assoc($groups)) {
|
|
$groupEntries[] = $row;
|
|
}
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('TEXT-NO-DELIVERY-GROUPS-FOUND')." --- </b></p>";
|
|
return;
|
|
}
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$classInfo = getClassInfo($record_num, 'internal');
|
|
|
|
$groupField = "<select name='delivery_group_$record_num' class='delivery-group' rnum='$record_num'>";
|
|
$groupField .= "<option></option>";
|
|
for ($i = 0; $i < count($groupEntries); $i++) {
|
|
$gRow = $groupEntries[$i];
|
|
$selected = "";
|
|
if ($delivery_group == $gRow['group_id']) $selected = " selected='selected'";
|
|
$groupField .= "<option value=\"".$gRow['group_id']."\"$selected>".$gRow['group_title']."</option>";
|
|
}
|
|
$groupField .= "</select>";
|
|
|
|
$data[] = array($classInfo, $groupField);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 600;
|
|
if (!isset($totals)) $totals = array();
|
|
if (isset($totals)) $return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'classes-list':
|
|
// startLog('classes-list');
|
|
|
|
$columnFields = array();
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
|
|
$columnFields[] = 'teachers';
|
|
$columnHeaders[] = $GlobalText['Teacher'];
|
|
$columnAlign[] = 'left';
|
|
|
|
if ($school_record['p_display_division'] != 'N' || $school_record['i_display_division'] != 'N') {
|
|
$columnFields[] = 'division';
|
|
$columnHeaders[] = $school_record['division_class_num_text'];
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
if ($school_record['p_display_grade'] != 'N' || $school_record['i_display_grade'] != 'N') {
|
|
$columnFields[] = 'grade';
|
|
$columnHeaders[] = getLanguageText('TEXT-GRADE');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
if ($school_record['p_display_program'] != 'N' || $school_record['i_display_program'] != 'N') {
|
|
$columnFields[] = 'class_program';
|
|
$columnHeaders[] = getLanguageText('TEXT-PROGRAM');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
$columnFields[] = 'description';
|
|
$columnHeaders[] = getLanguageText('TEXT-DESCRIPTION');
|
|
$columnAlign[] = 'left';
|
|
|
|
// $columnFields[] = 'label_description';
|
|
// $columnHeaders[] = getLanguageText('TEXT-LABEL-DESCRIPTION');
|
|
// $columnAlign[] = 'left';
|
|
|
|
$columnFields[] = 'default_price_category';
|
|
$columnHeaders[] = getLanguageText('TEXT-DEFAULT-PRICE-CATEGORY');
|
|
$columnAlign[] = 'center';
|
|
|
|
if ($school_record['implement_delivery_groups'] == 'Y') {
|
|
$columnFields[] = 'delivery_group';
|
|
$columnHeaders[] = getLanguageText('TEXT-DELIVERY-GROUP');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
$columnFields[] = 'num_students';
|
|
$columnHeaders[] = getLanguageText('TEXT-NUMBER');
|
|
$columnAlign[] = 'center';
|
|
|
|
|
|
// Get set of class programs
|
|
$Programs = array();
|
|
$query = "SELECT * FROM class_programs WHERE school_num = $base_school_num ORDER BY sequence";
|
|
writeLog("query: $query");
|
|
$results = db_query($query);
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$Programs[$row['record_num']] = $row['program_name'];
|
|
}
|
|
|
|
// Get records to display
|
|
$query = "SELECT * FROM classes WHERE school_num = $base_school_num AND entry_type = 'Class' ORDER BY sequence";
|
|
writeLog("query: $query");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
writeLog("Classes: ".db_num_rows($results));
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
writeLog(print_r($row,true));
|
|
|
|
$teachers = '';
|
|
if (intval($teacher1) > 0) {
|
|
$r = db_getVal("SELECT title,first_name,last_name FROM people WHERE school_num = $base_school_num AND record_num = $teacher1");
|
|
if (is_array($r)) {
|
|
extract($r);
|
|
if ($school_record['staff_titles'] == 'Y') $teachers = "$title $first_name $last_name";
|
|
else $teachers = "$first_name $last_name";
|
|
}
|
|
}
|
|
|
|
if (intval($teacher2) > 0) {
|
|
$r = db_getVal("SELECT title,first_name,last_name FROM people WHERE school_num = $base_school_num AND record_num = $teacher2");
|
|
if (is_array($r)) {
|
|
extract($r);
|
|
if ($school_record['staff_titles'] == 'Y') $teachers .= "<br>$title $first_name $last_name";
|
|
else $teachers .= "<br>$first_name $last_name";
|
|
}
|
|
}
|
|
|
|
$num_students = db_getVal("SELECT count(*) FROM people WHERE school_num = $base_school_num AND class_num = $record_num AND people_type != 'Student'");
|
|
$delete_flag = 'Y';
|
|
if ($num_students > 0) $delete_flag = 'N';
|
|
|
|
$entry = array();
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
$value = $$fname;
|
|
|
|
if ($fname == 'class_program' && array_key_exists($value, $Programs)) $value = $Programs[$value];
|
|
if ($fname == 'default_price_category') {
|
|
$ftext = getLanguageText('TEXT-'.$default_price_category);
|
|
$mclass = '';
|
|
if ($default_price_category != 'Regular') {
|
|
$mclass = 'warning';
|
|
switch ($default_price_category) {
|
|
case 'Special 1':
|
|
if (strlen($school_record['special1_text'])) $ftext = $school_record['special1_text'];
|
|
break;
|
|
case 'Special 2':
|
|
if (strlen($school_record['special2_text'])) $ftext = $school_record['special2_text'];
|
|
break;
|
|
case 'Special 3':
|
|
if (strlen($school_record['special3_text'])) $ftext = $school_record['special3_text'];
|
|
break;
|
|
}
|
|
}
|
|
|
|
$mcat = strtolower(str_replace(' ','',$default_price_category));
|
|
$ftext = "<span class='price-category' snum='$record_num' mcat='$mcat'><span class='$mclass'>" . $ftext . "</span></span>";
|
|
$value = $ftext;
|
|
}
|
|
|
|
$tText = $value;
|
|
if ($fname == 'description' && strlen($value) > 50) {
|
|
$value = substr($value, 0, 45)."...";
|
|
$value = "<span title='$tText'>$value</span>";
|
|
}
|
|
if ($fname == 'grade' && strlen($value) > 30) {
|
|
$value = substr($value, 0, 25)."...";
|
|
$value = "<span title='$tText'>$value</span>";
|
|
}
|
|
// $entry[] = "<span title='$tText'>$value</span>";
|
|
$entry[] = $value;
|
|
}
|
|
$entry['record_num'] = $record_num;
|
|
$entry['delete_flag'] = $delete_flag;
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='m=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='#' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
$commands[] = "<a href='#' class='view-class-list' rnum='%d' dflag='%s' title='View Class List'>$students_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
writeLog("customTableID: $customTableID");
|
|
$TableWidth = 850;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'locations-list':
|
|
$columnFields = array();
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
|
|
$columnFields[] = 'description';
|
|
$columnHeaders[] = getLanguageText('TEXT-DESCRIPTION');
|
|
$columnAlign[] = 'left';
|
|
|
|
$columnFields[] = 'label_description';
|
|
$columnHeaders[] = getLanguageText('TEXT-LABEL-DESCRIPTION');
|
|
$columnAlign[] = 'left';
|
|
|
|
if ($school_record['implement_delivery_groups'] == 'Y') {
|
|
$columnFields[] = 'delivery_group';
|
|
$columnHeaders[] = getLanguageText('TEXT-DELIVERY-GROUP');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
// Get records to display
|
|
$query = "SELECT * FROM classes WHERE school_num = $base_school_num AND entry_type = 'Location' ORDER BY sequence";
|
|
writeLog("query: $query");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$entry = array();
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
|
|
$value = $$fname;
|
|
if ($fname == 'class_program') $value = $Programs[$value];
|
|
$entry[] = $value;
|
|
}
|
|
$entry['record_num'] = $record_num;
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
writeLog("customTableID: $customTableID");
|
|
$TableWidth = 850;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'suppliers-list':
|
|
$set = 'Active';
|
|
if (array_key_exists('set', $_GET)) $set = $_GET['set'];
|
|
|
|
$columnFields = array();
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
|
|
$columnFields[] = 'supplier_name';
|
|
$columnHeaders[] = getLanguageText('TEXT-SUPPLIER');
|
|
$columnAlign[] = 'left';
|
|
|
|
$columnFields[] = 'contact_name';
|
|
$columnHeaders[] = getLanguageText('TEXT-CONTACT-PERSON');
|
|
$columnAlign[] = 'left';
|
|
|
|
$columnFields[] = 'work_phone';
|
|
$columnHeaders[] = getLanguageText('TEXT-PHONE');
|
|
$columnAlign[] = 'left';
|
|
|
|
$columnFields[] = 'status';
|
|
$columnHeaders[] = getLanguageText('TEXT-STATUS');
|
|
$columnAlign[] = 'left';
|
|
|
|
$columnFields[] = 'num_products';
|
|
$columnHeaders[] = getLanguageText('TEXT-PRODUCTS');
|
|
$columnAlign[] = 'center';
|
|
|
|
$swhere = "";
|
|
if ($set == 'Active') $swhere = "and s.status NOT IN ('Inactive','Deleted') ";
|
|
|
|
// Get records to display
|
|
$query = "select supplier_name,contact_name,work_phone,s.status," .
|
|
"count(distinct sp.record_num) as num_products,email,s.school_num as actual_school_num,s.record_num " .
|
|
"from suppliers as s left join supplier_products as sp on " .
|
|
"sp.school_num = $supplier_school_num and s.record_num = sp.supplier_num AND sp.status = 'Active' AND product_type = 'Product' " .
|
|
"where s.school_num = $supplier_school_num " .
|
|
$swhere .
|
|
"group by 1,2,3,4,6,7,8 " .
|
|
"order by supplier_name";
|
|
writeLog("query: $query");
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$entry = array();
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
|
|
$value = $$fname;
|
|
if ($fname == 'num_products' && intval($value) > 0) {
|
|
$query = "SELECT * FROM supplier_products " .
|
|
"WHERE school_num = $supplier_school_num " .
|
|
"AND supplier_num = $record_num " .
|
|
"AND status = 'Active' " .
|
|
"AND product_type = 'Product' " .
|
|
"ORDER BY sequence";
|
|
$products = db_query($query);
|
|
$numProducts = db_num_rows($products);
|
|
$value = $numProducts;
|
|
$entry['delete_flag'] = 'Y';
|
|
|
|
if ($numProducts > 0) {
|
|
$Tip = "<table width='450' cellpadding='3'>" .
|
|
"<tr>" .
|
|
"<td align='left'><b>".getLanguageText('TEXT-PRODUCT')."</b></td>" .
|
|
"<td align='left'><b>".getLanguageText('TEXT-COST')."</b></td>" .
|
|
"<td align='left'><b>".getLanguageText('TEXT-PRICE')."</b></td>" .
|
|
"</tr>";
|
|
|
|
$pcount = 0;
|
|
while ($prow = db_fetch_array($products)) {
|
|
$Tip .= "<tr>" .
|
|
"<td align='left'>" . $prow['product_name'] . "</td>" .
|
|
"<td align='left'>$" . number_format($prow['package_cost'],2) . "</td>" .
|
|
"<td align='left'>$" . number_format($prow['standard_online_price'],2) . "</td>" .
|
|
"</tr>";
|
|
$pcount++;
|
|
if ($pcount > 15) {
|
|
$Tip .= "<tr><td align='left'><b>$numProducts " . getLanguageText('TEXT-TOTAL-ITEMS') . "</b></td></tr>";
|
|
break 1;
|
|
}
|
|
}
|
|
|
|
$Tip .= "</table>";
|
|
$value = "<div class='hl-tooltip'> $numProducts " .
|
|
"<span class='hl-tooltiptext hl-tooltip-left' style='textalign: left'>$Tip</span>\n" .
|
|
"</div>";
|
|
|
|
$entry['delete_flag'] = 'N';
|
|
}
|
|
}
|
|
|
|
if ($fname == 'status' && $value != 'Active') $value = "<span class='warning'>$value</span>";
|
|
|
|
$entry[] = $value;
|
|
}
|
|
$entry['record_num'] = $record_num;
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
$edit_icon = "<img src='images/icons/edit16.png' alt='Edit Supplier Information' border='0'>";
|
|
$product_icon = "<img src='images/icons/folder16.png' alt='Edit Supplier Products' border='0'>";
|
|
$upload_icon = "<img src='images/icons/folderopenb16.png' alt='Upload Supplier Products' border='0'>";
|
|
$prices_icon = "<img src='images/icons/money16.png' alt='Update Product Prices' border='0'>";
|
|
$post_icon = "<img src='images/icons/gotoapp16.png' alt='Post Product Info to Menu' border='0'>";
|
|
$create_menu_icon = "<img src='images/icons/app16.png' alt='Create A Menu' border='0'>";
|
|
$delete_products = "<img src='images/icons/folderdelete16.png' alt='Delete Supplier Products' border='0'>";
|
|
$print_icon = "<img src='images/icons/printer16.png' alt='Print Products' border='0'>";
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
$commands[] = "<a href='?action=supplier-products&naction=list&supplier_num=%d' asnum='$actual_school_num' title='Edit Supplier Products'>$product_icon</a>";
|
|
// $commands[] = "<a href='?action=supplier-products&naction=upload-form&supplier_num=%d' asnum='$actual_school_num' title='Upload Supplier Products'>$upload_icon</a>";
|
|
// $commands[] = "<a href='?action=supplier-products-update&selected_supplier=%d' asnum='$actual_school_num' title='Update Product Prices'>$prices_icon</a>";
|
|
$commands[] = "<a href='?action=supplier-products-post&selected_supplier=%d' asnum='$actual_school_num' title='Post Product Info to Menu'>$post_icon</a>";
|
|
// $commands[] = "<a href='?action=suppliers&naction=delete-products&selected_supplier=%d' asnum='$actual_school_num' title='Delete Supplier Products'>$delete_products</a>";
|
|
$commands[] = "<a href='?action=supplier-products-print&selected_supplier=%d' asnum='$actual_school_num' title='Print Supplier Products'>$print_icon</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
writeLog("customTableID: $customTableID");
|
|
$TableWidth = 850;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'supplier-products-list':
|
|
$set = 'Active';
|
|
$supplier_num = 0;
|
|
if (array_key_exists('set', $_GET)) $set = $_GET['set'];
|
|
if (array_key_exists('supplier_num', $_GET)) $supplier_num = intval($_GET['supplier_num']);
|
|
|
|
// startLog("supplier-products-list");
|
|
writeLog("supplier_num: $supplier_num");
|
|
writeLog("set: $set");
|
|
|
|
$columnFields = array();
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
$columnWidths = array();
|
|
|
|
$columnFields[] = 'product_name';
|
|
$columnHeaders[] = getLanguageText('TEXT-PRODUCT');
|
|
$columnAlign[] = 'left';
|
|
$columnWidths[] = 250;
|
|
|
|
if ($set != 'Description') {
|
|
if ($set != 'Special') {
|
|
$columnFields[] = 'label_name';
|
|
$columnHeaders[] = getLanguageText('TEXT-LABEL');
|
|
$columnAlign[] = 'left';
|
|
$columnWidths[] = 200;
|
|
|
|
$columnFields[] = 'supplier_name';
|
|
$columnHeaders[] = getLanguageText('TEXT-SUPPLIER');
|
|
$columnAlign[] = 'left';
|
|
$columnWidths[] = 150;
|
|
|
|
$columnFields[] = 'package_qty';
|
|
$columnHeaders[] = getLanguageText('TEXT-PACKAGE-QUANTITY');
|
|
$columnAlign[] = 'center';
|
|
$columnWidths[] = 30;
|
|
}
|
|
|
|
$columnFields[] = 'package_cost';
|
|
$columnHeaders[] = getLanguageText('TEXT-COST');
|
|
$columnAlign[] = 'right';
|
|
$columnWidths[] = 60;
|
|
|
|
$columnFields[] = 'standard_online_price';
|
|
$columnHeaders[] = getLanguageText('TEXT-ON-LINE-PRICE');
|
|
$columnAlign[] = 'right';
|
|
$columnWidths[] = 60;
|
|
|
|
$columnFields[] = 'standard_offline_price';
|
|
$columnHeaders[] = getLanguageText('TEXT-PAPER-PRICE');
|
|
$columnAlign[] = 'right';
|
|
$columnWidths[] = 60;
|
|
|
|
if ($set == 'Special') {
|
|
$columnFields[] = 'special_price1';
|
|
$columnHeaders[] = $Special1_Title;
|
|
$columnAlign[] = 'right';
|
|
$columnWidths[] = 60;
|
|
|
|
$columnFields[] = 'special_price2';
|
|
$columnHeaders[] = $Special2_Title;
|
|
$columnAlign[] = 'right';
|
|
$columnWidths[] = 60;
|
|
|
|
$columnFields[] = 'special_price3';
|
|
$columnHeaders[] = $Special3_Title;
|
|
$columnAlign[] = 'right';
|
|
$columnWidths[] = 60;
|
|
}
|
|
}
|
|
else {
|
|
$columnFields[] = 'product_description';
|
|
$columnHeaders[] = getLanguageText('TEXT-DESCRIPTION');
|
|
$columnAlign[] = 'left';
|
|
$columnWidths[] = 200;
|
|
|
|
$columnFields[] = 'label_name';
|
|
$columnHeaders[] = getLanguageText('TEXT-LABEL');
|
|
$columnAlign[] = 'left';
|
|
$columnWidths[] = 200;
|
|
}
|
|
|
|
$columnFields[] = 'sales_summary_item';
|
|
$columnHeaders[] = "<span id='reset-sales-summary' supplier-num='$supplier_num'>".getLanguageText('TEXT-SALES-SUMMARY')."</span>";
|
|
$columnAlign[] = 'center';
|
|
$columnWidths[] = 30;
|
|
|
|
$swhere = "";
|
|
if ($set == 'Active' || $set == 'Special') $swhere = "and sp.status = 'Active' AND s.status = 'Active' ";
|
|
if ($supplier_num > 0) {
|
|
// if (strlen($swhere)) $swhere .= "AND ";
|
|
$swhere .= "AND supplier_num = $supplier_num ";
|
|
}
|
|
|
|
|
|
// Get records to display
|
|
$query = "select supplier_num,product_type,product_name,product_description,label_name,supplier_code,sp.status," .
|
|
"package_qty,package_cost,standard_online_price,standard_offline_price,special_price1,special_price2,special_price3," .
|
|
"sales_summary_item,sequence,sp.record_num,supplier_name " .
|
|
"from supplier_products as sp, suppliers as s " .
|
|
"WHERE s.school_num = $supplier_school_num " .
|
|
"AND sp.school_num = $supplier_school_num " .
|
|
"AND s.record_num = sp.supplier_num " .
|
|
"AND sp.product_type = 'Product' " .
|
|
$swhere .
|
|
"order by sequence,product_name,supplier_name";
|
|
writeLog("query: $query");
|
|
$results = db_query($query);
|
|
$num_records = db_num_rows($results);
|
|
writeLog("Num Records: $num_records");
|
|
$return_data['num_records'] = $num_records;
|
|
|
|
if ($num_records) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$entry = array();
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
|
|
switch ($fname) {
|
|
case 'product_name':
|
|
if ($set != 'Description') {
|
|
$style = "";
|
|
if ($status == 'Inactive') $style = " class='warning'";
|
|
$entry[] = "<b><span id='delete-title1-$record_num'$style>$product_name</span></b><br><span class='small'>$product_description</span>";
|
|
}
|
|
else {
|
|
$value = $product_name;
|
|
$fid = $fname . '_' . $record_num;
|
|
$class = 'supplier_product_field';
|
|
$field = "<input type='text' name='$fname' id='$fid' class='$class' size='30' snum='$supplier_num' rnum='$record_num' value='$value'>";
|
|
$entry[] = $field;
|
|
}
|
|
break;
|
|
|
|
case 'product_description':
|
|
$value = $product_description;
|
|
$fid = $fname . '_' . $record_num;
|
|
$class = 'supplier_product_field';
|
|
$field = "<input type='text' name='$fname' id='$fid' class='$class' size='50' snum='$supplier_num' rnum='$record_num' value='$value'>";
|
|
$entry[] = $field;
|
|
break;
|
|
|
|
case 'label_name':
|
|
$value = $label_name;
|
|
$fid = $fname . '_' . $record_num;
|
|
$class = 'supplier_product_field';
|
|
$field = "<input type='text' name='$fname' id='$fid' class='$class' size='20' snum='$supplier_num' rnum='$record_num' value='$value'>";
|
|
$entry[] = $field;
|
|
break;
|
|
|
|
case 'package_cost':
|
|
case 'standard_online_price':
|
|
case 'standard_offline_price':
|
|
$value = $currencySymbol. sprintf($costFmt,$$fname);
|
|
if ($set == 'Special') $entry[] = $value;
|
|
else {
|
|
$style = "style='text-align: right;'";
|
|
$fid = $fname . '_' . $record_num;
|
|
$class = 'supplier_product_field';
|
|
$field = "<input type='text' name='$fname' id='$fid' class='$class' size='5' snum='$supplier_num' rnum='$record_num' value='$value' $style>";
|
|
$entry[] = $field;
|
|
}
|
|
break;
|
|
|
|
case 'special_price1':
|
|
case 'special_price2':
|
|
case 'special_price3':
|
|
$value = $currencySymbol. sprintf($costFmt,$$fname);
|
|
$style = "style='text-align: right;'";
|
|
$fid = $fname . '_' . $record_num;
|
|
$class = 'supplier_product_field';
|
|
$field = "<input type='text' name='$fname' id='$fid' class='$class' size='5' snum='$supplier_num' rnum='$record_num' value='$value' $style>";
|
|
$entry[] = $field;
|
|
break;
|
|
|
|
case 'package_qty':
|
|
$value = intval($$fname);
|
|
if ($supplier_num == 0) $entry[] = $value;
|
|
else {
|
|
$style = "style='text-align: center;'";
|
|
$fid = $fname . '_' . $record_num;
|
|
$class = 'supplier_product_field';
|
|
$field = "<input type='text' name='$fname' id='$fid' class='$class' size='2' snum='$supplier_num' rnum='$record_num' value='$value' $style>";
|
|
$entry[] = $field;
|
|
}
|
|
break;
|
|
|
|
case 'sales_summary_item':
|
|
$entry[] = $$fname;
|
|
break;
|
|
|
|
default:
|
|
$entry[] = $$fname;
|
|
break;
|
|
}
|
|
}
|
|
$entry['record_num'] = $record_num;
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
$copy_icon = "<img src='images/icons/redo24.png' alt='Copy Supplier Product' border='0'>";
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='copy-product' rnum='%d' title='Copy Supplier Product'>$copy_icon</a>";
|
|
|
|
// $table_id = "products-table";
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
writeLog("customTableID: $customTableID");
|
|
$TableWidth = 920;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
// writeLog($return_data['content']);
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'menu-dates-list':
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') startLog("menu-dates-list");
|
|
|
|
if (array_key_exists('schedule_num', $_GET)) $schedule_num = intval($_GET['schedule_num']);
|
|
|
|
writeLog("schedule_num: $schedule_num");
|
|
|
|
// Get schedule record
|
|
$results = db_query("SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $schedule_num");
|
|
if (db_num_rows($results) == 0) {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-INVALID-SCHEDULE-NUM')." --- </b></p>";
|
|
break;
|
|
}
|
|
|
|
$hotlunch_schedule = db_fetch_assoc($results);
|
|
|
|
|
|
// Get menu orders data
|
|
$query = "SELECT menu_num, sum(qty) AS qty_ordered FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND ordered_by_type != 'Concession' " .
|
|
"AND active != 'N' " .
|
|
"AND order_num NOT IN (" .
|
|
"SELECT record_num FROM hotlunch_order_header " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND status IN ('Deleted','Inactive')) " .
|
|
"GROUP BY 1";
|
|
$results = db_query($query);
|
|
$MenuOrderCount = array();
|
|
if (db_num_rows($results) > 0) {
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
writeLog("$menu_num => $qty_ordered");
|
|
$MenuOrderCount[$menu_num] = $qty_ordered;
|
|
|
|
if ($qty_ordered == 0) {
|
|
db_query("UPDATE hotlunch_menu_dates SET order_revenue = 0, other_revenue = 0, supplier_costs = 0, other_costs = 0 WHERE school_num = $school_num AND record_num = $menu_num");
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
db_query("UPDATE hotlunch_menu_dates SET order_revenue = 0, other_revenue = 0, supplier_costs = 0, other_costs = 0 WHERE school_num = $school_num AND schedule_num = $schedule_num");
|
|
}
|
|
|
|
|
|
// Determine if there are any linked menus in this set
|
|
db_query("UPDATE hotlunch_menu_dates SET menu_link = 'No' WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_link = ''");
|
|
db_query("UPDATE hotlunch_menu_dates SET current_menu_link = 'No' WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_link = 'No'");
|
|
$num_links = db_getVal("select count(*) from hotlunch_menu_dates where school_num = $school_num and schedule_num = $schedule_num and menu_link != 'No'");
|
|
$num_titles = db_getVal("select count(*) from hotlunch_menu_dates where school_num = $school_num and schedule_num = $schedule_num and length(menu_title) > 0");
|
|
|
|
|
|
// Setup arrays
|
|
$columnFields = array();
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
$columnWidths = array();
|
|
|
|
$numCols = 0;
|
|
$groupBy = "";
|
|
$queryCols = "";
|
|
|
|
if ($num_titles > 0) {
|
|
$columnFields[] = 'menu_title';
|
|
$columnHeaders[] = getLanguageText('TEXT-TITLE');
|
|
$columnAlign[] = 'left';
|
|
$columnWidths[] = 150;
|
|
$queryCols .= "hlmd.menu_title,";
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= $numCols;
|
|
$date_col = 0;
|
|
}
|
|
|
|
$displayDate = false;
|
|
if ($hotlunch_schedule['schedule_type'] == 'Date Sensitive' || $hotlunch_schedule['menu_display_mode'] == 'Calendar') $displayDate = true;
|
|
if ($hotlunch_schedule['display_menu_date'] == 'Y' || $hotlunch_schedule['menu_display_mode'] == 'Calendar') $displayDate = true;
|
|
if ($displayDate) {
|
|
$columnFields[] = 'menu_date';
|
|
$columnHeaders[] = getLanguageText('TEXT-DATE');
|
|
$columnAlign[] = "center";
|
|
$columnWidths[] = 60;
|
|
$queryCols .= "hlmd.menu_date,";
|
|
$date_col = 1;
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= "$numCols";
|
|
}
|
|
|
|
$columnFields[] = 'num_items';
|
|
if ($siteType == 'hotlunch' || $siteType == 'fundraising') {
|
|
$columnHeaders[] = getLanguageText('TEXT-NUMBER-OF-ITEMS')."<br> (".getLanguageText('TEXT-ORDERS').")";
|
|
}
|
|
else {
|
|
$columnHeaders[] = getLanguageText('TEXT-NUMBER-OF-ITEMS');
|
|
}
|
|
$columnAlign[] = "center";
|
|
$columnWidths[] = 60;
|
|
$queryCols .= "count(hlmi.record_num) as num_items,";
|
|
$numCols++;
|
|
|
|
if ($siteType == 'hotlunch' || $siteType == 'fundraising') {
|
|
if ($hotlunch_schedule['schedule_type'] != 'Volunteer Only') {
|
|
$columnFields[] = 'revenue';
|
|
$columnHeaders[] = getLanguageText('TEXT-REVENUE');
|
|
$columnAlign[] = "right";
|
|
$columnWidths[] = 60;
|
|
$queryCols .= "concat('$currencySymbol',hlmd.order_revenue + hlmd.other_revenue) as revenue,";
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= "$numCols";
|
|
|
|
$columnFields[] = 'costs';
|
|
$columnHeaders[] = getLanguageText('TEXT-COSTS');
|
|
$columnAlign[] = "right";
|
|
$columnWidths[] = 60;
|
|
$queryCols .= "concat('$currencySymbol',hlmd.supplier_costs + hlmd.other_costs) as costs,";
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= "$numCols";
|
|
|
|
$columnFields[] = 'net';
|
|
$columnHeaders[] = getLanguageText('TEXT-NET');
|
|
$columnAlign[] = "right";
|
|
$columnWidths[] = 60;
|
|
$queryCols .= "concat('$currencySymbol',hlmd.order_revenue + hlmd.other_revenue - hlmd.supplier_costs - hlmd.other_costs) as net,";
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= "$numCols";
|
|
}
|
|
}
|
|
|
|
$columnFields[] = 'active';
|
|
$columnHeaders[] = getLanguageText('TEXT-ACTIVE');
|
|
$columnAlign[] = "center";
|
|
$columnWidths[] = 40;
|
|
$queryCols .= "hlmd.active,";
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= "$numCols";
|
|
|
|
if ($siteType == 'hotlunch' || $siteType == 'fundraising') {
|
|
if ($num_links > 0) {
|
|
$columnFields[] = 'menu_link';
|
|
$columnHeaders[] = getLanguageText('TEXT-LINK');
|
|
$columnAlign[] = "center";
|
|
$columnWidths[] = 60;
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= "$numCols";
|
|
|
|
$columnFields[] = 'source_menu';
|
|
$columnHeaders[] = getLanguageText('TEXT-SOURCE-MENU');
|
|
$columnAlign[] = "center";
|
|
$columnWidths[] = 60;
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= "$numCols";
|
|
$linkCol = $numCols - 1;
|
|
|
|
$queryCols .= "hlmd.menu_link,hlmd.source_menu,";
|
|
}
|
|
}
|
|
|
|
$queryCols .= "hlmd.record_num";
|
|
$numCols++;
|
|
if (strlen($groupBy)) $groupBy .= ",";
|
|
$groupBy .= "$numCols";
|
|
|
|
writeLog("columnFields: ".count($columnFields));
|
|
|
|
$query = "select $queryCols " .
|
|
"from hotlunch_menu_dates as hlmd left join hotlunch_menu_items as hlmi " .
|
|
"on hlmi.school_num = $school_num and hlmd.record_num = hlmi.menu_num and hlmi.item_type != 'Heading' " .
|
|
"where hlmd.school_num = $school_num " .
|
|
"and hlmd.schedule_num = $schedule_num " .
|
|
"GROUP BY $groupBy " .
|
|
"ORDER BY hlmd.sequence,hlmd.menu_date asc";
|
|
writeLog($query);
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
$numRecords = db_num_rows($results);
|
|
|
|
if ($numRecords > 0) {
|
|
|
|
$data = array();
|
|
$menuDates = array();
|
|
$max_items = 0;
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$record_num = $row['record_num'];
|
|
|
|
if (array_key_exists('menu_date', $row)) {
|
|
$menu_date = $row['menu_date'];
|
|
$menuDates[$record_num] = $menu_date;
|
|
}
|
|
|
|
$menu_link = 'No';
|
|
if (array_key_exists('menu_link', $row)) $menu_link = $row['menu_link'];
|
|
|
|
$entry = array();
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
|
|
$value = $row[$fname];
|
|
switch ($fname) {
|
|
case 'menu_title':
|
|
$value = "<span id='delete-title1-$record_num' rnum='$record_num'>$value</span>";
|
|
break;
|
|
|
|
case 'menu_date':
|
|
$dow = dateString('day', strtotime($value));
|
|
$value = "<span class='menu-date-field' id='delete-title2-$record_num' rnum='$record_num'>$value</span><br>($dow)";
|
|
break;
|
|
|
|
case 'active':
|
|
$value = "<span class='menu-active-field' rnum='$record_num'>$value</span>";
|
|
$mtitle = "";
|
|
if (array_key_exists('menu_title', $row)) $mtitle .= $row['menu_title'];
|
|
if (array_key_exists('menu_date', $row)) {
|
|
if (strlen($mtitle) > 0) $mtitle .= ' - ';
|
|
$mtitle .= $row['menu_date'];
|
|
}
|
|
if (strlen($mtitle)) {
|
|
$value .= "<input type='hidden' id='mtitle-$record_num' value='$mtitle'>";
|
|
}
|
|
break;
|
|
|
|
case 'num_items':
|
|
writeLog("num_items: $record_num");
|
|
$num_items = $row['num_items'];
|
|
|
|
$value = "<a href='?action=menu-items&naction=list&schedule_num=$schedule_num&menu_num=$record_num'>$value</a>";
|
|
|
|
$menu_items_tooltip = "";
|
|
if ($num_items > 0) {
|
|
$menu_items = db_query("SELECT * FROM hotlunch_menu_items WHERE school_num = $school_num AND menu_num = $record_num ORDER BY sequence");
|
|
if (db_num_rows($menu_items)) {
|
|
$menu_items_tooltip .= "<table width='500'>";
|
|
$menu_items_tooltip .= "<tr>";
|
|
$menu_items_tooltip .= "<td align='left'><b>" . getLanguageText('TEXT-ITEM-NAME') . "</b></td>";
|
|
$menu_items_tooltip .= "<td align='right'><b>" . getLanguageText('TEXT-PAPER') . "</b></td>";
|
|
$menu_items_tooltip .= "<td align='right'><b>" . getLanguageText('TEXT-ON-LINE') . "</b></td>";
|
|
$menu_items_tooltip .= "<td align='center'><b>" . getLanguageText('TEXT-PRODUCTS') . "</b></td>";
|
|
$menu_items_tooltip .= "<td align='center'><b>" . getLanguageText('TEXT-MAXIMUM') . "</b></td>";
|
|
$menu_items_tooltip .= "<td align='center'><b>" . getLanguageText('TEXT-AVAILABLE') . "</b></td>";
|
|
$menu_items_tooltip .= "<td align='center'><b>" . getLanguageText('TEXT-ACTIVE') . "</b></td>";
|
|
$menu_items_tooltip .= "<td align='center'><b>" . getLanguageText('TEXT-GROUP') . "</b></td>";
|
|
$menu_items_tooltip .= "</tr>";
|
|
|
|
while ($mrow = db_fetch_assoc($menu_items)) {
|
|
if ($mrow['item_type'] == 'Heading') $menu_items_tooltip .= "<tr><td align='left' colspan='8'><b>" . $mrow['item_title'] . "</b></td></tr>";
|
|
else {
|
|
$menu_item_num = $mrow['record_num'];
|
|
$query = "SELECT count(*) FROM hotlunch_menu_products " .
|
|
"WHERE school_num IN ($supplier_school_num,$school_num) " .
|
|
"AND menu_item_num = $menu_item_num";
|
|
$prods = db_getVal($query);
|
|
$menu_items_tooltip .= "<tr>";
|
|
$menu_items_tooltip .= "<td align='left'>" . $mrow['item_title'] . "</td>";
|
|
$menu_items_tooltip .= "<td align='right'>$" . $mrow['offline_price'] . "</td>";
|
|
$menu_items_tooltip .= "<td align='right'>$" . $mrow['online_price'] . "</td>";
|
|
$menu_items_tooltip .= "<td align='center'>" . $prods . "</td>";
|
|
$menu_items_tooltip .= "<td align='center'>" . $mrow['max_quantity'] . "</td>";
|
|
$menu_items_tooltip .= "<td align='center'>" . $mrow['quantity_available'] . "</td>";
|
|
$menu_items_tooltip .= "<td align='center'>" . $mrow['active'] . "</td>";
|
|
$menu_items_tooltip .= "<td align='center'>" . $mrow['menu_group'] . "</td>";
|
|
$menu_items_tooltip .= "</tr>";
|
|
}
|
|
}
|
|
|
|
$menu_items_tooltip .= "</table>";
|
|
}
|
|
}
|
|
|
|
if (strlen($menu_items_tooltip)) {
|
|
$value = "<div class='hl-tooltip'> $value " .
|
|
"<span class='hl-tooltiptext hl-tooltip-right' style='textalign: left'>$menu_items_tooltip</span>\n" .
|
|
"</div>";
|
|
}
|
|
|
|
$value .= "<input type='hidden' id='num-menu-items-$record_num' value='$num_items'>";
|
|
if (array_key_exists($record_num, $MenuOrderCount) && $MenuOrderCount[$record_num] > 0) {
|
|
$value .= "<br>(".$MenuOrderCount[$record_num].")";
|
|
}
|
|
$menu_link = 'No';
|
|
if (array_key_exists('menu_link', $row)) $menu_link = $row['menu_link'];
|
|
$value .= "<input type='hidden' id='menu-date-link-$record_num' value='$menu_link'>";
|
|
break;
|
|
|
|
case 'menu_link':
|
|
switch($menu_link) {
|
|
case 'No':
|
|
$text = getLanguageText('TEXT-NOT-LINKED');
|
|
break;
|
|
case 'Admin':
|
|
$text = getLanguageText('TEXT-LINKED-FOR-ADMIN');
|
|
break;
|
|
case 'Paper':
|
|
$text = getLanguageText('TEXT-LINKED-FOR-PAPER-ORDERS');
|
|
break;
|
|
case 'All':
|
|
$text = getLanguageText('TEXT-LINKED-FOR-ALL-ORDERS');
|
|
break;
|
|
}
|
|
$value = "<span id='menu-link-span-$record_num' class='menu-link-span' menu_num='$record_num' link='$menu_link'>$text</span>";
|
|
break;
|
|
|
|
case 'source_menu':
|
|
if (array_key_exists($value, $menuDates)) $value = $menuDates[$value];
|
|
else $value = '';
|
|
break;
|
|
}
|
|
|
|
if (count($data) == 0) writeLog("value: $value");
|
|
$entry[] = $value;
|
|
}
|
|
$entry['record_num'] = $record_num;
|
|
|
|
$delete_flag = 'Y';
|
|
if (array_key_exists($record_num, $MenuOrderCount) && $MenuOrderCount[$record_num] > 0) $delete_flag = 'N';
|
|
if (!isset($menu_link)) $menu_link = 'No';
|
|
writeLog("$delete_flag ".$menu_link);
|
|
if ($delete_flag == 'Y' && $menu_link == 'No') {
|
|
$nLinked = db_getVal("SELECT count(*) FROM hotlunch_menu_dates WHERE school_num = $school_num AND source_menu = $record_num");
|
|
writeLog("nLinked: $nLinked");
|
|
if ($nLinked > 0) {
|
|
$delete_flag = 'N';
|
|
$localContent .= "<input type='hidden' id='msg-$record_num' value='" . getLanguageText('ERRORMSG-UNABLE-TO-DELETE-SOURCE-MENU') . "'>\n";
|
|
}
|
|
writeLog("delete_flag: $delete_flag");
|
|
}
|
|
$entry['delete_flag'] = $delete_flag;
|
|
|
|
|
|
$record_num = $row['record_num'];
|
|
$menu_num = $record_num;
|
|
|
|
// Check if school is in session on this date
|
|
if (array_key_exists('menu_date',$entry)) {
|
|
$menu_date = $entry['menu_date'];
|
|
$numEvents = db_getVal("SELECT count(*) FROM event_calendar, event_types " .
|
|
"WHERE event_calendar.school_num = $school_num " .
|
|
"AND event_types.school_num = $school_num " .
|
|
"AND event_type = event_type_title " .
|
|
"AND school_in_session = 'N' " .
|
|
"AND start_date <= '$menu_date' AND '$menu_date' <= end_date");
|
|
if ($numEvents > 0) $entry['menu_date'] = "<span class='red'>" . $entry['menu_date'] . "</span>";
|
|
}
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
// Commands
|
|
$menu_icon = "<img src='images/icons/menu24.png' alt='Manage Menu Items' border='0'>";
|
|
$copy_icon = "<img src='images/icons/documentsorcopy24.png' alt='Copy or Link Order Menus' border='0'>";
|
|
$classlist_icon = "<img src='images/icons/printer24.png' alt='Print Class Delivery List' border='0'>";
|
|
$sup_orders_icon = "<img src='images/icons/pastfile24.png' alt='Print Supplier Orders for Menu Date' border='0'>";
|
|
$totals_icon = "<img src='images/icons/money24.png' alt='Edit Transaction Totals for Menu Date' border='0'>";
|
|
$menu_generate_icon = "<img src='images/icons/app24.png' alt='Generate Menu from Supplier Products' border='0'>";
|
|
$set_source_icon = "<img src='images/icons/cutb24.png' alt='Change Source Menu to This Date' border='0'>";
|
|
$print_icon = "<img src='images/icons/printer24.png' alt='Print Menu Order Form' border='0'>";
|
|
|
|
// Determine which icons can be displayed
|
|
$num_orders = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num AND status NOT IN ('Inactive','Deleted','Concession')");
|
|
$numSuppliers = db_getVal("SELECT count(*) FROM suppliers WHERE school_num = $supplier_school_num AND status = 'Active'");
|
|
$num_links = db_getVal("select count(*) from hotlunch_menu_dates where school_num = $school_num and schedule_num = $schedule_num and menu_link != 'No' and active != 'N'");
|
|
|
|
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
$commands[] = "<a href='?action=menu-items&naction=list&schedule_num=$schedule_num&menu_num=%d' title='Manage Menu Items'>$menu_icon</a>";
|
|
|
|
if ($num_orders == 0 || $_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
$commands[] = "<a href='#' class='copy-menu-icon' mnum='%d' title='Copy or Link Order Menus'>$copy_icon</a>";
|
|
if ($numSuppliers > 0) {
|
|
$commands[] = "<a href='#' class='generate-menu-icon' mnum='%d' title='Generate Menu from Supplier Products'>$menu_generate_icon</a>";
|
|
$commands[] = "<a href='?action=supplier-orders&schedule_num=$schedule_num&menu_num=%d' title='Edit Transaction Totals for Menu Date'>$totals_icon</a>";
|
|
}
|
|
}
|
|
else {
|
|
if ($numSuppliers > 0) {
|
|
if ($num_links == 0) {
|
|
$commands[] = "<a href='#' class='generate-menu-icon' mnum='%d' title='Generate Menu from Supplier Products'>$menu_generate_icon</a>";
|
|
}
|
|
|
|
$commands[] = "<a href='?action=delivery-details-print&schedule_num=$schedule_num&menu_num=%d' title='Print Class Delivery List'>$classlist_icon</a>";
|
|
$commands[] = "<a href='?action=supplier-orders-print&schedule_num=$schedule_num&menu_num=%d' title='Print Supplier Orders for Menu Date'>$sup_orders_icon</a>";
|
|
$commands[] = "<a href='?action=supplier-orders&schedule_num=$schedule_num&menu_num=%d' title='Edit Transaction Totals for Menu Date'>$totals_icon</a>";
|
|
$commands[] = "<a href='?action=orders-print-form&schedule_num=$schedule_num&menu_num=%d' title='Print Menu Order Form'>$print_icon</a>";
|
|
}
|
|
}
|
|
|
|
$commands[] = "<a href='?action=orders-print-form&schedule_num=$schedule_num&menu_num=%d' title='Print Menu Order Form'>$print_icon</a>";
|
|
$commands[] = "<input type='checkbox' class='menu-date-checkbox' id='%d' {DISABLED-FLAG}>";
|
|
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
writeLog("customTableID: $customTableID");
|
|
$TableWidth = 900;
|
|
if (!isset($totals)) $totals = array();
|
|
if (!isset($titleText)) $titleText = '';
|
|
$return_data['count'] = count($data);
|
|
$return_data['content'] = $titleText . getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'menu-items-list':
|
|
// startLog("menu-items-list");
|
|
|
|
if (array_key_exists('schedule_num', $_GET)) $schedule_num = intval($_GET['schedule_num']);
|
|
if (array_key_exists('menu_num', $_GET)) $menu_num = intval($_GET['menu_num']);
|
|
if (array_key_exists('menu_link', $_GET)) $menu_link = db_escape_string($_GET['menu_link']);
|
|
|
|
writeLog("schedule_num: $schedule_num");
|
|
writeLog("menu_num: $menu_num");
|
|
|
|
// Get schedule record
|
|
$results = db_query("SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $schedule_num");
|
|
if (db_num_rows($results) == 0) {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-INVALID-SCHEDULE-NUM')." --- </b></p>";
|
|
break;
|
|
}
|
|
|
|
$hotlunch_schedule = db_fetch_assoc($results);
|
|
|
|
|
|
// Determine if groups are in use in this menu
|
|
$query = "SELECT count(*) FROM hotlunch_menu_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND menu_num = $menu_num " .
|
|
"AND menu_group IN ('A','B','C','D','E')";
|
|
$groupCount = db_getVal($query);
|
|
|
|
// Setup arrays
|
|
$columnFields = array();
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
$columnWidths = array();
|
|
$queryCols = "";
|
|
|
|
$numCols = 0;
|
|
|
|
$columnFields[] = 'item_title';
|
|
$columnHeaders[] = getLanguageText('TEXT-TITLE');
|
|
$columnAlign[] = 'left';
|
|
$columnWidths[] = 200;
|
|
$queryCols .= "item_title,";
|
|
$numCols++;
|
|
|
|
// $columnFields[] = 'item_type';
|
|
// $columnHeaders[] = getLanguageText('TEXT-TYPE');
|
|
// $columnAlign[] = 'left';
|
|
// $columnWidths[] = 50;
|
|
// $queryCols .= "item_type,";
|
|
// $numCols++;
|
|
|
|
$columnFields[] = 'label_title';
|
|
$columnHeaders[] = getLanguageText('TEXT-LABEL-TITLE');
|
|
$columnAlign[] = 'left';
|
|
$columnWidths[] = 100;
|
|
$queryCols .= "label_title,";
|
|
$numCols++;
|
|
|
|
// if ($groupCount > 0) {
|
|
$columnFields[] = 'menu_group';
|
|
$columnHeaders[] = getLanguageText('TEXT-GROUP');
|
|
$columnAlign[] = 'center';
|
|
$columnWidths[] = 50;
|
|
$queryCols .= "menu_group,";
|
|
$numCols++;
|
|
// }
|
|
|
|
$columnFields[] = 'online_price';
|
|
$columnHeaders[] = getLanguageText('TEXT-ON-LINE');
|
|
$columnAlign[] = 'right';
|
|
$columnWidths[] = 50;
|
|
$queryCols .= "online_price,";
|
|
$numCols++;
|
|
|
|
$columnFields[] = 'offline_price';
|
|
$columnHeaders[] = getLanguageText('TEXT-PAPER');
|
|
$columnAlign[] = 'right';
|
|
$columnWidths[] = 50;
|
|
$queryCols .= "offline_price,";
|
|
$numCols++;
|
|
|
|
$columnFields[] = 'num_products';
|
|
$columnHeaders[] = getLanguageText('TEXT-PRODUCTS');
|
|
$columnAlign[] = 'center';
|
|
$columnWidths[] = 50;
|
|
// $queryCols .= "num_products,";
|
|
$numCols++;
|
|
|
|
$columnFields[] = 'active';
|
|
$columnHeaders[] = getLanguageText('TEXT-ACTIVE');
|
|
$columnAlign[] = 'center';
|
|
$columnWidths[] = 50;
|
|
$queryCols .= "active,";
|
|
$numCols++;
|
|
|
|
$columnFields[] = 'sales_summary_item';
|
|
$columnHeaders[] = getLanguageText('TEXT-SUMMARY');
|
|
$columnAlign[] = 'center';
|
|
$columnWidths[] = 50;
|
|
$queryCols .= "sales_summary_item,";
|
|
$numCols++;
|
|
|
|
|
|
// Get menu items
|
|
$query = "SELECT $queryCols item_description,item_type,heading_visibility,record_num FROM hotlunch_menu_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND menu_num = $menu_num " .
|
|
"ORDER BY sequence";
|
|
$menu_items = db_query($query);
|
|
|
|
if (db_num_rows($menu_items)) {
|
|
|
|
$data = array();
|
|
while ($menu_item = db_fetch_assoc($menu_items)) {
|
|
$item_num = $menu_item['record_num'];
|
|
$record_num = $menu_item['record_num'];
|
|
$item_title = $menu_item['item_title'];
|
|
$item_type = $menu_item['item_type'];
|
|
$entry = array();
|
|
writeLog($item_title);
|
|
|
|
if ($item_type == 'Item') {
|
|
|
|
$query = "SELECT supplier_name,product_name,package_qty,package_cost,product_sequence,supplier_product_qty,suppliers.status " .
|
|
"FROM suppliers,supplier_products,hotlunch_menu_products " .
|
|
"WHERE suppliers.school_num IN ($supplier_school_num,$school_num) " .
|
|
"AND suppliers.status = 'Active' " .
|
|
"AND supplier_products.school_num IN ($supplier_school_num,$school_num) " .
|
|
"AND hotlunch_menu_products.school_num IN ($supplier_school_num,$school_num) " .
|
|
"AND hotlunch_menu_products.menu_item_num = $item_num " .
|
|
"AND hotlunch_menu_products.supplier_product_num = supplier_products.record_num " .
|
|
"AND supplier_products.supplier_num = suppliers.record_num " .
|
|
"ORDER BY product_sequence";
|
|
writeLog($query);
|
|
$products = db_query($query);
|
|
$menu_item['num_products'] = db_num_rows($products);
|
|
|
|
$products_tooltip = "";
|
|
if (db_num_rows($products)) {
|
|
$products_tooltip .= "<table width='450'>";
|
|
while ($row = db_fetch_assoc($products)) {
|
|
$status = $row['status'];
|
|
$products_tooltip .= "<tr><td valign='top' width='120'>".getLanguageText('TEXT-SUPPLIER')."</td><td valign='top'>".$row['supplier_name']." ($status)</td></tr>";
|
|
$products_tooltip .= "<tr><td valign='top'>".getLanguageText('TEXT-PRODUCT')."</td><td valign='top'>".$row['product_name']."</td></tr>";
|
|
$products_tooltip .= "<tr><td valign='top'>".getLanguageText('TEXT-QUANTITY')."</td><td valign='top'>".$row['supplier_product_qty']."</td></tr>";
|
|
$products_tooltip .= "<tr><td valign='top'>".getLanguageText('TEXT-PACKAGE-QUANTITY')."</td><td valign='top'>".$row['package_qty']."</td></tr>";
|
|
$products_tooltip .= "<tr><td valign='top'>".getLanguageText('TEXT-PACKAGE-COST')."</td><td valign='top'>$currencySymbol".sprintf("%0.".$school_record['supplier_costs_decimals']."f",$row['package_qty'])."</td></tr>";
|
|
}
|
|
$products_tooltip .= "</table>";
|
|
}
|
|
|
|
$row = $menu_item;
|
|
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
|
|
$value = '';
|
|
if (array_key_exists($fname, $row)) $value = $row[$fname];
|
|
|
|
switch ($fname) {
|
|
case 'item_title':
|
|
$item_type = $menu_item['item_type'];
|
|
$item_type = "<input type='hidden' id='menu-item-type-$record_num' value='$item_type'>";
|
|
|
|
$value = "<b><span class='menu-item-title' id='delete-title1-$item_num' rnum='$item_num'>$value</span></b>$item_type";
|
|
if (strlen($row['item_description'])) {
|
|
$max = 40;
|
|
$item_description = $row['item_description'];
|
|
if (strlen($item_description) > $max) $item_description = substr($item_description,0,$max)."...";
|
|
$value .= "<br><span class='small'> - ".$item_description."</span>";
|
|
}
|
|
break;
|
|
|
|
case 'online_price':
|
|
case 'offline_price':
|
|
$value = $currencySymbol.number_format(floatval($value),2);
|
|
if ($menu_link == 'No') {
|
|
$style = "style='text-align: right;'";
|
|
$fid = $fname . '_' . $record_num;
|
|
$class = 'menu_item_field';
|
|
$field = "<input type='text' name='$fname' id='$fid' class='$class' size='5' mnum='$menu_num' rnum='$record_num' value='$value' $style>";
|
|
$value = $field;
|
|
}
|
|
break;
|
|
|
|
case 'num_products':
|
|
if (strlen($products_tooltip)) {
|
|
$value = "<div class='hl-tooltip'> $value " .
|
|
"<span class='hl-tooltiptext hl-tooltip-left' style='textalign: left'>$products_tooltip</span>\n" .
|
|
"</div>";
|
|
}
|
|
break;
|
|
|
|
case 'menu_group':
|
|
if ($menu_link == 'No') {
|
|
$v = $value;
|
|
if ($value == "") {
|
|
$v = 'none';
|
|
$value = getLanguageText('TEXT-NO-GROUP');
|
|
}
|
|
$fid = 'menu_group_' . $record_num;
|
|
$value = "<span id='$fid' class='menu-group-field' fname='menu_group' item_num='$record_num' cvalue='$v'>$value</span>";
|
|
}
|
|
break;
|
|
|
|
case 'active':
|
|
if ($menu_link == 'No') {
|
|
$value_text = getLanguageText('TEXT-'.$value);
|
|
$value = "<span class='toggle-field' fname='active' item_num='$record_num' value='$value'>$value_text</span>";
|
|
}
|
|
break;
|
|
|
|
case 'sales_summary_item':
|
|
if ($menu_link == 'No') {
|
|
$value_text = getLanguageText('TEXT-'.$value);
|
|
$value = "<span class='toggle-field' fname='sales_summary_item' item_num='$record_num' value='$value'>$value_text</span>";
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
$entry[] = $value;
|
|
writeLog($value);
|
|
}
|
|
$record_num = $item_num;
|
|
$entry['record_num'] = $record_num;
|
|
|
|
$delete_flag = 'Y';
|
|
$query = "SELECT count(*) FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_num = $menu_num " .
|
|
"AND menu_item_num = $item_num " .
|
|
"AND active = 'Y'";
|
|
$numOrders = db_getVal($query);
|
|
if ($numOrders > 0) $delete_flag = 'N';
|
|
$entry['delete_flag'] = $delete_flag;
|
|
}
|
|
else {
|
|
writeLog("item_title: $item_title");
|
|
$item_type = "<input type='hidden' id='menu-item-type-$record_num' value='Heading'>";
|
|
$value = "<span class='menu-items-heading'>".$menu_item['item_title']."</span>$item_type";
|
|
$entry[] = $value;
|
|
|
|
$value = $menu_item['heading_visibility'];
|
|
$value_text = getLanguageText('TEXT-'.$value);
|
|
$value = "<span class='toggle-field' fname='heading_visibility' item_num='$record_num' value='$value'>$value_text</span>";
|
|
$entry[] = $value;
|
|
|
|
for ($i = 2; $i < count($columnFields); $i++) {
|
|
$entry[] = '';
|
|
}
|
|
$entry['delete_flag'] = 'Y';
|
|
$record_num = $item_num;
|
|
$entry['record_num'] = $record_num;
|
|
}
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
// Commands
|
|
$copy_icon_small = "<img src='images/icons/redo24.png' alt='Copy Menu Item' border='0'>";
|
|
|
|
$commands = array();
|
|
// if ($menu_link == 'No' || $_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
if ($menu_link == 'No') {
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='copy-menu-item' rnum='%d' title='Copy Menu Item'>$copy_icon_small</a>";
|
|
}
|
|
else {
|
|
$titleText = getLanguageText('TEXT-MENU-LINK').' - ';
|
|
switch ($menu_link) {
|
|
case 'Admin':
|
|
$titleText .= getLanguageText('TEXT-LINKED-FOR-ADMIN');
|
|
break;
|
|
|
|
case 'All':
|
|
$titleText .= getLanguageText('TEXT-LINKED-FOR-ALL-ORDERS');
|
|
break;
|
|
|
|
case 'Paper':
|
|
$titleText .= getLanguageText('TEXT-LINKED-FOR-PAPER-ORDERS');
|
|
break;
|
|
}
|
|
$titleText = "<br><span style='display: block; width: 500px; padding: 5px; color: #ffffff; background-color: #ff0000;'><b>$titleText</b></span>";
|
|
}
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 900;
|
|
if (!isset($totals)) $totals = array();
|
|
if (!isset($titleText)) $titleText = '';
|
|
$return_data['count'] = count($data);
|
|
$return_data['content'] = $titleText . getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals,'N');
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'supplier-products-select':
|
|
// startLog("supplier-products-select");
|
|
|
|
if (array_key_exists('supplier_num', $_GET)) $supplier_num = intval($_GET['supplier_num']);
|
|
if (!isset($supplier_num)) return;
|
|
writeLog("supplier_num: $supplier_num");
|
|
|
|
$mode = 'select';
|
|
if (array_key_exists('mode', $_GET)) $mode = db_escape_string($_GET['mode']);
|
|
|
|
|
|
// Get supplier info
|
|
// $supplier = db_getVal("SELECT * FROM suppliers WHERE school_num = $supplier_school_num AND record_num = $supplier_num");
|
|
$supplier = db_getVal("SELECT * FROM suppliers WHERE record_num = $supplier_num");
|
|
if (is_array($supplier)) {
|
|
$schoolNum = $supplier['school_num'];
|
|
$schoolName = db_getVal("SELECT school_name FROM schools WHERE record_num = $schoolNum");
|
|
|
|
$num_products = db_getVal("SELECT count(*) FROM supplier_products WHERE supplier_num = $supplier_num AND status = 'Active'");
|
|
if ($num_products == 0) {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-SUPPLIER-HAS-NO-PRODUCTS')." --- </b></p>";
|
|
$return_data['ajax_return_code'] = -1;
|
|
break;
|
|
}
|
|
|
|
$products = db_query("SELECT * FROM supplier_products WHERE supplier_num = $supplier_num AND status = 'Active' ORDER BY sequence,product_name");
|
|
$count = 0;
|
|
if (db_num_rows($products) > 0) {
|
|
$content = "<h2>$schoolName</h2>\n";
|
|
$content .= "<table width='550' cellpadding='2' cellspacing='2' class='content-table'>";
|
|
$content .= "<tr class='heading'>";
|
|
$content .= "<td align='center'>".$supplier['supplier_name']."</td>";
|
|
if ($mode == 'select') $content .= "<td align='center'><input type='checkbox' id='select-all-products' checked='checked'></td>";
|
|
$content .= "</tr>";
|
|
|
|
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>";
|
|
else $product_description = "<span class='small'>$price</span>";
|
|
|
|
$content .= "<tr class='$bgclass'>";
|
|
$content .= "<td align='left' valign='top'>";
|
|
$content .= "<b>$product_name</b>";
|
|
$content .= "<br>";
|
|
$content .= "$product_description";
|
|
$content .= "</td>";
|
|
|
|
if ($mode == 'select') {
|
|
$content .= "<td width='50' align='center' valign='top'>";
|
|
$content .= "<input type='checkbox' name='selected_products[]' class='selected_products' checked='checked' value='$record_num'>";
|
|
$content .= "</td>";
|
|
}
|
|
|
|
$content .= "</tr>";
|
|
}
|
|
$content .= "</table>";
|
|
$return_data['content'] = $content;
|
|
$return_data['ajax_return_code'] = 0;
|
|
$return_data['num_products'] = $count;
|
|
}
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
$return_data['ajax_return_code'] = -1;
|
|
}
|
|
break;
|
|
|
|
case 'copy-menu-dates-list':
|
|
// startLog("copy-menu-dates-list");
|
|
|
|
$field_name = 'selected_menu_dates';
|
|
$title = getLanguageText('TEXT-COPY-TO-MENUS');
|
|
$curr_menu_num = 0;
|
|
|
|
if (array_key_exists('schedule_num', $_GET)) $schedule_num = intval($_GET['schedule_num']);
|
|
if (array_key_exists('menu_num', $_GET)) $curr_menu_num = intval($_GET['menu_num']);
|
|
if (array_key_exists('field_name', $_GET)) $field_name = db_escape_string($_GET['field_name']);
|
|
if (array_key_exists('title', $_GET)) $title = db_escape_string($_GET['title']);
|
|
if (!isset($schedule_num)) return;
|
|
|
|
writeLog("schedule_num: $schedule_num");
|
|
writeLog("curr_menu_num: $curr_menu_num");
|
|
|
|
// Get schedule info
|
|
$schedule = db_getVal("SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $schedule_num");
|
|
|
|
// Get other menus
|
|
if ($field_name == 'selected_menu_dates') {
|
|
$query = "SELECT * FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND record_num != $curr_menu_num " .
|
|
"ORDER BY sequence,menu_date";
|
|
}
|
|
else {
|
|
$query = "SELECT * FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_link = 'No' " .
|
|
"ORDER BY sequence,menu_date";
|
|
}
|
|
$menus = db_query($query);
|
|
$numMenus = db_num_rows($menus);
|
|
|
|
if ($numMenus > 0) {
|
|
$id = 'select-all-menu-dates';
|
|
if ($field_name == 'generate_menu_dates') $id = 'select-all-generate-menu-dates';
|
|
|
|
$content = "<table width='550' cellpadding='2' cellspacing='2' class='content-table'>";
|
|
$content .= "<tr class='heading'>";
|
|
$content .= "<td colspan=2 align='center'>$title</td>";
|
|
$content .= "<td align='center'><input type='checkbox' id='$id'></td>";
|
|
$content .= "</tr>";
|
|
|
|
$count = 0;
|
|
|
|
while ($row = db_fetch_assoc($menus)) {
|
|
extract($row);
|
|
|
|
$bgclass = 'data-odd';
|
|
if ($count % 2) $bgclass = 'data-even';
|
|
$count++;
|
|
|
|
if ($schedule['schedule_type'] == 'Hot Lunch' || $schedule['schedule_type'] == 'Date Sensitive') {
|
|
if (strlen($menu_title)) $menu_title .= ' - ';
|
|
$menu_title .= $menu_date;
|
|
}
|
|
|
|
$num_items = db_getVal("SELECT count(*) FROM hotlunch_menu_items WHERE school_num = $school_num AND menu_num = $record_num");
|
|
|
|
$content .= "<tr class='$bgclass'>";
|
|
$content .= "<td align='left' valign='top'>";
|
|
$content .= "<b>$menu_title</b>";
|
|
$content .= "</td>";
|
|
$content .= "<td width='50' align='center' valign='top'>";
|
|
$content .= "<b>$num_items ".getLanguageText('TEXT-ITEMS')."</b>";
|
|
$content .= "</td>";
|
|
$content .= "<td width='50' align='center' valign='top'>";
|
|
|
|
$checked = '';
|
|
if ($field_name == 'generate_menu_dates' && $curr_menu_num == $record_num) $checked = " checked='checked'";
|
|
|
|
$content .= "<input type='checkbox' name='".$field_name."[]' class='$field_name' value='$record_num'$checked>";
|
|
$content .= "</td>";
|
|
$content .= "</tr>";
|
|
}
|
|
$content .= "</table>";
|
|
$return_data['content'] = $content;
|
|
$return_data['ajax_return_code'] = 0;
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
$return_data['ajax_return_code'] = -1;
|
|
}
|
|
break;
|
|
|
|
case 'users-list':
|
|
$order_by_field = "last_name,first_name";
|
|
$swhere = "";
|
|
$show_status = "";
|
|
$show_type = "";
|
|
$mwhere = "";
|
|
$mhaving = "";
|
|
$lookup_where = '';
|
|
|
|
if (array_key_exists('match', $_GET)) $match = db_escape_string($_GET['match']);
|
|
|
|
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
|
|
|
|
if (!isset($match) || strlen($match) < 3) {
|
|
$titleText = getLanguageText('TEXT-ALL-USERS');
|
|
|
|
// Get parameters
|
|
if (array_key_exists('record_num', $_GET)) {
|
|
$record_num = intval($_GET['record_num']);
|
|
if ($record_num > 0) $swhere = "AND u.record_num = $record_num ";
|
|
}
|
|
|
|
if (array_key_exists('sortby', $_GET)) {
|
|
$sortby = db_escape_string($_GET['sortby']);
|
|
if (strlen($sortby)) $order_by_field = $sortby . ",last_name,first_name";
|
|
}
|
|
|
|
if (array_key_exists('show_status',$_REQUEST) && strlen($_REQUEST['show_status'])) {
|
|
$show_status = db_escape_string($_REQUEST['show_status']);
|
|
$swhere = "and u.status = '$show_status' ";
|
|
}
|
|
|
|
if (array_key_exists('show_type',$_REQUEST) && strlen($_REQUEST['show_type'])) {
|
|
$show_type = db_escape_string($_REQUEST['show_type']);
|
|
if ($show_type == 'Admin') {
|
|
$swhere = "and u.type not in ('Parent','Guest','Staff','Supplier') ";
|
|
$titleText = getLanguageText('TEXT-ADMIN-USERS');
|
|
}
|
|
else {
|
|
$swhere = "and u.type = '$show_type' ";
|
|
switch ($show_type) {
|
|
case 'Staff':
|
|
$titleText = getLanguageText('TEXT-STAFF');
|
|
break;
|
|
case 'Parent':
|
|
$titleText = getLanguageText('TEXT-PARENTS');
|
|
break;
|
|
case 'Guest':
|
|
$titleText = getLanguageText('TEXT-GUESTS');
|
|
break;
|
|
case 'Supplier':
|
|
$titleText = getLanguageText('TEXT-SUPPLIERS');
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (array_key_exists('show_modifier',$_REQUEST) && strlen($_REQUEST['show_modifier'])) {
|
|
$show_modifier = db_escape_string($_REQUEST['show_modifier']);
|
|
|
|
if ($show_modifier == 'noemail') $mwhere = "and (u.email = '' or u.email is null) ";
|
|
if ($show_modifier == 'balance-owing') $mhaving = "having sum(ua.transaction_amount) > 0 ";
|
|
if ($show_modifier == 'balance-payable') $mhaving = "having sum(ua.transaction_amount) < 0 ";
|
|
if ($show_modifier == 'volunteers') $mwhere = "and u.available_to_volunteer = 'Y' ";
|
|
|
|
if (strlen($titleText)) $titleText .= ' - ';
|
|
$titleText .= getLanguageText('TEXT-'.strtoupper($show_modifier));
|
|
}
|
|
}
|
|
else {
|
|
$word = $match;
|
|
$lookup_where = "AND (userid LIKE '%$word%' " .
|
|
"OR first_name LIKE '$word%' " .
|
|
"OR last_name LIKE '$word%' " .
|
|
"OR email LIKE '%$word%' " .
|
|
"OR home_phone LIKE '%$word%' " .
|
|
"OR cell_phone LIKE '%$word%' " .
|
|
"OR daytime_phone LIKE '%$word%') ";
|
|
writeLog($lookup_where);
|
|
}
|
|
|
|
|
|
// Get set of user records
|
|
$columnHeaders = array(getLanguageText('TEXT-USER-ID'),
|
|
getLanguageText('TEXT-NAME'),
|
|
getLanguageText('TEXT-TYPE'),
|
|
$GlobalText['Students'],
|
|
getLanguageText('TEXT-STATUS'),
|
|
getLanguageText('TEXT-ORDER'),
|
|
getLanguageText('TEXT-EMAIL'),
|
|
getLanguageText('TEXT-SYSTEM-REMINDER'),
|
|
getLanguageText('TEXT-BALANCE'));
|
|
$columnAlign = array('left','left','left','center','center','center','center','center','center');
|
|
|
|
$columnFields = array('userid',
|
|
'name',
|
|
'type',
|
|
'nstudents',
|
|
'status_display',
|
|
'can_order_display',
|
|
'receive_emails_display',
|
|
'email_reminders_display',
|
|
'balance');
|
|
|
|
|
|
if (isset($titleText) && strlen($titleText)) $titleText = "<p><b>$titleText</b></p>";
|
|
|
|
$query = "SELECT email,userid,first_name,last_name,type,status,can_order,receive_emails,sum(ua.transaction_amount) as balance,trx_status," .
|
|
"home_phone,cell_phone,date_added,last_login,email_flag,email_reminders,u.record_num " .
|
|
"FROM users AS u LEFT JOIN user_account AS ua ON user_num = u.record_num and ua.school_num = $school_num and (ua.deleted != 'Y' or ua.deleted is null) " .
|
|
"WHERE u.school_num = $base_school_num " .
|
|
$lookup_where .
|
|
$swhere .
|
|
$mwhere .
|
|
"GROUP BY 1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17 " .
|
|
$mhaving .
|
|
"ORDER BY $order_by_field";
|
|
writeLog($query);
|
|
$menu_dates = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($menu_dates);
|
|
$numRecords = db_num_rows($menu_dates);
|
|
|
|
if ($numRecords > 0) {
|
|
$count = 0;
|
|
$data = array();
|
|
while ($row = db_fetch_array($menu_dates)) {
|
|
extract($row);
|
|
|
|
$userNum = $record_num;
|
|
|
|
$userid = "<span id='delete-title1-$record_num'>$userid</span>";
|
|
|
|
$query = "SELECT * FROM people " .
|
|
"WHERE school_num = $base_school_num " .
|
|
"AND user_num = $record_num " .
|
|
"AND active != 'N' " .
|
|
"AND people_type IN ('Student','Customer')";
|
|
$students = db_query($query);
|
|
$numStudents = db_num_rows($students);
|
|
|
|
if (isset($show_modifier) && $show_modifier == 'nostudents' && $numStudents > 0) continue;
|
|
$nstudents = $numStudents;
|
|
|
|
if ($numStudents > 0) {
|
|
$Tip = "<table width='450' cellpadding='3'>";
|
|
while ($row = db_fetch_assoc($students)) {
|
|
$people_type = $row['people_type'];
|
|
$class_info = getLanguageText('TEXT-'.strtoupper($people_type));
|
|
if ($numClasses > 0) $class_info = getClassInfo($row['class_num'], 'internal');
|
|
$Tip .= "<tr><td width='10'> </td><td align='left'>".$row['first_name'].' '.$row['last_name']." - $class_info</td>";
|
|
}
|
|
$Tip .= "</table>";
|
|
$nstudents = "<div class='hl-tooltip'> $numStudents " .
|
|
"<span class='hl-tooltiptext hl-tooltip-right' style='textalign: left'>$Tip</span>\n" .
|
|
"</div>";
|
|
}
|
|
|
|
if (strlen($email)) {
|
|
if ($email == $userid) $userid = "<a href='mailto:$email'>$email</a>";
|
|
else $userid .= "<br><a href='mailto:$email'>$email</a>";
|
|
}
|
|
$userid .= "<input type='hidden' id='email_$record_num' value='$email'>";
|
|
|
|
$balance = floatval($balance);
|
|
if ($balance >= 0) $balance = '$' . number_format($balance,2);
|
|
else $balance = '-$' . number_format(abs($balance),2);
|
|
|
|
$Tip = "<table width='400'>" .
|
|
"<tr><td width='30%' align='right'>".getLanguageText('TEXT-NAME').": </td><td align='left'>$first_name $last_name</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-EMAIL').": </td><td align='left'>$email</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-PHONE').": </td><td align='left'>$home_phone</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-CELL-PHONE').": </td><td align='left'>$cell_phone</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-TYPE').": </td><td align='left'>$type</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-DATE-ADDED').": </td><td align='left'>$date_added</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-LAST-LOGIN').": </td><td align='left'>$last_login</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-ACCOUNT-BALANCE').": </td><td align='left'>$balance</td></tr>" .
|
|
"</table>";
|
|
$userid = "<div class='hl-tooltip'>$userid" .
|
|
"<span class='hl-tooltiptext hl-tooltip-center' style='textalign: left'>$Tip</span>" .
|
|
"</div>";
|
|
|
|
$name = "$first_name $last_name";
|
|
|
|
if (!isset($receive_emails) || $receive_emails == '') {
|
|
$receive_emails = 'N';
|
|
db_query("UPDATE users SET receive_emails = '$receive_emails' WHERE school_num = $base_school_num AND record_num = $userNum");
|
|
}
|
|
$receive_emails_display = '-';
|
|
if ($receive_emails == 'Y') $receive_emails_display = getLanguageText('TEXT-YES');
|
|
if ($receive_emails == 'N') $receive_emails_display = getLanguageText('TEXT-NO');
|
|
$receive_emails_display = "<span id='email$record_num' class='user-emails' val='$receive_emails' rnum='$record_num'>$receive_emails_display</span>";
|
|
if ($school_record['email_system'] == 'Y' && $type == 'Parent') $receive_emails_display .= "<br><span class='email-flag' val='$email_flag' rnum='$record_num'>($email_flag)</span>";
|
|
|
|
if (!isset($email_reminders) || $email_reminders == '') {
|
|
$email_reminders = 'N';
|
|
db_query("UPDATE users SET email_reminders = '$email_reminders' WHERE school_num = $base_school_num AND record_num = $userNum");
|
|
}
|
|
$email_reminders_display = '-';
|
|
if ($email_reminders == 'Y') $email_reminders_display = getLanguageText('TEXT-YES');
|
|
if ($email_reminders == 'N') $email_reminders_display = getLanguageText('TEXT-NO');
|
|
$email_reminders_display = "<span id='reminder$record_num' class='user-reminder' val='$email_reminders' rnum='$record_num'>$email_reminders_display</span>";
|
|
|
|
if (!isset($can_order) || $can_order == '') {
|
|
$can_order = 'Yes';
|
|
db_query("UPDATE users SET can_order = '$can_order' WHERE school_num = $base_school_num AND record_num = $userNum");
|
|
}
|
|
$can_order_display = '-';
|
|
if ($can_order == 'Yes') $can_order_display = getLanguageText('TEXT-YES');
|
|
if ($can_order == 'No') $can_order_display = getLanguageText('TEXT-NO');
|
|
if ($can_order == 'Balance') $can_order_display = getLanguageText('TEXT-BALANCE');
|
|
$can_order_display = "<span class='user-can-order' rnum='$record_num' val='$can_order'>$can_order_display</span>";
|
|
|
|
if ($status == 'Active') $status_display = getLanguageText('TEXT-ACTIVE');
|
|
if ($status == 'Inactive') $status_display = getLanguageText('TEXT-INACTIVE');
|
|
if ($status == 'Deleted') $status_display = getLanguageText('TEXT-DELETED');
|
|
if ($status == 'Pending') $status_display = getLanguageText('TEXT-PENDING');
|
|
if ($status == 'Suspended') $status_display = getLanguageText('TEXT-SUSPENDED');
|
|
$status_display = "<span class='user-status' rnum='$record_num' val='$status'>$status_display</span>";
|
|
|
|
$entry = array();
|
|
for ($i = 0; $i < count($columnFields); $i++) {
|
|
$fname = $columnFields[$i];
|
|
|
|
$value = $$fname;
|
|
if ($fname == 'class_program') $value = $Programs[$value];
|
|
$entry[] = $value;
|
|
}
|
|
$entry['record_num'] = $record_num;
|
|
$entry['delete_flag'] = 'Y';
|
|
if ($numStudents > 0) $entry['delete_flag'] = 'N';
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
// Commands
|
|
$students_icon = "<img src='images/icons/groupofusers16.png' alt='View Students' border='0'>";
|
|
$contacts_icon = "<img src='images/icons/userid16.png' alt='View Contact Information' border='0'>";
|
|
$reminder_icon = "<img src='images/icons/mailsend16.png' alt='Send Account Login Reminder Email' border='0'>";
|
|
$weekly_reminder_icon = "<img src='images/icons/mailsend16.png' alt='Send Weekly Menu Reminder Email' border='0'>";
|
|
$money_icon = "<img src='images/icons/money16.png' alt='Post to User Account' border='0'>";
|
|
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
$commands[] = "<a href='#' class='account-students' rnum='%d' title='View Students'>$students_icon</a>";
|
|
|
|
$title = getLanguageText('TEXT-SEND-LOGIN-REMINDER');
|
|
$commands[] = "<a href='#' class='login-reminder' rnum='%d' title='$title'>$reminder_icon</a>";
|
|
|
|
$title = getLanguageText('TEXT-SEND-WEEKLY-EMAIL-REMINDER');
|
|
$commands[] = "<a href='#' class='weekly-reminder' rnum='%d' title='$title'>$weekly_reminder_icon</a>";
|
|
|
|
$title = getLanguageText('TEXT-VIEW-ACCOUNT-TRANSACTIONS');
|
|
$commands[] = "<a href='#' class='user-account' rnum='%d' title='$title'>$money_icon</a>";
|
|
|
|
$title = getLanguageText('TEXT-MANAGE-ACCOUNT-TRANSACTIONS');
|
|
$commands[] = "<a href='#' class='manage-user-account' rnum='%d' title='$title'>$money_icon</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
writeLog("customTableID: $customTableID");
|
|
$TableWidth = 850;
|
|
if (!isset($totals)) $totals = array();
|
|
if (!isset($titleText)) $titleText = '';
|
|
$return_data['count'] = count($data);
|
|
$return_data['content'] = $titleText . getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
}
|
|
else {
|
|
if (!isset($titleText)) $titleText = '';
|
|
$return_data['content'] = $titleText . "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'user-account-students':
|
|
if (array_key_exists('user_num', $_GET)) $user_num = intval($_GET['user_num']);
|
|
if (!isset($user_num)) return;
|
|
|
|
// Get schedules data
|
|
$Schedules = array();
|
|
$query = "SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND status IN ('Pending','Active')";
|
|
$results = db_query($query);
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$snum = $row['record_num'];
|
|
$title = $row['schedule_name'];
|
|
$Schedules[$snum] = $title;
|
|
}
|
|
|
|
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
|
|
|
|
|
|
// Get user data
|
|
$results = db_query("SELECT * FROM users WHERE school_num = $base_school_num AND record_num = $user_num");
|
|
if (db_num_rows($results)) {
|
|
$user = db_fetch_assoc($results);
|
|
extract($user);
|
|
|
|
$header = "<p style='text-align: left;'> <b>$first_name $last_name</b>";
|
|
$header .= "<br><b>$userid</b>";
|
|
if (strlen($email)) $header .= "<br><a href='mailto:$email'>$email</a>";
|
|
if (strlen($home_phone)) $header .= "<br>$home_phone";
|
|
|
|
$query = "SELECT * FROM people WHERE school_num = $base_school_num AND user_num = $user_num ORDER BY first_name, last_name";
|
|
$students = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($students);
|
|
|
|
if (db_num_rows($students)) {
|
|
$return_data['content'] = $header;
|
|
$return_data['content'] .= "<table width='98%' cellspacing='5' style='border: 1px solid #404040;'>";
|
|
$return_data['content'] .= "<tr style='color: #ffffff; background-color: #000000;'>";
|
|
$return_data['content'] .= "<td align='left'>".getLanguageText('TEXT-NAME')."</td>";
|
|
$return_data['content'] .= "<td align='center'>".getLanguageText('TEXT-ORDERS')."</td>";
|
|
$return_data['content'] .= "<td align='left'></td>";
|
|
$return_data['content'] .= "<td align='center'></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$rclass = 'data-odd';
|
|
while ($row = db_fetch_assoc($students)) {
|
|
extract($row);
|
|
$return_data['content'] .= "<tr class='$rclass'>";
|
|
if ($rclass == 'data-odd') $rclass = 'data-even';
|
|
else $rclass = 'data-odd';
|
|
|
|
$return_data['content'] .= "<td align='left'><b>$first_name $last_name</b></td>";
|
|
|
|
$orders = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $record_num ORDER BY added_time");
|
|
$norders = db_num_rows($orders);
|
|
$Tip = '';
|
|
if ($norders > 0) {
|
|
$Tip = "<table width='350' cellpadding='3'>";
|
|
$Tip .= "<tr><td></td><td colspan='3'><b>$first_name $last_name</b></td></tr>";
|
|
$orderCount = 0;
|
|
while ($row = db_fetch_assoc($orders)) {
|
|
$snum = $row['schedule_num'];
|
|
if (array_key_exists($snum, $Schedules)) {
|
|
$title = $Schedules[$snum];
|
|
$amt = '$'.$row['order_total'];
|
|
$ostatus = $row['status'];
|
|
$Tip .= "<tr><td width='10'> </td><td align='left'>$title: </td><td width='50' align='right'>$amt</td><td align='center'>$ostatus</td>";
|
|
$orderCount++;
|
|
}
|
|
}
|
|
$Tip .= "</table>";
|
|
$norders = $orderCount;
|
|
if ($orderCount > 0) $norders = "<div class='hl-tooltip student-orders' rnum='$record_num'> $orderCount\n" .
|
|
"<span class='hl-tooltiptext hl-tooltip-center' style='textalign: left'>$Tip</span>\n" .
|
|
"</div>";
|
|
}
|
|
$return_data['content'] .= "<td align='center'>$norders</td>";
|
|
|
|
$class_info = getLanguageText('TEXT-'.strtoupper($people_type));
|
|
if ($numClasses > 0) $class_info = getClassInfo($class_num, 'internal');
|
|
$return_data['content'] .= "<td align='center'>$class_info</td>";
|
|
|
|
$edit_student = "<a href='#' class='edit-student' unum='$user_num' snum='$record_num'>$edit_icon_small</a>";
|
|
$return_data['content'] .= "<td align='center'>$edit_student</td>";
|
|
|
|
$return_data['content'] .= "</tr>";
|
|
}
|
|
|
|
$return_data['content'] .= "</table>";
|
|
}
|
|
}
|
|
break;
|
|
|
|
case 'student-orders':
|
|
$display_mode = 'AllSchedules';
|
|
if (array_key_exists('display_mode', $_GET)) $display_mode = db_escape_string($_GET['display_mode']);
|
|
if (array_key_exists('student_num', $_GET)) $student_num = intval($_GET['student_num']);
|
|
|
|
if (!isset($student_num)) return;
|
|
|
|
$person = db_getVal("SELECT * FROM people WHERE school_num = $base_school_num AND record_num = $student_num");
|
|
$class_num = $person['class_num'];
|
|
$Name = $person['first_name'].' '.$person['last_name'];
|
|
$titleText = "<p><b>$Name</b></p>";
|
|
$return_data['name'] = $Name;
|
|
|
|
$time = date("H",time());
|
|
$now = date("Y-m-d H:i:s",time());
|
|
|
|
$orderButtonText = getLanguageText('TEXT-ORDER');
|
|
if (isset($order_button_text) && strlen($order_button_text)) $orderButtonText = $order_button_text;
|
|
// $orderButtonText = str_replace(' ',' ',$orderButtonText);
|
|
|
|
|
|
// Determine the number of currently active schedules
|
|
$today = date("Y-m-d",time());
|
|
$now = date("Y-m-d H:i:s",time());
|
|
$cutoff_date = date("Y-m-d 00:00:00",time() - 60 * 60 * 24 * 300);
|
|
|
|
$swhere = "AND start_order_datetime <= '$now' AND status in ('Active') ";
|
|
$cwhere = "AND start_order_datetime > '$cutoff_date' ";
|
|
|
|
if ($display_mode == 'AllSchedules') $cwhere = '';
|
|
|
|
$num_active = db_getVal("SELECT count(*) FROM hotlunch_schedules " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_type != 'Volunteer Only' " .
|
|
$cwhere .
|
|
$swhere);
|
|
|
|
// Check if there is a current schedule
|
|
$today = date("Y-m-d",time());
|
|
|
|
db_query("UPDATE hotlunch_schedules SET start_order_date = start_order_datetime, end_order_date = end_order_datetime WHERE school_num = $school_num");
|
|
|
|
$query = "select * from hotlunch_schedules " .
|
|
"where school_num = $school_num " .
|
|
"AND schedule_type != 'Volunteer Only' " .
|
|
$cwhere .
|
|
$swhere .
|
|
"order by start_order_date DESC";
|
|
writeLog($query);
|
|
$current_schedules = db_query($query);
|
|
$num_schedules = db_num_rows($current_schedules);
|
|
writeLog("num_schedules: $num_schedules");
|
|
$num_classes = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
|
|
|
|
$schedules = array();
|
|
$displayDiscounts = False;
|
|
|
|
|
|
if (db_num_rows($current_schedules) > 0) {
|
|
$cutoff_date = date("Y-m-d",time() - 60 * 60 * 24 * 45);
|
|
|
|
while ($row = db_fetch_array($current_schedules)) {
|
|
$schedule_num = $row['record_num'];
|
|
$schedule_name = $row['schedule_name'];
|
|
$start_order_date = $row['start_order_date'];
|
|
writeLog("schedule_name: $schedule_name - $start_order_date");
|
|
|
|
// Check that the schedule has menu dates and items defined
|
|
$numDates = db_getVal("SELECT count(*) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num");
|
|
if ($numDates == 0) continue;
|
|
|
|
$numItems = db_getVal("SELECT count(*) FROM hotlunch_menu_dates AS hlmd, hotlunch_menu_items AS hlmi " .
|
|
"WHERE hlmd.school_num = $school_num " .
|
|
"AND hlmi.school_num = $school_num " .
|
|
"AND hlmd.schedule_num = $schedule_num " .
|
|
"AND hlmi.menu_num = hlmd.record_num");
|
|
if ($numItems == 0) continue;
|
|
|
|
|
|
// Check if there is an order for this schedule
|
|
$results = db_query("SELECT * FROM hotlunch_order_header " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND ordered_by_num = $student_num " .
|
|
"AND schedule_num = $schedule_num");
|
|
if (db_num_rows($results)) {
|
|
$schedules[] = $row;
|
|
continue;
|
|
}
|
|
|
|
|
|
// Check if this is a limited access schedule by class
|
|
$class_entries = db_getVal("select count(*) from hotlunch_schedules_classes where school_num = $school_num and schedule_num = $schedule_num");
|
|
|
|
if ($class_entries > 0 && $class_num > 0) {
|
|
$query = "select count(*) from hotlunch_schedules_classes " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and class_num = $class_num";
|
|
$schedule_access = db_getVal($query);
|
|
if ($schedule_access == 0) continue;
|
|
}
|
|
|
|
// Check if this is a limited access schedule by category
|
|
$category_entries = db_getVal("select count(*) from hotlunch_schedules_categories " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num");
|
|
|
|
if ($category_entries > 0) {
|
|
$query = "SELECT count(*) FROM hotlunch_schedules_categories AS hlsc, people_categories AS pc " .
|
|
"WHERE hlsc.school_num = $school_num " .
|
|
"AND pc.school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND hlsc.category_num = pc.category_num " .
|
|
"AND pc.people_num = $student_num";
|
|
$schedule_access = db_getVal($query);
|
|
if ($schedule_access == 0) continue;
|
|
}
|
|
|
|
|
|
$schedules[] = $row;
|
|
$schedule_num = $row['record_num'];
|
|
$discount = db_getVal("SELECT discount_amount " .
|
|
"FROM hotlunch_order_header " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND ordered_by_num = $student_num " .
|
|
"AND ordered_by_type IN ('Staff','Student','Customer')");
|
|
if ($discount > 0) $displayDiscounts = True;
|
|
}
|
|
}
|
|
|
|
|
|
$content = '';
|
|
if (count($schedules) > 0) {
|
|
|
|
// Initialize the totals
|
|
$t_balance = 0;
|
|
$t_subtotal = 0;
|
|
$t_total = 0;
|
|
$t_discount = 0;
|
|
$t_paid = 0;
|
|
|
|
$columnHeaders = array();
|
|
$columnHeaders[] = getLanguageText('TEXT-SCHEDULE');
|
|
$columnHeaders[] = getLanguageText('TEXT-TOTAL');
|
|
if ($displayDiscounts) $columnHeaders[] = getLanguageText('TEXT-DISCOUNT');
|
|
$columnHeaders[] = getLanguageText('TEXT-AMOUNT-PAID');
|
|
$columnHeaders[] = getLanguageText('TEXT-STATUS');
|
|
$columnHeaders[] = getLanguageText('TEXT-CATEGORY');
|
|
$columnHeaders[] = '';
|
|
|
|
$columnAlign = array();
|
|
$columnAlign[] = 'left';
|
|
$columnAlign[] = 'right';
|
|
if ($displayDiscounts) $columnAlign[] = 'right';
|
|
$columnAlign[] = 'right';
|
|
$columnAlign[] = 'center';
|
|
$columnAlign[] = 'center';
|
|
|
|
$order_total = 0;
|
|
$order_net = 0;
|
|
|
|
$lcount = 0;
|
|
$schedule_status = "";
|
|
for ($sn = 0; $sn < count($schedules); $sn++) {
|
|
$schedule = $schedules[$sn];
|
|
extract($schedule);
|
|
$ScheduleName = $schedule_name;
|
|
$schedule_num = $record_num;
|
|
$schedule_status = "";
|
|
writeLog($status);
|
|
if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator'))) $schedule_status = "(" . $status . ")";
|
|
|
|
writeLog("schedule_name: $schedule_name");
|
|
|
|
$start_order_datet = $start_order_date;
|
|
$end_order_datet = $end_order_date;
|
|
|
|
if (isset($start_order_datetime) && strlen($start_order_datetime)) {
|
|
$start_order_datet = substr($start_order_datetime,0,16);
|
|
$end_order_datet = substr($end_order_datetime,0,16);
|
|
}
|
|
|
|
$Tip = "<table width='350'>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-SCHEDULE')."</td><td align='left'>$schedule_name</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-START-ORDER')."</td><td align='left'>$start_order_datet</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-END-ORDER')."</td><td align='left'>$end_order_datet</td></tr>";
|
|
|
|
if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator'))) {
|
|
if ($schedule_type == 'Hot Lunch' || $schedule_type == 'Date Sensitive') {
|
|
$Tip .= "<tr><td align='right'>".getLanguageText('TEXT-SCHEDULE-START')."</td><td align='left'>$schedule_start_date</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-SCHEDULE-END')."</td><td align='left'>$schedule_end_date</td></tr>";
|
|
}
|
|
$Tip .= "<tr><td align='right'>".getLanguageText('TEXT-TYPE')."</td><td align='left'>$schedule_type</td></tr>";
|
|
}
|
|
|
|
$Tip .= "</table>";
|
|
|
|
// Get order information for this student and this schedule
|
|
$query = "select schedule_num,order_subtotal,discount_amount,order_total," .
|
|
"amount_paid,status,price_category,record_num as order_num " .
|
|
"from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and ordered_by_num = $student_num " .
|
|
"and status != 'Deleted'";
|
|
$results = db_query($query);
|
|
$return_data['num_records'] = db_num_rows($results);
|
|
|
|
$order_subtotal = 0;
|
|
$discount_amount = 0;
|
|
$order_total = 0;
|
|
$amount_paid = 0;
|
|
$balance = 0;
|
|
$status = getLanguageText('TEXT-NO-ORDER');
|
|
$order_num = 0;
|
|
$price_category = '';
|
|
$l_bgclass = 'data-odd';
|
|
if ($lcount % 2) $l_bgclass = 'data-even';
|
|
$lcount++;
|
|
|
|
if (db_num_rows($results) > 0) {
|
|
$row = db_fetch_assoc($results);
|
|
extract($row);
|
|
$balance = $order_subtotal - $discount_amount - $amount_paid;
|
|
|
|
$t_subtotal += $order_subtotal;
|
|
$t_total += $order_total;
|
|
$t_discount += $discount_amount;
|
|
$t_paid += $amount_paid;
|
|
$t_balance += $balance;
|
|
}
|
|
|
|
|
|
$schedule_link = "?action=orders&naction=edit&schedule_num=$schedule_num&student_num=$student_num&entered_order_num=$order_num";
|
|
$edit_order_link = "?action=orders&naction=edit-header&schedule_num=$schedule_num&order_num=$order_num";
|
|
$print_order_link = "?action=orders-print&schedule_num=$schedule_num&order_num=$order_num";
|
|
|
|
// Change schedule name to a link
|
|
$now = date("Y-m-d H:i:00",time());
|
|
if ($end_order_datetime >= $now) {
|
|
$schedule_name = "<a href='$schedule_link'>" . $schedule_name . "</a> ";
|
|
}
|
|
$schedule_name = "<div class='hl-tooltip'>$schedule_name $schedule_status\n" .
|
|
"<span class='hl-tooltiptext hl-tooltip-right' style='text-align: center; width: 400px;'>$Tip</span>\n" .
|
|
"</div>";
|
|
|
|
$orders = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $record_num ORDER BY added_time");
|
|
|
|
// Define commands for this entry
|
|
$commands = '';
|
|
|
|
writeLog("order_num: $order_num end_order_datetime: $end_order_datetime");
|
|
if ((isset($order_num) && $order_num > 0) || $end_order_datetime > $now) {
|
|
$commands .= " <a href='$schedule_link' class='btn btn--outline btn--xsmall'>$orderButtonText</a> ";
|
|
}
|
|
else {
|
|
$commands .= getLanguageText('TEXT-ORDERING-HAS-ENDED');
|
|
}
|
|
|
|
if (isset($order_num) && $order_num > 0 && $_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
$commands .= "<a href='$edit_order_link'>$edit_icon_small</a> ";
|
|
}
|
|
|
|
if (isset($order_num) && $order_num > 0) {
|
|
$commands .= "<a href='$print_order_link'>$print_icon_small</a> ";
|
|
}
|
|
|
|
$price_category_text = '';
|
|
if (isset($price_category) && strlen($price_category)) {
|
|
$pcat = strtolower(str_replace(' ','',$price_category));
|
|
$pclass = '';
|
|
$price_category_text = getLanguageText('TEXT-'.$price_category);
|
|
if ($price_category != 'Regular') {
|
|
$pclass = 'warning';
|
|
switch ($price_category) {
|
|
case 'Special 1':
|
|
if (strlen($school_record['special1_text'])) $price_category_text = $school_record['special1_text'];
|
|
break;
|
|
case 'Special 2':
|
|
if (strlen($school_record['special2_text'])) $price_category_text = $school_record['special2_text'];
|
|
break;
|
|
case 'Special 3':
|
|
if (strlen($school_record['special3_text'])) $price_category_text = $school_record['special3_text'];
|
|
break;
|
|
}
|
|
}
|
|
|
|
$ScheduleName = str_replace("'","'",$ScheduleName);
|
|
$price_category = "<span class='order-price-category $pclass' snum='$student_num' onum='$order_num' schedule='$schedule_num' sname='$ScheduleName' mcat='$pcat'>" . $price_category_text . "</span>";
|
|
}
|
|
|
|
$entry = array();
|
|
$entry[] = $schedule_name;
|
|
$entry[] = $currencySymbol.number_format($order_total,2);
|
|
if ($displayDiscounts) $entry[] = $currencySymbol.number_format($discount_amount,2);
|
|
$entry[] = $currencySymbol.number_format($amount_paid,2);
|
|
$entry[] = getLanguageText('TEXT-'.strtoupper($status));
|
|
$entry[] = $price_category;
|
|
$entry[] = $commands;
|
|
$entry['record_num'] = $order_num;
|
|
|
|
switch ($display_mode) {
|
|
case 'AllSchedules':
|
|
$data[] = $entry;
|
|
break;
|
|
|
|
case 'OrdersOnly':
|
|
if (isset($order_num) && $order_num > 0) {
|
|
$data[] = $entry;
|
|
}
|
|
break;
|
|
|
|
case 'OrdersAndCurrent':
|
|
if (isset($order_num) && $order_num > 0) {
|
|
$data[] = $entry;
|
|
}
|
|
else {
|
|
$ordering_date = date("Y-m-d H:i:00",time() - 60 * 60 * 24 * 200);
|
|
writeLog("ordering_date: $ordering_date");
|
|
writeLog("end_order_datetime: $end_order_datetime");
|
|
if ($end_order_datetime > $ordering_date) {
|
|
$data[] = $entry;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!isset($titleText)) $titleText = '';
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 750;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = $titleText . getDataCustom($data,$columnHeaders,$action,array(),'N',$columnAlign,$totals);
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('TEXT-NO-ORDERS-FOUND')." --- </b></p>";
|
|
}
|
|
|
|
break;
|
|
|
|
case 'students-list':
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') startLog("students-list");
|
|
// startLog("students-list");
|
|
|
|
if (!array_key_exists('type', $_SESSION['UserInfo'])) {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
break;
|
|
}
|
|
|
|
$displayMode = 'AdminDisplay';
|
|
$curr_school_num = $school_num;
|
|
|
|
$show_commands = 'Y';
|
|
if (array_key_exists('show_commands', $_GET)) $show_commands = db_escape_string($_GET['show_commands']);
|
|
if (array_key_exists('match', $_GET)) $match = db_escape_string($_GET['match']);
|
|
$swhere = "";
|
|
|
|
$ParentAcctsTypes = array('Parent', 'Staff', 'Guest', 'Application Volunteer', 'Administration Team', 'Schedule Team', 'Financial Team');
|
|
if (array_key_exists('type', $_SESSION['UserInfo']) && in_array($_SESSION['UserInfo']['type'], $ParentAcctsTypes)) {
|
|
$unum = intval($_SESSION['UserInfo']['record_num']);
|
|
$swhere = "AND user_num = $unum ";
|
|
$displayMode = 'ParentDisplay';
|
|
writeLog("displayMode: $displayMode");
|
|
}
|
|
else {
|
|
|
|
if (!isset($match) || strlen($match) < 3) {
|
|
$titleText = $GlobalText['AllStudents'];
|
|
$swhere = "AND people_type IN ('Student','Customer','Staff') ";
|
|
writeLog("swhere: $swhere");
|
|
|
|
// Get parameters
|
|
if (array_key_exists('show_type', $_GET)) $show_type = db_escape_string($_GET['show_type']);
|
|
if (array_key_exists('naction', $_GET)) $naction = db_escape_string($_GET['naction']);
|
|
if (array_key_exists('record_num', $_GET)) $record_num = intval($_GET['record_num']);
|
|
|
|
if (isset($record_num)) $swhere = "AND st.record_num = $record_num ";
|
|
writeLog("swhere: $swhere");
|
|
|
|
$header = "";
|
|
|
|
if (isset($naction)) {
|
|
writeLog("naction: $naction");
|
|
switch ($naction) {
|
|
case 'view-class-students':
|
|
$cnum = 0;
|
|
if (array_key_exists('class_num', $_GET)) $cnum = intval($_GET['class_num']);
|
|
if ($cnum == 0) return;
|
|
$swhere = "AND class_num = $cnum ";
|
|
writeLog("swhere: $swhere");
|
|
break;
|
|
|
|
case 'view-meal-locations':
|
|
$cnum = 0;
|
|
if (array_key_exists('class_num', $_GET)) $cnum = intval($_GET['class_num']);
|
|
if ($cnum > 0) $swhere = "AND class_num = $cnum ";
|
|
// $swhere = "AND class_num != meal_location ";
|
|
writeLog("swhere: $swhere");
|
|
break;
|
|
|
|
case 'view-account-students':
|
|
$unum = 0;
|
|
if (array_key_exists('user_num', $_GET)) $unum = intval($_GET['user_num']);
|
|
if ($unum == 0) return;
|
|
$swhere = "AND user_num = $unum ";
|
|
break;
|
|
|
|
case 'view-unverified':
|
|
$swhere = "AND st.status = 'Unverified' ";
|
|
break;
|
|
|
|
case 'view-inactive':
|
|
$swhere = "AND active = 'N' ";
|
|
$swhere = "AND st.status = 'Inactive' ";
|
|
break;
|
|
|
|
case 'view-unassigned':
|
|
$swhere = "AND (class_num < 3 OR class_num IS NULL) AND people_type = 'Student' ";
|
|
break;
|
|
|
|
case 'view-price-category':
|
|
if (array_key_exists('price_category', $_GET)) {
|
|
$price_category = db_escape_string($_GET['price_category']);
|
|
$swhere = "AND menu_price_category = '$price_category' ";
|
|
}
|
|
break;
|
|
|
|
case 'view-flex-pricing':
|
|
$swhere = "AND access_to_multiple_item_prices = 'Y' ";
|
|
break;
|
|
|
|
case 'view-missing-student-number':
|
|
$swhere = "AND (student_number = '' OR student_number IS NULL) ";
|
|
break;
|
|
|
|
case 'view-students':
|
|
$swhere = "AND people_type = 'Student' ";
|
|
$header = $GlobalText['Students'];
|
|
break;
|
|
|
|
case 'view-staff':
|
|
$swhere = "AND people_type = 'Staff' ";
|
|
break;
|
|
|
|
case 'view-customers':
|
|
$swhere = "AND people_type = 'Customer' ";
|
|
break;
|
|
|
|
case 'view-all':
|
|
$swhere = "AND active = 'Y' ";
|
|
break;
|
|
|
|
case 'view-category-students':
|
|
$cnum = 0;
|
|
if (array_key_exists('category_num',$_GET)) $cnum = intval($_GET['category_num']);
|
|
$swhere = "AND st.record_num IN (SELECT people_num FROM people_categories WHERE school_num = $school_num AND category_num = $cnum) ";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
$naction = 'match';
|
|
$word = trim($match);
|
|
$lookup_where = "AND (st.first_name LIKE '$word%' " .
|
|
"OR st.last_name LIKE '$word%' " .
|
|
"OR st.email LIKE '$word%' " .
|
|
"OR u.userid LIKE '$word%' " .
|
|
"OR student_number LIKE '$word%' " .
|
|
"OR label_note LIKE '%$word%' " .
|
|
"OR cust_phone LIKE '%$word%' " .
|
|
"OR cust_phone LIKE '%$word%' " .
|
|
"OR cust_address LIKE '%$word%' " .
|
|
"OR st.notes LIKE '%$word%') ";
|
|
}
|
|
}
|
|
|
|
// Get schedules data
|
|
$Schedules = array();
|
|
$query = "SELECT * FROM hotlunch_schedules WHERE school_num = $curr_school_num AND status IN ('Pending','Active')";
|
|
$results = db_query($query);
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$snum = $row['record_num'];
|
|
$title = $row['schedule_name'];
|
|
$Schedules[$snum] = $title;
|
|
}
|
|
|
|
$Classes = array();
|
|
$Classes[0] = array(
|
|
'class_info' => getClassInfo(0),
|
|
'division' => '',
|
|
'grade' => getLanguageText('TEXT-STAFF'),
|
|
'gfield' => 'grade',
|
|
'eclass' => ''
|
|
);
|
|
|
|
$Classes[1] = array(
|
|
'class_info' => getClassInfo(1),
|
|
'division' => '',
|
|
'grade' => getLanguageText('TEXT-CUSTOMER'),
|
|
'gfield' => 'grade',
|
|
'eclass' => ''
|
|
);
|
|
|
|
$Classes[2] = array(
|
|
'class_info' => getClassInfo(2),
|
|
'division' => '',
|
|
'grade' => '-',
|
|
'gfield' => 'grade',
|
|
'eclass' => ''
|
|
);
|
|
|
|
$results = db_query("SELECT * FROM classes WHERE school_num = $base_school_num");
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$cnum = $row['record_num'];
|
|
$type = $row['entry_type'];
|
|
$div = $row['division'];
|
|
$grade = $row['grade'];
|
|
$gfield = 'grade';
|
|
$eclass = '';
|
|
|
|
if (!strlen($grade)) {
|
|
$grade = $row['label_description'];
|
|
$gfield = 'label_description';
|
|
|
|
if (strlen($grade) == 0 && strlen($row['description'])) {
|
|
$grade = $row['description'];
|
|
$gfield = 'description';
|
|
}
|
|
|
|
if (strlen($grade) == 0 && strlen($row['division'])) {
|
|
$grade = $row['division'];
|
|
$gfield = 'division';
|
|
}
|
|
|
|
if (!strlen($grade)) {
|
|
if (isset($people_type) && $people_type != 'Staff') {
|
|
$grade = " error ";
|
|
$eclass = " error";
|
|
$class_info = '';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if ($type == 'Class') $text = getClassInfo($cnum);
|
|
else $text = $row['description'];
|
|
|
|
if (strlen($grade) > 30) $grade = substr($grade, 0, 25)."...";
|
|
|
|
$entry = array();
|
|
$entry['class_info'] = $text;
|
|
$entry['division'] = $div;
|
|
$entry['grade'] = $grade;
|
|
$entry['gfield'] = $gfield;
|
|
$entry['eclass'] = $eclass;
|
|
|
|
$Classes[$cnum] = $entry;
|
|
}
|
|
|
|
$columnHeaders = array();
|
|
$columnHeaders[] = getLanguageText('TEXT-NAME');
|
|
if (isset($naction) && $naction != 'view-meal-locations') {
|
|
if ($displayMode == 'AdminDisplay') $columnHeaders[] = getLanguageText('TEXT-ACCOUNT');
|
|
$columnHeaders[] = getLanguageText('TEXT-ORDERS');
|
|
if ($school_record['collect_student_number'] == 'Y') $columnHeaders[] = getLanguageText('TEXT-STUDENT-NUMBER');
|
|
if ($school_record['participant_grouping'] != 'None') {
|
|
$columnHeaders[] = $GlobalText['Class'];
|
|
if ($school_record['i_display_division'] == 'Y') {
|
|
$columnHeaders[] = getLanguageText('TEXT-DIVISION');
|
|
}
|
|
}
|
|
if ($displayMode == 'AdminDisplay') $columnHeaders[] = getLanguageText('TEXT-TYPE');
|
|
$columnHeaders[] = getLanguageText('TEXT-STATUS');
|
|
if ($displayMode == 'AdminDisplay' && $school_record['implement_multiple_item_prices'] == 'Y') {
|
|
$columnHeaders[] = getLanguageText('TEXT-FLEX-PRICING');
|
|
}
|
|
if ($displayMode == 'AdminDisplay') $columnHeaders[] = getLanguageText('TEXT-DISPLAY');
|
|
$columnAlign = array('left','center','center','center','center','center','center','center','center','center');
|
|
}
|
|
else {
|
|
$columnHeaders[] = getLanguageText('TEXT-TYPE');
|
|
$columnHeaders[] = $GlobalText['Class'];
|
|
$columnHeaders[] = getLanguageText('TEXT-ALTERNATE-LOCATION');
|
|
$columnAlign = array('left','center','center');
|
|
}
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
// $columnHeaders[] = 'rNum';
|
|
// $columnAlign[] = 'center';
|
|
// }
|
|
|
|
if (!isset($swhere)) $swhere = '';
|
|
if (!isset($lookup_where)) $lookup_where = '';
|
|
writeLog("swhere: $swhere");
|
|
writeLog("lookup_where: $lookup_where");
|
|
|
|
$query = "SELECT st.* FROM people AS st, users AS u " .
|
|
"WHERE st.school_num = $base_school_num " .
|
|
"AND u.school_num = $base_school_num " .
|
|
"AND st.user_num = u.record_num " .
|
|
$swhere .
|
|
$lookup_where .
|
|
"order by last_name, first_name";
|
|
writeLog($query);
|
|
$students = db_query($query);
|
|
$numRecords = db_num_rows($students);
|
|
$return_data['num_records'] = $numRecords;
|
|
|
|
if ($numRecords) {
|
|
$data = array();
|
|
while ($row = db_fetch_array($students)) {
|
|
extract($row);
|
|
$student_num = $record_num;
|
|
writeLog("---------------------------------------------------");
|
|
writeLog("student_num: $student_num");
|
|
$delete_flag = 'Y';
|
|
|
|
$eclass = '';
|
|
|
|
$people_info = "<table width='400'>";
|
|
$people_info .= "<tr><td align='left'>$people_type</td></tr>";
|
|
if (intval($class_num) > 2 && array_key_exists($class_num, $Classes)) $people_info .= "<tr><td align='left'>".$Classes[$class_num]['class_info']."</td></tr>";
|
|
|
|
// Check for allergen info
|
|
$query = "SELECT allergen FROM allergies, allergens " .
|
|
"WHERE allergies.school_num = $base_school_num " .
|
|
"AND allergens.school_num = $base_school_num " .
|
|
"AND allergies.allergen_num = allergens.record_num " .
|
|
"AND people_num = $student_num " .
|
|
"ORDER BY allergen";
|
|
writeLog($query);
|
|
$allergies = db_query($query);
|
|
writeLog("Num Allergies: ".db_num_rows($allergies));
|
|
if (db_num_rows($allergies)) {
|
|
$people_info .= "<tr><td align='left'><br><span style='text-align: left'>".getLanguageText('TEXT-ALLERGIES')."</span>";
|
|
$people_info .= "<ul align='left'>";
|
|
while ($row = db_fetch_assoc($allergies)) {
|
|
$people_info .= "<li>".$row['allergen']."</li>";
|
|
}
|
|
$people_info .= "</ul></td></tr>";
|
|
}
|
|
|
|
$people_info .= "</table>";
|
|
writeLog("$last_name, $first_name -- $class_num $meal_location");
|
|
|
|
if (!isset($show_commands) || $show_commands == 'Y') {
|
|
$name = "<span id='delete-title1-$record_num' class='edit-data' rnum='$record_num'>$last_name, $first_name</span>";
|
|
}
|
|
else {
|
|
$name = "<span id='delete-title1-$record_num' rnum='$record_num'>$last_name, $first_name</span>";
|
|
}
|
|
$name = "<div class='hl-tooltip'>$name\n" .
|
|
"<span class='hl-tooltiptext hl-tooltip-right' style='text-align: center; width: 400px;'>$people_info</span>\n" .
|
|
"</div>";
|
|
|
|
$query = "SELECT * FROM hotlunch_order_header WHERE school_num = $curr_school_num AND ordered_by_num = $record_num ORDER BY added_time DESC";
|
|
writeLog($query);
|
|
$orders = db_query($query);
|
|
$norders = db_num_rows($orders);
|
|
$numOrders = intval($norders);
|
|
if ($numOrders > 0) $delete_flag = 'N';
|
|
|
|
$ordersTip = '';
|
|
if (isset($naction) && $naction != 'view-meal-locations' && $norders > 0) {
|
|
$delete_flag = 'N';
|
|
$ordersTip = "<table width='450' cellpadding='3'>";
|
|
$ordersTip .= "<tr><td></td><td colspan='2'><b>$first_name $last_name</b></td></tr>";
|
|
$orderCount = 0;
|
|
while ($row = db_fetch_assoc($orders)) {
|
|
$snum = $row['schedule_num'];
|
|
if (array_key_exists($snum, $Schedules)) {
|
|
$title = $Schedules[$snum];
|
|
$amt = '$'.$row['order_total'];
|
|
$ostatus = $row['status'];
|
|
$ordersTip .= "<tr><td width='10'> </td><td align='left'>$title: </td><td width='50' align='right'>$amt</td><td align='center'>$ostatus</td>";
|
|
$orderCount++;
|
|
}
|
|
}
|
|
$ordersTip .= "</table>";
|
|
$norders = "<div class='hl-tooltip student-orders' rnum=$record_num num=$norders> $orderCount\n" .
|
|
"<span class='hl-tooltiptext hl-tooltip-right' style='textalign: left'>$ordersTip</span>\n" .
|
|
"</div><input type='hidden' id='norders-$record_num' value='$norders'>";
|
|
}
|
|
|
|
// If there is a valid user_num create the tip
|
|
if (isset($naction) && $naction != 'view-meal-locations' && isset($user_num) && $user_num > 0) {
|
|
$uresults = db_query("SELECT * FROM users WHERE school_num = $base_school_num and record_num = $user_num");
|
|
if (db_num_rows($uresults)) {
|
|
$urow = db_fetch_array($uresults);
|
|
$userid = $urow['userid'];
|
|
|
|
// Get user balance
|
|
$query = "SELECT sum(transaction_amount) AS balance FROM user_account " .
|
|
"WHERE school_num = $curr_school_num " .
|
|
"AND user_num = $user_num " .
|
|
"AND (deleted != 'Y' OR deleted IS NULL)";
|
|
$user_balance = db_getVal($query);
|
|
$user_balance = $currencySymbol . number_format(floatval($user_balance),2);
|
|
|
|
$num_students = db_getVal("SELECT count(*) FROM people WHERE school_num = $base_school_num AND user_num = $user_num");
|
|
|
|
$userAdditional = '';
|
|
if (array_key_exists('type', $_SESSION['UserInfo']) && $_SESSION['UserInfo']['type'] == 'SuperUser')
|
|
$userAdditional = "<tr><td align='right'>User Num:</td><td align='left'>$user_num</td></tr>";
|
|
|
|
$Tip = "<table width='350'>" .
|
|
"<tr><td width='30%' align='right'>".getLanguageText('TEXT-USER-ID').": </td><td align='left'>$userid</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-NAME').": </td><td align='left'>$urow[first_name] $urow[last_name]</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-EMAIL').": </td><td align='left'>$urow[email]</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-PHONE').": </td><td align='left'>$urow[home_phone]</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-CELL-PHONE').": </td><td align='left'>$urow[cell_phone]</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-NUMBER-OF-STUDENTS').": </td><td align='left'>$num_students</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-TYPE').": </td><td align='left'>$urow[type]</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-DATE-ADDED').": </td><td align='left'>$urow[date_added]</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-LAST-LOGIN').": </td><td align='left'>$urow[last_login]</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-ACCOUNT-BALANCE').": </td><td align='left'>$user_balance</td></tr>" .
|
|
$userAdditional .
|
|
"</table>";
|
|
$userid = "<div class='hl-tooltip edit-user' unum='$user_num'>$userid" .
|
|
"<span class='hl-tooltiptext hl-tooltip-right' style='textalign: left'>$Tip</span>" .
|
|
"</div>";
|
|
}
|
|
}
|
|
|
|
$statusText = getLanguageText('TEXT-'.strtoupper($status));
|
|
$statusText = "<span class='student-status' id='student-status-$record_num' snum='$record_num' status='$status'>$statusText</span>\n" .
|
|
"<input type='hidden' id='status-$record_num' value='$status'>";
|
|
|
|
if ($displayMode == 'AdminDisplay') {
|
|
$mcat = strtolower(str_replace(' ','',$menu_price_category));
|
|
$mpText = getLanguageText('TEXT-'.strtoupper($menu_price_category));
|
|
switch ($menu_price_category) {
|
|
case 'Special 1':
|
|
$mpText = $Special1_Title;
|
|
break;
|
|
case 'Special 2':
|
|
$mpText = $Special2_Title;
|
|
break;
|
|
case 'Special 3':
|
|
$mpText = $Special3_Title;
|
|
break;
|
|
}
|
|
if ($menu_price_category != 'Regular') $mpText = "<span class='warning'>$mpText</span>";
|
|
$mpText = "<span id='span-price-category-$record_num' class='price-category' snum='$record_num' mcat='$mcat'>$mpText</span>";
|
|
|
|
$statusText .= "<br>$mpText";
|
|
}
|
|
|
|
$people_type = getLanguageText('TEXT-'.strtoupper($people_type));
|
|
|
|
$entry = array();
|
|
$entry[] = $name;
|
|
|
|
if (isset($naction) && $naction != 'view-meal-locations') {
|
|
if ($displayMode == 'AdminDisplay') $entry[] = $userid;
|
|
$entry[] = $norders . "<input type='hidden' id='norders-$record_num' value='$numOrders'>";
|
|
if ($school_record['collect_student_number'] == 'Y') $entry[] = $student_number;
|
|
if ($school_record['participant_grouping'] != 'None') {
|
|
$grade = '';
|
|
$eclass = '';
|
|
$gfield = '';
|
|
$class_info = '';
|
|
if (array_key_exists($class_num, $Classes)) {
|
|
$grade = $Classes[$class_num]['grade'];
|
|
$eclass = $Classes[$class_num]['eclass'];
|
|
$gfield = $Classes[$class_num]['gfield'];
|
|
$class_info = $Classes[$class_num]['class_info'];
|
|
}
|
|
$entry[] = "<span id='span-grade-$record_num' class='grade-entry$eclass' cnum='$class_num' gfield='$gfield' title='$class_info' rnum='$record_num'> $grade </span>";
|
|
if ($school_record['i_display_division'] == 'Y') {
|
|
if (isset($class_num) && $class_num != '' && array_key_exists($class_num, $Classes)) $entry[] = $Classes[$class_num]['division'];
|
|
else $entry[] = '';
|
|
}
|
|
}
|
|
if ($displayMode == 'AdminDisplay') $entry[] = $people_type;
|
|
$entry[] = $statusText;
|
|
|
|
if ($displayMode == 'AdminDisplay' && $school_record['implement_multiple_item_prices'] == 'Y') {
|
|
$entry[] = "<span id='flex-pricing-span-$record_num' class='flex-pricing' snum='$record_num'>$access_to_multiple_item_prices</span>";
|
|
}
|
|
|
|
if ($displayMode == 'AdminDisplay') $entry[] = "<span id='display-$record_num' class='display-flag' snum='$record_num'>$display</span>";
|
|
}
|
|
else {
|
|
$entry[] = $people_type;
|
|
if ($meal_location == '' || intval($meal_location) == 0) $meal_location = intval($class_num);
|
|
if (array_key_exists($meal_location, $Classes)) {
|
|
$alt_location = $Classes[$meal_location]['class_info'];
|
|
|
|
if (array_key_exists($class_num, $Classes)) {
|
|
$entry[] = $Classes[$class_num]['class_info'];
|
|
$entry[] = "<span id='meal-location-$record_num' class='meal-location-span' mlocation=$meal_location cnum=$class_num rnum=$record_num>" . $alt_location . "</span>";
|
|
if ($class_num != $meal_location) $entry["class_2"] = "warning";
|
|
}
|
|
else {
|
|
$entry[] = '';
|
|
$entry[] = '';
|
|
}
|
|
}
|
|
}
|
|
|
|
// if (array_key_exists('type', $_SESSION['UserInfo']) && $_SESSION['UserInfo']['type'] == 'SuperUser') $entry[] = $record_num;
|
|
$entry['record_num'] = $record_num;
|
|
$entry['delete_flag'] = $delete_flag;
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
$money_icon = "<img src='images/icons/money16.png' alt='Post to User Account' border='0'>";
|
|
|
|
$commands = array();
|
|
if (!isset($show_commands) || $show_commands != 'N') {
|
|
$commands[] = "<a href='#' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='#' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if ($displayMode == 'AdminDisplay') {
|
|
// $commands[] = "<a href='#' class='user-account' snum='%d' title='User Account Transactions'>$money_icon</a>";
|
|
$commands[] = "<a href='#' class='student-orders' rnum='%d'>$order_icon_small</a>";
|
|
}
|
|
else {
|
|
$commands[] = "<a href='#' class='display-student-orders btn btn--primary btn--xsmall' rnum='%d'>".getLanguageText('TEXT-ORDERS')."</a>";
|
|
}
|
|
}
|
|
|
|
$totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'parent-student-list':
|
|
// startLog("parent-students-list");
|
|
|
|
$ParentAcctsTypes = array('Parent', 'Staff', 'Guest', 'Application Volunteer', 'Administration Team', 'Schedule Team', 'Financial Team');
|
|
if (array_key_exists('type', $_SESSION['UserInfo']) && in_array($_SESSION['UserInfo']['type'], $ParentAcctsTypes)) {
|
|
$unum = intval($_SESSION['UserInfo']['record_num']);
|
|
$swhere = "AND user_num = $unum ";
|
|
$displayMode = 'ParentDisplay';
|
|
writeLog("displayMode: $displayMode");
|
|
}
|
|
else {
|
|
$return_data['content'] = '<p>' . getLanguageText('ERRORMSG-INVALID-ACCESS') . '</p>';
|
|
break;
|
|
}
|
|
|
|
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
|
|
|
|
$query = "SELECT st.* FROM people AS st, users AS u " .
|
|
"WHERE st.school_num = $base_school_num " .
|
|
"AND u.school_num = $base_school_num " .
|
|
"AND st.user_num = u.record_num " .
|
|
$swhere .
|
|
"order by last_name, first_name";
|
|
writeLog($query);
|
|
$students = db_query($query);
|
|
|
|
if (db_num_rows($students)) {
|
|
$content = "<div id='parents-students-list'>\n";
|
|
while ($row = db_fetch_assoc($students)) {
|
|
extract($row);
|
|
$student_num = $record_num;
|
|
|
|
$snums = $school_record['linked_sites'];
|
|
$query = "SELECT count(*) FROM hotlunch_order_header AS hloh, hotlunch_schedules AS hls " .
|
|
"WHERE hloh.school_num IN ($snums) " .
|
|
"AND hls.school_num IN ($snums) " .
|
|
"AND hloh.schedule_num = hls.record_num " .
|
|
"AND hls.status IN ('Pending','Active') " .
|
|
"AND ordered_by_num = $record_num";
|
|
$numOrders = db_getVal($query);
|
|
|
|
$statusText = getLanguageText('TEXT-'.$status);
|
|
|
|
$class_info = getLanguageText('TEXT-'.strtoupper($people_type));
|
|
if ($numClasses > 0) $class_info = getClassInfo($class_num, 'external',5,true);
|
|
// $class_info = getClassInfo($class_num,'external',5,true);
|
|
|
|
|
|
$content .= "<div class='parent-student-entry'>\n";
|
|
$content .= " <br>\n";
|
|
|
|
$content .= " <div class='parent-student-info info'>\n";
|
|
|
|
$content .= " <div class='parent-student-prompt student-div'>".getLanguageText('TEXT-NAME').":</div>";
|
|
$content .= " <div class='parent-student-data student-div'>$last_name, $first_name</div>\n";
|
|
|
|
$content .= " <div class='parent-student-prompt student-div'>".getLanguageText('TEXT-STATUS').":</div>";
|
|
$content .= " <div class='parent-student-data student-div'>$statusText</div>\n";
|
|
|
|
$content .= " <div class='parent-student-prompt student-div'>".getLanguageText('TEXT-CLASS').":</div>";
|
|
$content .= " <div class='parent-student-data student-div'>$class_info</div>\n";
|
|
|
|
$content .= " <br>\n";
|
|
$content .= " <br>\n";
|
|
$content .= " <br>\n";
|
|
|
|
$content .= " </div>\n";
|
|
|
|
$content .= " <div class='parent-student-buttons buttons'>\n";
|
|
|
|
if ($school_record['allow_parents_to_edit_students'] != 'N') {
|
|
$content .= " <div><button class='edit-data parent-student-button btn btn--primary btn--xsmall' style='width: 60px;' rnum='$record_num' sname='$last_name, $first_name'> " .
|
|
getLanguageText('TEXT-EDIT') . " </button></div>\n";
|
|
}
|
|
if ($numOrders == 0) {
|
|
$content .= " <br>\n";
|
|
$content .= " <div><button class='delete-data parent-student-button btn btn--primary btn--xsmall' rnum='$record_num' style='width: 60px;'> " .
|
|
getLanguageText('TEXT-DELETE')." </button></div>\n";
|
|
}
|
|
|
|
$content .= " <br>\n";
|
|
$content .= " <div><button class='view-student-orders parent-student-button btn btn--primary btn--xsmall' rnum='$record_num' style='width: 60px;'> " .
|
|
getLanguageText('TEXT-ORDERS')." </button></div>\n";
|
|
$content .= " <br>\n";
|
|
$content .= " </div>\n";
|
|
|
|
//
|
|
// Get student orders and schedules
|
|
//
|
|
if (isset($record_num)) $student_num = $record_num;
|
|
|
|
// Determine the number of currently active schedules
|
|
$today = date("Y-m-d",time());
|
|
$now = date("Y-m-d H:i:s",time());
|
|
$school_num = $school_record['record_num'];
|
|
|
|
$swhere = "AND start_order_datetime <= '$now' AND status in ('Active') ";
|
|
|
|
$num_active = db_getVal("SELECT count(*) FROM hotlunch_schedules " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_type != 'Volunteer Only' " .
|
|
$swhere);
|
|
|
|
// Check if there is a current schedule
|
|
$query = "select * from hotlunch_schedules " .
|
|
"where school_num = $school_num " .
|
|
"AND schedule_type != 'Volunteer Only' " .
|
|
$swhere .
|
|
"order by end_order_datetime DESC";
|
|
$current_schedules = db_query($query);
|
|
$num_schedules = db_num_rows($current_schedules);
|
|
$num_classes = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
|
|
|
|
$schedules = array();
|
|
$displayDiscounts = False;
|
|
|
|
writeLog("count current_schedules: ".db_num_rows($current_schedules));
|
|
if (db_num_rows($current_schedules) > 0) {
|
|
if ($num_classes > 0) $class_num = db_getVal("select class_num from people where school_num = $base_school_num and record_num = $student_num");
|
|
else {
|
|
$class_num = 3;
|
|
if ($_SESSION['UserInfo']['type'] == 'Staff') $class_num = 1;
|
|
if ($_SESSION['UserInfo']['type'] == 'Guest') $class_num = 2;
|
|
}
|
|
|
|
$cutoff_date = date("Y-m-d",time() - 60 * 60 * 24 * 45);
|
|
|
|
while ($row = db_fetch_array($current_schedules)) {
|
|
$schedule_num = $row['record_num'];
|
|
|
|
// Check that the schedule has menu dates and items defined
|
|
$numDates = db_getVal("SELECT count(*) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num");
|
|
if ($numDates == 0) continue;
|
|
|
|
$numItems = db_getVal("SELECT count(*) FROM hotlunch_menu_dates AS hlmd, hotlunch_menu_items AS hlmi " .
|
|
"WHERE hlmd.school_num = $school_num " .
|
|
"AND hlmi.school_num = $school_num " .
|
|
"AND hlmd.schedule_num = $schedule_num " .
|
|
"AND hlmi.menu_num = hlmd.record_num");
|
|
if ($numItems == 0) continue;
|
|
|
|
// Check if there is an order for this schedule
|
|
$results = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $student_num AND schedule_num = $schedule_num");
|
|
if (db_num_rows($results)) {
|
|
$schedules[] = $row;
|
|
continue;
|
|
}
|
|
|
|
// Check if this is a limited access schedule by class
|
|
$class_entries = db_getVal("select count(*) from hotlunch_schedules_classes where school_num = $school_num and schedule_num = $schedule_num");
|
|
|
|
if ($class_entries > 0 && (($people_type != 'Staff' && $class_num > 0) || ($people_type == 'Staff' && $class_num == 0))) {
|
|
$query = "select count(*) from hotlunch_schedules_classes " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and class_num = $class_num";
|
|
$schedule_access = db_getVal($query);
|
|
if ($schedule_access == 0) continue;
|
|
}
|
|
|
|
// Check if this is a limited access schedule by category
|
|
$category_entries = db_getVal("select count(*) from hotlunch_schedules_categories where school_num = $school_num and schedule_num = $schedule_num");
|
|
|
|
if ($category_entries > 0) {
|
|
$query = "SELECT count(*) FROM hotlunch_schedules_categories AS hlsc, people_categories AS pc " .
|
|
"WHERE hlsc.school_num = $school_num " .
|
|
"AND pc.school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND hlsc.category_num = pc.category_num " .
|
|
"AND pc.people_num = $student_num";
|
|
$schedule_access = db_getVal($query);
|
|
if ($schedule_access == 0) continue;
|
|
}
|
|
|
|
$schedules[] = $row;
|
|
$schedule_num = $row['record_num'];
|
|
}
|
|
}
|
|
|
|
if (count($schedules) > 0) {
|
|
|
|
// Initialize the totals
|
|
$t_balance = 0;
|
|
$t_subtotal = 0;
|
|
$t_discount = 0;
|
|
$t_paid = 0;
|
|
$order_total = 0;
|
|
$order_net = 0;
|
|
|
|
$content .= " <div id='student-orders-$student_num' class='student-orders footer' style='display: none'>\n";
|
|
$content .= " <table width='75%' cellpadding='2' cellspacing='1' class='content-table' align='center'>\n";
|
|
$content .= " <tr class='heading'>";
|
|
$content .= " <td align='left' width='45%'><b>".getLanguageText('TEXT-SCHEDULE')."</b></td>\n";
|
|
$content .= " <td align='right' width='20%'><b>".getLanguageText('TEXT-TOTAL')."</b></td>\n";
|
|
// $content .= " <td align='center' width='20%'><b>".getLanguageText('TEXT-STATUS')."</b></td>\n";
|
|
$content .= " <td align='center' width='15%'></td>\n";
|
|
$content .= " </tr>\n";
|
|
|
|
$schedule_status = "";
|
|
$bgclass = 'data-odd';
|
|
|
|
for ($sn = 0; $sn < count($schedules); $sn++) {
|
|
$schedule = $schedules[$sn];
|
|
extract($schedule);
|
|
$schedule_num = $record_num;
|
|
|
|
$editPaid = 'Y';
|
|
if ($school_record['allow_edit_of_paid_orders'] == 'N') $editPaid = 'N';
|
|
if ($edit_paid_orders == 'N') $editPaid = 'N';
|
|
if ($edit_paid_orders == 'Y') $editPaid = 'Y';
|
|
|
|
$Tip = "<table width='550'>" .
|
|
"<tr><td width='30%' align='right'>".getLanguageText('TEXT-SCHEDULE').": </td><td align='left'>$schedule_name</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-START-ORDER').": </td><td align='left'>$start_order_datetime</td></tr>" .
|
|
"<tr><td align='right'>".getLanguageText('TEXT-END-ORDER').": </td><td align='left'>$end_order_datetime</td></tr>" .
|
|
"</table>";
|
|
$schedule_name = "<div class='hl-tooltip'>$schedule_name" .
|
|
"<span class='hl-tooltiptext hl-tooltip-right' style='textalign: left'>$Tip</span>" .
|
|
"</div>";
|
|
|
|
$bgclass = 'data-odd';
|
|
if ($sn % 2) $bgclass = 'data-even';
|
|
|
|
$order_subtotal = 0;
|
|
$discount_amount = 0;
|
|
$order_total = 0;
|
|
$amount_paid = 0;
|
|
$balance = 0;
|
|
$t_total = 0;
|
|
$status = "No Order";
|
|
unset($order_num);
|
|
|
|
// Get order information for this student and this schedule
|
|
$query = "select schedule_num,order_subtotal,discount_amount,order_total," .
|
|
"amount_paid,status,record_num as order_num " .
|
|
"from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and ordered_by_num = $student_num " .
|
|
"and status != 'Deleted'";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$balance = $order_subtotal - $discount_amount - $amount_paid;
|
|
$t_subtotal += $order_subtotal;
|
|
$t_total += $order_total;
|
|
$t_discount += $discount_amount;
|
|
$t_paid += $amount_paid;
|
|
$t_balance += $balance;
|
|
|
|
$statusText = getLanguageText('TEXT-'.$status);
|
|
|
|
$content .= " <tr class='$bgclass'>\n";
|
|
$content .= " <td align='left'>$schedule_name</td>\n";
|
|
$content .= " <td align='right'>$currencySymbol".number_format($order_total,2)."</td>\n";
|
|
// $content .= " <td align='center'>$statusText</td>\n";
|
|
|
|
if (isset($order_num) || $end_order_datetime > $now) {
|
|
$edit = 'Y';
|
|
$buttonText = getLanguageText('TEXT-ORDER');
|
|
if ($end_order_datetime < $now) {
|
|
$edit = 'N';
|
|
$buttonText = getLanguageText('TEXT-VIEW');
|
|
}
|
|
else {
|
|
if ($status == 'Paid' && $editPaid == 'Y') {
|
|
$buttonText = getLanguageText('TEXT-EDIT');
|
|
}
|
|
}
|
|
|
|
$content .= " <td align='center'><button class='order-button parent-student-button btn btn--primary btn--xsmall' snum='$schedule_num' stnum='$student_num' onum='$order_num'> $buttonText </button>";
|
|
|
|
if (isset($order_num) && $order_num > 0) {
|
|
$content .= " <a href='?action=orders-print&schedule_num=$schedule_num&naction=edit-header&order_num=$order_num'>$print_icon</a>";
|
|
}
|
|
|
|
$content .= "</td>\n";
|
|
}
|
|
else {
|
|
$content .= " <td align='center'>".getLanguageText('TEXT-NOT-AVAILABLE')."</td>\n";
|
|
}
|
|
|
|
$content .= " </tr>\n";
|
|
}
|
|
}
|
|
else {
|
|
|
|
$statusText = getLanguageText('TEXT-NO-ORDER');
|
|
$orderText = getLanguageText('TEXT-NOT-AVAILABLE');
|
|
|
|
if ($end_order_datetime > $now) {
|
|
if (!isset($order_num)) $order_num = 0;
|
|
$buttonText = getLanguageText('TEXT-ORDER');
|
|
$orderText = "<button class='order-button btn btn--primary btn--xsmall' snum='$schedule_num' stnum='$student_num' onum='$order_num'> $buttonText </button>";
|
|
}
|
|
|
|
$content .= " <tr class='$bgclass'>\n";
|
|
$content .= " <td align='left'>$schedule_name</td>\n";
|
|
$content .= " <td align='right'>$currencySymbol".number_format($order_total,2)."</td>\n";
|
|
// $content .= " <td align='center'>$statusText</td>\n";
|
|
$content .= " <td align='center'>$orderText</td>\n";
|
|
$content .= " </tr>\n";
|
|
}
|
|
}
|
|
|
|
$content .= " </table>\n";
|
|
$content .= " <br>\n";
|
|
|
|
$content .= " </div>\n";
|
|
|
|
}
|
|
|
|
$content .= "</div>\n";
|
|
}
|
|
$content .= "</div>\n";
|
|
}
|
|
$return_data['content'] = $content;
|
|
|
|
break;
|
|
|
|
case 'classified-ads':
|
|
// startLog('classified-ads');
|
|
$today = date("Y-m-d",time());
|
|
$query = "SELECT cc.category, cs.subcategory, ca.* " .
|
|
"FROM classified_ads AS ca, classified_categories AS cc, classified_subcategories AS cs " .
|
|
"WHERE ca.school_num = $school_num " .
|
|
"AND ca.subcategory_num = cs.record_num " .
|
|
"AND cs.category_num = cc.record_num " .
|
|
"AND ca.post_until_date >= '$today' " .
|
|
"ORDER BY category, subcategory, posted_time";
|
|
writeLog($query);
|
|
$ads = db_query($query);
|
|
$num = db_num_rows($ads);
|
|
writeLog("num: $num");
|
|
|
|
if ($num > 0) {
|
|
$content = "<div id='classified-ads'>\n";
|
|
|
|
$pcat = "";
|
|
$psubcat = "";
|
|
|
|
while ($row = db_fetch_assoc($ads)) {
|
|
extract($row);
|
|
writeLog($category);
|
|
writeLog($subcategory);
|
|
writeLog($title);
|
|
|
|
if ($category != $pcat) {
|
|
if (strlen($pcat) > 0) $content .= "</div>";
|
|
$content .= "<div class='classified-category-div'>\n";
|
|
$content .= "<div class='classified-category'>$category</div>\n";
|
|
$pcat = $category;
|
|
$psubcat = "";
|
|
}
|
|
|
|
if ($subcategory != $psubcat) {
|
|
$content .= "<div class='classified-subcategory'>$subcategory</div>\n";
|
|
$psubcat = $subcategory;
|
|
}
|
|
|
|
$contact_email = "<a href='mailto:$contact_email'>$contact_email</a>";
|
|
|
|
$content .= "<div class='classified-ad'>\n";
|
|
$content .= "<div class='classified-title'>$title</div>\n";
|
|
$content .= "<div class='classified-description'>".nl2br($description)."</div>\n";
|
|
$content .= "<div class='classified-contact'>$contact_info</div>\n";
|
|
$content .= "<div class='classified-contact'>$contact_email</div>\n";
|
|
|
|
if ($userType == 'Admin') {
|
|
$content .= "<br>";
|
|
$content .= "<button rnum='$record_num' class='edit-data btn btn--outline btn--xsmall'>".getLanguageText('TEXT-EDIT')."</button>";
|
|
$content .= "<button rnum='$record_num' class='delete-data btn btn--outline btn--xsmall'>".getLanguageText('TEXT-DELETE')."</button>";
|
|
}
|
|
|
|
$content .= "</div>\n";
|
|
}
|
|
|
|
$content .= "</div>\n";
|
|
$content .= "</div>\n";
|
|
}
|
|
else {
|
|
$content = "<p><br><b>".getLanguageText('TEXT-THERE-ARE-NO-CLASSIFIED-ADS-AT-THIS-TIME')."</b></p>";
|
|
}
|
|
|
|
writeLog($content);
|
|
$return_data['content'] = $content;
|
|
break;
|
|
|
|
case 'allergens':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-ALLERGEN'),
|
|
getLanguageText('TEXT-NUMBER')
|
|
);
|
|
$columnAlign = array('left','center');
|
|
|
|
// Get records to display
|
|
$query = "select allergen,count(al.people_num) AS number,sequence,a.record_num " .
|
|
"from allergens as a left join allergies as al on a.school_num = al.school_num and a.record_num = al.allergen_num " .
|
|
"left join people as p on p.school_num = a.school_num and al.people_num = p.record_num " .
|
|
"where a.school_num = $school_num " .
|
|
"group by 1,3,4 " .
|
|
"order by sequence";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
if ($number > 0) $delete_flag = 'N';
|
|
|
|
$data[] = array($allergen,
|
|
$number,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 650;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'resellers-list':
|
|
// Setup format
|
|
$columnHeaders = array("Reseller Code", "Business", "Contact", "Phone", "Email", "Schools");
|
|
$columnAlign = array('left','left','left','left','left','center');
|
|
|
|
// Get records to display
|
|
$query = "select * from resellers order by business_name";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$number = db_getVal("SELECT count(*) FROM schools WHERE reseller = '$reseller_code' AND status = 'Active'");
|
|
|
|
$delete_flag = 'Y';
|
|
if ($number > 0) $delete_flag = 'N';
|
|
|
|
if (strlen($email)) $email = "<a href='mailto:$email'>$email</a>";
|
|
|
|
$data[] = array($reseller_code,
|
|
$business_name,
|
|
$contact_name,
|
|
$phone,
|
|
$email,
|
|
$number,
|
|
"record_num" => $record_num,
|
|
"delete_flag" => $delete_flag);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='edit-data' rnum='%d' title='Edit Current Entry'>$edit_icon_small</a>";
|
|
$commands[] = "<a href='?record_num=%d' class='delete-data' rnum='%d' dflag='%s' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 850;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'category-people':
|
|
// Get category number
|
|
$cnum = intval($_GET['cnum']);
|
|
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-NAME'),
|
|
);
|
|
$columnAlign = array('left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "SELECT p.* FROM people_categories AS pc, people AS p " .
|
|
"WHERE pc.school_num = $school_num " .
|
|
"AND p.school_num = $school_num " .
|
|
"AND p.record_num = pc.people_num " .
|
|
"AND pc.category_num = $cnum " .
|
|
"ORDER BY last_name,first_name";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$name = $first_name.' '.$last_name;
|
|
$delete_flag = 'Y';
|
|
|
|
$data[] = array($name,
|
|
"record_num" => $record_num);
|
|
}
|
|
|
|
// Commands
|
|
$commands = array();
|
|
$commands[] = "<a href='?record_num=%d' class='delete-people-category' rnum='%d' cnum='$cnum' title='Delete Current Entry'>$delete_icon_small</a>";
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 450;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'meal-locations':
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-ALTERNATE-LOCATION'),
|
|
getLanguageText('TEXT-NUMBER'),
|
|
);
|
|
$columnAlign = array('left','center','center');
|
|
|
|
// Get records to display
|
|
$query = "SELECT * FROM meal_locations " .
|
|
"WHERE school_num = $school_num " .
|
|
"ORDER BY sequence";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$delete_flag = 'Y';
|
|
$numPeople = db_getVal("SELECT count(*) FROM people WHERE meal_location = $record_num");
|
|
|
|
$data[] = array($location,
|
|
$numPeople,
|
|
"record_num" => $record_num);
|
|
}
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 450;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,$totals);
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'delete-trx-info':
|
|
// startLog('delete-trx-info');
|
|
|
|
// Get parameters
|
|
if (array_key_exists('user_num', $_GET)) $user_num = intval($_GET['user_num']);
|
|
if (array_key_exists('trx_num', $_GET)) $tn = intval($_GET['trx_num']);
|
|
|
|
if (!isset($user_num)) return;
|
|
writeLog("user_num: $user_num");
|
|
if (!isset($tn)) return;
|
|
writeLog("tn: $tn");
|
|
|
|
// Get user information
|
|
$results = db_query("SELECT * FROM users WHERE school_num = $base_school_num AND record_num = $user_num");
|
|
$user_info = db_fetch_array($results);
|
|
$user_email = $user_info['email'];
|
|
$userid = $user_info['userid'];
|
|
// $userid = "<a href='mailto:$user_email'>$userid</a>";
|
|
|
|
$user_name = $user_info['first_name'] . ' ' . $user_info['last_name'];
|
|
$user_contact = "$userid<br>\n$user_name - " . $user_info['home_phone'];
|
|
writeLog("user_contact: $user_contact");
|
|
|
|
|
|
$query = "SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $user_num AND record_num = $tn";
|
|
writeLog($query);
|
|
$results = db_query($query);
|
|
if (db_num_rows($results) == 0) {
|
|
writeLog("TRX not found");
|
|
return;
|
|
}
|
|
|
|
$trx = db_fetch_array($results);
|
|
|
|
// Get entered by userid
|
|
$entered_by_userid = "automatic";
|
|
writeLog("entered_by_userid: $entered_by_userid");
|
|
if ($trx['entered_by_user_num'] > 0) {
|
|
if ($trx['entered_by_user_num'] != 1)
|
|
$entered_by_userid = db_getVal("SELECT userid FROM users WHERE school_num = $base_school_num AND record_num = $trx[entered_by_user_num]");
|
|
}
|
|
writeLog("entered_by_userid: $entered_by_userid");
|
|
|
|
$payment_method = "--";
|
|
if (strlen($trx['payment_method'])) $payment_method = translateText($trx['payment_method']);
|
|
|
|
$return_data['content'] = "<table width='400' cellspacing='5'>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td align='right' valign='top'>" . getLanguageText('TEXT-NAME') . ": </td>";
|
|
$return_data['content'] .= "<td align='left' valign='top'><b>$user_contact</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td align='right' valign='top'>" . getLanguageText('TEXT-TRANSACTION-TYPE') . ": </td>";
|
|
$return_data['content'] .= "<td align='left' valign='top'><b>" . translateText($trx['transaction_type']) . "</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td align='right' valign='top'>" . getLanguageText('TEXT-PAYMENT-METHOD') . ": </td>";
|
|
$return_data['content'] .= "<td align='left' valign='top'><b>$payment_method</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td align='right' valign='top'>" . getLanguageText('TEXT-TRANSACTION-AMOUNT') . ": </td>";
|
|
$return_data['content'] .= "<td align='left' valign='top'><b>" . $trx['transaction_amount'] . "</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td align='right' valign='top'>" . getLanguageText('TEXT-TRANSACTION-NOTE') . ": </td>";
|
|
$return_data['content'] .= "<td align='left' valign='top'><b>" . translateText($trx['note']) . "</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td align='right' valign='top'>" . getLanguageText('TEXT-PAYMENT-REFERENCE') . ": </td>";
|
|
$return_data['content'] .= "<td align='left' valign='top'><b>" . $trx['payment_reference'] . "</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td align='right' valign='top'>" . getLanguageText('TEXT-ENTERED-BY') . ": </td>";
|
|
$return_data['content'] .= "<td align='left' valign='top'><b>$entered_by_userid</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "</table>";
|
|
writeLog($return_data['content']);
|
|
break;
|
|
|
|
case 'upcoming-demos':
|
|
case 'recent-demos':
|
|
// Get school demo info
|
|
$today = date("Y-m-d 00:00:00",time());
|
|
$cutoff = date("Y-m-d 00:00:00",time() - 24 * 60 * 60 * 60);
|
|
|
|
if ($action == 'upcoming-demos') $query = "SELECT * FROM schools WHERE demo_scheduled_date > '$today' ORDER BY demo_scheduled_date";
|
|
if ($action == 'recent-demos') $query = "SELECT * FROM schools WHERE demo_scheduled_date > '$cutoff' AND demo_scheduled_date <= '$today' ORDER BY demo_scheduled_date";
|
|
|
|
$return_data['content'] = "<p>[<a href='#' class='upcoming-demo-list'>Upcoming</a>] [<a href='#' class='recent-demo-list'>Recent</a>]</p>";
|
|
|
|
$results = db_query($query);
|
|
writeLog("num rows: " . db_num_rows($results) . "\n");
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
$return_data['content'] .= "<p><b> --- No Demos Scheduled --- </b></p>";
|
|
writeLog($return_data['content'] . "\n");
|
|
}
|
|
else {
|
|
$return_data['content'] .= "<p><b>-- Hot Lunch Demos --</b></p>";
|
|
$return_data['content'] .= "<center><table cellpadding='1' cellspacing='3' border='0'>";
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt show-school-info' snum='$record_num' align='left' width='300'>$school_name</td>";
|
|
$return_data['content'] .= "<td class='prompt show-school-info' snum='$record_num' width='150'>$demo_scheduled_date</td>";
|
|
$return_data['content'] .= "</tr>";
|
|
}
|
|
$return_data['content'] .= "</table>";
|
|
$return_data['content'] .= "</center>";
|
|
}
|
|
break;
|
|
|
|
case 'schedule-info':
|
|
// startLog("schedule-info");
|
|
|
|
if (array_key_exists('schedule_num', $_GET)) $schedule_num = intval($_GET['schedule_num']);
|
|
if (!isset($schedule_num)) return;
|
|
writeLog("schedule_num: $schedule_num");
|
|
|
|
if ($schedule_num == 0) {
|
|
$return_data['content'] = "";
|
|
break;
|
|
}
|
|
|
|
$supplier_school_num = intval($school_record['supplier_school_num']);
|
|
if ($supplier_school_num == 0) $supplier_school_num = $school_num;
|
|
|
|
$query = "SELECT * FROM hotlunch_schedules WHERE school_num IN ($school_num, $supplier_school_num) AND record_num = $schedule_num";
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser') $query = "SELECT * FROM hotlunch_schedules WHERE record_num = $schedule_num";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results) == 0) {
|
|
$return_data['content'] = getLanguageText('ERRORMSG-INVALID-SCHEDULE');
|
|
writeLog("Invalid Schedule");
|
|
break;
|
|
}
|
|
|
|
$schedule = db_fetch_assoc($results);
|
|
extract($schedule);
|
|
|
|
writeLog("schedule_name: $schedule_name");
|
|
$return_data['new_schedule'] = $schedule_name;
|
|
$return_data['ordering_start'] = substr($start_order_datetime,0,16);
|
|
$return_data['ordering_end'] = substr($end_order_datetime,0,16);
|
|
$return_data['schedule_start'] = $schedule_start_date;
|
|
|
|
$query = "SELECT count(*) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num";
|
|
writeLog($query);
|
|
$numMenus = db_getVal($query);
|
|
writeLog("numMenus: $numMenus");
|
|
|
|
$numItems = db_getVal("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)");
|
|
|
|
$startDate = date("l F d, Y",strtotime($schedule_start_date));
|
|
|
|
$content = "<b>$schedule_name</b> ($schedule_type)<br>" .
|
|
getLanguageText('TEXT-MENUS') . ": $numMenus</br >" .
|
|
getLanguageText('TEXT-MENU-ITEMS') . ": $numItems<br>" .
|
|
getLanguageText('TEXT-SCHEDULE-START-DATE') . ": <b>$startDate</b>";
|
|
writeLog($content);
|
|
$return_data['content'] = $content;
|
|
break;
|
|
|
|
case 'school-info':
|
|
// startLog("school-info");
|
|
$school_num = intval($_GET['school_num']);
|
|
|
|
// Get school info
|
|
$query = "SELECT * FROM schools WHERE record_num = $school_num";
|
|
$results = db_query($query);
|
|
|
|
$row = db_fetch_assoc($results);
|
|
extract($row);
|
|
|
|
date_default_timezone_set($timezone);
|
|
$timeNow = date("Y-m-d H:i",time());
|
|
date_default_timezone_set("Canada/Pacific");
|
|
|
|
$sprices = "";
|
|
if (strlen($special_item_prices)) $sprices = " ($special_item_prices)";
|
|
|
|
$last_login = "";
|
|
$userid = "";
|
|
$query = "SELECT last_login,userid FROM login_log WHERE school_num = $school_num AND userid != 'superuser' ORDER BY last_login DESC LIMIT 0,1";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$row = db_fetch_assoc($results);
|
|
$last_login = $row['last_login'];
|
|
$userid = $row['last_login'];
|
|
}
|
|
|
|
// Adjust URL if required
|
|
switch ($url) {
|
|
case 'larondepac.ca':
|
|
case 'aeslunchbox.com':
|
|
case 'clesharks.ca':
|
|
case 'ggpac.org':
|
|
case 'stonecresthotlunch.ca':
|
|
case 'sullivanpac.com':
|
|
$url = "www.$url";
|
|
break;
|
|
}
|
|
|
|
if (strlen($bill_organization) == 0) $bill_organization = 'None';
|
|
|
|
$return_data['content'] = "<b>$school_name</b> ($school_num) " .
|
|
"- [<a href='#' class='edit-school' rnum='$school_num'>edit</a>] " .
|
|
"- [<a href='#' snum='$school_num' class='refresh-info'>refresh</a>] " .
|
|
"- <a href='http://$url' target='_blank'>$url</a> " .
|
|
"- [<a href='https://$url/?db_mode=Current&display_content=No&action=logout' target='_blank'>Clean</a>] $sprices<br>" .
|
|
"$city, $province - $phone<br>" .
|
|
"$principal - <a href='mailto:$principal_email'>$principal_email</a><br>";
|
|
$return_data['content'] .= " - Status: <span id='status-$school_num' class='status' snum='$school_num' status='$status'>$status</span><br>" .
|
|
" - Support: <span id='support-$school_num' class='support' snum='$school_num' support='$support_level'>$support_level</span><br>" .
|
|
" - Configuration: <span id='config-$school_num' class='configuration' snum='$school_num' config='$system_configuration'>$system_configuration</span><br>" .
|
|
" - Small School Discount: <span id='small-school-$school_num' class='small-school-discount' snum='$school_num' discount='$small_school_discount'>$small_school_discount</span><br>" .
|
|
" - Start Date: $start_date<br>" .
|
|
" - Expiry Date: <span id='info-ed-$school_num' class='expiry-date' snum='$school_num' edate='$expiry_date'>$expiry_date</span><br>" .
|
|
" - Last Login: $last_login ($userid)<br>" .
|
|
" - Timezone: $timezone<br>" .
|
|
" - Time Now: <b>$timeNow</b><br>" .
|
|
" - Access Code: $system_access_code<br>" .
|
|
" - Reseller Code: <span class='reseller-code'>$reseller</span><br>" .
|
|
" - Billing Organization: <span class='billing-organization-code'>$bill_organization</span><br>" .
|
|
" - Reminder Day: $email_reminder_day ($email_reminder_weeks)<br>" .
|
|
"<br>";
|
|
|
|
if ($paypal_enabled == 'Y') {
|
|
$return_data['content'] .= " - PayPal Code: $paypal_code<br>\n";
|
|
$return_data['content'] .= " - PayPal Verified: <span class='paypal-verified' snum='$school_num'>$paypal_verified</span><br>\n";
|
|
}
|
|
|
|
if ($bambora_enabled == 'Y') {
|
|
$return_data['content'] .= " - Bambora MID: $bambora_merchant_id<br>\n";
|
|
}
|
|
|
|
// Check for schools linked to this school as a supplier
|
|
$query = "SELECT * FROM schools WHERE supplier_school_num = $school_num ORDER BY school_name";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$return_data['content'] .= "<br>\n";
|
|
$return_data['content'] .= "<b>Connected Supplier Schools</b><br>\n";
|
|
$return_data['content'] .= "<div id='connected-schools-div'>";
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$sname = $row['school_name'];
|
|
$url = $row['url'];
|
|
$snum = $row['record_num'];
|
|
$editLink = "<a href='#' class='edit-school' rnum='$snum'>$edit_icon_small</a> ";
|
|
$return_data['content'] .= "<div class='edit-connected-school'>$editLink $sname ($snum)</div>";
|
|
$return_data['content'] .= "<div class='connect-school-url'><a href='https://$url' target='_blank'>$url</a></div>\n";
|
|
}
|
|
$return_data['content'] .= "</div><br>\n";
|
|
}
|
|
|
|
$return_data['content'] .= "<a href='/school-setup.php?school_num=$record_num' target='_blank' title='School Setup'>setup</a><br>";
|
|
|
|
// Demo and followup info
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "<div style='width: 100%; overflow: hidden;'>\n";
|
|
$return_data['content'] .= "<div style='width: 400px; float: left; margin: 0 0 0 20px;'>\n";
|
|
$return_data['content'] .= "<table width='350' cellpadding='0' cellspacing='2' border='0'>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><span class='welcome-email-sent' snum='$school_num'><b>Welcome Email Sent:</b></span></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center' width='150'><span id='welcome-email-sent-$school_num' class='welcome-email-sent' snum='$school_num'>$welcome_email_sent</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><span class='followup-email-sent' snum='$school_num'><b>Followup Email Sent:</b></span></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><span id='followup-email-sent-$school_num' class='followup-email-sent' snum='$school_num'>$followup_email_sent</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><span class='demo-scheduled' snum='$school_num'><b>Demo Scheduled For:</b></span></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><span id='demo-scheduled-$school_num' class='demo-scheduled' snum='$school_num'>$demo_scheduled_date</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><span class='followup1-date' snum='$school_num'><b>Followup Date 1:</b></span></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><span id='followup1-date-$school_num' class='followup1-date' snum='$school_num'>$followup1_date</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><b>Followup Note 1:</b></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><input type='text' name='followup_note1' id='followup_note1' size='30' class='followup-note' snum='$school_num' " .
|
|
"note='1' value='$followup_note1'></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><span class='followup2-date' snum='$school_num'><b>Followup Date 2:</b></span></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><span id='followup2-date-$school_num' class='followup2-date' snum='$school_num'>$followup2_date</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><b>Followup Note 2:</b></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><input type='text' name='followup_note2' id='followup_note2' size='30' class='followup-note' snum='$school_num' " .
|
|
"note='2' value='$followup_note2'></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><span class='last-contact' snum='$school_num'><b>Last Contact Date:</b></span></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><span id='last-contact-date-$school_num' class='last-contact' snum='$school_num'>$last_contact_date</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><span class='testimonial' snum='$school_num'><b>Testimonial:</b></span></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><span id='testimonial-$school_num' class='testimonial' snum='$school_num'>$testimonial</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td class='prompt'><span class='renewal-contact' snum='$school_num'><b>Renewal Contact:</b></span></td>";
|
|
$return_data['content'] .= "<td class='school-data' align='center'><span id='renewal-contact-$school_num' class='renewal-contact' snum='$school_num'>$renewal_contact</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "</table>";
|
|
$return_data['content'] .= "</div>\n";
|
|
|
|
$return_data['content'] .= "<div style='margin-left: 420px;'>\n";
|
|
// $return_data['content'] .= "<b>Notes:</b> - [<a href='#' id='edit-notes' snum='$school_num'>edit</a>]<br>\n";
|
|
$return_data['content'] .= "<b>Notes:</b><br>\n";
|
|
$return_data['content'] .= "<textarea rows='8' cols='45' id='school-notes'>$notes</textarea>";
|
|
$return_data['content'] .= "<input type='hidden' id='school-num' value='$school_num'>\n";
|
|
$return_data['content'] .= "</div>\n";
|
|
|
|
$return_data['content'] .= "</div>\n";
|
|
|
|
$return_data['contacts'] = "";
|
|
$return_data['invoices'] = "";
|
|
|
|
// Get list of admin accounts
|
|
$query = "SELECT * FROM users WHERE school_num = $school_num AND type = 'System Administrator' ORDER BY userid";
|
|
// $return_data['contacts'] .= "<br>$query<br><br>";
|
|
$results = db_query("SELECT * FROM users WHERE school_num = $school_num AND type = 'System Administrator' ORDER BY userid");
|
|
if (db_num_rows($results)) {
|
|
$return_data['contacts'] .= "<b>Administrator Accounts:</b><br>";
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
// if ($userid == 'admin') {
|
|
if ($userid == 'admin' && $password != 'admin') {
|
|
$rlink = " [<span class='reset-admin' snum='$school_num' unum='$record_num'>Reset Admin Password</span>]";
|
|
$return_data['contacts'] .= " - <span class='reset-admin' snum='$school_num' unum='$record_num'>$userid</span> / $password $rlink<br>";
|
|
}
|
|
else $return_data['contacts'] .= " - $userid / $password<br>";
|
|
}
|
|
}
|
|
|
|
// Get contact list
|
|
$query = "SELECT * FROM school_contact_list WHERE school_num = $school_num ORDER BY sequence";
|
|
// $return_data['contacts'] .= "<br>$query<br><br>";
|
|
$results = db_query("SELECT * FROM school_contact_list WHERE school_num = $school_num ORDER BY sequence");
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$return_data['contacts'] .= "<br><b>$contact_name</b>";
|
|
if (strlen($contact_email)) $return_data['contacts'] .= " - <a href='mailto:$contact_email'>$contact_email</a>";
|
|
$return_data['contacts'] .= "<br>";
|
|
if (strlen($contact_phone)) $return_data['contacts'] .= " - Phone: $contact_phone<br>";
|
|
if (strlen($contact_cell)) $return_data['contacts'] .= " - Cell: $contact_cell<br>";
|
|
}
|
|
|
|
if (strpos($url,'hotlunches.net') !== false || strpos($url,'payschoolfees.net') !== false ||
|
|
strpos($url,'parentcouncil.net') !== false || strpos($url,'fundraiserorders.com') !== false ||
|
|
strpos($url,'registrationnow.net') !== false || strpos($url,'schoolcouncil.net') !== false ||
|
|
strpos($url,'schoollunchorders.net') !== false) {
|
|
|
|
$BaseURL = str_replace("$default_url_code.",'',$url);
|
|
$schoolID = $default_url_code;
|
|
$alias_email = trim($support_email);
|
|
if (strlen($alias_email) == 0) $alias_email = trim($reply_email);
|
|
$return_data['contacts'] .= "<br><br>";
|
|
$return_data['contacts'] .= "<b>Email Alias:</b> $schoolID@$BaseURL => $alias_email";
|
|
$return_data['contacts'] .= "<br><br>";
|
|
}
|
|
|
|
|
|
// Get any linked sites
|
|
$results = db_query("SELECT * FROM schools WHERE status = 'Linked' AND linked_site = $school_num ORDER BY link_sequence");
|
|
if (db_num_rows($results)) {
|
|
$return_data['content'] .= "<br>";
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$editLink = "[<a href='?action=schools-list&naction=edit&record_num=$record_num'>edit</a>]";
|
|
$return_data['content'] .= "- ($record_num) <a href='http://$url' target='_blank'>$url</a> " .
|
|
"- <a href='http://$url/?display_content=No' target='_blank'>Clean</a> " .
|
|
"$editLink ($special_item_prices)<br>";
|
|
}
|
|
}
|
|
|
|
// Get current schedules information
|
|
$cutoff = date("Y-m-d", time() - 60 * 60 * 24 * 10);
|
|
$results = db_query("SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND status = 'Active' AND schedule_end_date > '$cutoff' ORDER BY schedule_start_date");
|
|
$return_data['schedules'] = '';
|
|
$return_data['schedules'] .= "<br>";
|
|
$return_data['schedules'] = "<b>$school_name</b> ($school_num) " .
|
|
"- [<a href='?action=schools-list&naction=edit&record_num=$school_num'>edit</a>] " .
|
|
"- [<a href='#' snum='$school_num' class='refresh-info'>refresh</a>] " .
|
|
"- <a href='http://$url' target='_blank'>$url</a> $sprices<br><br>";
|
|
if (db_num_rows($results)) {
|
|
$return_data['schedules'] .= "<table class='invoices-table'>";
|
|
$return_data['schedules'] .= "<tr>";
|
|
$return_data['schedules'] .= "<td align='left' width='300'>".getLanguageText('TEXT-TITLE')."</td>";
|
|
$return_data['schedules'] .= "<td align='center' width='80'>".getLanguageText('TEXT-STATUS')."</td>";
|
|
$return_data['schedules'] .= "<td align='center' width='80'>".getLanguageText('TEXT-ORDERS')."</td>";
|
|
$return_data['schedules'] .= "<td align='center' width='80'>$Special1_Title</td>";
|
|
$return_data['schedules'] .= "<td align='center' width='80'>$Special2_Title</td>";
|
|
$return_data['schedules'] .= "<td align='center' width='80'>$Special3_Title</td>";
|
|
$return_data['schedules'] .= "</tr>";
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$numOrders = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $record_num");
|
|
$numSpecial1 = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $record_num AND price_category = 'Special 1'");
|
|
$numSpecial2 = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $record_num AND price_category = 'Special 2'");
|
|
$numSpecial3 = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $record_num AND price_category = 'Special 3'");
|
|
|
|
$return_data['schedules'] .= "<tr>";
|
|
$return_data['schedules'] .= "<td align='left'>$schedule_name</td>";
|
|
$return_data['schedules'] .= "<td align='center'>$status</td>";
|
|
$return_data['schedules'] .= "<td align='center'>$numOrders</td>";
|
|
$return_data['schedules'] .= "<td align='center'>$numSpecial1</td>";
|
|
$return_data['schedules'] .= "<td align='center'>$numSpecial2</td>";
|
|
$return_data['schedules'] .= "<td align='center'>$numSpecial3</td>";
|
|
$return_data['schedules'] .= "</tr>";
|
|
}
|
|
|
|
$return_data['schedules'] .= "</table>";
|
|
}
|
|
|
|
// Get any invoices info
|
|
$return_data['invoices'] .= "<br>";
|
|
$return_data['invoices'] = "<b>$school_name</b> ($school_num) " .
|
|
"- [<a href='?action=schools-list&naction=edit&record_num=$school_num'>edit</a>] " .
|
|
"- [<a href='#' snum='$school_num' class='refresh-info'>refresh</a>] " .
|
|
"- <a href='http://$url' target='_blank'>$url</a> $sprices<br><br>";
|
|
$return_data['invoices'] .= "<span id='invoices-message-span' style='color: red'></span><br><br>";
|
|
|
|
$query = "SELECT * FROM invoice_header WHERE school_num = $school_num ORDER BY invoice_date DESC";
|
|
// $return_data['invoices'] .= "$query<br><br>";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$return_data['invoices'] .= "<table class='invoices-table'>";
|
|
$return_data['invoices'] .= "<tr>";
|
|
$return_data['invoices'] .= "<td align='center' width='80'>YEAR</td>";
|
|
$return_data['invoices'] .= "<td align='center' width='80'>NUM</td>";
|
|
$return_data['invoices'] .= "<td align='center' width='80'>DATE</td>";
|
|
$return_data['invoices'] .= "<td align='center' width='70'>STATUS</td>";
|
|
$return_data['invoices'] .= "<td align='center' width='70'>TOTAL</td>";
|
|
$return_data['invoices'] .= "<td align='center' width='70'>PAID</td>";
|
|
$return_data['invoices'] .= "<td align='center' width='70'>BALANCE</td>";
|
|
$return_data['invoices'] .= "<td align='center' width='110'>METHOD</td>";
|
|
$return_data['invoices'] .= "<td align='center' width='190'> </td>";
|
|
$return_data['invoices'] .= "</tr>";
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$invnum = sprintf("%08d",$record_num + 500);
|
|
$edit = "?action=invoices&selected_school=$school_num&naction=edit&record_num=$record_num";
|
|
$print = "?action=inv-print&invoice_num=$record_num";
|
|
|
|
$inv_num = sprintf("%06d-HL",$record_num + 500);
|
|
$file_name = str_replace("/","-",$school_name);
|
|
$inv_file = normalizeString($inv_num . "." . $file_name . ".pdf");
|
|
$invlink = '';
|
|
if (is_file("invoices/$inv_file")) $invlink = "[<a href='invoices/$inv_file'>view</a>] ";
|
|
|
|
$pay = "";
|
|
if ($status == 'Open') {
|
|
$pay = "[<a href='?action=invoices&naction=inv-paid&return=schools-list&invoice_num=$record_num' snum='$school_num' inum='$record_num' amt='$total' class='paid-link'>paid</a>]";
|
|
$pay = "[<a href='#' snum='$school_num' inum='$record_num' amt='$total' class='paid-link'>paid</a>]";
|
|
$pay .= "[<a href='#' snum='$school_num' inum='$record_num' amt='$total' class='ezs-link'>ezs</a>]";
|
|
}
|
|
else {
|
|
$yesterday = date("Y-m-d",time() - 60 * 60 * 24);
|
|
if ($payment_date >= $yesterday) $pay .= "[<a href='#' snum='$school_num' inum='$record_num' amt='$total' class='ezs-link'>ezs</a>]";
|
|
}
|
|
|
|
$send = "[<a href='?action=invoices&naction=inv-outstanding&invoice_num=$record_num' class='send-link'>send</a>]";
|
|
|
|
$balance = number_format($total - $amount_paid,2);
|
|
$return_data['invoices'] .= "<tr>";
|
|
$return_data['invoices'] .= "<td align='center'>$school_year</td>";
|
|
$return_data['invoices'] .= "<td align='center'>#$invnum</td>";
|
|
$return_data['invoices'] .= "<td align='center'>$invoice_date</td>";
|
|
$return_data['invoices'] .= "<td align='center'>$status</td>";
|
|
$return_data['invoices'] .= "<td align='center'>$currencySymbol$total</td>";
|
|
$return_data['invoices'] .= "<td align='center'>$currencySymbol$amount_paid</td>";
|
|
$return_data['invoices'] .= "<td align='center'>$currencySymbol$balance</td>";
|
|
$return_data['invoices'] .= "<td title='$payment_date' align='center'>$payment_method</td>";
|
|
$return_data['invoices'] .= "<td align='center'>[<a href='$edit'>edit</a>] $invlink [<a href='$print'>print</a>] $pay $send</td>";
|
|
$return_data['invoices'] .= "</tr>";
|
|
}
|
|
$return_data['invoices'] .= "</table>";
|
|
}
|
|
$return_data['invoices'] .= " [<a href='?action=invoices&selected_school=$school_num&naction=add'>Add Invoice</a>]";
|
|
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "[<a href='?action=schools-list&naction=create-link&record_num=$school_num'>Add Site</a>]";
|
|
$return_data['content'] .= " ";
|
|
$return_data['content'] .= "[<a href='?action=schools-list&naction=send-notification&record_num=$school_num'>Send Notification</a>]";
|
|
|
|
break;
|
|
|
|
case 'school-notifications':
|
|
$delete_icon = "<img src='images/icons/delete16.png' border='0'>";
|
|
|
|
$return_data['content'] = "<table width='90%'><tr><td align='left'>";
|
|
$return_data['content'] .= "<p><b>Notifications:</b></p>";
|
|
|
|
$cutoff = date("Y-m-d 00:00:00", time() - 60 * 60 * 24 * 45);
|
|
$query = "SELECT * FROM school_notifications WHERE notification_date > '$cutoff' ORDER BY notification_date DESC";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$query = "SELECT * FROM schools WHERE record_num = $school_num";
|
|
$r = db_query($query);
|
|
$school = db_fetch_assoc($r);
|
|
|
|
if ($school['status'] != 'Active') {
|
|
db_query("DELETE FROM school_notifications WHERE record_num = $record_num");
|
|
continue;
|
|
}
|
|
|
|
$note = $school['notes'];
|
|
$start_date = $school['start_date'];
|
|
|
|
$query = "SELECT * FROM login_log WHERE school_num = $school_num AND userid = 'admin' AND last_login > '$notification_date'";
|
|
$r = db_query($query);
|
|
if (db_num_rows($r) > 0) {
|
|
db_query("DELETE FROM school_notifications WHERE record_num = $record_num");
|
|
continue;
|
|
}
|
|
|
|
$return_data['content'] .= "<p>$notification_date";
|
|
$return_data['content'] .= " <span class='delete-notification' rnum='$record_num'>$delete_icon</span><br>";
|
|
$return_data['content'] .= "<b><span class='show-school-info' snum='$school_num' category=''>".$school['school_name']."</span></b> ($start_date)<br>";
|
|
$return_data['content'] .= " - ".$school['city'].' '.$school['province'].' '.$school['country']."<br>";
|
|
$return_data['content'] .= " - Phone: ".$school['phone']."<br>";
|
|
$return_data['content'] .= "<br>";
|
|
|
|
if (strlen($notification_name1)) {
|
|
$return_data['content'] .= " - <a href='mailto:$notification_email1'>$notification_name1</a><br>";
|
|
}
|
|
if (strlen($notification_name2)) {
|
|
$return_data['content'] .= " - <a href='mailto:$notification_email2'>$notification_name2</a><br>";
|
|
}
|
|
if (strlen($notification_name3)) {
|
|
$return_data['content'] .= " - <a href='mailto:$notification_email3'>$notification_name3</a><br>";
|
|
}
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "<span class='notification-note' rnum='$record_num' snum='$school_num'>Note: <span id='note-$record_num'>$note</span></span>";
|
|
$return_data['content'] .= "</p>";
|
|
$return_data['content'] .= "<p>===============================================</p>";
|
|
}
|
|
}
|
|
$return_data['content'] .= "</td></tr></table>";
|
|
break;
|
|
|
|
case 'user-info':
|
|
// startLog("user-info");
|
|
if (array_key_exists('user_num', $_GET)) $user_num = intval($_GET['user_num']);
|
|
if (array_key_exists('school_num', $_GET)) $school_num = intval($_GET['school_num']);
|
|
|
|
writeLog("school_num: $school_num");
|
|
|
|
$reseller = false;
|
|
if (array_key_exists('reseller_school', $_GET)) {
|
|
$reseller = true;
|
|
$school_num = intval($_GET['reseller_school']);
|
|
writeLog("reseller school_num: $school_num");
|
|
}
|
|
|
|
// Get user info
|
|
$query = "SELECT * FROM users WHERE record_num = $user_num";
|
|
writeLog($query);
|
|
$results = db_query($query);
|
|
|
|
$row = db_fetch_assoc($results);
|
|
extract($row);
|
|
$user_type = $type;
|
|
$user_num = $record_num;
|
|
$user_status = $status;
|
|
|
|
writeLog("name: $first_name $last_name");
|
|
writeLog("user_type: $user_type");
|
|
writeLog("school_num: $school_num");
|
|
|
|
|
|
// Get school info
|
|
$query = "SELECT * FROM schools WHERE record_num = $school_num";
|
|
writeLog($query);
|
|
$results = db_query($query);
|
|
$row = db_fetch_assoc($results);
|
|
extract($row);
|
|
|
|
if (!isset($sprices)) $sprices = '';
|
|
$return_data['content'] = "<b><span class='show-school-info' snum='$school_num'>$school_name</span></b> ($school_num) " .
|
|
"- <a href='http://$url' target='_blank'>$url</a> $sprices<br>" .
|
|
"$city, $province - $phone<br>";
|
|
|
|
$return_data['content'] .= "<br><br>" .
|
|
"<b><span class='user-id-span' rnum='$user_num' snum='$school_num'>$userid</span> - $first_name $last_name</b> ($user_type)<br>" .
|
|
"<a href='mailto:$email'>$email</a> - $phone<br>" .
|
|
"Last Login: $last_login<br>";
|
|
|
|
$return_data['content'] .= "<b><span onclick='#' class='user-status' rnum='$user_num' snum='$school_num'>$user_status</span></b><br><br>";
|
|
|
|
|
|
$query = "select sum(transaction_amount) as balance from user_account where school_num = $school_num and user_num = $user_num AND (deleted != 'Y' OR deleted IS NULL)";
|
|
$balance = floatval(db_getVal($query));
|
|
$return_data['content'] .= "<p>".getLanguageText('TEXT-ACCOUNT-BALANCE').": $".number_format($balance,2)."</p>";
|
|
|
|
// Get student info
|
|
$query = "SELECT * FROM people WHERE school_num = $school_num AND user_num = $user_num ORDER BY last_name, first_name";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$return_data['content'] .= "<b>Students:</b><br>";
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$return_data['content'] .= " - ".$row['first_name'].' '.$row['last_name']."<br>";
|
|
}
|
|
}
|
|
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
$return_data['content'] .= "<br><br><button id='reset-user-password' snum='$school_num' unum='$user_num' userid='$userid' last='$last_login' class='btn btn--primary btn--xsmall'> Update Password </button><br><br>";
|
|
}
|
|
break;
|
|
|
|
case 'user-account-transactions':
|
|
// Get user number
|
|
$user_num = intval($_GET['user_num']);
|
|
|
|
// Get records
|
|
$columnHeaders = array(getLanguageText('TEXT-USER-ID'),
|
|
getLanguageText('TEXT-TRANSACTION-DATE'),
|
|
getLanguageText('TEXT-TRANSACTION-TYPE'),
|
|
getLanguageText('TEXT-CHARGES'),
|
|
getLanguageText('TEXT-CREDITS'),
|
|
getLanguageText('TEXT-METHOD')
|
|
);
|
|
$columnAlign = array('left','center','left','right','right','left');
|
|
$query = "SELECT u.userid,substring(transaction_datetime,1,10) as trx_date,transaction_type,note,transaction_amount,schedule_num,order_num," .
|
|
"payment_method,payment_reference,order_payments,ua.user_num,people_num,people_type,additional_note,ua.record_num,deleted," .
|
|
"transaction_status,deleted_datetime,deleted_by_user_num,delete_reason,u.first_name,u.last_name " .
|
|
"FROM user_account as ua LEFT JOIN people as p ON ua.people_num = p.record_num, users AS u " .
|
|
"WHERE u.school_num = $base_school_num " .
|
|
"AND ua.school_num = $school_num " .
|
|
"AND ua.user_num = u.record_num " .
|
|
"AND ua.user_num = $user_num " .
|
|
"ORDER BY transaction_datetime,record_num";
|
|
$transactions = db_query($query);
|
|
|
|
$data = array();
|
|
while ($row = db_fetch_assoc($transactions)) {
|
|
extract($row);
|
|
|
|
if ($transaction_amount < 0) {
|
|
$charge = "";
|
|
$credit = "-$currencySymbol".number_format(abs($transaction_amount),2);
|
|
}
|
|
else {
|
|
$credit = "";
|
|
$charge = "$currencySymbol".number_format(abs($transaction_amount),2);
|
|
}
|
|
|
|
if ($transaction_type == 'Order') {
|
|
if (intval($schedule_num) > 0) {
|
|
$sname = db_getVal("SELECT schedule_name FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $schedule_num");
|
|
$transaction_type .= " (#$order_num - $sname)";
|
|
}
|
|
|
|
if ($order_num > 0) {
|
|
$r = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND record_num = $order_num");
|
|
if (db_num_rows($r)) {
|
|
$order = db_fetch_assoc($r);
|
|
$Tip = "<table width='600'>";
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-ORDER-NUMBER') . ": ",$order_num);
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-ORDERED-FOR') . ": ",$order['ordered_by_type']);
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-SCHEDULE') . ": ",$sname);
|
|
|
|
if ($order['discount_amount'] > 0) {
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-SUBTOTAL') . ": ",$currencySymbol . number_format($order['order_subtotal'],2));
|
|
sprintf($otipROW2,getLanguageText('TEXT-DISCOUNT') . ": ",$currencySymbol . number_format($order['discount_amount'],2));
|
|
}
|
|
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-ORDER-TOTAL') . ": ",$currencySymbol . number_format($order['order_total'],2));
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-AMOUNT-PAID') . ": ",$currencySymbol . number_format($order['amount_paid'],2));
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-STATUS') . ": ",$order['status']);
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-ORDER-DATE') . ": ",$order['added_date']);
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-SOURCE') . ": ",$order['source']);
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-UPDATED-DATE') . ": ",$order['updated_date']);
|
|
|
|
if ($order['paid_date']) {
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-PAID-DATE') . ": ",$order['paid_date']);
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-PAYMENT-METHOD') . ": ",$order['payment_method']);
|
|
}
|
|
|
|
$Tip .= sprintf($otipROW2,"TRX: ",$record_num);
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-TRANSACTION-STATUS') . ": ",$transaction_status);
|
|
$Tip .= sprintf($otipROW2,getLanguageText('TEXT-ENTERED-BY') . ": ",$order['entered_by']);
|
|
$Tip .= "<tr><td width='200'></td><td></td></tr>";
|
|
$Tip .= "</table>";
|
|
|
|
$transaction_type = "<div class='hl-tooltip'> $transaction_type " .
|
|
"<span class='hl-tooltiptext hl-tooltip-center' style='textalign: left'>$Tip</span>\n" .
|
|
"</div>";
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($payment_method == 'Check') $payment_method .= " #$payment_reference";
|
|
|
|
$data[] = array($userid,$trx_date,$transaction_type,$charge,$credit,$payment_method);
|
|
}
|
|
|
|
writeLog("TRXs: ".count($data));
|
|
$customTableID = "account-table";
|
|
$TableWidth = 900;
|
|
if (!isset($totals)) $totals = array();
|
|
$return_data['count'] = count($data);
|
|
$titleText = "<p><button id='edit-user-account-transactions' unum='$user_num' class='btn btn--primary btn--xsmall'>".getLanguageText('TEXT-EDIT')."</button> " .
|
|
"<button class='trx-close-window-btn btn btn--outline btn--xsmall'>".getLanguageText('TEXT-CLOSE')."</button></p>";
|
|
$return_data['content'] = $titleText . getDataCustom($data,$columnHeaders,$action,array(),'N',$columnAlign,$totals);
|
|
|
|
break;
|
|
|
|
case 'trx-history':
|
|
// Get trx number
|
|
$rnum = intval($_GET['rnum']);
|
|
writeLog("rnum: $rnum\n");
|
|
$info = "<center><table width='90%' class='content-table'>";
|
|
$info .= "<tr class='data-header'>";
|
|
$info .= "<td align='left'><b>".getLanguageText('TEXT-TRANSACTION-TYPE')."</b></td>";
|
|
$info .= "<td align='right'><b>".getLanguageText('TEXT-AMOUNT')."</b></td>";
|
|
$info .= "<td align='left'><b>".getLanguageText('TEXT-SCHEDULE')."</b></td>";
|
|
$info .= "</tr>";
|
|
|
|
// Get record
|
|
$query = "SELECT * FROM user_account WHERE school_num = $school_num AND record_num = $rnum";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$row = db_fetch_assoc($results);
|
|
writeLog("trx_history: ".$row['trx_history']."\n");
|
|
|
|
$entries = explode("\n",$row['trx_history']);
|
|
for ($i = 0; $i < count($entries); $i++) {
|
|
$row = explode('|',$entries[$i]);
|
|
|
|
if (strlen($row[0])) {
|
|
$bgclass = "data-even";
|
|
if ($i % 2) $bgclass = "data-odd";
|
|
|
|
$info .= "<tr class='$bgclass'>";
|
|
$info .= "<td align='left' valign='top'>".$row[0]."</td>";
|
|
$info .= "<td align='right' valign='top'>".$row[1]."</td>";
|
|
$info .= "<td align='left' valign='top'>".$row[2]."<br>".$row[3]."</td>";
|
|
$info .= "</tr>";
|
|
}
|
|
}
|
|
|
|
$info .= "</table></center><br>";
|
|
|
|
$return_data['content'] = $info;
|
|
|
|
break;
|
|
|
|
case 'trx-receipt':
|
|
// startLog('trx-receipt');
|
|
|
|
// Get trx number
|
|
$trxNum = intval($_GET['trxnum']);
|
|
writeLog("trxNum: $trxNum");
|
|
|
|
if ($trxNum == 0) {
|
|
$return_data['content'] = getLanguageText('ERRORMSG-UNABLE-TO-COMPLETE-ACTION');
|
|
break;
|
|
}
|
|
|
|
// Get trx record
|
|
$query = "SELECT * FROM user_account WHERE school_num = $school_num AND record_num = $trxNum";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results)) {
|
|
$return_data['content'] = getLanguageText('ERRORMSG-UNABLE-TO-COMPLETE-ACTION');
|
|
break;
|
|
}
|
|
|
|
$trx = db_fetch_assoc($results);
|
|
$userNum = 0;
|
|
if (array_key_exists('user_num', $trx)) $userNum = $trx['user_num'];
|
|
writeLog("userNum: $userNum");
|
|
if ($userNum == 0) {
|
|
$return_data['content'] = getLanguageText('ERRORMSG-UNABLE-TO-COMPLETE-ACTION');
|
|
break;
|
|
}
|
|
|
|
adjustUserAccountDetails($userNum);
|
|
|
|
// Get receipt number
|
|
$user_num = intval($userNum);
|
|
$rcptNum = db_getVal("SELECT receipt_number FROM user_account_detail WHERE school_num = $school_num AND user_num = $user_num AND transaction_num = $trxNum LIMIT 0,1");
|
|
writeLog("rcptNum: $rcptNum\n");
|
|
|
|
// Get user info
|
|
$query = "SELECT * FROM users WHERE school_num = $base_school_num AND record_num = $user_num";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$user = db_fetch_assoc($results);
|
|
$name = $user['first_name'].' '.$user['last_name'];
|
|
|
|
// Get transaction information
|
|
$trx_details = "";
|
|
|
|
$trxTotal = 0;
|
|
|
|
// Transaction based processing
|
|
if ($school_record['select_transactions_on_post'] == 'Y') {
|
|
// Get transactions in this receipt
|
|
$query = "SELECT detail.*,ua.transaction_type,ua.transaction_amount AS trx_amount,ua2.transaction_datetime,ua.note,ua.schedule_num,ua.order_num " .
|
|
"FROM user_account_detail AS detail, user_account AS ua, user_account AS ua2 " .
|
|
"WHERE detail.school_num = $school_num " .
|
|
"AND detail.school_num = ua.school_num " .
|
|
"AND detail.school_num = ua2.school_num " .
|
|
"AND ua.user_num = $user_num " .
|
|
"AND ua2.user_num = $user_num " .
|
|
"AND detail.user_num = $user_num " .
|
|
"AND detail.receipt_number = '$rcptNum' " .
|
|
"AND detail.posted_to_transaction = ua.record_num " .
|
|
"AND detail.transaction_num = ua2.record_num " .
|
|
"AND (ua.deleted != 'Y' OR ua.deleted IS NULL) " .
|
|
"AND (ua2.deleted != 'Y' OR ua2.deleted IS NULL) " .
|
|
"ORDER BY ua2.transaction_datetime,ua.record_num";
|
|
writeLog("query: $query\n");
|
|
$transactions = db_query($query);
|
|
writeLog("# transactions: ".db_num_rows($transactions)."\n");
|
|
|
|
while ($row = db_fetch_assoc($transactions)) {
|
|
if ($row['transaction_num'] == $trxNum) {
|
|
$trnum = $row['transaction_num'];
|
|
$ptnum = $row['posted_to_transaction'];
|
|
$amt = $row['posted_amount'] * -1;
|
|
$type = $row['transaction_type'];
|
|
$note = $row['note'];
|
|
$onum = $row['order_num'];
|
|
$snum = $row['schedule_num'];
|
|
$prnum = $row['record_num'];
|
|
$rcpt = $row['receipt_number'];
|
|
$trxdate = $row['transaction_datetime'];
|
|
|
|
$trx_total = db_getVal("SELECT transaction_amount FROM user_account WHERE school_num = $school_num AND record_num = $trnum");
|
|
|
|
if ($type == 'Order') {
|
|
$type .= " (#$onum)";
|
|
$query = "SELECT transaction_datetime FROM user_account_detail WHERE school_num = $school_num AND user_num = $user_num AND receipt_number = '$rcptNum' AND posted_to_transaction = $ptnum";
|
|
writeLog("query: $query\n");
|
|
// $amt = db_getVal($query) * -1;
|
|
// $amt = $trx_total;
|
|
// $row['transaction_datetime'] = db_getVal($query);
|
|
$amt = $row['trx_amount'];
|
|
}
|
|
|
|
// Get schedule name
|
|
$sname = '';
|
|
if ($snum == 1) $sname = getLanguageText('TEXT-MISCELLANEOUS-CHARGES');
|
|
if (intval($snum) > 1) {
|
|
$query = "SELECT schedule_name FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $snum";
|
|
writeLog("query: $query\n");
|
|
$sname = db_getVal($query);
|
|
$note .= " ($sname)";
|
|
}
|
|
if ($trx_total > 0) $note .= " $currencySymbol".number_format($trx_total,2);
|
|
}
|
|
else {
|
|
$trnum = $row['transaction_num'];
|
|
$ptnum = $row['posted_to_transaction'];
|
|
$amt = $row['posted_amount'];
|
|
$rcpt = $row['receipt_number'];
|
|
|
|
$results = db_query("SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $user_num AND record_num = $trnum");
|
|
$row = db_fetch_assoc($results);
|
|
$type = $row['transaction_type'];
|
|
$note = $row['note'];
|
|
}
|
|
|
|
$sign = '';
|
|
if ($amt < 0) $sign = '- ';
|
|
|
|
$trxTotal += $amt;
|
|
$date = date($school_record['date_format'],strtotime($row['transaction_datetime']));
|
|
|
|
$trx_details .= "<tr>";
|
|
$trx_details .= "<td valign='top' align='left'>".translateText($type)."</td>";
|
|
$trx_details .= "<td valign='top' align='left'>$date</td>";
|
|
$trx_details .= "<td valign='top' align='left'>".translateText($note)."</td>";
|
|
$trx_details .= "<td valign='top' align='right'>$sign$currencySymbol".number_format(abs($amt),2)."</td>";
|
|
$trx_details .= "</tr>";
|
|
|
|
}
|
|
|
|
if (!isset($date)) $date = '';
|
|
|
|
// Add current trx to details
|
|
$trx_details .= "<tr>";
|
|
$trx_details .= "<td valign='top' align='left'>".translateText($trx['transaction_type'])."</td>";
|
|
$trx_details .= "<td valign='top' align='left'>$date</td>";
|
|
$trx_details .= "<td valign='top' align='left'>".translateText($trx['note'])."</td>";
|
|
$trx_details .= "<td valign='top' align='right'>- $currencySymbol".number_format(abs($trx['transaction_amount']),2)."</td>";
|
|
$trx_details .= "</tr>";
|
|
|
|
$trxTotal += $trx['transaction_amount'];
|
|
}
|
|
|
|
// Get order information
|
|
if ($school_record['select_transactions_on_post'] != 'Y' && strlen($trx['order_payments']) && strlen($trx['transaction_payments']) == 0) {
|
|
$orders = explode('|',$trx['order_payments']);
|
|
$trx_details = "";
|
|
$trxTotal = 0;
|
|
for ($i = 0; $i < count($orders); $i++) {
|
|
$oinfo = $orders[$i];
|
|
$oinfo = str_replace('{','',$oinfo);
|
|
$oinfo = str_replace('}','',$oinfo);
|
|
list($onum,$amt) = explode(':',$oinfo);
|
|
|
|
if ($onum > 0) {
|
|
// Get order information
|
|
$query = "SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND record_num = $onum";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$order = db_fetch_assoc($results);
|
|
|
|
$snum = $order['schedule_num'];
|
|
$pnum = $order['ordered_by_num'];
|
|
|
|
// Get schedule name
|
|
$sname = "";
|
|
if (intval($snum) > 1) {
|
|
$query = "SELECT schedule_name FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $snum";
|
|
writeLog("query: $query\n");
|
|
$sname = db_getVal($query);
|
|
}
|
|
|
|
// Get person name
|
|
$query = "SELECT * FROM people WHERE school_num = $base_school_num AND record_num = $pnum";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$person = db_fetch_assoc($results);
|
|
|
|
$pname = $person['first_name'].' '.$person['last_name'];
|
|
|
|
$trx_details .= "<tr>";
|
|
$trx_details .= "<td valign='top' align='left'>$pname</td>";
|
|
$trx_details .= "<td valign='top' align='left'>$sname</td>";
|
|
$trx_details .= "<td valign='top' align='right'>$currencySymbol".number_format($amt,2)."</td>";
|
|
$trx_details .= "</tr>";
|
|
|
|
$trxTotal += $amt;
|
|
|
|
$query = "SELECT * FROM user_account WHERE school_num = $school_num AND order_num = $onum AND transaction_type != 'Order' AND deleted != 'Y' ORDER BY record_num";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$tname = $row['transaction_type'];
|
|
$note = translateText($row['note']);
|
|
$amt = $row['transaction_amount'];
|
|
|
|
$trx_details .= "<tr>";
|
|
$trx_details .= "<td valign='top' align='left'>$tname</td>";
|
|
$trx_details .= "<td valign='top' align='left'>$note</td>";
|
|
$trx_details .= "<td valign='top' align='right'>$currencySymbol".number_format($amt,2)."</td>";
|
|
$trx_details .= "</tr>";
|
|
|
|
$trxTotal += $amt;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$transaction_type = $trx['transaction_type'];
|
|
if (strlen($trx['payment_method'])) {
|
|
if ($trx['payment_method'] == 'Check') $transaction_type .= " - ".getLanguageText('TEXT-'.strtoupper($trx['payment_method']));
|
|
else $transaction_type .= " - ".$trx['payment_method'];
|
|
if ($trx['payment_method'] == 'Check') $transaction_type .= " (#".$trx['payment_reference'].")";
|
|
}
|
|
|
|
$transaction_time = dateString('datetime',strtotime($trx['transaction_datetime']));
|
|
|
|
|
|
// Start content
|
|
$return_data['content'] = "<table width='100%'><tr><td align='left'>";
|
|
|
|
// School header
|
|
$return_data['content'] .= "<table width='100%'><tr><td align='left'>";
|
|
$return_data['content'] .= "<span class='school-name'>".$school_record['pac_name']."</span><br>";
|
|
$return_data['content'] .= $school_record['address'].", ".$school_record['city'].", ".$school_record['province']." ".$school_record['postal']."<br>";
|
|
|
|
// Receipt header
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "<span class='receipt-title'>".getLanguageText('TEXT-RECEIPT')."</span><br>";
|
|
$return_data['content'] .= "<div class='line'></div>";
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "</td></tr></table>";
|
|
|
|
// Receipt content
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "<table width='100%'><tr><td width='75%' align='left'>";
|
|
$return_data['content'] .= "<span class='receipt-large'>".getLanguageText('TEXT-FOR').": $name</span><br>";
|
|
$return_data['content'] .= "</td>";
|
|
$return_data['content'] .= "<td width='30%' align='left' style='border: 1px solid #000000; padding: 3px;'>";
|
|
// $return_data['content'] .= "<span class='receipt-large'> # $rcptNum</span><br>";
|
|
$return_data['content'] .= "<span><b> # $rcptNum</b></span><br>";
|
|
$return_data['content'] .= "</td></tr></table>";
|
|
|
|
// Payment content
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "<table width='100%'><tr><td width='25%' align='left' style='border: 1px solid #000000; padding: 3px;'>";
|
|
$return_data['content'] .= "<span class='receipt-large'> ".getLanguageText('TEXT-PAID').": $currencySymbol".number_format(abs($trx['transaction_amount']),2)."</span><br>";
|
|
$return_data['content'] .= "</td>";
|
|
$return_data['content'] .= "<td width='75%' align='center'>";
|
|
$return_data['content'] .= "<span class='receipt-large'> $transaction_type</span><br>";
|
|
$return_data['content'] .= $transaction_time."<br>";
|
|
$return_data['content'] .= "</td></tr></table>";
|
|
|
|
// Detail content
|
|
if (strlen($trx_details)) {
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "<table width='100%'>";
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td width='15%' valign='top' align='left' style='border-bottom: 1px solid #000000'><b>".getLanguageText('TEXT-NAME')."</b></td>";
|
|
$return_data['content'] .= "<td width='20%' valign='top' align='left' style='border-bottom: 1px solid #000000'><b>".getLanguageText('TEXT-DATE')."</b></td>";
|
|
$return_data['content'] .= "<td width='45%' valign='top' align='left' style='border-bottom: 1px solid #000000'><b>".getLanguageText('TEXT-ITEM')."</b></td>";
|
|
$return_data['content'] .= "<td width='20%' valign='top' align='right' style='border-bottom: 1px solid #000000'><b>".getLanguageText('TEXT-AMOUNT')."</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= $trx_details;
|
|
|
|
if ($trxTotal > -0.01 && $trxTotal < 0.01) $trxTotal = 0.00;
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td colspan='3' align='left'> </td>";
|
|
$return_data['content'] .= "<td align='right' style='border-top: 1px solid #000000'><b>$currencySymbol".number_format($trxTotal,2)."</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td colspan='3'><br><br><br><br><br></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$balance = db_getVal("SELECT sum(transaction_amount) FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND user_num = $user_num " .
|
|
"AND (deleted != 'Y' OR deleted IS NULL)");
|
|
$balance = intval($balance * 100) / 100;
|
|
if ($balance > -0.01 && $balance < 0.01) $balance = 0.00;
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td colspan='2' valign='top' align='right'><b>".getLanguageText('TEXT-CURRENT-ACCT-BALANCE').": </b></td>";
|
|
$return_data['content'] .= "<td valign='top' align='right'><b>$currencySymbol".number_format($balance,2)."</b></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$return_data['content'] .= "<tr>";
|
|
$return_data['content'] .= "<td colspan='3'><br><br><br><br><br></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
$return_data['content'] .= "</table>";
|
|
}
|
|
|
|
$printed_time = dateString('datetime',time());
|
|
$return_data['content'] .= "<br>";
|
|
$return_data['content'] .= "<p><b>".getLanguageText('TEXT-PRINTED').": $printed_time</b></p>";
|
|
|
|
// End content table
|
|
$return_data['content'] .= "</td></tr></table>";
|
|
|
|
break;
|
|
|
|
case 'login-log':
|
|
// Get login log parameters
|
|
$sdate = db_escape_string($_GET['sdate']);
|
|
$edate = db_escape_string($_GET['edate']);
|
|
$userid = db_escape_string($_GET['userid']);
|
|
$ip = db_escape_string($_GET['ip']);
|
|
|
|
$where = "AND last_login BETWEEN '$sdate 00:00:00' AND '$edate 23:59:59' ";
|
|
if ($userid != 'All') $where .= "AND userid = '$userid' ";
|
|
if ($ip != 'All') $where .= "AND user_ip = '$ip' ";
|
|
|
|
if ($_SESSION['UserInfo']['type'] != 'SuperUser') $where .= "AND userid != 'superuser' ";
|
|
|
|
|
|
$columnHeaders = array(getLanguageText('TEXT-USERID'),
|
|
getLanguageText('TEXT-LOGIN'),
|
|
getLanguageText('TEXT-LAST-ACTIVITY'),
|
|
getLanguageText('TEXT-DURATION'),
|
|
getLanguageText('TEXT-IP-ADDRESS'));
|
|
$query = "SELECT * FROM login_log " .
|
|
"WHERE school_num = $school_num " .
|
|
$where .
|
|
"ORDER BY last_login desc";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
|
|
$data = array();
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$dstr = "";
|
|
$last_action = "";
|
|
|
|
$last_action = date("Y-m-d H:i:s",$last_activity);
|
|
$duration = $last_activity - $login_time;
|
|
$dhr = intval($duration / 3600);
|
|
$dmin = ($duration % 3600) / 60;
|
|
$dsec = $duration % 60;
|
|
$dstr = sprintf("%dh %02dm %02ds",$dhr,$dmin,$dsec);
|
|
|
|
$userRecord = db_getVal("SELECT * FROM users where school_num = $school_num AND record_num = $user_num");
|
|
$user_info = '';
|
|
if (is_array($userRecord)) {
|
|
$user_info .= $userRecord['first_name'].' '.$userRecord['last_name']."\n";
|
|
$user_info .= $userRecord['type']."\n";
|
|
}
|
|
$user_info .= $user_agent;
|
|
|
|
$data[] = array("<a href='?action=users&naction=show-info&user_num=$user_num' title='$user_info' class='title-text'>$userid</a>",
|
|
$last_login,
|
|
$last_action,
|
|
$dstr,
|
|
$user_ip);
|
|
}
|
|
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,array(),'N');
|
|
break;
|
|
|
|
|
|
case 'payment-posting-errors':
|
|
// startLog("payment-posting-errors");
|
|
|
|
// Get parameters
|
|
$sdate = $_GET['sdate'];
|
|
$edate = $_GET['edate'];
|
|
|
|
$columnHeaders = array(getLanguageText('TEXT-DATE'),
|
|
getLanguageText('TEXT-USER-ID'),
|
|
getLanguageText('TEXT-NAME'),
|
|
getLanguageText('TEXT-ORDER-NUMBER'),
|
|
getLanguageText('TEXT-PAYMENT-METHOD'),
|
|
getLanguageText('TEXT-ORDER-TOTAL'),
|
|
getLanguageText('TEXT-AMOUNT-PAID'));
|
|
|
|
$query = "SELECT school_num, record_num, ordered_by_num, added_date, payment_method, order_total, amount_paid " .
|
|
"FROM hotlunch_order_header " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND amount_paid > (order_total * 2) " .
|
|
"AND added_date BETWEEN '$sdate' AND '$edate' " .
|
|
"ORDER BY added_date";
|
|
writeLog($query);
|
|
$orders = db_query($query);
|
|
$num = db_num_rows($orders);
|
|
writeLog("num: $num");
|
|
|
|
$data = array();
|
|
while ($row = db_fetch_assoc($orders)) {
|
|
extract($row);
|
|
|
|
$query = "SELECT * FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num";
|
|
$results = db_query($query);
|
|
$student = db_fetch_assoc($results);
|
|
$user_num = $student['user_num'];
|
|
$name = $student['first_name'].' '.$student['last_name'];
|
|
writeLog("$user_num - $name");
|
|
|
|
$userid = getLanguageText('TEXT-UNKNOWN') . " $ordered_by_num";
|
|
if (intval($user_num) > 0) {
|
|
$query = "SELECT * FROM users WHERE school_num = $base_school_num AND record_num = $user_num";
|
|
$results = db_query($query);
|
|
$user = db_fetch_assoc($results);
|
|
$userid = $user['userid'];
|
|
}
|
|
|
|
$order_total = '$' . number_format($order_total,2);
|
|
$amount_paid = '$' . number_format($amount_paid,2);
|
|
|
|
$entry = array();
|
|
$entry[] = $added_date;
|
|
$entry[] = $userid;
|
|
$entry[] = $name;
|
|
$entry[] = $record_num;
|
|
$entry[] = $payment_method;
|
|
$entry[] = $order_total;
|
|
$entry[] = $amount_paid;
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,'',array(),'N');
|
|
|
|
break;
|
|
|
|
|
|
case 'order-log-detail':
|
|
// Get order log detail
|
|
$order_num = intval($_GET['order_num']);
|
|
$record_num = intval($_GET['record_num']);
|
|
|
|
$return_data['content'] = "";
|
|
|
|
$query = "SELECT * FROM hotlunch_order_change_log WHERE school_num = $school_num AND order_num = $order_num AND record_num = $record_num";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results) == 1) {
|
|
$row = db_fetch_assoc($results);
|
|
extract($row);
|
|
|
|
$userid = "Unknown";
|
|
if ($updated_by > 1) $userid = db_getVal("SELECT userid FROM users WHERE school_num = $base_school_num AND record_num = $updated_by");
|
|
if (!$userid) $userid = "Unknown";
|
|
|
|
$student_name = "";
|
|
if ($ordered_by_num > 0) $student_name = db_getVal("SELECT concat(first_name,' ',last_name) FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
|
|
|
|
$return_data['content'] .= "<table width='400'>";
|
|
|
|
$return_data['content'] .= "<tr><td align='left' width='100'>".getLanguageText("TEXT-ACTIVITY").":</td><td align='left'><b>$order_action</b></td></tr>\n";
|
|
$return_data['content'] .= "<tr><td align='left'>".getLanguageText("TEXT-DATE").":</td><td align='left'><b>$updated_time</b></td></tr>\n";
|
|
$return_data['content'] .= "<tr><td align='left'>".getLanguageText("TEXT-USER-ID").":</td><td align='left'><b>$userid</b></td></tr>\n";
|
|
|
|
$return_data['content'] .= "<tr><td colspan='2'> </td></tr>";
|
|
|
|
$return_data['content'] .= "<tr><td align='left'>".getLanguageText("TEXT-ORDER-NUMBER").":</td><td align='left'><b>$order_num</b></td></tr>\n";
|
|
$return_data['content'] .= "<tr><td align='left'>".getLanguageText("TEXT-ORDERED-BY").":</td><td align='left'><b>$student_name</b></td></tr>\n";
|
|
|
|
if ($user_num > 1) {
|
|
$userid = db_getVal("SELECT userid FROM users WHERE school_num = $base_school_num AND record_num = $user_num");
|
|
if ($userid) $return_data['content'] .= "<tr><td align='left'>".getLanguageText("TEXT-USER-ACCOUNT").":</td><td align='left'><b>$userid</b></td></tr>\n";
|
|
}
|
|
|
|
$order_total = $currencySymbol . number_format($order_total,2);
|
|
$return_data['content'] .= "<tr><td align='left'>".getLanguageText("TEXT-ORDER-TOTAL").":</td><td align='left'><b>$order_total</b></td></tr>\n";
|
|
|
|
$return_data['content'] .= "</table>";
|
|
}
|
|
else {
|
|
$return_data['content'] = "<span class='error'>".getLanguageText("ERRORMSG-NOT-FOUND")."</span><br><br>";
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
case 'email-queue':
|
|
// Get email queue parameters
|
|
$sdate = $_GET['sdate'];
|
|
$edate = $_GET['edate'];
|
|
|
|
$columnHeaders = array(getLanguageText('TEXT-POSTED-TIME'),
|
|
getLanguageText('TEXT-STATUS'),
|
|
getLanguageText('TEXT-EMAIL'),
|
|
getLanguageText('TEXT-EMAIL-SUBJECT'));
|
|
$query = "SELECT posted_time,posted_date_time,status,email_to,email_subject,record_num " .
|
|
"FROM email_queue " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND posted_date_time BETWEEN '$sdate 00:00:00' AND '$edate 23:59:59' " .
|
|
"ORDER BY posted_date_time";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
|
|
$data = array();
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$posted_date_time = date($school_record['date_format'].' '.$school_record['time_format'],$posted_time);
|
|
$data[] = array("<span class='msg' rnum='$record_num'>$posted_date_time</span>",
|
|
"<span class='msg' rnum='$record_num'>$status</span>",
|
|
"<span class='msg' rnum='$record_num'>$email_to</span>",
|
|
"<span class='msg' rnum='$record_num'>$email_subject</span>");
|
|
}
|
|
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,array(),'N');
|
|
break;
|
|
|
|
case 'email-msg':
|
|
// Get email queue number
|
|
$rnum = intval($_GET['rnum']);
|
|
|
|
$query = "SELECT * FROM email_queue WHERE school_num = $school_num AND record_num = $rnum";
|
|
writeLog("query: $query\n");
|
|
$results = db_query($query);
|
|
$msg = db_fetch_assoc($results);
|
|
extract($msg);
|
|
|
|
$sent_time = dateFormat($processing_end_time);
|
|
|
|
$msg = strip_tags($email_message);
|
|
if ($msg == $email_message) $email_message = nl2br($email_message);
|
|
|
|
$info = "<center><table width='95%' class='content-table'>";
|
|
$info .= "<tr><td align='left' valign='top'><b>".getLanguageText('TEXT-EMAIL') .":</b></td><td>$email_to</td></tr>";
|
|
$info .= "<tr><td align='left' valign='top'><b>".getLanguageText('TEXT-EMAIL-SUBJECT') .":</b></td><td>$email_subject</td></tr>";
|
|
$info .= "<tr><td align='left' valign='top'><b>".getLanguageText('TEXT-PROCESSED-TIME') .":</b></td><td>$sent_time</td></tr>";
|
|
$info .= "<tr><td align='left' valign='top'><b>".getLanguageText('TEXT-STATUS') .":</b></td><td>$status</td></tr>";
|
|
$info .= "<tr><td colspan='2' valign='top'><hr></td></tr>";
|
|
$info .= "<tr><td colspan='2' align='left' valign='top'><b>".getLanguageText('TEXT-MESSAGE') .":</b><br>".nl2br($email_message)."</td></tr>";
|
|
$info .= "</table></center><br>";
|
|
$return_data['content'] = $info;
|
|
|
|
break;
|
|
|
|
case 'cafeteria-students':
|
|
// Get parameters
|
|
$menuNum = intval($_GET['menuNum']);
|
|
$classNum = intval($_GET['classNum']);
|
|
|
|
$where = "";
|
|
if ($classNum > 0) $where = "AND class_num = $classNum ";
|
|
|
|
$query = "SELECT * FROM people WHERE school_num = $base_school_num $where ORDER BY last_name,first_name";
|
|
$people = db_query($query);
|
|
|
|
if (db_num_rows($people)) {
|
|
$return_data['content'] .= "<div class='cafeteria-students-div'>\n";
|
|
while ($row = db_fetch_assoc($people)) {
|
|
extract($row);
|
|
$people_num = $record_num;
|
|
|
|
$uBalance = db_getVal("SELECT sum(transaction_amount) FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND user_num = $user_num " .
|
|
"AND (deleted != 'Y' OR deleted IS NULL)");
|
|
$userBalance = round(floatval($uBalance));
|
|
|
|
$balance_class = "";
|
|
if ($userBalance > $school_record['cafeteria_balance_limit']) $balance_class = " cafeteria-balance-low";
|
|
|
|
$prefix = $school_record['currency_symbol'];
|
|
if ($userBalance < 0) $prefix = "- " . $school_record['currency_symbol'];
|
|
if (!isset($class)) $class = '';
|
|
$userBalance = "<span class='$class'>" . $prefix . number_format(abs($userBalance),2) . "</span>";
|
|
|
|
$itemsOrdered = db_getVal("SELECT count(*) FROM hotlunch_order_items WHERE school_num = $school_num AND ordered_by_num = $people_num AND menu_num = $menuNum");
|
|
$oclass = "";
|
|
if ($itemsOrdered > 0) $oclass = "cafeteria-student-with-order";
|
|
|
|
$return_data['content'] .= "<div class='cafeteria-student-entry $oclass' rnum='$record_num' name='$first_name $last_name'>\n";
|
|
$return_data['content'] .= "<a href='#' class='cafeteria-student-name'>$first_name $last_name</a> ($people_type)";
|
|
$return_data['content'] .= "<div class='cafeteria-balance$balance_class'>$userBalance</div>";
|
|
$return_data['content'] .= "</div>\n";
|
|
}
|
|
$return_data['content'] .= "</div>\n";
|
|
$return_data['content'] .= "<br>\n";
|
|
$return_data['content'] .= "<br>\n";
|
|
}
|
|
|
|
break;
|
|
|
|
case 'cafeteria-student-menu':
|
|
// Get parameters
|
|
$scheduleNum = intval($_GET['scheduleNum']);
|
|
$menuNum = intval($_GET['menuNum']);
|
|
$classNum = intval($_GET['classNum']);
|
|
$studentNum = intval($_GET['studentNum']);
|
|
|
|
$query = "SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $scheduleNum";
|
|
$results = db_query($query);
|
|
$schedule = db_fetch_assoc($results);
|
|
|
|
$query = "SELECT * FROM hotlunch_menu_dates WHERE school_num = $school_num AND record_num = $menuNum";
|
|
$results = db_query($query);
|
|
$menu_date = db_fetch_assoc($results);
|
|
|
|
$qtyFieldFormat = $menu_date['order_format'];
|
|
|
|
$query = "SELECT * FROM people WHERE school_num = $base_school_num AND record_num = $studentNum";
|
|
$results = db_query($query);
|
|
$people = db_fetch_assoc($results);
|
|
extract($people);
|
|
|
|
$order_num = intval(db_getVal("SELECT record_num FROM hotlunch_orders WHERE school_num = $school_num AND student_num = $studentNum AND schedule_num = $scheduleNum"));
|
|
if ($orderNum > 0) $orderNum = " ($order_num)";
|
|
else $orderNum = "";
|
|
|
|
if ($classNum > 0) $class = getClassInfo($classNum);
|
|
|
|
$return_data['content'] .= "<span class='cafeteria-student-name-text'>$first_name $last_name $orderNum</span><br>";
|
|
if ($classNum > 0) $return_data['content'] .= "<span class='cafeteria-student-class-text'>$class</span><br>";
|
|
|
|
$query = "SELECT * FROM hotlunch_menu_items WHERE school_num = $school_num AND menu_num = $menuNum";
|
|
writeLog("query: $query\n");
|
|
$menu_items = db_query($query);
|
|
|
|
$symbol = $school_record['currency_symbol'];
|
|
|
|
$iconWidth = 25;
|
|
$iconHeight = 25;
|
|
|
|
$orderTotal = 0;
|
|
$tabIndex = 1;
|
|
|
|
if (db_num_rows($menu_items)) {
|
|
|
|
$return_data['content'] .= "<table class='cafeteria-menu-entry'>";
|
|
|
|
while ($row = db_fetch_assoc($menu_items)) {
|
|
extract($row);
|
|
$menu_item_num = $record_num;
|
|
|
|
if ($item_type == 'Heading') {
|
|
$return_data['content'] .= "<tr class='cafeteria-heading'>";
|
|
$return_data['content'] .= "<td colspan='4'>";
|
|
$return_data['content'] .= "<span class='menu-item-title'>$item_title</span>";
|
|
$return_data['content'] .= "</td>";
|
|
$return_data['content'] .= "</tr>\n";
|
|
}
|
|
|
|
if ($item_type == 'Item') {
|
|
$query = "SELECT * FROM hotlunch_order_items WHERE school_num = $school_num AND ordered_by_num = $studentNum AND menu_num = $menuNum AND menu_item_num = $menu_item_num";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$ordered_item = db_fetch_assoc($results);
|
|
$qty = $ordered_item['qty'];
|
|
}
|
|
else $qty = 0;
|
|
|
|
$item_price = $online_price;
|
|
$item_total = $qty * $item_price;
|
|
$jprice = $item_price;
|
|
|
|
if (strlen($item_description)) $item_title .= "<br><span class='cafeteria-item-description'>$item_description</span>";
|
|
|
|
// Handle options
|
|
|
|
|
|
if ($item_price == 0.00) {
|
|
$jprice = 0;
|
|
$item_price = "";
|
|
$item_total = "";
|
|
}
|
|
|
|
$line_total = $qty * $jprice;
|
|
$orderTotal += $line_total;
|
|
|
|
$lineTotal = "";
|
|
if ($line_total != 0) {
|
|
if ($line_total > 0) $lineTotal = $symbol . number_format($line_total,2);
|
|
else $lineTotal = "- " . $symbol . number_format(abs($line_total),2);
|
|
}
|
|
|
|
$return_data['content'] .= "<tr class='cafeteria-item' item_num='$menu_item_num'>";
|
|
$return_data['content'] .= "<td class='cafeteria-menu-item-title'>$item_title</td>";
|
|
$return_data['content'] .= "<td class='cafeteria-menu-item-qty'>";
|
|
|
|
if ($qtyFieldFormat == 'Quantity' && $menu_item_format == 'D' || $menu_item_format == 'Q') {
|
|
$return_data['content'] .= "<table cellpadding='0' cellspacing='0' class='qty-table'><tr>" .
|
|
"<td valign='top'><a href='#' class='minus' item_num='$menu_item_num' price='$jprice'>" .
|
|
"<img src='images/minus.png' align='left' hspace='10' vspace='0' height='$iconHeight' width='$iconWidth'></a></td>" .
|
|
"<td valign='top'><input type='text' class='cafeteria-qty' size='2' id='qty_$menu_item_num' value='$qty' item_num='$menu_item_num' price='$jprice' tabindex='$tabIndex'></td>" .
|
|
"<td valign='top'><a href='#' class='plus' item_num='$menu_item_num' price='$jprice'>" .
|
|
"<img src='images/plus.png' align='right' hspace='10' vspace='0' height='$iconHeight' width='$iconWidth'></a></td>" .
|
|
"</tr></table>";
|
|
}
|
|
else {
|
|
$checked = "";
|
|
if ($qty == 1) $checked = "checked='checked'";
|
|
$return_data['content'] .= "<input type='checkbox' class='cafeteria-checkbox' id='qty_$menu_item_num' value='1' $checked item_num='$menu_item_num' price='$jprice'>";
|
|
}
|
|
|
|
$return_data['content'] .= "<input type='hidden' class='line-total' id='total-$menu_item_num' value='$line_total'>";
|
|
$return_data['content'] .= "<input type='hidden' id='prev_qty_$menu_item_num' value='$qty'>";
|
|
$return_data['content'] .= "</td>";
|
|
$return_data['content'] .= "<td class='cafeteria-menu-item-price' id='price_$menu_item_num'>$symbol" . number_format($item_price,2) . "</td>";
|
|
$return_data['content'] .= "<td class='cafeteria-menu-item-price'><span id='total_$menu_item_num'>$lineTotal</span></td>";
|
|
$return_data['content'] .= "</tr>";
|
|
|
|
$tabIndex++;
|
|
}
|
|
}
|
|
|
|
$return_data['content'] .= "<tr><td colspan='3' align='right'>" . getLanguageText('TEXT-TOTAL') .
|
|
"</td><td class='cafeteria-item cafeteria-menu-item-price'><span id='cafeteria-total'>$symbol" . number_format($orderTotal,2) . "</span></td></tr>\n";
|
|
$return_data['content'] .= "</table>\n";
|
|
|
|
$return_data['content'] .= "<input type='hidden' name='cafeteria_schedule_num' id='cafeteria_schedule_num' value='$scheduleNum'>";
|
|
$return_data['content'] .= "<input type='hidden' name='cafeteria_menu_num' id='cafeteria_menu_num' value='$menuNum'>";
|
|
$return_data['content'] .= "<input type='hidden' name='cafeteria_student_num' id='cafeteria_student_num' value='$studentNum'>";
|
|
$return_data['content'] .= "<input type='hidden' name='cafeteria_order_num' id='cafeteria_order_num' value='$order_num'>";
|
|
|
|
$return_data['content'] .= "<span id='order_num_span'>$order_num</span>";
|
|
}
|
|
|
|
break;
|
|
|
|
case 'update-students':
|
|
$logging = false;
|
|
$user_num = intval($_GET['usernum']);
|
|
$mode = $_GET['mode'];
|
|
$return_data['count'] = 0;
|
|
|
|
$query = "SELECT* FROM people WHERE school_num = $base_school_num AND user_num = $user_num AND people_type = 'Student'";
|
|
writeLog("query: $query\n");
|
|
$students = db_query($query);
|
|
|
|
if (db_num_rows($students)) {
|
|
$return_data['count'] = db_num_rows($students);
|
|
|
|
// Get classes
|
|
$Classes = array();
|
|
$results = db_query("SELECT * FROM classes WHERE school_num = $base_school_num AND entry_type = 'Class' ORDER BY sequence");
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$cnum = $row['record_num'];
|
|
$classInfo = getClassInfo($cnum,'dropdown');
|
|
$row['info'] = $classInfo;
|
|
$Classes[] = $row;
|
|
}
|
|
|
|
$content = "<center><table width='95%' class='content-table'>";
|
|
$content .= "<tr>";
|
|
$content .= "<td class='heading'>" . getLanguageText('TEXT-NAME') . "</td>";
|
|
$content .= "<td class='heading'>" . $GlobalText['Class'] . "</td>";
|
|
$content .= "</tr>";
|
|
|
|
$class = 'data-odd';
|
|
|
|
while ($row = db_fetch_assoc($students)) {
|
|
extract($row);
|
|
writeLog("class_num: $class_num\n");
|
|
|
|
if ($class == 'data-odd') $class = 'data-even';
|
|
else $class = 'data-odd';
|
|
|
|
$content .= "<tr>";
|
|
$content .= "<td class='$class'>$first_name $last_name</td>";
|
|
$content .= "<td class='$class'>";
|
|
$content .= "<select name='student_class' class='student-class' snum='$record_num'>";
|
|
|
|
if ($class_num == 0) $content .= "<option value=0></option>";
|
|
|
|
for ($i = 0; $i < count($Classes); $i++) {
|
|
$class = $Classes[$i];
|
|
$cnum = $class['record_num'];
|
|
$info = $class['info'];
|
|
$selected = "";
|
|
if ($class_num == $cnum) $selected = " selected='selected'";
|
|
$content .= "<option value=$cnum $selected>$info</option>";
|
|
}
|
|
|
|
$content .= "</select>";
|
|
$content .= "</td>";
|
|
$content .= "</tr>";
|
|
}
|
|
|
|
$content .= "</table></center>";
|
|
$return_data['content'] = $content;
|
|
}
|
|
|
|
break;
|
|
|
|
case 'load-email-reminders-log':
|
|
// startLog("load-email-reminders-log");
|
|
|
|
if (array_key_exists('school_num',$_GET) && $_SESSION['UserInfo']['type'] == 'SuperUser') $school_num = intval($_GET['school_num']);
|
|
writeLog("school_num: $school_num");
|
|
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-DATE'),
|
|
getLanguageText('TEXT-SCHEDULES'),
|
|
getLanguageText('TEXT-USERS'),
|
|
getLanguageText('TEXT-EMAILS-SENT'),
|
|
);
|
|
$columnAlign = array('left','center','center','center','center');
|
|
|
|
$commands = array();
|
|
$commands[] = "<a href='#' class='view-log-details' rnum='%d' title='View Details'>$view_icon_small</a>";
|
|
|
|
|
|
$query = "SELECT * FROM email_reminders_log WHERE school_num = $school_num ORDER BY reminder_date,send_start ASC";
|
|
writeLog($query);
|
|
$logs = db_query($query);
|
|
writeLog("Num records: ".db_num_rows($logs));
|
|
|
|
if (db_num_rows($logs)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($logs)) {
|
|
extract($row);
|
|
|
|
$data[] = array($reminder_date,
|
|
$num_schedules,
|
|
$num_users,
|
|
$num_emails,
|
|
"record_num" => $record_num);
|
|
}
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 750;
|
|
$return_data['content'] = getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,array());
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
|
|
break;
|
|
|
|
case 'load-email-reminders-log-detail':
|
|
// startLog("load-email-reminders-log-detail");
|
|
|
|
if (array_key_exists('school_num',$_GET) && $_SESSION['UserInfo']['type'] == 'SuperUser') $school_num = intval($_GET['school_num']);
|
|
writeLog("school_num: $school_num");
|
|
if (array_key_exists('log_num',$_GET)) $log_num = intval($_GET['log_num']);
|
|
writeLog("log_num: $log_num");
|
|
|
|
// Setup format
|
|
$columnHeaders = array(getLanguageText('TEXT-USERID'),
|
|
getLanguageText('TEXT-EMAIL'),
|
|
getLanguageText('TEXT-TIME'),
|
|
);
|
|
$columnAlign = array('left','left','left');
|
|
|
|
$commands = array();
|
|
$commands[] = "<a href='#' class='view-log-message' rnum='%d' title='View Message'>$view_icon_small</a>";
|
|
|
|
$results = db_query("SELECT * FROM email_reminders_log WHERE school_num = $school_num AND record_num = $log_num");
|
|
if (db_num_rows($results)) {
|
|
|
|
$query = "SELECT * FROM email_reminders_log_detail WHERE school_num = $school_num AND log_num = $log_num ORDER BY userid,time_sent ASC";
|
|
writeLog($query);
|
|
$logs = db_query($query);
|
|
writeLog("Num records: ".db_num_rows($logs));
|
|
|
|
if (db_num_rows($logs)) {
|
|
$data = array();
|
|
|
|
while ($row = db_fetch_assoc($logs)) {
|
|
extract($row);
|
|
|
|
$msg = "<table><tr><td align=left>" . nl2br(str_replace("'",""",$email_message)) . "</td></tr></table>";
|
|
$userid .= "<input type='hidden' id='msg-$record_num' value='$msg'>";
|
|
|
|
$data[] = array($userid,
|
|
$email_address,
|
|
$time_sent,
|
|
"record_num" => $record_num);
|
|
}
|
|
|
|
if (isset($table_id) && strlen($table_id)) $customTableID = $table_id;
|
|
$TableWidth = 750;
|
|
$return_data['content'] = "<h2>".getLanguageText('TEXT-DATE').": $reminder_date</h2>";
|
|
$return_data['content'] .= getDataCustom($data,$columnHeaders,$action,$commands,'N',$columnAlign,array());
|
|
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('ERRORMSG-NO-RECORDS')." --- </b></p>";
|
|
}
|
|
|
|
break;
|
|
|
|
case 'load-image-list':
|
|
if ($userType != 'Admin') return;
|
|
|
|
$content = "";
|
|
$image_path = "files/$subpath/image";
|
|
if (is_dir($image_path)) {
|
|
$imagedir = opendir($image_path);
|
|
|
|
$file_names = array();
|
|
while ($file = readdir($imagedir)) {
|
|
if ($file == ".") continue;
|
|
if ($file == "..") continue;
|
|
$file_names[] = $file;
|
|
}
|
|
}
|
|
|
|
if (count($file_names)) {
|
|
sort($file_names);
|
|
$class = 'data-odd';
|
|
$content .= "<table width='100%' cellpadding='2'>";
|
|
for ($i = 0; $i < count($file_names); $i++) {
|
|
$fname = db_escape_string($file_names[$i]);
|
|
if ($class == 'data-odd') $class = 'data-even';
|
|
else $class = 'data-odd';
|
|
$content .= "<tr class='$class'><td align='left'>$fname</td>" .
|
|
"<td align='center'><a href='#' image='$fname' class='btn btn--primary btn--xsmall image-delete'>".getLanguageText('TEXT-DELETE')."</td></tr>\n";
|
|
}
|
|
$content .= "</table>";
|
|
|
|
$return_data['content'] = $content;
|
|
}
|
|
else {
|
|
$return_data['content'] = "<p><b> --- ".getLanguageText('TEXT-NO-IMAGES-FOUND')." --- </b></p>";
|
|
}
|
|
break;
|
|
|
|
case 'load-image-gallery':
|
|
// startLog('load-image-gallery');
|
|
if ($userType != 'Admin') return;
|
|
|
|
$content = "";
|
|
$image_path = "files/$subpath/image";
|
|
writeLog("image_path: $image_path");
|
|
if (is_dir($image_path)) {
|
|
$imagedir = opendir($image_path);
|
|
|
|
$file_names = array();
|
|
while ($file = readdir($imagedir)) {
|
|
if ($file == ".") continue;
|
|
if ($file == "..") continue;
|
|
|
|
if (strstr($file,"-tn.jpg") !== false) $file_names[] = $file;
|
|
if (strstr($file,"-tn.jpeg") !== false) $file_names[] = $file;
|
|
if (strstr($file,"-tn.png") !== false) $file_names[] = $file;
|
|
if (strstr($file,"-tn.gif") !== false) $file_names[] = $file;
|
|
}
|
|
}
|
|
|
|
sort($file_names);
|
|
$count = count($file_names);
|
|
$rows = intval(($count + 3) / 4);
|
|
$columns = 4;
|
|
$img = 0;
|
|
|
|
if (count($file_names)) {
|
|
$content = "<center><table width='850' class='content-table'>";
|
|
|
|
for ($r = 0; $r < $rows; $r++) {
|
|
$content .= "<tr>";
|
|
|
|
for ($c = 0; $c < $columns; $c++) {
|
|
$content .= "<td align='center' width='200'>";
|
|
|
|
if ($img < count($file_names)) {
|
|
$thumbnail = $file_names[$img];
|
|
$image = str_replace("-tn.",".",$thumbnail);
|
|
writeLog("image_path: $image_path");
|
|
writeLog("image: $image");
|
|
$content .= "<img src='$image_path/$thumbnail' class='gallery-image' filename='$image_path/$image' style='border: solid 1px #000000'>";
|
|
$img++;
|
|
}
|
|
else $content .= " ";
|
|
|
|
$content .= "</td>";
|
|
}
|
|
|
|
$content .= "</tr>";
|
|
}
|
|
|
|
$content .= "</table></center>";
|
|
}
|
|
|
|
$return_data['content'] = $content;
|
|
break;
|
|
}
|
|
|
|
$return_data['content'] .= $localContent;
|
|
// writeLog("".$return_data['content']."\n");
|
|
|
|
writeLog("complete\n");
|
|
echo(json_encode($return_data));
|
|
|
|
?>
|