<?php 
    include 'session.php';
    include 'style.php';
    include 'navbar.php';

    $status_masakan_mey = 0;
    $status_flabby = 0;
    
    
?>


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body {
    font-family:'Segoe UI', Roboto, Oxygen, Ubuntu,   Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif
}

.coupon {
  border: 5px dotted #bbb;
  width: 90%;
  border-radius: 5px;
  margin: 0 auto;
  max-width: 600px;
}

.container {
  padding: 2px 16px;
  background-color: #f1f1f1;
}

.promo {
  background: #ccc;
  padding: 3px;
}

.expire {
  color: red;
}

/* zebra table */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  border: 1px solid #ddd;
  font-size: 12px;
}

th, td {
  text-align: left;
  padding: 4px;
}


/* label */
.label {
  color: white;
  padding: 5px; 
  font-family: Arial;
  font-size: small;
  line-height:1.75;
}
.success {background-color: #04AA6D;} /* Green */
.info {background-color: #2196F3;} /* Blue */
.warning {background-color: #ff9800;} /* Orange */
.danger {background-color: #f44336;} /* Red */ 
.other {background-color: #e7e7e7; color: black;} /* Gray */ 

/*button */
.btn {
  border: none;
  color: white;
  padding: 14px 100px;
  font-size: 16px;
  cursor: pointer;
  width:100%;
}

.btnflight {
  border: none;
  color: white;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  width:40%;
}

.success {background-color: #04AA6D;} /* Green */
.success:hover {background-color: #46a049;}

* {
  box-sizing: border-box;
}

#myInput {
  background-image: url('/css/searchicon.png');
  background-position: 10px 10px;
  background-repeat: no-repeat;
  width: 100%;
  font-size: 16px;
  padding: 12px 20px 12px 40px;
  border: 1px solid #ddd;
  margin-bottom: 12px;
}

#myTable {
  border-collapse: collapse;
  width: 100%;
  border: 1px solid #ddd;
  font-size: 10px;
}

#myTable th, #myTable td {
  text-align: left;
  padding: 8px;
}

#myTable tr {
  border-bottom: 1px solid #ddd;
}

#myTable tr.header, #myTable tr:hover {
  background-color: #f1f1f1;
}

.watermark {
    position: absolute;
    color: lightgray;
    opacity: 0.25;
    font-size: 3em;
    width: 100%;
    top: 50%; 
 
    right: 30%;   
    text-align: center;
    z-index: 0;
}
hr {
            border-top: 5px solid black; /* atur ketebalan menjadi 2 piksel, garis hitam */
            border-bottom: none; /* menghapus garis bawah */
        }
</style>
</head>

<body>
<?php
    //$order_no = $_POST["order_no"];
    //$ongkir = $_POST["ongkir"];

    $query_sql = "SELECT * FROM order_data 
                WHERE order_datetime IS NOT NULL AND (DATE_FORMAT(order_datetime, '%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d'))";

    $result = mysqli_query($conn, $query_sql);

    while ($row = mysqli_fetch_array($result))
    {
        ?> <hr> <?php
        $order_no = $row['order_no'];
        $nama = $row['order_nama'];
        $alamat = $row['order_alamat'];
        $nowa = $row['order_nowa'];
        $order_total = $row['order_total'];
        /*
        if ($row['jenis_nama']=='Masakan Mey') {
            $status_masakan_mey = 1;
        }

        if ($row['jenis_nama']=='Flabby Patty') {
            $status_flabby = 1;
        }
            */

        ?>
        <div class="coupon">
            <div class="container">
                <?php if ($status_masakan_mey==1) { ?>
                <img src="masakanmey_logo.PNG" alt="Avatar" style="width:40%; float:right;">
                <h3>Masakan Mey Receipt</h3>
                <?php } else if ($status_flabby==1) { ?>
                <img src="flabbypatty.jpeg" alt="Avatar" style="width:25%; float:right;">
                <h3>Flabby Patty Receipt</h3>
                <?php } else { ?>
                <img src="header.PNG" alt="Avatar" style="width:40%; float:right;">
                <h3><font size=6>IniSpikoe</h3>
                <?php } ?>
                
            </div>
        

            <div class="container" style="background-color:white">
                <table>
                <tr>
                    <td><font size=4>No. Nota</td>
                </tr>
                <tr>
                    <td><font size=5><b><?php echo $order_no; ?></td>
                </tr>
                <tr>
                    <td><font size=4>Nama</td>

                </tr>
                <tr>

                    <td><font size=5><b><?php echo $nama; ?></td>
                </tr>
                <tr>
                    <td><font size=4>Alamat</td>
                </tr>
                <tr>
                    <td><font size=6><b><?php echo $alamat; ?></td>
                </tr>
                <tr>
                    <td><font size=4>No WA</td>

                </tr>
                <tr>

                    <td><font size=5><b><?php echo $nowa; ?></td>
                </tr>
                </table>
                <hr>

                <table id="myTable">
                    <tr class="header">
                        <th style="width:40%;"><font size=5>Barang</th>
                        <th style="width:10%;"><font size=5>Jumlah</th>
                    </tr>

                    <?php
                        $total_item = 0;
                        $query_sql_detail = "SELECT
                                            DATE_FORMAT(order_datetime, '%H:%i') AS jam_pesan,
                                        produk_temp.*,
                                        order_data.*,
                                        produk.*
                                        FROM produk_temp 
                                        LEFT JOIN order_data ON order_no = temp_master
                                        LEFT JOIN produk ON produk_id = temp_produk
                                        WHERE order_no = $order_no";
                        $result_detail = mysqli_query($conn, $query_sql_detail);
                        while($mas_detail = mysqli_fetch_array($result_detail)){
                          $total_item = $total_item + $mas_detail['temp_jumlah'];
                        ?>
                            <tr>

                                <td><font size=3><?php echo $mas_detail['produk_nama']?></td>
                                <td><font size=3><?php echo $mas_detail['temp_jumlah']?></td>
                            </tr>
                        <?php
                        
                        }
                    ?>
                    
                            <tr>
                                <td><font size=3><b>Total Item</td>
                                <td><font size=3><b><?php echo $total_item?></td>
                            </tr>
                </table>
                <h3><font size=3>Terima Kasih!</h3>
            </div>
        </div>
        <?php
    }
?>
</body>
</html> 

