-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrans.php
More file actions
102 lines (91 loc) · 3.52 KB
/
trans.php
File metadata and controls
102 lines (91 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
session_start();
include "dbcon.php";
if(!isset($_SESSION['user_id'])){
header("Location: register.php");
exit();
}
$userID = $_SESSION['user_id'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Transactions</title>
<style>
body{margin:0;font-family: Arial, sans-serif;background:#d1ecec;}
.topbar{background:#8cc9c9;padding:15px 20px;display:flex;justify-content:space-between;align-items:center;}
.logo{font-size:18px;font-weight:bold;line-height:16px;}
.logo span{display:block;}
.profile-icon{font-size:28px;text-decoration:none;}
.main{padding:40px 20px 120px 20px;text-align:center;}
.title{font-size:50px;margin-bottom:30px;color:#35524a;font-family: monolisa;}
.trans-box{width:100%;max-width:250px;margin:0 auto;background:#7fb5b5;padding:20px;border-radius:15px;color:#0f3f3f;}
.trans-header{font-size:18px;margin-bottom:10px;text-align:center;font-weight:bold;}
.divider{width:90%;margin:0 auto 15px auto;height:1px;background:#35524a;}
.trans-item{background:#9acccc;padding:10px;border-radius:10px;margin-bottom:10px;text-align:left;}
.trans-date{font-size:12px;opacity:0.8;}
.footer{position:fixed;bottom:0;left:0;width:100%;background:#8cc9c9;padding:15px 0;display:flex;justify-content:space-around;align-items:center;z-index:999;}
.footer a{text-decoration:none;text-align:center;color:#0f3f3f;font-size:12px;}
.nav-icon{display:block;font-size:28px;margin-bottom:2px;}
.footer a.active{font-weight:bold;color:#1e3b36;}
.footer a:hover{opacity:0.7;}
.plus{color:green;font-weight:bold;}
.minus{color:red;font-weight:bold;}
</style>
</head>
<body>
<div class="topbar">
<div class="logo"><span>Trash</span><span>to</span><span>Kash</span></div>
<a href="user.php" class="profile-icon">👤</a>
</div>
<div class="main">
<div class="title">TrashToKash</div>
<div class="trans-box" id="transBox">
<div class="trans-header">Transaction History</div>
<div class="divider"></div>
<p>Loading...</p>
</div>
</div>
<div class="footer">
<a href="home.php" ><span class="nav-icon">⌂</span>Home</a>
<a href="trans.php" class="active"><span class="nav-icon">⎙</span>Transactions</a>
<a href="qr.php"><span class="nav-icon">⛶</span>QR code</a>
</div>
<script>
// Fetch transactions every 5 seconds
function refreshTransactions(){
fetch('trans_fetch.php')
.then(res=>res.json())
.then(data=>{
const box = document.getElementById('transBox');
if(!data.success) return;
if(data.transactions.length === 0){
box.innerHTML = '<div class="trans-header">Transaction History</div><div class="divider"></div><p>No transactions yet</p>';
} else {
let html = `<div class="trans-header">Transaction History</div><div class="divider"></div>`;
data.transactions.forEach(t=>{
// NEW CLEAN FORMAT
let sign = t.points > 0 ? "+" : "-";
let absVal = Math.abs(t.points);
let colorClass = t.points > 0 ? "plus" : "minus";
html += `
<div class="trans-item">
<div class="trans-date">${t.created_at}</div>
<div>
<span class="${colorClass}">${sign}${absVal}</span>
(${t.description})
</div>
</div>
`;
});
box.innerHTML = html;
}
});
}
refreshTransactions();
setInterval(refreshTransactions,5000);
</script>
</body>
</html>