Files
HotLunches/payment_message.log.php
2026-10-19 15:22:52 -07:00

175 lines
5.5 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
//
// Process all actions to list and edit records
//
$action = "payment-message-log";
$CurrentTable = "payment_message_queue";
$FormFile = "";
$TitleText = getLanguageText('TEXT-PAYMENT-MESSAGE-LOG');
$OrderBy = "sent_time";
// Start the template and output buffering
startTemplate();
$templatePageTitle = "$TitleText";
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Communications Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team');
if (checkPermission($AllowedUserTypes) != 1) {
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
include "form.messages.php";
endTemplate();
exit();
}
$school_num = $school_record['record_num'];
//
// Parse any parameters
//
if (array_key_exists('action',$_POST) && strlen($_POST['action']) > 0) {
$where = "";
// Handle selected date ranges
$start_date = date("Y-m-d 00:00:00",time());
$end_date = date("Y-m-d 23:59:59",time());
if (array_key_exists('start_date',$_POST) && strlen($_POST['start_date']) > 0) $start_date = date("Y-m-d 00:00:00",strtotime($_POST['start_date']));
if (array_key_exists('end_date',$_POST) && strlen($_POST['end_date']) > 0) {
$end_date = $_POST['end_date'];
if ($end_date < substr($start_date,0,10)) {
$end_date = substr($start_date,0,10);
$error_message = getLanguageText('ERRORMSG-INVALID-DATE-RANGE');
}
$end_date = date("Y-m-d 23:59:59",strtotime($end_date));
}
$stime = strtotime($start_date);
$etime = strtotime($end_date);
$where .= "and sent_time between '$stime' and '$etime' ";
$args = "&where=" . urlencode($where);
$args .= "&stime=$stime";
$args .= "&etime=$etime";
$naction = 'list';
header("Location: /?action=$action&naction=$naction$args" . "&error_message=" . urlencode($error_message));
ob_end_clean();
exit();
}
else {
if (array_key_exists('where',$_GET) && strlen($_GET['where']) > 0) {
$where = "where school_num = $school_num " . $_GET['where'];
$stime = intval($_GET['stime']);
$etime = intval($_GET['etime']);
}
else {
$where = "where school_num = $school_num ";
// Handle selected date ranges
$start_date = date("Y-m-d 00:00:00",time());
$end_date = date("Y-m-d 23:59:59",time());
$stime = strtotime($start_date);
$etime = strtotime($end_date);
$where .= "and sent_time between '$stime' and '$etime' ";
}
}
$sdate = date("Y-m-d",$stime);
$edate = date("Y-m-d",$etime);
$message_width = 400;
include "form.messages.php";
$scriptName = str_replace("/m/data1/app.hotlunches.net/","",__FILE__);
include "help.docs.php";
?>
<br>
<form method='post' name='messagelog'>
<table width='450' cellpadding='5' class='content-table'>
<tr height='5'>
<td align='left'><img src='images/spacer.gif' height='5'></td>
</tr>
<tr>
<td align='right'><?php displayLanguageText('TEXT-START-DATE'); ?>: </td>
<td align='left' colspan='2'><input type='text' name='start_date' value='<?php echo($sdate) ?>' size='15' class='date-field'></td>
</tr>
<tr>
<td valign='top' align='right'><?php displayLanguageText('TEXT-END-DATE'); ?>: </td>
<td valign='top' align='left' colspan='2'>
<input type='text' name='end_date' value='<?php echo($edate) ?>' size='15' class='date-field'>
<a href='#' class='btn btn--primary btn--xsmall' onClick='document.messagelog.submit();'><span><?php displayLanguageText('TEXT-VIEW'); ?></span></a>
<br>
<br>
</td>
</tr>
</table>
<input type='hidden' name='action' value='payment-message-log'>
</form>
<br>
<center>
<?php
//
// List all requested records
//
$columnHeaders = array(getLanguageText('TEXT-SCHEDULE-TITLE'),
getLanguageText('TEXT-NAME'),
getLanguageText('TEXT-EMAIL'),
"",
getLanguageText('TEXT-DATE'));
$columnAlign = array('left','left','left','center','center');
$query = "select * from payment_message_queue $where order by sent_time, record_num";
$results = db_query($query);
$data = array();
while ($row = db_fetch_assoc($results)) {
extract($row);
$sname = db_getVal("SELECT schedule_name FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $schedule_num");
$student = db_getVal("SELECT concat(first_name,' ',last_name) FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
$stime = date("Y-m-d h:i a",$sent_time);
$data[] = array($sname,$student,$email_recipient,"<span class='sent-flag' rnum='$record_num'>$sent_flag</span>",$stime);
}
listDataCustom($data,$columnHeaders,$action,array(),'N',$columnAlign);
?>
<script>
$(document).ready(function() {
<?php include "include/ajax.Setup.php" ?>
$(document).on('click', '.sent-flag', function(e) {
e.preventDefault();
var cSpan = $(this);
var flag = $(this).html();
var rnum = $(this).attr('rnum');
$.ajax({
type: 'GET',
dataType: 'json',
url: "ajax.ToggleSentFlag.php",
data: { record_num: rnum, sent_flag: flag }
}).done(function(data) {
cSpan.html(data.flag);
});
});
});
</script>
<?php
endTemplate();
?>