First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
+355
@@ -0,0 +1,355 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /?error_message=" . urlencode(getLanguageText('ERRORMSG-SESSION-EXPIRED')));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
$action = '';
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
// startLog("order_log.php");
|
||||
writeLog(print_r($_POST,true));
|
||||
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$action = "order-log";
|
||||
$CurrentTable = "hotlunch_order_change_log";
|
||||
$FormFile = "";
|
||||
$OrderBy = "log_time asc";
|
||||
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = getLanguageText('TEXT-ORDER-LOG');
|
||||
$headerArgs = "";
|
||||
|
||||
|
||||
if (array_key_exists('selected_user_num',$_GET)) $selected_user_num = $_GET['selected_user_num'];
|
||||
if (array_key_exists('selected_user_num',$_POST)) $selected_user_num = $_POST['selected_user_num'];
|
||||
if (array_key_exists('selected_order_num',$_GET)) $selected_order_num = $_GET['selected_order_num'];
|
||||
if (array_key_exists('selected_order_num',$_POST)) $selected_order_num = $_POST['selected_order_num'];
|
||||
if (array_key_exists('selected_people_num',$_GET)) $selected_people_num = $_GET['selected_people_num'];
|
||||
if (array_key_exists('selected_people_num',$_POST)) $selected_people_num = $_POST['selected_people_num'];
|
||||
if (array_key_exists('selected_start_date',$_POST)) $selected_start_date = $_POST['selected_start_date'];
|
||||
if (array_key_exists('selected_end_date',$_POST)) $selected_end_date = $_POST['selected_end_date'];
|
||||
|
||||
$dateSearch = false;
|
||||
if (isset($selected_start_date) && isset($selected_end_date)) $dateSearch = true;
|
||||
|
||||
|
||||
$school_num = $school_record['record_num'];
|
||||
|
||||
|
||||
$message_width = 400;
|
||||
include "form.messages.php";
|
||||
|
||||
$ParametersEntered = false;
|
||||
|
||||
// Process naction parameters
|
||||
if (array_key_exists('naction',$_GET) && strlen($_GET['naction']) > 0) $naction = $_GET['naction'];
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Parse any parameters
|
||||
//
|
||||
$where = "where school_num = $school_num ";
|
||||
|
||||
|
||||
// View only a selected user_num
|
||||
if (isset($selected_user_num) && strlen($selected_user_num) > 0) {
|
||||
$where .= "and user_num = '" . intval($selected_user_num) . "' ";
|
||||
$ParametersEntered = true;
|
||||
}
|
||||
|
||||
// View only a selected order_num
|
||||
if (isset($selected_order_num) && strlen($selected_order_num) > 0) {
|
||||
$where .= "and order_num = '" . intval($selected_order_num) . "' ";
|
||||
$ParametersEntered = true;
|
||||
}
|
||||
|
||||
// View only a selected people_num
|
||||
if (isset($selected_people_num) && strlen($selected_people_num) > 0) {
|
||||
$where .= "and ordered_by_num = '" . intval($selected_people_num) . "' ";
|
||||
$ParametersEntered = true;
|
||||
}
|
||||
|
||||
if ($dateSearch) {
|
||||
$where .= "and updated_time BETWEEN '$selected_start_date 00:00:00' AND '$selected_end_date 23:59:59' ";
|
||||
$ParametersEntered = true;
|
||||
}
|
||||
|
||||
if (!isset($selected_start_date)) $selected_start_date = date("Y-m-d",time());
|
||||
if (!isset($selected_end_date)) $selected_end_date = date("Y-m-d",time());
|
||||
|
||||
?>
|
||||
<br>
|
||||
<form method='post' name='orderlog_date_search' id='orderlog_date_search' action="/">
|
||||
<table width='500' cellpadding='5' class='content-table'>
|
||||
<tr>
|
||||
<td align='left'>
|
||||
<?php displayLanguageText('TEXT-START-DATE'); ?>:<br>
|
||||
<input type='text' name='selected_start_date' id='selected_start_date' class='date-field' value='<?php echo($selected_start_date) ?>'><br>
|
||||
<?php displayLanguageText('TEXT-END-DATE'); ?>:<br>
|
||||
<input type='text' name='selected_end_date' id='selected_end_date' class='date-field' value='<?php echo($selected_end_date) ?>'>
|
||||
</td>
|
||||
<td align='right'><br><a href='#' class='btn btn--primary btn--xsmall' onClick='document.orderlog_date_search.submit();'><?php displayLanguageText('TEXT-VIEW'); ?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='hidden' name='action' value='order-log'>
|
||||
<input type='hidden' name='selected_people_num' id='selected_people_num'>
|
||||
</form>
|
||||
<br>
|
||||
<form method='post' name='orderlog_person_search' id='orderlog_person_search' action="/">
|
||||
<table width='500' cellpadding='5' class='content-table'>
|
||||
<tr>
|
||||
<td align='left'><?php displayLanguageText('TEXT-ORDERED-BY'); ?>:<br>
|
||||
<input type='text' name='selected_person_search' id='selected_person_search'></td>
|
||||
<td align='right'><br><a href='#' class='btn btn--primary btn--xsmall' onClick='document.orderlog_person_search.submit();'><?php displayLanguageText('TEXT-VIEW'); ?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='hidden' name='action' value='order-log'>
|
||||
<input type='hidden' name='selected_people_num' id='selected_people_num'>
|
||||
</form>
|
||||
<br>
|
||||
<form method='post' name='orderlog_order_num' id='orderlog_order_num' action="/">
|
||||
<table width='500' cellpadding='5' class='content-table'>
|
||||
<tr>
|
||||
<td align='left'><?php displayLanguageText('TEXT-ORDER-NUMBER'); ?>:<br>
|
||||
<input type='text' name='selected_order_num' id='order_num'></td>
|
||||
<td align='right'><br><a href='#' class='btn btn--primary btn--xsmall' onClick='document.orderlog_order_num.submit();'><?php displayLanguageText('TEXT-VIEW'); ?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='hidden' name='action' value='order-log'>
|
||||
</form>
|
||||
<br>
|
||||
<!--
|
||||
<form method='post' name='orderlog_person' action="/">
|
||||
<table width='500' cellpadding='5' class='content-table'>
|
||||
<tr>
|
||||
<td align='left'><?php displayLanguageText('TEXT-ORDERED-BY'); ?>:<br>
|
||||
<select name='selected_people_num' class='select-width400'>
|
||||
<option value=''><?php displayLanguageText('TEXT-SELECT'); ?></option>
|
||||
<?php
|
||||
// List people from order_log
|
||||
$results = db_query("SELECT DISTINCT p.first_name,p.last_name,p.record_num,count(*) AS num " .
|
||||
"FROM hotlunch_order_change_log AS hlol, people AS p " .
|
||||
"WHERE hlol.school_num = $school_num " .
|
||||
"AND p.school_num = $base_school_num " .
|
||||
"AND p.record_num = hlol.ordered_by_num " .
|
||||
"GROUP BY 1,2,3 " .
|
||||
"ORDER BY last_name,first_name ASC");
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
$people_num = $row['record_num'];
|
||||
$name = $row['first_name'] . ' ' . $row['last_name'];
|
||||
$num = $row['num'];
|
||||
$selected = "";
|
||||
if (isset($selected_people_num) && $selected_people_num == $people_num) $selected = " selected='selected'";
|
||||
echo(" <option value='$people_num'$selected>$name ($num)</option>\n");
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td align='right'><br><a href='#' class='btn btn--primary btn--xsmall' onClick='document.orderlog_person.submit();'><?php displayLanguageText('TEXT-VIEW'); ?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='hidden' name='action' value='order-log'>
|
||||
</form>
|
||||
<br>
|
||||
-->
|
||||
<form method='post' name='orderlog_user' action="/">
|
||||
<table width='500' cellpadding='5' class='content-table'>
|
||||
<tr>
|
||||
<td align='left'><?php displayLanguageText('TEXT-USER-ID'); ?>:<br>
|
||||
<select name='selected_user_num' class='select-width400'>
|
||||
<option value=''><?php displayLanguageText('TEXT-SELECT'); ?></option>
|
||||
<?php
|
||||
// List userid's from order_log
|
||||
$results = db_query("SELECT DISTINCT u.* " .
|
||||
"FROM users AS u " .
|
||||
"WHERE u.school_num = $base_school_num " .
|
||||
"ORDER BY userid ASC");
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
$user_num = $row['record_num'];
|
||||
$userid = $row['userid'];
|
||||
$name = $row['first_name'] . ' ' . $row['last_name'];
|
||||
$selected = "";
|
||||
if (isset($selected_user_num) && $selected_user_num == $user_num) $selected = " selected='selected'";
|
||||
echo(" <option value='$user_num'$selected>$userid - $name</option>\n");
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td align='right'><br><a href='#' class='btn btn--primary btn--xsmall' onClick='document.orderlog_user.submit();'><?php displayLanguageText('TEXT-VIEW'); ?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='hidden' name='action' value='order-log'>
|
||||
</form>
|
||||
<center>
|
||||
<?php
|
||||
|
||||
//
|
||||
// Only show superuser entries to superuser
|
||||
//
|
||||
// if ($_SESSION['UserInfo']['type'] != 'SuperUser') $where .= "and userid != 'superuser' ";
|
||||
|
||||
|
||||
//
|
||||
// List all requested records
|
||||
//
|
||||
if ($ParametersEntered) {
|
||||
$columnHeaders = array(getLanguageText('TEXT-USER'),
|
||||
getLanguageText('TEXT-STUDENT'),
|
||||
getLanguageText('TEXT-ORDER-NUMBER'),
|
||||
getLanguageText('TEXT-SCHEDULE-TITLE'),
|
||||
getLanguageText('TEXT-DATE'),
|
||||
getLanguageText('TEXT-TOTAL'),
|
||||
getLanguageText('TEXT-ACTIVITY'));
|
||||
if (isset($selected_order_num) && intval($selected_order_num) > 0) {
|
||||
$columnHeaders = array(getLanguageText('TEXT-USER'),
|
||||
getLanguageText('TEXT-STUDENT'),
|
||||
getLanguageText('TEXT-ORDER-NUMBER'),
|
||||
getLanguageText('TEXT-DATE'),
|
||||
getLanguageText('TEXT-TOTAL'),
|
||||
getLanguageText('TEXT-BALANCE'),
|
||||
getLanguageText('TEXT-ACTIVITY'));
|
||||
}
|
||||
|
||||
$query = "SELECT * " .
|
||||
"FROM hotlunch_order_change_log $where order by log_time";
|
||||
$entries = db_query($query);
|
||||
|
||||
$data = array();
|
||||
$balance = 0;
|
||||
$prev = 0;
|
||||
while ($row = db_fetch_assoc($entries)) {
|
||||
extract($row);
|
||||
|
||||
$student = "Unknown";
|
||||
if ($ordered_by_num > 0) {
|
||||
$results = db_query("SELECT * FROM people WHERE school_num IN ($school_num, $base_school_num) AND record_num = $ordered_by_num");
|
||||
$student = "";
|
||||
if (db_num_rows($results)) {
|
||||
$person = db_fetch_assoc($results);
|
||||
$student = $person['first_name'].' '.$person['last_name'];
|
||||
$user_num = $person['user_num'];
|
||||
$snum = $person['school_num'];
|
||||
if ($snum != $base_school_num) $student = "<span class='warning'>$student</span>";
|
||||
}
|
||||
}
|
||||
|
||||
$userid = "Unknown";
|
||||
if ($user_num > 0) {
|
||||
$results = db_query("SELECT * FROM users WHERE school_num IN ($school_num, $base_school_num) AND record_num = $user_num");
|
||||
$userid = "";
|
||||
if (db_num_rows($results)) {
|
||||
$user = db_fetch_assoc($results);
|
||||
$userid = $user['first_name'].' '.$user['last_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$schedule = "Unknown";
|
||||
if ($schedule_num > 0) {
|
||||
$results = db_query("SELECT * FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $schedule_num");
|
||||
$schedule = "";
|
||||
if (db_num_rows($results)) {
|
||||
$row = db_fetch_assoc($results);
|
||||
$schedule = $row['schedule_name'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$prefix = '$';
|
||||
if (strstr($order_action,"PAYMENT") !== FALSE) {
|
||||
$prefix = '';
|
||||
$order_change = $order_total - $prev;
|
||||
$balance = 0;
|
||||
$ot = '';
|
||||
}
|
||||
else {
|
||||
$order_change = $order_total - $prev;
|
||||
$balance += $order_change;
|
||||
$ot = $order_total;
|
||||
}
|
||||
$prev = $order_total;
|
||||
|
||||
if ($balance < 0) $bal = '-$'.number_format($balance,2);
|
||||
else $bal = '$'.number_format($balance,2);
|
||||
|
||||
if (isset($selected_order_num) && intval($selected_order_num) > 0) {
|
||||
$data[] = array("<span class='user-id' rnum='$user_num'>$userid</span>",
|
||||
$student,
|
||||
$order_num,
|
||||
date("Y-m-d H:i:s",$log_time),
|
||||
$prefix.$ot,
|
||||
$bal,
|
||||
"<span class='order-action' onum='$order_num' rnum='$record_num'>$order_action</span>");
|
||||
}
|
||||
else {
|
||||
$data[] = array("<span class='user-id' rnum='$user_num'>$userid</span>",
|
||||
$student,
|
||||
$order_num,
|
||||
$schedule,
|
||||
date("Y-m-d H:i:s",$log_time),
|
||||
$prefix.$ot,
|
||||
"<span class='order-action' onum='$order_num' rnum='$record_num'>$order_action</span>");
|
||||
}
|
||||
}
|
||||
|
||||
listDataCustom($data,$columnHeaders,$action,array(),'N');
|
||||
}
|
||||
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
||||
<?php include "include/ajax.Setup.php" ?>
|
||||
|
||||
$("#selected_person_search").autocomplete({
|
||||
source: "ajax.studentSearch.php",
|
||||
minLength: 2,
|
||||
width: 750,
|
||||
selectFirst: false,
|
||||
select: function( event, results ) {
|
||||
var student_num = results.item.student_num;
|
||||
$("#selected_people_num").val(student_num);
|
||||
$("#orderlog_person_search").submit();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.order-action', function(){
|
||||
var order_num = $(this).attr('onum');
|
||||
var record_num = $(this).attr('rnum');
|
||||
|
||||
var data = "table_name=hotlunch_order_log"+
|
||||
"&sequence_flag=N"+
|
||||
"&action=order-log-detail"+
|
||||
"&table_id="+
|
||||
"&order_num="+order_num+
|
||||
"&record_num="+record_num;
|
||||
|
||||
// Display order detail
|
||||
$.getJSON( "ajax.DataTable.Fetch.php",data,
|
||||
function(results) {
|
||||
$("#info-content").html(results.content);
|
||||
$("#text-info-dialog").dialog("open");
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user