<?php ob_start();
include("security.php"); ?>
<?php require_once('../setup.php'); ?>
<!DOCTYPE html>
<html lang="en">

  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>
      <?= $main_capital_name; ?>
    </title>
    <!-- plugins:css -->
    <link rel="stylesheet" href="vendors/feather/feather.css">
    <link rel="stylesheet" href="vendors/ti-icons/css/themify-icons.css">
    <link rel="stylesheet" href="vendors/css/vendor.bundle.base.css">
    <!-- endinject -->
    <!-- Plugin css for this page -->
    <link rel="stylesheet"
      href="vendors/datatables.net-bs4/dataTables.bootstrap4.css">
    <link rel="stylesheet" href="vendors/ti-icons/css/themify-icons.css">
    <link rel="stylesheet" type="text/css" href="js/select.dataTables.min.css">
    <link rel="stylesheet" href="vendors/mdi/css/materialdesignicons.min.css">
    <!-- End plugin css for this page -->
    <!-- inject:css -->
    <link rel="stylesheet" href="css/vertical-layout-light/style.css">
    <!-- endinject -->
    <link rel="shortcut icon" href="../assets/images/logo.png" />
  </head>

  <body>
    <div class="container-scroller">
      <!-- partial:partials/_navbar.html -->
      <?php include('topbar.php'); ?>
      <!-- partial -->
      <div class="container-fluid page-body-wrapper">
        <!-- partial:partials/_sidebar.html -->
        <?php include('nav.php'); ?>
        <!-- partial -->
        <div class="main-panel">
          <div class="content-wrapper">
            <div class="row">
              <div class="col-md-6 grid-margin stretch-card">
                <div class="card">
                  <div class="card-body">
                    <h4 class="card-title"><i class="mdi mdi-bitcoin menu-icon"></i> Deposit Via Bitcoin</h4>
                    <p class="card-description">
                      In order to credit your account via Bitcoin, kindly follow the instructions below.
                    </p>
                    <?php

                    use PHPMailer\PHPMailer\PHPMailer;

                    if (isset($_POST['deposit'])) {
                      require_once("conn.php");

                      $d_amount = $_POST['amount'];
                      $d_crypto_type = $_POST['crypto_type'];
                      $d_status = 'Pending';
                      $newdate = date('d-m-Y H:i');
                      $transaction_id = SHA1(rand(0, 999999));

                      //Send Debit Alert
                      require 'PHPMailer/src/Exception.php';

                      /* The main PHPMailer class. */
                      require 'PHPMailer/src/PHPMailer.php';

                      /* SMTP class, needed if you want to use SMTP. */
                      require 'PHPMailer/src/SMTP.php';

                      $date = date('Y');

                      /* Create a new PHPMailer object. */
                      $mail2 = new PHPMailer();

                      /* Set the mail sender. */
                      $mail2->setFrom($main_email_support, $main_name);

                      /* Add a recipient. */
                      $mail2->addAddress($dbemail);

                      /* Set the subject. */
                      $mail2->Subject = 'Deposit Initiated';

                      /* Set the mail message body. */
                      $mail2->isHTML(TRUE);
                      $mail2->Body = '<html>
                        <head>
                            <meta http-equiv="Content-Type" content="text/html;charset=charset=utf-8" />
                            <title>' . $main_name . '</title>
                            </head>
                            <body>
                              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tbody>
                                  <tr>
                                    <td valign="middle" align="center" style="background-color:#333; border-bottom:3px solid #7b59d0;"><h1 style="color:#fff;"><span style="color:#7b59d0; font-weight:bolder;">' . $main_name . '</span></h1></td>
                                  </tr>
                                  <tr>
                                    <td style="background-color:#fff; padding:10px;" align="justify" width="100">
                                      <p>Dear ' . $new_name . ',</p>
                                      <p>We wish to inform you that a Deposit through '.$d_crypto_type.' was initiated on your account.</p>
                                      <p>The details of this transaction are shown below:</p>
                                      <p><u><b>Transaction Notification</b></u></p>
                                      <table border="0">
                                        <tr>
                                          <td>Deposit To</td>
                                          <td>******' . substr($dbaccount_number, -4) . '</td>
                                        </tr>
                                        <tr>
                                          <td>Deposit Type</td>
                                          <td>'.$d_crypto_type.'</td>
                                        </tr>
                                        <tr>
                                          <td>Description</td>
                                          <td>FUNDS DEPOSIT</td>
                                        </tr>
                                        <tr>
                                          <td>Amount </td>
                                          <td>'.$dbcurrency.'' . number_format($d_amount, 2) . '</td>
                                        </tr>
                                        <tr>
                                          <td>Value Date</td>
                                          <td>' . $newdate . '</td>
                                        </tr>
                                      </table>
                                      <p>The privacy and security of your Bank Account details is important to us.</p>
                                      <p>Thank you for choosing ' . $main_name . ' Bank</p>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td valign="middle" align="center" style="background-color:#333; border-top:3px solid #7b59d0; padding:10px; color:#fff;">© <span style="color: #7b59d0;">' . $main_name . '</span> ' . $date . '.  All Rights Reserved</td>
                                  </tr>
                                </tbody>
                              </table>
                            </body>
                        </html>';
                      /* Finally send the mail. */
                      if ($mail2->send()) {
                        $sql = "INSERT INTO transactions (user_id, amount, account_number, account_name, bank, remark, transaction_id, tag, date, type) VALUES ('$dbid', '$d_amount', '$dbaccount_number', '$dbfirst_name', '$d_crypto_type', 'Deposit Via Bitcoin', '$transaction_id', 'others', '$newdate', 'Credit')";
                        if ($dbconfig->query($sql) === true) {
                          header("Refresh: 5; url=transaction");
                          echo '<div align="center" class=" alert alert-success"><b>Deposit was successfully initiated.</b><br>Your account would be credited as soon as the deposit has been confirmed.</div>';
                        }
                      }
                    }
                    ?>
                    <form method="POST" action="">
                      <hr>
                      <div class="modal-body">
                        <p><i class="text-info">
                            <?php echo '<b>Transaction ID</b> - ' . substr(SHA1(rand(0, 999999)), 0, 15); ?>
                          </i></p>
                        <p class="text-center">
                          To make deposit via bitcoin, kindly enter the amount to be deposited into the input
                          box below.
                          <input type="hidden" class="form-control" name="i"
                            value="5ec22fe48ee2956d73a217ac" required>
                          <input type="number" class="form-control" name="amount"
                            placeholder="Enter Amount Here..." required>
                          <input type="hidden" class="form-control" name="crypto_type"
                            value="Bitcoin" required>
                          To proceed, kindly send the exact amount of Crypto you entered above to
                          the <b>Wallet Address</b> below or scan the <b>QR Code</b>. Your balance
                          would be credited automatically once deposit is detected on below address.
                          <br>
                          <b class="text-success">Bitcoin Wallet Address</b>
                          <br>
                          <img src="images/qr.png" width="150">
                        <div
                          style="border: 1px dashed #444; padding-top: 3px; padding-bottom: 3px; padding-left: 20px; padding-right: 20px; border-radius: 5px; text-align: center;">
                          <i>bc1qa97vant5a7wqj6zzc2sk0xwdgcd5ztz69jec4a</i></div>
                        </p>
                        <p class="text-center">
                          Copy & Paste this address to your wallet. After sending to the above
                          address click 'Confirm Payment' below to send us a mail.
                        </p>
                      </div>
                      <div class="modal-footer">
                        <button class="btn btn-primary btn-sm" type="submit" name="deposit">Confirm Payment</button>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <!-- content-wrapper ends -->
          <!-- partial:partials/_footer.html -->
          <footer class="footer">
            <?php
          include('footer.php');
          ?>
          </footer>
          <!-- partial -->
        </div>
        <!-- main-panel ends -->
      </div>
      <!-- page-body-wrapper ends -->
    </div>
    <!-- container-scroller -->

    <!-- plugins:js -->
    <script src="vendors/js/vendor.bundle.base.js"></script>
    <!-- endinject -->
    <!-- Plugin js for this page -->
    <script src="vendors/chart.js/Chart.min.js"></script>
    <script src="vendors/datatables.net/jquery.dataTables.js"></script>
    <script src="vendors/datatables.net-bs4/dataTables.bootstrap4.js"></script>
    <script src="js/dataTables.select.min.js"></script>

    <!-- End plugin js for this page -->
    <!-- inject:js -->
    <script src="js/off-canvas.js"></script>
    <script src="js/hoverable-collapse.js"></script>
    <script src="js/template.js"></script>
    <script src="js/settings.js"></script>
    <script src="js/todolist.js"></script>
    <!-- endinject -->
    <!-- Custom js for this page-->
    <script src="js/dashboard.js"></script>
    <script src="js/Chart.roundedBarCharts.js"></script>
    <!-- End custom js for this page-->
    <?php include('../chat.php'); ?>
  </body>

</html>
