Commit 4fedb5bc authored by Erma Safira Nurmasyita's avatar Erma Safira Nurmasyita
Browse files

[FIX] Switch page Search->Detail & Review->History

parent 5c75c95f
......@@ -3,17 +3,16 @@
require ('view_modal.php');
//check login state
//if (isLogin()) {
// $user_token = getTokenLogin();
// $user_id = getUserInfo(getUserIDbyToken($user_token))
$user_id = 1;
if (isLogin()) {
$user_token = getTokenLogin();
$user = getUserInfo(getUserIDbyToken($user_token));
$book_id = $_GET['book_id'];
$quantity = $_GET['qty'];
//$orderstatus = createNewOrder($book_id, $user_id, $quantity);
$order_id = 100;
$order_id = createNewOrder($book_id, $user['ID'], $quantity);
//$order_id = 100; //dummy
showOrderModal($order_id);
///}
}
function createNewOrder($book_id, $user_id, $quantity) {
$conn = connect_to_mysql();
......@@ -24,12 +23,17 @@
. $book_id . '", "' . $user_id . '")';
$result = $conn->query($sql_query);
$sql_query = 'SELECT * FROM files WHERE id = SCOPE_IDENTITY()';
$result = $conn->query($sql_query);
$order_id = $result->fetch_assoc();
if ($result != NULL) {
$sql_query = 'SELECT @@IDENTITY';
$result = $conn->query($sql_query);
$order = $result->fetch_assoc();
$order_id = $order['Nomor_Order'];
} else {
$order_id = NULL;
}
$conn->close();
return $order_id['Nomor_Order'];
return $order_id;
} else {
return NULL;
}
......
......@@ -12,7 +12,6 @@ function ratingClick(starValue) {
}
}
document.getElementById("rating-given").value = starValue;
document.getElementById("output").innerHTML = document.getElementById("rating-given").value;
}
function hoverStar(starValue) {
......
......@@ -6,18 +6,18 @@
$user_token = getTokenLogin();
$user = getUserInfo(getUserIDbyToken($user_token));
//if (isset($_GET['id'])) {
//$order_id = $_GET['id'];
$order_id = 301; //dummy
if (isset($_GET['id'])) {
$order_id = $_GET['id'];
//$order_id = 301; //dummy
if (reviewController::validateOrderHistory($order_id, $user['ID'])) {
$review = new reviewController($order_id, $user['username']);
$review->showReviewForm();
} else {
include ('../404.html');
}
//} else {
// include ('../404.html');
//}
} else {
include ('../404.html');
}
} else {
$login = '../login';
header('Location: '.$login);
......
......@@ -7,7 +7,7 @@
$order_id = $_POST['order-id'];
$insertsuccess = insertReview($order_id, $rating, $comment);
include('../history');
header("Location: ../history");
function insertReview($order_id, $rating, $comment) {
$conn = connect_to_mysql();
......
......@@ -37,7 +37,6 @@
<div class="add-flex-direction-column" id="rightbar-pic" align="center">
<div class="flex-1">
<img id="book-pict" src="../images/books_picture/4.jpg">
<p id="output"></p>
</div>
</div>
</div>';
......
Markdown is supported
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