<?php
include('session.php');
$postID = $_GET['postID'];
$getUser = mysqli_query($conn,"SELECT * FROM `tb_user` WHERE cuid = '$postID'") or die(mysqli_error());
$gu = mysqli_fetch_array($getUser);
$getBank = mysqli_query($conn,"SELECT * FROM `tb_bank` WHERE userID = '$postID'") or die(mysqli_error());
$gb = mysqli_fetch_array($getBank);
?>
<!DOCTYPE html>

<html
  lang="en"
  class="light-style layout-navbar-fixed layout-menu-fixed"
  dir="ltr"
  data-theme="theme-default"
  data-assets-path="<?php echo $assets; ?>/assets/"
  data-template="vertical-menu-template"
>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
    />

    <title><?php echo $s0['instansi']; ?></title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="resource-type" content="document" />
    <meta http-equiv="content-type" content="text/html; charset=US-ASCII" />
    <meta http-equiv="content-language" content="en-us" />
    <meta name="author" content="CXFTEAMS" />
    <meta name="contact" content="cxfteams.sbs" />
    <meta name="copyright" content="Copyright (c) cxfteams.sbs. All Rights Reserved." />
    <meta name="robots" content="index, nofollow">

    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="<?php echo $urlwebs; ?>/upload/favicon.png" />

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
      rel="stylesheet"
    />

    <!-- Icons -->
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/fonts/fontawesome.css" />
    <link rel="stylesheet" href="<?php echo $urlweb; ?>/assets/vendor/fonts/tabler-icons.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/fonts/flag-icons.css" />

    <!-- Core CSS -->
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/css/rtl/core.css" class="template-customizer-core-css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/css/rtl/theme-default.css" class="template-customizer-theme-css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/css/demo.css" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/node-waves/node-waves.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/typeahead-js/typeahead.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/select2/select2.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/apex-charts/apex-charts.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/datatables-bs5/datatables.bootstrap5.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.css" />
    <link rel="stylesheet" href="<?php echo $assets; ?>/assets/vendor/libs/summernote/dist/summernote-bs4.css"/>

    <!-- Page CSS -->

    <!-- Helpers -->
    <script src="<?php echo $assets; ?>/assets/vendor/js/helpers.js"></script>

    <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
    <!--? Template customizer: To hide customizer set displayCustomizer value false in config.js.  -->
    
    <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
    <script src="<?php echo $assets; ?>/assets/js/config.js"></script>
  </head>

  <body>
    <!-- Layout wrapper -->
    <div class="layout-wrapper layout-content-navbar">
      <div class="layout-container">
        <!-- Menu -->

        <?php include('sidebar.php'); ?>
        <!-- / Menu -->

        <!-- Layout container -->
        <div class="layout-page">
          <!-- Navbar -->

          <nav
            class="layout-navbar container-xxl navbar navbar-expand-xl navbar-detached align-items-center bg-navbar-theme"
            id="layout-navbar"
          >
            <div class="layout-menu-toggle navbar-nav align-items-xl-center me-3 me-xl-0 d-xl-none">
              <a class="nav-item nav-link px-0 me-xl-4" href="javascript:void(0)">
                <i class="ti ti-menu-2 ti-sm"></i>
              </a>
            </div>

            <div class="navbar-nav-right d-flex align-items-center" id="navbar-collapse">
              <?php include('top-menu.php'); ?>
            </div>

            <!-- Search Small Screens -->
            <div class="navbar-search-wrapper search-input-wrapper d-none">
              <input
                type="text"
                class="form-control search-input container-xxl border-0"
                placeholder="Search..."
                aria-label="Search..."
              />
              <i class="ti ti-x ti-sm search-toggler cursor-pointer"></i>
            </div>
          </nav>

          <!-- / Navbar -->

          <!-- Content wrapper -->
          <div class="content-wrapper">
            <!-- Content -->
            <div class="container-xxl flex-grow-1 container-p-y">
              <h4 class="fw-bold py-3 mb-4">
                <span class="text-muted fw-light">Dashboard /</span> Profiles <?php echo $gu['user']; ?>

              </h4>
              <div class="row">
                <div class="col-sm-6">
                  <div class="card">
                    <div class="card-body">
                      <?php
                        error_reporting(0);
                        if (!empty($_GET['notif'])) {
                          if ($_GET['notif'] == 1) {
                            echo '
                              <div class="alert alert-success d-flex align-items-center" role="alert">
                                <span class="alert-icon text-success me-2">
                                  <i class="ti ti-check ti-xs"></i>
                                </span>
                                <span><strong>Well Done!</strong> Profiles Saved!</span>
                              </div>
                            ';
                          }
                          if ($_GET['notif'] == 2) {
                            echo '
                              <div class="alert alert-warning d-flex align-items-center" role="alert">
                                <span class="alert-icon text-warning me-2">
                                  <i class="ti ti-bell ti-xs"></i>
                                </span>
                                <span><strong>Warning!</strong> Max Image Size 2MB!</span>
                              </div>
                            ';
                          }
                          if ($_GET['notif'] == 3) {
                            echo '
                              <div class="alert alert-warning d-flex align-items-center" role="alert">
                                <span class="alert-icon text-warning me-2">
                                  <i class="ti ti-bell ti-xs"></i>
                                </span>
                                <span><strong>Warning!</strong> Only JPG atau PNG!</span>
                              </div>
                            ';
                          }
                        }
                      ?>
                      <form role="form" action="<?php echo $urlweb; ?>/function/edit-member.php" method="post" enctype="multipart/form-data">
                        <div class="card-title" style="font-weight: 700;">Informasi Pribadi</div>
                        <div class="form-group mb-2">
                          <label class="form-label">Username :</label>
                          <input class="form-control" type="text" name="user" value="<?php echo $gu['user']; ?>">
                          <input class="form-control" type="hidden" name="postID" value="<?php echo $gu['cuid']; ?>" readonly>
                        </div>
                        <div class="form-group mb-2">
                          <label class="form-label">Password :</label>
                          <input class="form-control" type="password" name="pass" value="<?php echo $gu['re_pass']; ?>">
                        </div>
                        <div class="form-group mb-2">
                          <label class="form-label">Alamat Email :</label>
                          <input class="form-control" type="text" name="email" value="<?php echo $gu['email']; ?>" placeholder="Alamat Email">
                        </div>
                        <div class="form-group mb-2">
                          <label class="form-label">No. Handphone / Whatsapp :</label>
                          <input class="form-control" type="text" name="no_hp" value="<?php if($u['cuid'] == 1){ echo $gu['no_hp']; } else { echo '08XXXXXXXXXXXX'; } ?>" placeholder="No. Handphone">
                        </div>
                        <div class="card-title" style="font-weight: 700;">Informasi Rekening</div>
                        <div class="form-group mb-2">
                          <label class="form-label">Nama Bank :</label>
                          <select class="form-control input-shadow" style="height: 50px;" name="akun" required>
                            <option value="BANK BCA"<?php if($gb['akun'] == 'BANK BCA') { echo ' selected=selected'; } ?>>BANK BCA</option>
                            <option value="BANK BNI"<?php if($gb['akun'] == 'BANK BNI') { echo ' selected=selected'; } ?>>BANK BNI</option>
                            <option value="BANK TABUNGAN NEGARA"<?php if($gb['akun'] == 'BANK TABUNGAN NEGARA') { echo ' selected=selected'; } ?>>BANK TABUNGAN NEGARA</option>
                            <option value="BANK MANDIRI"<?php if($gb['akun'] == 'BANK MANDIRI') { echo ' selected=selected'; } ?>>BANK MANDIRI</option>
                            <option value="BANK MASPION"<?php if($gb['akun'] == 'BANK MASPION') { echo ' selected=selected'; } ?>>BANK MASPION</option>
                            <option value="BANK SINARMAS"<?php if($gb['akun'] == 'BANK SINARMAS') { echo ' selected=selected'; } ?>>BANK SINARMAS</option>
                            <option value="BANK MAYORA"<?php if($gb['akun'] == 'BANK MAYORA') { echo ' selected=selected'; } ?>>BANK MAYORA</option>
                            <option value="BANK BRI"<?php if($gb['akun'] == 'BANK BRI') { echo ' selected=selected'; } ?>>BANK BRI</option>
                            <option value="BANK BCA SYARIAH"<?php if($gb['akun'] == 'BANK BCA SYARIAH') { echo ' selected=selected'; } ?>>BANK BCA SYARIAH</option>
                            <option value="BANK MUAMALAT INDONESIA"<?php if($gb['akun'] == 'BANK MUAMALAT INDONESIA') { echo ' selected=selected'; } ?>>BANK MUAMALAT INDONESIA</option>
                            <option value="BANK OCBC NISP"<?php if($gb['akun'] == 'BANK OCBC NISP') { echo ' selected=selected'; } ?>>BANK OCBC NISP</option>
                            <option value="BANK UOB"<?php if($gb['akun'] == 'BANK UOB') { echo ' selected=selected'; } ?>>BANK UOB</option>
                            <option value="BANK PERMATA"<?php if($gb['akun'] == 'BANK PERMATA') { echo ' selected=selected'; } ?>>BANK PERMATA</option>
                            <option value="BANK DANAMON"<?php if($gb['akun'] == 'BANK DANAMON') { echo ' selected=selected'; } ?>>BANK DANAMON</option>
                            <option value="BANK BUKOPIN"<?php if($gb['akun'] == 'BANK BUKOPIN') { echo ' selected=selected'; } ?>>BANK BUKOPIN</option>
                            <option value="BANK CIMB NIAGA"<?php if($gb['akun'] == 'BANK') { echo ' selected=selected'; } ?>>BANK CIMB NIAGA</option>
                            <option value="BANK SYARIAH INDONESIA"<?php if($gb['akun'] == 'BANK SYARIAH INDONESIA') { echo ' selected=selected'; } ?>>BANK SYARIAH INDONESIA</option>
                            <option value="BANK ARTHA GRAHA"<?php if($gb['akun'] == 'BANK ARTHA GRAHA') { echo ' selected=selected'; } ?>>BANK ARTHA GRAHA</option>
                            <option value="BANK ARTOS"<?php if($gb['akun'] == 'BANK ARTOS') { echo ' selected=selected'; } ?>>BANK ARTOS</option>
                            <option value="BANK BJB"<?php if($gb['akun'] == 'BANK BJB') { echo ' selected=selected'; } ?>>BANK BJB</option>
                            <option value="BANK BTPN"<?php if($gb['akun'] == 'BANK BTPN') { echo ' selected=selected'; } ?>>BANK BTPN</option>
                            <option value="BANK COMMONWEATLH"<?php if($gb['akun'] == 'BANK COMMONWEATLH') { echo ' selected=selected'; } ?>>BANK COMMONWEATLH</option>
                            <option value="BANK DBS"<?php if($gb['akun'] == 'BANK DBS') { echo ' selected=selected'; } ?>>BANK DBS</option>
                            <option value="BANK DKI"<?php if($gb['akun'] == 'BANK DKI') { echo ' selected=selected'; } ?>>BANK DKI</option>
                            <option value="BANK HSBC"<?php if($gb['akun'] == 'BANK HSBC') { echo ' selected=selected'; } ?>>BANK HSBC</option>
                            <option value="BANK JATIM"<?php if($gb['akun'] == 'BANK JATIM') { echo ' selected=selected'; } ?>>BANK JATIM</option>
                            <option value="BANK MAYBANK"<?php if($gb['akun'] == 'BANK MAYBANK') { echo ' selected=selected'; } ?>>BANK MAYBANK</option>
                            <option value="BANK MEGA"<?php if($gb['akun'] == 'BANK MEGA') { echo ' selected=selected'; } ?>>BANK MEGA</option>
                            <option value="BANK NAGARI"<?php if($gb['akun'] == 'BANK NAGARI') { echo ' selected=selected'; } ?>>BANK NAGARI</option>
                            <option value="OVO"<?php if($gb['akun'] == 'OVO') { echo ' selected=selected'; } ?>>OVO</option>
                            <option value="GOPAY"<?php if($gb['akun'] == 'GOPAY') { echo ' selected=selected'; } ?>>GOPAY</option>
                            <option value="DANA"<?php if($gb['akun'] == 'DANA') { echo ' selected=selected'; } ?>>DANA</option>
                            <option value="LINKAJA"<?php if($gb['akun'] == 'LINKAJA') { echo ' selected=selected'; } ?>>LINKAJA</option>
                            <option value="SAKUKU"<?php if($gb['akun'] == 'SAKUKU') { echo ' selected=selected'; } ?>>SAKUKU</option>
                            <option value="SHOPEEPAY"<?php if($gb['akun'] == 'SHOPEEPAY') { echo ' selected=selected'; } ?>>SHOPEEPAY</option>
                          </select>
                        </div>
                        <div class="form-group mb-2">
                          <label class="form-label">Nama Direkening :</label>
                          <input class="form-control" type="text" name="pemilik" value="<?php echo $gb['pemilik']; ?>">
                        </div>
                        <div class="form-group mb-2">
                          <label class="form-label">No. Rekening :</label>
                          <input class="form-control" type="text" name="no_rek" value="<?php echo $gb['no_rek']; ?>">
                        </div>
                        <button type="submit" name="submit" class="btn btn-primary">Edit Profile</button>
                      </form>
                    </div>
                  </div>
                </div>
                <div class="col-sm-6">
                  <div class="card">
                    <div class="card-body">
                        <?php
                            $hitungDepo = mysqli_query($conn,"SELECT COUNT(*) as totalDepo, SUM(total) as jmlDepo FROM `tb_transaksi` WHERE userID = '$postID' AND jenis = 1 AND status = 1") or die(mysqli_error());
                            $hd = mysqli_fetch_array($hitungDepo);
                            $hitungWede = mysqli_query($conn,"SELECT COUNT(*) as totalWede, SUM(total) as jmlWede FROM `tb_transaksi` WHERE userID = '$postID' AND jenis = 2 AND status = 1") or die(mysqli_error());
                            $hw = mysqli_fetch_array($hitungWede);
                        ?>
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <tbody>
                                    <tr>
                                        <td>Status Member</td>
                                        <td class="text-right" style="text-align: right;">
                                            <?php
                                                if($gu['status'] == 1){
                                                    echo 'Aktif';
                                                }
                                                else if($gu['status'] == 2){
                                                    echo 'Suspended';
                                                }
                                            ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Tanggal Mendaftar</td>
                                        <td class="text-right" style="text-align: right;"><?php echo $gu['join_date']; ?></td>
                                    </tr>
                                    <tr>
                                        <td>Terakhir Login</td>
                                        <td class="text-right" style="text-align: right;"><?php echo $gu['last_login']; ?></td>
                                    </tr>
                                    <tr>
                                        <td>Total Deposit</td>
                                        <td class="text-right" style="text-align: right;"><?php echo $hd['totalDepo']; ?></td>
                                    </tr>
                                    <tr>
                                        <td>Total Deposit (Rp)</td>
                                        <td class="text-right" style="text-align: right;"><?php echo ($hd['jmlDepo']); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Total Withdraw</td>
                                        <td class="text-right" style="text-align: right;"><?php echo $hw['totalWede']; ?></td>
                                    </tr>
                                    <tr>
                                        <td>Total Withdraw (Rp)</td>
                                        <td class="text-right" style="text-align: right;"><?php echo ($hw['jmlWede']); ?></td>
                                    </tr>
                                    <!--<tr>
                                        <td colspan="2">
                                            <a href="<?php echo $urlweb; ?>/function/user-status.php?postID=<?php echo $s1['cuid']; ?>&status=<?php echo $gu['status']; ?>&tipe=1" class="btn <?php if($gu['status'] == 1){ echo 'btn-danger'; } else { echo 'btn-success'; } ?> w-100 btn-block">
                                                <?php if($gu['status'] == 1){ echo 'SUSPEND MEMBER'; } else { echo 'ACTIVATE MEMBER'; } ?>
                                            </a>
                                        </td>-->
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <!-- / Content -->

            <!-- Footer -->
            <footer class="content-footer footer bg-footer-theme">
              <div class="container-xxl">
                <div
                  class="footer-container d-flex align-items-center justify-content-between py-2 flex-md-row flex-column"
                >
                  <div>
                    ©
                    <script>
                      document.write(new Date().getFullYear());
                    </script>
                    , <?php echo $s0['instansi']; ?> All Rights Reserved.
                  </div>
                </div>
              </div>
            </footer>
            <!-- / Footer -->

            <div class="content-backdrop fade"></div>
          </div>
          <!-- Content wrapper -->
        </div>
        <!-- / Layout page -->
      </div>

      <!-- Overlay -->
      <div class="layout-overlay layout-menu-toggle"></div>

      <!-- Drag Target Area To SlideIn Menu On Small Screens -->
      <div class="drag-target"></div>
    </div>
    <!-- / Layout wrapper -->

    <!-- Core JS -->
    <!-- build:js assets/vendor/js/core.js -->
    <script src="<?php echo $assets; ?>/assets/vendor/libs/jquery/jquery.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/popper/popper.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/js/bootstrap.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/node-waves/node-waves.js"></script>

    <script src="<?php echo $assets; ?>/assets/vendor/libs/hammer/hammer.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/i18n/i18n.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/typeahead-js/typeahead.js"></script>

    <script src="<?php echo $assets; ?>/assets/vendor/js/menu.js"></script>
    <!-- endbuild -->

    <!-- Vendors JS -->
    <script src="<?php echo $assets; ?>/assets/vendor/libs/select2/select2.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/apex-charts/apexcharts.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/datatables/jquery.dataTables.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/datatables-bs5/datatables-bootstrap5.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/datatables-responsive/datatables.responsive.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/datatables-buttons/datatables-buttons.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/datatables-buttons/buttons.html5.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/datatables-buttons/buttons.print.js"></script>

    <!-- Main JS -->
    <script src="<?php echo $assets; ?>/assets/js/main.js"></script>
    <script src="<?php echo $assets; ?>/assets/js/forms-selects.js"></script>
    <script src="<?php echo $assets; ?>/assets/vendor/libs/summernote/dist/summernote-bs4.min.js"></script>
    <script>
    $(document).ready(function() {
      //Default data table
      $('#default-datatable').DataTable();
    });
  </script>
  </body>
</html>
