<!doctype html>
<html lang="en">
    <head>
    </head>
    <style>
        @media (min-width: 200px) {
            .Profile-container{
                padding:0px 0px;
            } 	
        }
        @media (min-width: 600px) {
            .Profile-container{
                padding:5% 5%;
            } 	
        }
        @media (min-width: 990px) and (max-width: 1799px) {
            .Profile-container{
                padding:0% 10%;
            } 
        }

        @media (min-width: 1800px) {  

            .Profile-container{
                padding:0px 15%;
            } 
        }

        .Profile-name, .Profile-Phone, .Profile-Addresses{

            background-color:#f6f6f6;
            padding:15px;
            margin:20px 0px;
            border:1px solid #e0e0e0;
            position:relative;
            box-sizing: border-box;
            float:inherit;
            font-size:15px;
        }

        .Profile-in-l{
            font-size:15px;
            padding-bottom:10px;
        }

        .Profile-in-r{
            background:#FFFFFF;
            border:1px solid #e0e0e0;
            border-radius: 5px;
        }

        .rp-info{
            padding:20px 0px;
        }

        /*@media (min-width: 200px) {
        .btn-center{
                padding:20px 18%;
        } 	
        }
        @media (min-width: 600px) and (max-width: 990px) {
        .btn-center{
                padding:20px 37%;
        } 	
        }
        @media (min-width: 990px) and (max-width: 1799px) {
        .btn-center{
                padding:20px 42%;
        } 
        }
        
        @media (min-width: 1800px) {  
        
        .btn-center{
                padding:20px 45%;
        } 
        }*/


    </style>
    <body>
        <div class="Profile-container">
            <h1>帳戶資訊</h1>

            <form action="includes/edit_profile.php" method="post">
                <div  role="tabpanel" class="Profile-all col-lg-12 col-md-12 col-sm-12 col-xs-12" id="Profile">
                    <div class="Profile-l col-lg-6 col-md-6 col-sm-6 col-xs-12">

                        <div class="Profile-name col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 form-group">
                                <div class="Profile-in-l col-lg-4 col-md-4 col-sm-12 col-xs-12">
                                    *用戶名稱
                                </div>
                                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                                    <?php echo $_SESSION["username"] ?>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="Profile-l col-lg-6 col-md-6 col-sm-6 col-xs-12">

                        <div class="Profile-name col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 form-group">
                                <div class="Profile-in-l col-lg-4 col-md-4 col-sm-12 col-xs-12">
                                    *電郵地址
                                </div>
                                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                                    <?php echo $_SESSION["email"] ?>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="Profile-l col-lg-6 col-md-6 col-sm-6 col-xs-12">

                        <div class="Profile-name col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 form-group">
                                <div class="Profile-in-l col-lg-4 col-md-4 col-sm-12 col-xs-12">
                                    *電話號碼
                                </div>
                                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                                    <input name="phone" style="background-color:transparent; border:0px" value="<?php echo $_SESSION["phone"] ?>" />
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="Profile-l col-lg-6 col-md-6 col-sm-6 col-xs-12">

                        <div class="Profile-name col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 form-group">
                                <div class="Profile-in-l col-lg-4 col-md-4 col-sm-12 col-xs-12">
                                    *地址
                                </div>
                                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                                    <textarea name="address" style="background-color:transparent; border:0px"><?php echo $_SESSION["address"] ?></textarea>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="Profile-l col-lg-6 col-md-6 col-sm-6 col-xs-12">

                        <div class="Profile-name col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 form-group">
                                <div class="Profile-in-l col-lg-4 col-md-4 col-sm-12 col-xs-12">
                                    *密碼
                                </div>
                                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                                    <a href="includes/resetpassword.php?action=reset">重設密碼</a>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="Profile-l col-lg-6 col-md-6 col-sm-6 col-xs-12">

                        <div class="Profile-name col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 form-group">
                                <div class="Profile-in-l col-lg-4 col-md-4 col-sm-12 col-xs-12">
                                    接收宣傳郵件:
                                </div>
                                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                                    <input type="checkbox" name="subscription" <?php
                                    //ask mailchimp if the user has subscripted
                                    include_once('../mailchimp/mailchimp-rest-api.php');
                                    $mc = new \VPS\MailChimp(MAILCHIMP_API_KEY);
                                    $mc_Email = md5(strtolower($_SESSION['email']));
                                    $mc_result = $mc->get("/lists/" . MAILCHIMP_LIST_ID . "/members/{$mc_Email}");
                                    if ($mc_result['status'] === 'subscribed')
                                        echo 'checked';
                                    ?> >
                                </div>
                            </div>
                        </div>

                    </div>
                    <div class="col-xs-8 col-sm-3 col-sm-offset-7 col-md-2 col-md-offset-9">
                        <input style="width:100%" name="submit" type="submit" value="Save Changes" class="btn btn-success" />
                    </div>
                    <div class="col-xs-4 col-sm-2 col-md-1">
                        <input style="width:100%" value="cancel" class="btn btn-warning" />
                    </div>

                </div>
            </form>

            <div  role="tabpanel" class="Profile-all col-lg-12 col-md-12 col-sm-12 col-xs-12" id="Profile" style="overflow:auto">
                <h1>訂單記錄</h1>
                <table class="table table-hover">
                    <?php
                    if (!empty($_SESSION['username'])) {
                        if (!empty($username)) {

                            $sql = "select * from orders where username='" . mysqlSecurity($conn, $username) . "' and `status` != 'delete' order by record desc";
                            $result = mysqli_query($conn, $sql);
                            if ($result->num_rows > 0) {
                                echo "<tr>
                    <td>訂單日期和時間</td>
                    <td>訂單編號</td>
                    <td>產品名稱</td>
                    <td>付款方式</td>
                    <td>付款狀態</td>
                    <td>送貨狀態	</td>
                    <td>詳情</td>
                    </tr>";
                                while ($row = $result->fetch_assoc()) {
                                    if ($row["status"] == 'bank') {
                                        $status = '銀行轉賬';
                                        $status1 = '準備中';
                                        $status2 = '準備中';
                                    }
                                    if ($row["status"] == 'perpare') {
                                        $status = 'PayPal';
                                        $status1 = '準備中';
                                        $status2 = '準備中';
                                    }
                                    if ($row["status"] == 'doing') {
                                        $status = 'PayPal';
                                        $status1 = '已完成';
                                        $status2 = '準備中';
                                    }
                                    if ($row["status"] == 'bank doing') {
                                        $status = '銀行轉賬';
                                        $status1 = '已完成';
                                        $status2 = '準備中';
                                    }
                                    if ($row["status"] == 'bank done') {
                                        $status = 'PayPal';
                                        $status1 = '已完成';
                                        $status2 = '已有帳單';
                                    }
                                    if ($row["status"] == 'paypal done') {
                                        $status = '銀行轉賬';
                                        $status1 = '已完成';
                                        $status2 = '已有帳單';
                                    }

                                    echo "<tr>
                            <td>" . $row["time"] . "</td>
                            <td>" . $row["paypal id"] . "</td>
                            <td>" . $row["bought_items"] . "</td>
                            <td>" . $status . "</td>
                            <td>" . $status1 . "</td>
                            <td>" . $status2 . "</td>
                            <td><a href='e-shop.php?page=13&order=" . $row["record"] . "'>[Details]</a></td>
                        </tr>";
                                }
                            } else {
                                echo '
            <div style=" padding-bottom:20%;text-align:center; padding-top:20px">
            <h2>你沒有任何購買記錄。</h2>

            <a href="#products" role="tab" data-toggle="tab" class="btn btn-color-primary" style="float:none !important;">去購物!</a>

            </div>';
                            }
                        }
                    }
                    ?>
                </table>
            </div>      


        </div>
    </body>
</html>