<?php
ob_start();
include('../include/db_conx.php');
isset($_SESSION['admin_login']);
if (!isset($_SESSION['admin_login'])) {
    header("location: auth-login.php");
    exit();
} else {
    include('../include/admin_head.php');

    $updateBtc = $_GET['updateBtc'];
    if ($updateBtc == 'true') {
        $msg = ' Details Successfully Changed';
        $link = 'details_skrill.php';
        swal_success($msg, $link);
    }

?>



    <body>

        <!-- <body data-layout="horizontal"> -->

        <!-- Begin page -->
        <div id="layout-wrapper">

            <?php include('../include/admin_header.php'); ?>

            <!-- ========== Left Sidebar Start ========== -->

            <!-- Left Sidebar End -->
            <?php include('../include/admin_sidebar.php'); ?>



            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="main-content">

                <div class="page-content">
                    <div class="container-fluid">

                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                    <h4 class="mb-sm-0 font-size-18">Skrill Details </h4>

                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="javascript: void(0);">Admin</a></li>
                                            <li class="breadcrumb-item active">Skrill Details</li>
                                        </ol>
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- end page title -->



                        <div class="row">
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-sm order-2 order-sm-1">

                                                <div class="flex-grow-1">
                                                    <div>
                                                        <h5 class="font-size-16 mb-1">Skrill Details</h5>
                                                        <p class="text-muted font-size-13">Admin Skrill Details</p>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-auto order-1 order-sm-2">
                                            <div class="d-flex align-items-start justify-content-end gap-2">
                                                <a href='index.php'>
                                                    <button type="button" class="btn btn-primary"><i class="me-1"></i> <i class="fas fa-chevron-left "></i> Return to Home </button>
                                                </a>

                                            </div>
                                        </div>
                                    </div>

                                    <ul class="nav nav-tabs-custom card-header-tabs border-top mt-4" id="pills-tab" role="tablist">
                                        <li class="nav-item">
                                            <a class="nav-link px-3 active" data-bs-toggle="tab" href="#overview" role="tab">Skrill Details</a>
                                        </li>

                                    </ul>
                                </div>
                                <!-- end card body -->
                            </div>
                            <!-- end card -->
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->

                    <?php
                    $sql_details = 'SELECT * FROM pay_details WHERE id =  3';
                    $query_details = $db_conx->query($sql_details);
                    $row_PD = mysqli_fetch_assoc($query_details);
                    $details1 = $row_PD['details1'];
                    $details2 = $row_PD['details2'];
                    $details3 = $row_PD['details3'];
                    $details4 = $row_PD['details4'];
                    $details5 = $row_PD['details5'];
                    $details6 = $row_PD['details6'];
                    $PD_status = $row_PD['status'];
                    $PD_image = $row_PD['image'];



                    ?>

                    <div class="card">
                        <div class="card-header">
                            <h4 class="card-title"> Current Skrill Details </h4>
                            <hr />
                            <p class="card-title-desc"> Current Bank Status: <?php

                                                                                if ($PD_status == 1) {
                                                                                    echo '<button type="button" class="btn btn-success btn-sm">Activated</button>';
                                                                                } else {
                                                                                    echo '<button type="button" class="btn btn-danger btn-sm">Deactivated</button>';
                                                                                }
                                                                                ?></p>
                            <p class="card-title-desc"> Skrill Name: <?php echo $details1; ?></p>
                            <p class="card-title-desc"> Skrill wallet: <?php echo $details2; ?></p>

                        </div>
                        <div class="card-body p-4">

                            <div class="row">
                                <form method="POST" autocomplete="off">
                                    <div class="col-lg-6 d-block m-auto">




                                        <div class="mb-3">
                                            <label for="example-search-input" class="form-label">Enter New Wallet Name</label>
                                            <input class="form-control" type="text" placeholder="100" min='1' name="new_name_wallet" value='<?php echo $details1 ?>' required>
                                        </div>
                                        <div class="mb-3">
                                            <label for="example-search-input" class="form-label">Enter New Skrill Wallet</label>
                                            <input class="form-control" type="text" placeholder="100" min='1' name="new_wallet" value='<?php echo $details2 ?>' required>
                                        </div>

                                        <div class="mb-3">
                                            <label for="inputState">Status</label>
                                            <select id="inputState" name='new_status' class="form-control">
                                                <option selected value='1'>Activate</option>
                                                <option value='0'> Deactivate</option>
                                            </select>
                                        </div>

                                        <button type="submit" class="btn btn-primary" name="submit_btc">Click Here to Update </button>


                                    </div>
                                </form>
                                <br />
                                <h4> Skrill image </h4>

                                <hr>
                                <br />
                                <style>
                                    img {
                                        max-width: 100%;
                                    }

                                    .pay_img {
                                        width: 100px;
                                        display: block;
                                        margin: 10px auto;
                                    }
                                </style>

                                <div class='pay_img'>
                                    <img src="../pay_image/<?= $PD_image ?>" class="rounded mx-auto d-block" alt="...">

                                </div>


                                <form method="POST" autocomplete="off" enctype="multipart/form-data">
                                    <div class="col-lg-6 d-block m-auto">




                                        <div class="mb-3">
                                            <label for="example-search-input" class="form-label">Enter New Wallet Name</label>
                                            <input type="file" class="form-control" id="customFileLang" name="file" accept="image/*" required>
                                        </div>


                                        <button type="submit" class="btn btn-primary" name="upload_cert2">Click Here to Update </button>


                                    </div>
                                </form>

                                <br />


                                <?php


                                if (isset($_POST['upload_cert2'])) {


                                    // collecting the passport uploaded 
                                    $files = $_FILES['file'];

                                    // this code is for the file 
                                    $fileName = $files['name'];
                                    $fileTmpName = $files['tmp_name'];
                                    $fileSize = $files['size'];
                                    $fileError = $files['error'];
                                    $fileType = $files['type'];
                                    $account_no = 'Skrill';





                                    $fileExt = explode('.', $fileName);
                                    $fileActualExt = strtolower(end($fileExt)); //the end get the last peice of data in an array 

                                    //creating an array of the information we want to allow 
                                    $allowed = array('jpg', 'jpeg', 'png', 'pdf');

                                    if (in_array(
                                        $fileActualExt,
                                        $allowed
                                    )) {
                                        if ($fileError === 0) {
                                            if ($fileSize < 2000000000) {
                                                // main upload file code 
                                                // we have to rename it so that it will not have same name for different images
                                                $fileNameNew =  $account_no . "." . $fileActualExt;
                                                $fileDestination = '../pay_image/' . $fileNameNew;
                                                //main upload code
                                                move_uploaded_file($fileTmpName, $fileDestination);
                                            }
                                        }
                                    } //end if for in_array


                                    // now we need to update the database 
                                    $sql_update2 = "UPDATE pay_details SET image = '$fileNameNew' WHERE id = '3';  ";
                                    $query_update2 = $db_conx->query($sql_update2);

                                    header('location:details_skrill.php?updateBtc=true');
                                }


                                if (isset($_POST['submit_btc'])) {
                                    $new_name_wallet = $db_conx->real_escape_string($_POST['new_name_wallet']);
                                    $new_wallet = $db_conx->real_escape_string($_POST['new_wallet']);
                                    $new_status = $db_conx->real_escape_string($_POST['new_status']);



                                    $sql_btc = "UPDATE pay_details SET details1 = '$new_name_wallet',details2 = '$new_wallet',status = '$new_status' WHERE id  = 3 ";

                                    $query_btc = $db_conx->query($sql_btc);


                                    if ($query_btc) {
                                        header('location:details_skrill.php?updateBtc=true');
                                    } else {
                                        echo 'An error has occurred please contact admin';
                                    }
                                }

                                ?>


                            </div>
                            <!-- end row -->
                        </div>


                    </div>



                </div> <!-- container-fluid -->
            </div>
            <!-- End Page-content -->


            <?php include('../include/admin_footer.php'); ?>
        </div>
        <!-- end main content-->

        </div>
        <!-- END layout-wrapper -->




        <!-- Right bar overlay-->
        <div class="rightbar-overlay"></div>

        <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
        <script src="assets/libs/metismenu/metisMenu.min.js"></script>
        <script src="assets/libs/simplebar/simplebar.min.js"></script>
        <script src="assets/libs/node-waves/waves.min.js"></script>
        <script src="assets/libs/feather-icons/feather.min.js"></script>
        <!-- pace js -->
        <script src="assets/libs/pace-js/pace.min.js"></script>

        <!-- flatpickr js -->
        <script src="assets/libs/flatpickr/flatpickr.min.js"></script>

        <!-- Required datatable js -->
        <script src="assets/libs/datatables.net/js/jquery.dataTables.min.js"></script>
        <script src="assets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"></script>

        <!-- Responsive examples -->
        <script src="assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
        <script src="assets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script>

        <!-- init js -->
        <script src="assets/js/pages/invoices-list.init.js"></script>

        <script src="assets/js/app.js"></script>
    </body>

    </html>

<?php  }
ob_end_flush();

?>