<?php

$pageName  = "Transaction";
include($_SERVER['DOCUMENT_ROOT'] . "/account/layout/header.php");

// Ofofonobs Developer WhatsAPP +2348114313795


// Bank Script Developer - Use For Educational Purpose Only

// Other scripts Available

// if (!$_SESSION['acct_email']) {
//     header("location:../login.php");
//     die;
// }


?>





<!-- --------------- -->


<style>
    .av-s-atv {
        border: 3px solid #FCD535;
        border-radius: 50%;
    }
</style>

<div class="col-md-9 px-0 anuphan border-left-lg pb-lg-5 expand-page-content bottom-padding" style="position: relative; z-index: 1;">

    <div class="secondary-bg-3 p-3 px-4 d-flex align-items-center">
        <div class="flex-fill">
            <h2 class="anuphan-3 mt-2">My Orders</h2>
        </div>
    </div>

    <div class="container px-lg-5">
        <div class="row">
            <div class="col-md-6">
                <div class="my-border mt-4 p-1 add-radius-sm white-bg order-tab-bg">
                    <div class="row">
                        <div class="col-6 text-center pr-1">
                            <button class="btn-grey xsmall py-1 tab anuphan-2" id="panelOne" onclick="openPanel(this)">
                                Deposit Orders
                            </button>
                        </div>
                        <div class="col-6 text-center pl-1">
                            <button class="btn-grey polygon-btn-blank xsmall py-1 tab anuphan-2" onclick="openPanel(this)" id="panelTwo">
                                Withdrawal Orders
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- ==== -->
        <div class="mt-5 panel panelOne">

            <!-- == -->
        <?php

            $sql2 = "SELECT * FROM transactions LEFT JOIN crypto_currency ON transactions.crypto_id = crypto_currency.id WHERE trans_type='Crypto Deposit' AND acct_email =:acct_email AND NOT (trans_type='Crypto Withdrawal') ORDER BY trans_id DESC";
         
            $wire = $conn->prepare($sql2);
            $wire->execute([
                'acct_email' => $_SESSION['acct_email']
            ]);



            $sn = 1;

            while ($result = $wire->fetch(PDO::FETCH_ASSOC)) {


               


            ?>


            <div class="row mb-4 border-bottom pb-4">
                 <div class="col-md-3 col-4">
                    <small class="xsmall2 anuphan-2 grey-color-3">REF</small>
                    <p class="m-0 xsmall">#<?php echo $result['refrence_id']; ?></p>
                </div>
                
                <div class="col-md-3 col-4">
                    <small class="xsmall2 bold-text grey-color">Value</small>
                    <p class="m-0 xsmall2 bold-text"><?= $page['currency'] ?><?= $result['amount'] ?> <?= $result['short_name'] ?></p>
                </div>
                 <div class="col-md-3 col-4">
                    <small class="xsmall2 bold-text grey-color">Crypto Name</small>
                    <p class="m-0 xsmall2"><?= $result['crypto_name'] ?></p>
                </div>
                <div class="col-md-3 col-4">
                    <small class="xsmall2 bold-text grey-color">Date</small>
                    <p class="m-0 xsmall2"><?= $result['created_at'] ?></p>
                </div>
                <!--<div class="col-md-3 mt-3 text-right">-->
                <!--    <a href="./order.php?id=<?php echo $result['refrence_id']; ?>">-->
                <!--        <button class="btn-grey fit-content py-2 anuphan-2 px-4">View</button>-->
                <!--    </a>-->
                <!--</div>-->
            </div>
            
             <?php

            }



            ?>
                
                
                
                
                
                
                
                
                <?php
            $sql2 = "SELECT * FROM transactions WHERE acct_email =:acct_email AND NOT (trans_type='Crypto Withdrawal')";
            $stmt = $conn->prepare($sql2);
            $stmt->execute([
                'acct_email' => $_SESSION['acct_email']
            ]);

            $rowCheck = $stmt->fetch(PDO::FETCH_ASSOC);

            if ($stmt->rowCount() == 0) {
            ?>
            
            
            
            
             <div class="py-5 text-center">
                <div>
                    <svg height="90px" width="90px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" fill="none" class="mirror css-z12rr9">
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M64 8H26v80h58V28H64V8zM36 37h38v4H36v-4zm0 9h38v4H36v-4zm38 9H36v4h38v-4zm-8 12l4 4-4 4-4-4 4-4zM50 18l-3 3 3 3 3-3-3-3z" fill="url(#not-found-data_svg__paint0_linear_22059_32288)"></path>
                        <path opacity="0.3" d="M86 50l3-3 3 3-3 3-3-3zM47 21l3-3 3 3-3 3-3-3zM84 28H64V8l20 20z" fill="#929AA5"></path>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M4.172 73.171l14.5-14.5 5.656 5.658-14.5 14.5-5.656-5.657z" fill="url(#not-found-data_svg__paint1_linear_22059_32288)"></path>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M51 48c0-8.837-7.163-16-16-16s-16 7.163-16 16 7.163 16 16 16 16-7.163 16-16zm4 0c0-11.046-8.954-20-20-20s-20 8.954-20 20 8.954 20 20 20 20-8.954 20-20z" fill="url(#not-found-data_svg__paint2_linear_22059_32288)"></path>
                        <defs>
                            <linearGradient id="not-found-data_svg__paint0_linear_22059_32288" x1="55" y1="8" x2="55" y2="88" gradientUnits="userSpaceOnUse">
                                <stop stop-color="#929AA5" stop-opacity="0.1"></stop>
                                <stop offset="1" stop-color="#929AA5" stop-opacity="0.25"></stop>
                            </linearGradient>
                            <linearGradient id="not-found-data_svg__paint1_linear_22059_32288" x1="4.172" y1="68.75" x2="24.328" y2="68.75" gradientUnits="userSpaceOnUse">
                                <stop stop-color="#929AA5"></stop>
                                <stop offset="1" stop-color="#76808F"></stop>
                            </linearGradient>
                            <linearGradient id="not-found-data_svg__paint2_linear_22059_32288" x1="15" y1="48" x2="55" y2="48" gradientUnits="userSpaceOnUse">
                                <stop stop-color="#929AA5"></stop>
                                <stop offset="1" stop-color="#76808F"></stop>
                            </linearGradient>
                        </defs>
                    </svg>
                </div>
                <p class="xsmall mt-2 grey-color-3">
                    No record.
                </p>
            </div>
            
            
            
              <?php
            } else {

            ?>


            <?php
            }
            ?>


        </div>


        <!-- ==== -->
        <div class="mt-5 panel panelTwo" style="display: none;">

           <?php

            $sql2 = "SELECT * FROM transactions LEFT JOIN crypto_currency ON transactions.crypto_id = crypto_currency.id WHERE trans_type='Crypto Withdrawal' AND acct_email =:acct_email AND NOT (trans_type='Crypto Deposit') ORDER BY trans_id DESC";
         
            $wire = $conn->prepare($sql2);
            $wire->execute([
                'acct_email' => $_SESSION['acct_email']
            ]);



            $sn = 1;

            while ($result = $wire->fetch(PDO::FETCH_ASSOC)) {


               


            ?>


            <div class="row mb-4 border-bottom pb-4">
                <div class="col-md-3 col-4">
                    <small class="xsmall2 anuphan-2 grey-color-3">REF</small>
                    <p class="m-0 xsmall">#<?php echo $result['refrence_id']; ?></p>
                </div>
                
                <div class="col-md-3 col-4">
                    <small class="xsmall2 bold-text grey-color">Value</small>
                    <p class="m-0 xsmall2 bold-text"><?= $page['currency'] ?><?= $result['amount'] ?> <?= $result['short_name'] ?></p>
                </div>
                 <div class="col-md-3 col-4">
                    <small class="xsmall2 bold-text grey-color">Crypto Name</small>
                    <p class="m-0 xsmall2"><?= $result['crypto_name'] ?></p>
                </div>
                <div class="col-md-3 col-4">
                    <small class="xsmall2 bold-text grey-color">Date</small>
                    <p class="m-0 xsmall2"><?= $result['created_at'] ?></p>
                </div>
                <!--<div class="col-md-3 mt-3 text-right">-->
                <!--    <a href="./order.php?id=<?php echo $result['refrence_id']; ?>">-->
                <!--        <button class="btn-grey fit-content py-2 anuphan-2 px-4">View</button>-->
                <!--    </a>-->
                <!--</div>-->
            </div>
            
             <?php

            }



            ?>
                
                
                
                
                
                
                
                
                <?php
            $sql2 = "SELECT * FROM transactions WHERE acct_email =:acct_email  AND NOT (trans_type='Crypto Deposit')";
            $stmt9 = $conn->prepare($sql2);
            $stmt9->execute([
                'acct_email' => $_SESSION['acct_email']
            ]);

            $rowCheck2 = $stmt9->fetch(PDO::FETCH_ASSOC);

            if ($stmt9->rowCount() == 0) {
            ?>
            
            
            
            
             <div class="py-5 text-center">
                <div>
                    <svg height="90px" width="90px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" fill="none" class="mirror css-z12rr9">
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M64 8H26v80h58V28H64V8zM36 37h38v4H36v-4zm0 9h38v4H36v-4zm38 9H36v4h38v-4zm-8 12l4 4-4 4-4-4 4-4zM50 18l-3 3 3 3 3-3-3-3z" fill="url(#not-found-data_svg__paint0_linear_22059_32288)"></path>
                        <path opacity="0.3" d="M86 50l3-3 3 3-3 3-3-3zM47 21l3-3 3 3-3 3-3-3zM84 28H64V8l20 20z" fill="#929AA5"></path>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M4.172 73.171l14.5-14.5 5.656 5.658-14.5 14.5-5.656-5.657z" fill="url(#not-found-data_svg__paint1_linear_22059_32288)"></path>
                        <path fill-rule="evenodd" clip-rule="evenodd" d="M51 48c0-8.837-7.163-16-16-16s-16 7.163-16 16 7.163 16 16 16 16-7.163 16-16zm4 0c0-11.046-8.954-20-20-20s-20 8.954-20 20 8.954 20 20 20 20-8.954 20-20z" fill="url(#not-found-data_svg__paint2_linear_22059_32288)"></path>
                        <defs>
                            <linearGradient id="not-found-data_svg__paint0_linear_22059_32288" x1="55" y1="8" x2="55" y2="88" gradientUnits="userSpaceOnUse">
                                <stop stop-color="#929AA5" stop-opacity="0.1"></stop>
                                <stop offset="1" stop-color="#929AA5" stop-opacity="0.25"></stop>
                            </linearGradient>
                            <linearGradient id="not-found-data_svg__paint1_linear_22059_32288" x1="4.172" y1="68.75" x2="24.328" y2="68.75" gradientUnits="userSpaceOnUse">
                                <stop stop-color="#929AA5"></stop>
                                <stop offset="1" stop-color="#76808F"></stop>
                            </linearGradient>
                            <linearGradient id="not-found-data_svg__paint2_linear_22059_32288" x1="15" y1="48" x2="55" y2="48" gradientUnits="userSpaceOnUse">
                                <stop stop-color="#929AA5"></stop>
                                <stop offset="1" stop-color="#76808F"></stop>
                            </linearGradient>
                        </defs>
                    </svg>
                </div>
                <p class="xsmall mt-2 grey-color-3">
                    No record.
                </p>
            </div>
            
            
            
              <?php
            } else {

            ?>


            <?php
            }
            ?>

            <!-- == -->


        </div>
    </div>

</div>





<!-- jS -->
<script>
    const openPanel = (e) => {
        $('.tab').addClass('polygon-btn-blank');
        $('.panel').each(function() {
            $(this).hide()
        })
        $('.' + e.id).fadeIn(200)
        $(e).removeClass('polygon-btn-blank')
    }
</script>




<?php
include($_SERVER['DOCUMENT_ROOT'] . "/account/layout/footer2.php");

?>