Files
Testing/user_plan_history.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

209 lines
3.1 KiB
PHP

<?php
header("Location: /premium.php");exit;
$page = "user_plan_history";
include "header.php";
// ENSURE SUBSCRIPTION IS ENABLED FOR THIS USER
if($user->level_info['level_subscriber_allow'] == 0) {
semods::redirect('home.php');
}
$p = semods::getpost('p', 1);
$s = semods::getpost('s', 'dd');
$search = semods::getpost('search');
$success_message = semods::getpost('success_message');
$error_message = semods::getpost('error_message');
// ENSURE POINTS ARE ENABLED FOR THIS USER (?)
// if($user->level_info['level_userpoints_allow'] == 0) { header("Location: user_home.php"); exit(); }
// SET ENTRY SORT-BY VARIABLES FOR HEADING LINKS
$d = "d"; // Date
$st = "st"; // Status
$a = "a"; // Amount
// SET SORT VARIABLE FOR DATABASE QUERY
if($s == "d") {
$sort = "userpaymenthistory_date";
$d = "dd";
} elseif($s == "dd") {
$sort = "userpaymenthistory_date DESC";
$d = "d";
} elseif($s == "st") {
$sort = "userpaymenthistory_state";
$st = "std";
} elseif($s == "std") {
$sort = "userpaymenthistory_state DESC";
$st = "st";
} elseif($s == "a") {
$sort = "userpaymenthistory_amount";
$a = "ad";
} elseif($s == "ad") {
$sort = "userpaymenthistory_amount DESC";
$a = "a";
} else {
$sort = "userpaymenthistory_id DESC";
$d = "d";
}
$sql_head = "SELECT * ";
$sql_body = "FROM se_semods_userpaymenthistory";
$filters = array();
$filters[] = "userpaymenthistory_user_id = {$user->user_info['user_id']}";
$search != "" ? $filters[] = "userpaymenthistory_text LIKE '%$search%'" :0;
!empty($filters) ? $sql_body .= " WHERE " . implode( " AND ", $filters):0;
$items_per_page = 10;
// GET TOTAL ITEMS
$sql_count = "SELECT COUNT(*) " . $sql_body;
$total_items = semods::db_query_count( $sql_count );
// MAKE PAGES
$page_vars = make_page($total_items, $items_per_page, $p);
$sql = $sql_head . $sql_body . " ORDER BY $sort LIMIT {$page_vars[0]}, $items_per_page";
$rows = $database->database_query( $sql );
while($row = $database->database_fetch_assoc($rows) ) {
$items[] = array(
'transaction_date' => $row['userpaymenthistory_date'],
'transaction_desc' => $row['userpaymenthistory_text'],
'transaction_status' => $payment_states[$row['userpaymenthistory_state']],
'transaction_amount' => $row['userpaymenthistory_amount']
);
SE_Language::_preload( $payment_states[$row['userpaymenthistory_state']] );
}
// ASSIGN VARIABLES AND SHOW VIEW ENTRIES PAGE
$smarty->assign('success_message', $success_message);
$smarty->assign('error_message', $error_message);
$smarty->assign('s', $s);
$smarty->assign('d', $d);
$smarty->assign('st', $st);
$smarty->assign('a', $a);
$smarty->assign('search', $search);
$smarty->assign('total_items', $total_items);
$smarty->assign('items', $items);
$smarty->assign('p', $page_vars[1]);
$smarty->assign('maxpage', $page_vars[2]);
$smarty->assign('p_start', $page_vars[0]+1);
$smarty->assign('p_end', $page_vars[0]+count($items));
include "footer.php";
?>