Commit 9bfeb6e1 authored by Erma Safira Nurmasyita's avatar Erma Safira Nurmasyita
Browse files

[ADD] Book_Order submission

parent 007468ec
......@@ -12,6 +12,7 @@ function ratingClick(starValue) {
}
}
document.getElementById("rating-given").value = starValue;
document.getElementById("output").innerHTML = document.getElementById("rating-given").value;
}
function hoverStar(starValue) {
......
......@@ -38,7 +38,7 @@
$form= '<h1>REGISTER</h1>
<form id="registrationform" action="registration/register.php" onsubmit="return submitValidation()" method = "POST">
'. getTable().
'<p id="account_existence"><a href="../login/login_form.php">Already have an account?</a></p>
'<p id="account_existence"><a href="../login">Already have an account?</a></p>
<input id="submit_button" type="submit" value="REGISTER">
</form>
';
......
......@@ -28,8 +28,8 @@
private function fetchOrderDetail() {
$conn = connect_to_mysql();
$sql_query = 'SELECT Judul, Pengarang
FROM (SELECT book_id FROM book_order WHERE Nomor_Order='. $this->order_id .
$sql_query = 'SELECT Judul, Pengarang, Nomor_Order as order_id, book_id
FROM (SELECT Nomor_Order, book_id FROM book_order WHERE Nomor_Order='. $this->order_id .
') as T1 INNER JOIN books ON id=book_id';
$result = $conn->query($sql_query);
......
<?php
include_once ('../database/accessDB.php');
$rating = $_POST['rating-value'];
$comment = $_POST['comment'];
$book_id = $_POST['book-id'];
$order_id = $_POST['order-id'];
$insertsuccess = insertReview($order_id, $rating, $comment);
include('../history');
function insertReview($order_id, $rating, $comment) {
$conn = connect_to_mysql();
$sql_query = 'INSERT INTO review(order_id, komentar, rating)
VALUES ('. $order_id .', "'.$comment.'", '.$rating.')';
$result = $conn->query($sql_query);
$querystatus = setOrderReviewed($conn, $order_id);
$conn->close();
return $querystatus;
}
function setOrderReviewed($conn, $order_id) {
$sql_query = 'UPDATE book_order SET has_reviewed=1 WHERE Nomor_Order='.$order_id;
$result = $conn->query($sql_query);
return $result != NULL;
}
?>
\ No newline at end of file
......@@ -47,6 +47,8 @@
onmouseout="noHoverStar(this.value)" onmouseover="hoverStar(this.value)">
<!-- Rating value submitted via POST Method-->
<input name="rating-value" id="rating-given" type="hidden" value="0">
<input name="order-id" type="hidden" value="0">
<input name="book-id" type="hidden" value="0">
</div>
</div>
</div>
......
......@@ -21,7 +21,7 @@
$str = '<body>
<div class="detail-container add-nunito-font">'.
self::showBookDesc($ordered_book).
self::showReviewForm().
self::showReviewForm($ordered_book['order_id'], $ordered_book['book_id']).
'</div>
</body>';
return $str;
......@@ -37,19 +37,21 @@
<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>';
return $str;
}
private function showReviewForm() {
private function showReviewForm($order_id, $book_id) {
$str = '
<form action="submit_review.php" method="POST">
<form action="review/submit_review.php" method="POST">
<div class="book-detail">
<div class="head-title">Add Rating</div>
<div class="order-select">'.
self::showRatingButton().
self::showRatingButton().
self::showHiddenInputForm($order_id, $book_id).
'</div>
</div>
<div class="book-detail">
......@@ -74,9 +76,7 @@
$str = '
<div class="rating-pict">'.
self::show5Stars().
'<!-- Rating value submitted via POST Method-->
<input name="rating-value" id="rating-given" type="hidden" value="0">
</div>';
'</div>';
return $str;
}
......@@ -91,5 +91,14 @@
}
return $str;
}
private function showHiddenInputForm($order_id, $book_id) {
$str = '
<!-- Values submitted via POST Method-->
<input name="rating-value" id="rating-given" type="hidden" value="0">
<input name="order-id" type="hidden" value="'.$order_id.'">
<input name="book-id" type="hidden" value="'.$book_id.'">';
return $str;
}
}
?>
\ No newline at end of file
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