view.php 4.96 KB
Newer Older
1
2
3
4
5
6
7
8
<?php
    class reviewFormViewer {
        public static function viewReviewForm($params) {
            $ordered_book = $params['ordered_book'];

            echo Header::generateHead($ordered_book['Judul'].' Review', 'review');
            Body::outputInBody(
                Header::headerLogin($params['username']).
9
                Header::headerMenu(Header::HISTORY).
10
11
12
13
14
15
16
17
18
19
20
21
22
                self::showScript().
                self::showBody($ordered_book)
            );
        }

        private function showScript() {
            return '<script type="text/javascript" src="../javascript/review-book.js"></script>';
        }

        private function showBody($ordered_book) {
            $str = '<body>
                        <div class="detail-container add-nunito-font">'.
                            self::showBookDesc($ordered_book).
23
                            self::showReviewForm($ordered_book['order_id'], $ordered_book['book_id']).
24
25
26
27
28
29
30
31
32
33
34
35
36
37
                        '</div>
                    </body>';
            return $str;
        }

        private function showBookDesc($ordered_book) {
            $str = '
                <div class="flex-container book-detail">
                    <div class="flex-1">
                        <div class="book-title orange-text"><b>'.$ordered_book['Judul'].'</b></div>
                        <div class="book-author"><b>'.$ordered_book['Pengarang'].'</b></div>
                    </div>
                    <div class="add-flex-direction-column" id="rightbar-pic" align="center">
                        <div class="flex-1">
38
                            <img id="book-pict" src="'.self::showPicture($ordered_book['book_id']).'">
39
                        </div>
40
                    </div>
41
42
43
                </div>';
            return $str;
        }
44
45
46
47
48
49
50
51

        private function showPicture($input) {
            if (fileProcessing::isExistBookImage($input)) {
                return fileProcessing::getImageBookPathFromRoot($input);
            } else {
                return '/images/books_picture/default.jpg';
            }
        }
52
        
53
        private function showReviewForm($order_id, $book_id) {
54
            $str = '
55
                <form id="book-review" action="review/submit_review.php" onsubmit="return trySubmitSearch()" method="POST">
56
57
58
                    <div class="book-detail">
                        <div class="head-title">Add Rating</div>
                        <div class="order-select">'.
59
60
                            self::showRatingButton().           
                            self::showHiddenInputForm($order_id, $book_id).                 
61
                        '</div>
62
                    </div>
63
64
65
66
                    <div class="book-detail">
                        <div class="head-title">Add Comment</div>
                        <div class="flex-review-tab">
                            <div class="comment-bar">
67
                                <textarea id="comment" class="textarea-comment" name="comment" cols="180" rows="5"></textarea>
68
69
                                <p id="comment-area" class="warning-empty-input red-theme alert-box text-size-20 add-nunito-font c-round">
                                    Input can\'t be empty</p>
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
                            </div>
                        </div>
                    </div>
                    <div class="review-button">
                        <div>
                            <button class="back-button c-button" type="button" onClick="window.history.back()">Back</button>
                            <button class="submit-button c-button light-blue" type="submit">Submit</button>
                        </div>
                    </div>
                </form>';
            return $str;
        }

        private function showRatingButton() {
            $str = '
                <div class="rating-pict">'.
                    self::show5Stars().
87
88
89
                    '<p id="rating-area" class="warning-empty-input red-theme alert-box text-size-20 add-nunito-font c-round">
                    Rating can\'t be empty</p>
                </div>';
90
91
92
93
94
95
96
97
98
99
100
101
102
103
            return $str;
        }

        private function show5Stars() {
            $str = "";
            for ($i=1; $i<=5; $i++) {
                $str = $str .
                        '<input type="image" id="star'.$i.'" class="fivestar-rating" 
                            onclick="ratingClick(this.value); return false;" src="../svgIcon/star.png"
                            value="'.$i.'" onmouseout="noHoverStar(this.value)"
                            onmouseover="hoverStar(this.value)">';
            }
            return $str;
        }
104
105
106
107
108
109
110
111
112

        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;
        }
113
114
    }
?>