Skip to content
Snippets Groups Projects
Commit 172a0b18 authored by Aldrich Valentino Halim's avatar Aldrich Valentino Halim
Browse files

added GET variable for user

parent 154f75e2
1 merge request!42Projekers - 13515051 - Girvandi Ilyas
...@@ -30,14 +30,15 @@ if($isDriver) { ...@@ -30,14 +30,15 @@ if($isDriver) {
<img class='user-image' src='../img/" . $image . "'/> <img class='user-image' src='../img/" . $image . "'/>
<div class='transaction-info'><div class='transaction-date'>" . $row['date'] . " </div> <div class='transaction-info'><div class='transaction-date'>" . $row['date'] . " </div>
<div class='user-name'>" . $username . "</div> <div class='user-name'>" . $username . "</div>
<div class='transaction-city'>" . $row['pickup'] . "=>" . $row['destination'] . "</div> <div class='transaction-city'>" . $row['pickup'] . " to " . $row['destination'] . "</div>
<div class='transaction-rating'>gave " . $row['rating'] . " star(s) for this order</div> <div class='transaction-rating'>gave " . $row['rating'] . " star(s) for this order</div>
<div class='transaction-comment'>and left comment <br />" . $row['comment'] . " </div></div> <div class='transaction-comment'>and left comment:<blockquote>\"" . $row['comment'] . "\"</blockquote></div></div>
<div class='hide-button'><button id='transaction-" . $i . "' onclick='hide(" . $i . ")'>HIDE</button></div> <div class='hide-button'><button id='transaction-" . $i . "' onclick='hide(" . $i . ")'>HIDE</button></div>
</div>"; </div>";
$i++; $i++;
} }
} }
header('Content-Type: text/xml');
echo $asDriverCompletedTransaction; echo $asDriverCompletedTransaction;
} else { } else {
$asUserCompletedTransaction = ""; $asUserCompletedTransaction = "";
...@@ -59,12 +60,13 @@ if($isDriver) { ...@@ -59,12 +60,13 @@ if($isDriver) {
<div class='user-name'>" . $fetched['name'] . "</div> <div class='user-name'>" . $fetched['name'] . "</div>
<div class='transaction-city'>" . $row['pickup'] . " to " . $row['destination'] . "</div> <div class='transaction-city'>" . $row['pickup'] . " to " . $row['destination'] . "</div>
<div class='transaction-rating'>you rated: " . $row['rating'] . "</div> <div class='transaction-rating'>you rated: " . $row['rating'] . "</div>
<div class='transaction-comment'>and left comment: <br />" . $row['comment'] . " </div></div> <div class='transaction-comment'>and left comment:<blockquote>\"" . $row['comment'] . "\"</blockquote></div></div>
<div class='hide-button'><button id='transaction-" . $i . "' onclick='hide(" . $i . ")'>HIDE</button></div> <div class='hide-button'><button id='transaction-" . $i . "' onclick='hide(" . $i . ")'>HIDE</button></div>
</div>"; </div>";
$i++; $i++;
} }
} }
header('Content-Type: text/xml');
echo $asUserCompletedTransaction; echo $asUserCompletedTransaction;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
box-sizing: border-box; box-sizing: border-box;
} }
.transaction-info { .transaction-info {
width: 60%; width: 65%;
display: inline-block; display: inline-block;
font-size: initial; font-size: initial;
vertical-align: top; vertical-align: top;
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
margin: 5px 0; margin: 5px 0;
} }
.hide-button { .hide-button {
width: 20%; width: 15%;
text-align: right; text-align: right;
display: inline-block; display: inline-block;
font-size: initial; font-size: initial;
......
function getAllTransaction(isDriver){ function getAllTransaction(isDriver){
//TODO: minta id dari session!! var id = sessionid;
var id = 1;
var xmlhttp = new XMLHttpRequest(); var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () { xmlhttp.onreadystatechange = function () {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById('driver-info').innerHTML = xmlhttp.responseText; document.getElementById('driver-info').innerHTML = xmlhttp.responseText;
//console.log(result.getElementById('transaction-id').innerHTML);
} }
}; };
xmlhttp.open('GET', '../controller/transactionController.php?id=' + id + '&driver=' + isDriver,true); xmlhttp.open('GET', '../controller/transactionController.php?id=' + id + '&driver=' + isDriver,true);
......
function getUserProfile(){ function getUserProfile(){
var id = sessionid;
var xmlhttp = new XMLHttpRequest(); var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () { xmlhttp.onreadystatechange = function () {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
...@@ -9,7 +10,7 @@ function getUserProfile(){ ...@@ -9,7 +10,7 @@ function getUserProfile(){
var phone = result.getElementsByTagName('phone')[0].childNodes[0].nodeValue; var phone = result.getElementsByTagName('phone')[0].childNodes[0].nodeValue;
var image =result.getElementsByTagName('image')[0].childNodes[0].nodeValue; var image =result.getElementsByTagName('image')[0].childNodes[0].nodeValue;
document.getElementById('username').innerHTML = 'Hi, ' + username + '!'; document.getElementById('username').innerHTML = 'Hello, ' + name + '!';
document.getElementById('profile-username').innerHTML = '@' + username; document.getElementById('profile-username').innerHTML = '@' + username;
document.getElementById('name').innerHTML = name; document.getElementById('name').innerHTML = name;
document.getElementById('email').innerHTML = email; document.getElementById('email').innerHTML = email;
...@@ -17,10 +18,7 @@ function getUserProfile(){ ...@@ -17,10 +18,7 @@ function getUserProfile(){
document.getElementById('user-image').style.backgroundImage = 'url(../img/' + image + ')'; document.getElementById('user-image').style.backgroundImage = 'url(../img/' + image + ')';
} }
}; };
//var userid = 1; xmlhttp.open('GET', '../controller/profile.php?id=' + id, true);
xmlhttp.open('GET', '../controller/profile.php?id=1', true);
xmlhttp.send(); xmlhttp.send();
} }
<?php
session_start();
$_SESSION['id'] = 1;
$_SESSION['name'] = 'Pikachu';
?>
<html> <html>
<head> <head>
<title>User Dashboard</title> <title>User Dashboard</title>
<link href="../css/primary.css" type="text/css" rel="stylesheet" /> <link href="../css/primary.css" type="text/css" rel="stylesheet" />
<link href="../css/dashboard.css" type="text/css" rel="stylesheet" /> <link href="../css/dashboard.css" type="text/css" rel="stylesheet" />
<link href="../css/history.css" type="text/css" rel="stylesheet" /> <link href="../css/history.css" type="text/css" rel="stylesheet" />
<script>
//send session id to JS files
var sessionid = "<?php echo $_GET['id']; ?>";
</script>
<script src="../js/dashboard.js"></script> <script src="../js/dashboard.js"></script>
<script src="../js/profile.js"></script> <script src="../js/profile.js"></script>
<script src="../js/history.js"></script> <script src="../js/history.js"></script>
</head> </head>
<body> <body onpageshow="getUserProfile()">
<div class="container"> <div class="container">
<div class="header"> <div class="header">
<div class="logo"><img src="../img/logo.png" /></div> <div class="logo"><img src="../img/logo.png" /></div>
...@@ -19,7 +29,7 @@ ...@@ -19,7 +29,7 @@
</div> </div>
<div class="menu"> <div class="menu">
<button class="submenu" id="order" onclick="order_clicked()">ORDER</button> <button class="submenu" id="order" onclick="order_clicked()">ORDER</button>
<button class="submenu" id="history" onclick="history_clicked();">HISTORY</button> <button class="submenu" id="history" onclick="history_clicked(); getAllTransaction(1)">HISTORY</button>
<button class="submenu selected" id="profile" onclick="getUserProfile(); profile_clicked();">PROFILE</button> <button class="submenu selected" id="profile" onclick="getUserProfile(); profile_clicked();">PROFILE</button>
</div> </div>
...@@ -65,9 +75,6 @@ ...@@ -65,9 +75,6 @@
</ul> </ul>
</div> </div>
</section> </section>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
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