Commit 4386a627 authored by arung-agamani's avatar arung-agamani
Browse files

Waktu fixed

parent 4d4a8e16
......@@ -24,8 +24,7 @@ echo createHeader();
window.location = `/coklat.php?id=${id}`;
}
function addTableTransactionItem(_nama, _banyak, _harga, _waktu, _alamat) {
console.log('anjay')
function addTableTransactionItem(_nama, _banyak, _harga, _waktu, _alamat, _id) {
var row = document.createElement('tr');
var nama = document.createElement('td');
var banyak = document.createElement('td')
......@@ -33,13 +32,13 @@ echo createHeader();
var tanggal = document.createElement('td')
var jam = document.createElement('td')
var alamat = document.createElement('td')
console.log('waow')
var tempWaktu = new Date(_waktu + " UTC");
var timestamp = _waktu.split(' ');
nama.innerText = _nama;
nama.innerHTML = `<a href="coklat.php?id=${_id}">${_nama}</a>`;
banyak.innerText = _banyak;
harga.innerText = parseInt(_banyak) * parseInt(_harga);
tanggal.innerText = timestamp[0];
jam.innerText = timestamp[1];
tanggal.innerText = `${tempWaktu.getDate()}/${tempWaktu.getMonth() + 1}/${tempWaktu.getFullYear()}`;
jam.innerText = `${tempWaktu.getHours()}:${tempWaktu.getMinutes()}:${tempWaktu.getSeconds()}`;
alamat.innerText = _alamat;
row.appendChild(nama);
row.appendChild(banyak);
......@@ -57,7 +56,7 @@ echo createHeader();
var resArr = JSON.parse(xhr.responseText);
for (var i = 0; i < resArr.length; i++) {
var res = resArr[i]
addTableTransactionItem(res[0], res[1], res[2], res[3], res[4]);
addTableTransactionItem(res[0], res[1], res[2], res[3], res[4], res[5]);
}
} else {
alert('Error on fetching transaction history');
......
......@@ -295,7 +295,7 @@ function getUserTransactions(string $username)
{
$conn = connectToDbName("willywangky");
if ($conn) {
$sql = "select nama, amount, harga, transactionTime, address from transaction, coklat where username='{$username}' and transaction.coklatId=coklat.id;";
$sql = "select nama, amount, harga, transactionTime, address, coklatId from transaction, coklat where username='{$username}' and transaction.coklatId=coklat.id order by transactionTime desc;";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$data = mysqli_fetch_all($result);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment