view.php 3.74 KB
Newer Older
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
1 2 3 4
<?php

require ('../autoload.php');

Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18
class historyView {
    public static function viewHistory (array $params) {
        echo Header::generateHead('History', 'history');
        Body::outputInBody(
            Header::headerLogin($params['username']).
            Header::headerMenu(Header::HISTORY).
            self::generateHistory($params)
        );
    }

    private static function generateHistory (array $params) {
        $resultHTML = '            
            <div id="label-history-div" class="orange-text text-size-80">
                <label id="label-history" >History</label>
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
19
            </div>
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
         ';
        return $resultHTML.self::generateHistoryItems($params);
    }


    private static function generateHistoryItems (array $params) {
        #Use map function, must read map array php, use for ease of read
        $newArrayData = array_map(array('historyView', 'generateItem'), $params['dataHistoryItem']);

        return join("",$newArrayData);
    }

    private  static  function generateItem (array $data) {
        if ($data['statusReviewed']) {
            return self::generateHistoryItemReviewed($data);
        } else {
            return self::generateHistoryItemNotReviewed($data);
        }
    }
    private static function generateHistoryItemNotReviewed (array $data) {
        $resultHTML = '
            <div class="flex-history-item align-items-flex-start">
                <div class="flex-1">
43
                    <img class="c-border history-image-item" src="'.$data['imgSource'].'">
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
44 45
                </div>
                <div class="flex-2" >
46 47 48
                    <div class="orange-text text-size-40 title-item-history" >'.$data['itemName'].'</div>
                    <div class="text-size-20 gray-text">Jumlah : '.$data['numberOfItem'].'</div>
                    <div class="text-size-20 gray-text">Anda belum memberikan review</div>
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
49 50 51
                </div>
                <div id="right-most-column-history-item">
                    <div class="flex-container align-items-flex-end  add-flex-direction-column ">
52 53
                        <div class="font-weight-bold text-size-20 gray-text">'.$data['date'].'</div>
                        <div class="font-weight-bold text-size-20 gray-text">Nomor Order : #'.$data['orderNumber'].'</div>                    
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
54 55
                    </div>
                    <div class="flex-container add-flex-end-justify ">
56
                        <a href="review?id='.$data['orderNumber'].'" class="c-button light-blue c-round">Review</a>
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
57 58
                    </div>
                </div>
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
59
            </div>
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
60 61 62 63 64 65 66 67 68 69
        ';

        return $resultHTML;
    }


    private static function generateHistoryItemReviewed (array $data) {
        $resultHTML = '
            <div class="flex-history-item align-items-flex-start">
                <div class="flex-1">
70
                    <img class="c-border history-image-item" src="'.$data['imgSource'].'">
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
71 72
                </div>
                <div class="flex-2" >
73 74 75
                    <div class="orange-text text-size-40 title-item-history" >'.$data['itemName'].'</div>
                    <div class="text-size-20 gray-text ">Jumlah : '.$data['numberOfItem'].'</div>
                    <div class="text-size-20 gray-text">Anda sudah memberikan review</div>
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
76 77 78
                </div>
                <div id="right-most-column-history-item">
                    <div class="flex-container align-items-flex-end  add-flex-direction-column ">
79 80
                        <div class="font-weight-bold text-size-20 gray-text">'.$data['date'].'</div>
                        <div class="font-weight-bold text-size-20 gray-text">Nomor Order #'.$data['orderNumber'].'</div>                    
Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
81 82 83 84 85 86 87 88
                    </div>
                </div>
            </div>
        ';

        return $resultHTML;
    }

Wildan Dicky Alnatara's avatar
Wildan Dicky Alnatara committed
89 90

}