277 lines
9.8 KiB
PHP
277 lines
9.8 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Process all actions to list and edit records
|
|
//
|
|
$action = "user-account-paypal";
|
|
$CurrentTable = "user_account";
|
|
$FormFile = "";
|
|
$TitleText = getLanguageText('TEXT-COMPLETED-PAYPAL-TRANSACTIONS');
|
|
$OrderBy = "transaction_datetime";
|
|
|
|
if (array_key_exists('type',$_REQUEST) && strlen($_REQUEST['type']) > 0 && $_REQUEST['type'] == 'deleted') {
|
|
$TitleText = getLanguageText('TEXT-DELETED-PAYPAL-TRANSACTIONS');
|
|
}
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = "$TitleText";
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
if (!in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team','Financial','Financial Team'))) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$school_num = $school_record['record_num'];
|
|
|
|
$print_cmd = "";
|
|
|
|
// 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));
|
|
}
|
|
|
|
$sdate = substr($start_date,0,10);
|
|
$edate = substr($end_date,0,10);
|
|
|
|
if (!isset($twhere)) $twhere = '';
|
|
$twhere .= "AND transaction_datetime BETWEEN '$start_date' AND '$end_date' ";
|
|
$print_cmd .= "&start_date=$sdate&end_date=$edate";
|
|
|
|
|
|
// View only a selected userid
|
|
$uwhere = "";
|
|
unset($selected_usernum);
|
|
if (array_key_exists('selected_usernum',$_POST) && strlen($_POST['selected_usernum']) > 0) {
|
|
$selected_usernum = intval($_POST['selected_usernum']);
|
|
$userid = db_getVal("SELECT userid FROM users WHERE record_num = $selected_usernum");
|
|
$uwhere = "AND ua.user_num = $selected_usernum ";
|
|
$print_cmd .= "&selected_usernum=$selected_usernum";
|
|
}
|
|
|
|
|
|
// View only selected transaction types
|
|
$selected_transaction_type = 'Payment';
|
|
$uwhere .= "AND ua.transaction_type = '$selected_transaction_type' ";
|
|
|
|
|
|
// View only selected payment methods
|
|
$selected_payment_method = 'PayPal';
|
|
$uwhere .= "AND ua.payment_method = '$selected_payment_method' ";
|
|
|
|
|
|
// View only selected schedule
|
|
$swhere = "";
|
|
$selected_schedule_num = 0;
|
|
if (array_key_exists('selected_schedule_num',$_POST) && strlen($_POST['selected_schedule_num']) > 0) {
|
|
$selected_schedule_num = intval($_POST['selected_schedule_num']);
|
|
$uwhere .= "AND ua.schedule_num = '$selected_schedule_num' ";
|
|
$print_cmd .= "&selected_schedule_num=$selected_schedule_num";
|
|
}
|
|
|
|
|
|
|
|
// Process an optional type parameter
|
|
unset($deleteType);
|
|
if (array_key_exists('type',$_REQUEST) && strlen($_REQUEST['type']) > 0 && $_REQUEST['type'] == 'deleted') {
|
|
$deleteType = $_REQUEST['type'];
|
|
$uwhere .= "AND deleted = 'Y' ";
|
|
$print_cmd .= "&type=$deleteType";
|
|
}
|
|
else {
|
|
$deleteType = "active";
|
|
$uwhere .= "AND (deleted != 'Y' OR deleted IS NULL) ";
|
|
}
|
|
|
|
|
|
?>
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
$("#paypal-fee-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
minHeight: 300,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$(document).on('click','.trx-ref',function() {
|
|
var rnum = $(this).attr('rnum');
|
|
var ref = $(this).attr('ref');
|
|
var amt = $(this).attr('amt');
|
|
var fee = $(this).attr('fee');
|
|
|
|
if (rnum == 0) return;
|
|
|
|
$("#trx-id").val(ref);
|
|
$("#trx-amt").val(Number(amt).toFixed(2));
|
|
$("#trx-fee").val(Number(fee).toFixed(2));
|
|
$("#record_num").val(rnum);
|
|
<?php if ($_SESSION['UserInfo']['type'] == 'SuperUser') { ?>
|
|
$("#rnum").html(rnum);
|
|
<?php } ?>
|
|
|
|
$("#paypal-fee-dialog").dialog("open");
|
|
});
|
|
|
|
$("#save-fee").click(function() {
|
|
var rnum = $("#record_num").val();
|
|
var ref = $("#trx-id").val();
|
|
var amt = $("#trx-amt").val();
|
|
var fee = $("#trx-fee").val();
|
|
|
|
if (fee.length) {
|
|
amt = Number(amt).toFixed(2);
|
|
fee = Number(fee).toFixed(2);
|
|
$("#trx-ref-"+rnum).attr('ref',ref);
|
|
$("#trx-ref-"+rnum).attr('amt',amt);
|
|
$("#trx-ref-"+rnum).attr('fee',fee);
|
|
$("#trx-ref-"+rnum).html(ref);
|
|
$("#trx-amt-"+rnum).html('$'+amt);
|
|
$("#trx-fee-"+rnum).html('$'+fee);
|
|
$("#paypal-fee-dialog").dialog("close");
|
|
|
|
var data = "table_name=user_account"+
|
|
"&payment_reference="+ref+
|
|
"&transaction_amount=-"+amt+
|
|
"&transaction_fee="+fee+
|
|
"&record_num="+rnum;
|
|
$.ajax({
|
|
url: "ajax.DataRecord.Update.php",
|
|
data: data
|
|
});
|
|
}
|
|
});
|
|
|
|
$("#close-dialog").click(function() {
|
|
$("#paypal-fee-dialog").dialog("close");
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
|
|
|
|
|
|
$message_width = 600;
|
|
include "form.messages.php";
|
|
|
|
?>
|
|
<form method='post' name='transactions'>
|
|
<table width='600' cellpadding='3' class='content-table'>
|
|
<tr>
|
|
<td align='right'><?php displayLanguageText('TEXT-START-DATE'); ?>: </td>
|
|
<td align='left'><input type='text' name='start_date' id='start_date' value='<?php echo($sdate) ?>' size='15' class='date-field'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'><?php displayLanguageText('TEXT-END-DATE'); ?>: </td>
|
|
<td align='left'><input type='text' name='end_date' id='end_date' value='<?php echo($edate) ?>' size='15' class='date-field'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-USER'); ?>: </td>
|
|
<td align='left'>
|
|
<select name='selected_usernum'>
|
|
<option value=''><?php displayLanguageText('TEXT-VIEW-ALL'); ?></option>
|
|
<?php
|
|
// List userid's from users table
|
|
$results = db_query("select userid,concat_ws(' ',first_name,last_name) as name,type,record_num from users where school_num = $base_school_num order by last_name,first_name");
|
|
while ($row = db_fetch_array($results)) {
|
|
$userid = $row['userid'];
|
|
$name = $row['name'];
|
|
$type = $row['type'];
|
|
$rnum = $row['record_num'];
|
|
|
|
$selected = "";
|
|
if (isset($selected_usernum) && $selected_usernum == $rnum) $selected = " selected='selected'";
|
|
echo(" <option value='$rnum'$selected>$name ($type - $userid)</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-SCHEDULE'); ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<select name='selected_schedule_num'>
|
|
<option value=''><?php displayLanguageText('TEXT-VIEW-ALL'); ?></option>
|
|
<?php
|
|
$end_date = date("Y-m-d",time() - 60 * 60 * 24 * 400);
|
|
$schedules = db_query("SELECT schedule_name,record_num FROM hotlunch_schedules WHERE school_num = $school_num AND schedule_end_date >= '$end_date' AND status != 'Deleted' ORDER BY schedule_end_date DESC");
|
|
while ($row = db_fetch_array($schedules)) {
|
|
$sname = $row['schedule_name'];
|
|
$rnum = $row['record_num'];
|
|
$selected = "";
|
|
if ($selected_schedule_num == $rnum) $selected = " selected='selected'";
|
|
echo(" <option value='$rnum'$selected>$sname</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'></td>
|
|
<td align='center' valign='top'><a href='#' class='btn btn--primary btn--xsmall' onClick='document.transactions.submit();'><span><?php displayLanguageText('TEXT-VIEW'); ?></span></a></td>
|
|
</tr>
|
|
</table>
|
|
<input type='hidden' name='action' value='user-account-paypal'>
|
|
</form>
|
|
<?php
|
|
|
|
|
|
//
|
|
// List all requested records
|
|
//
|
|
$columnHeaders = array("User ID","TRX Date","TRX Type","Note","Amount","Method");
|
|
$query = "SELECT u.userid,substring(transaction_datetime,1,10) as trx_date,transaction_type,note,transaction_amount,transaction_fee,schedule_num,order_num," .
|
|
"payment_method,payment_reference,ua.user_num,people_num,people_type,ua.record_num,deleted,deleted_datetime,deleted_by_user_num,delete_reason " .
|
|
"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 " .
|
|
$uwhere . $twhere . $swhere .
|
|
"ORDER BY transaction_datetime,record_num";
|
|
$transactions = db_query($query);
|
|
|
|
$mode = 'lookup';
|
|
include "user_account.paypal.list.php";
|
|
|
|
?>
|
|
<div id='paypal-fee-dialog' title="<?php displayLanguageText('TEXT-PAYPAL-FEE') ?>">
|
|
<p class='ltext'><label for='trx-id'><b><?php displayLanguageText('TEXT-TRX-ID') ?>:</b></label><br>
|
|
<input type='text' name='trx-id' id='trx-id' size='25'></p>
|
|
<p class='ltext'><label for='trx-amt'><b><?php displayLanguageText('TEXT-TRANSACTION-AMOUNT') ?>:</b></label><br>
|
|
<input type='text' name='trx-amt' id='trx-amt' size='15'></p>
|
|
<p class='ltext'><label for='trx-fee'><b><?php displayLanguageText('TEXT-PAYPAL-FEE') ?>:</b></label><br>
|
|
<input type='text' name='trx-fee' id='trx-fee' size='15'></p>
|
|
<p><button id='save-fee' class='btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-UPDATE') ?> </button>
|
|
<button id='close-dialog' class='btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button></p>
|
|
<input type='hidden' name='record_num' id='record_num'>
|
|
<span id='rnum'></span>
|
|
</div>
|
|
<?php
|
|
endTemplate();
|
|
?>
|