Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require_once("../../mainconfig.php");
- $page_type = "deposit";
- if (isset($_SESSION['user'])) {
- $sess_username = $_SESSION['user']['username'];
- $check_user = mysqli_query($db, "SELECT * FROM users WHERE username = '$sess_username'");
- $data_user = mysqli_fetch_assoc($check_user);
- if (mysqli_num_rows($check_user) == 0) {
- header("Location: ".$cfg_baseurl."logout.php");
- } else if ($data_user['status'] == "Suspended") {
- header("Location: ".$cfg_baseurl."logout.php");
- }
- include("../../lib/header.php");
- $msg_type = "nothing";
- $check_depo = mysqli_query($db, "SELECT * FROM history_topup WHERE username = '$sess_username' AND status = 'NO'");
- if (isset($_POST['submit'])) {
- $dip = random_number(3);
- $post_method = mysqli_real_escape_string($db, trim($_POST['method']));
- $post_quantity = mysqli_real_escape_string($db, trim($_POST['quantity']));
- $no_pengirim = mysqli_real_escape_string($db, trim($_POST['nopengirim']));
- $nohp=$no_pengirim;
- $min_depo = "10000";
- if(!preg_match('/[^+0-9]/',trim($nohp))){
- // cek apakah no hp karakter 1-3 adalah +62
- if(substr(trim($nohp), 0, 3)=='62'){
- $no_pengirim_pulsa = trim($nohp);
- }
- // cek apakah no hp karakter 1 adalah 0
- else if(substr(trim($nohp), 0, 1)=='0'){
- $no_pengirim_pulsa = '62'.substr(trim($nohp), 1);
- }
- }
- $check_data_history = mysqli_query($db, "SELECT * FROM history_topup WHERE jumlah_transfer = '$post_quantity' AND no_pengirim = '$no_pengirim_pulsa' AND datetime = '$date $time'");
- if ($post_quantity < $min_depo) {
- $msg_type = "error";
- $msg_content = "<b>Failed:</b> Minimum deposit adalah ".$min_depo.".";
- } else if (mysqli_num_rows($check_depo) == 1) {
- $msg_type = "error";
- $msg_content = "<b>Failed:</b> Anda memiliki deposito Pending, segera lunasi.";
- } else {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://serverh2h.id/order/deposit");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=Apikeymu&nopengirim=$no_pengirim&quantity=$post_quantity&provider=XL");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $chresult = curl_exec($ch);
- // echo $chresult;
- curl_close($ch);
- $json_result = json_decode($chresult, true);
- $kodee=$json_result['code'];
- if($json_result['code']==TRUE){
- $balance_amount=$post_quantity*0.88;
- $insert_topup = mysqli_query($db, "INSERT INTO history_topup (provider, amount, jumlah_transfer, username, no_pengirim, datetime, status, type, kode) VALUES ('XL','$balance_amount','$post_quantity','$sess_username','$no_pengirim_pulsa','$date $time','NO','WEB','$kodee')");
- if ($insert_topup == TRUE) {
- $msg_type = "success";
- $msg_content = "<b>Permintaan Telah Dikirim!</b><br />
- <b>Provider :</b> XL<br />
- <b>Jumlah:</b> ".number_format($post_quantity,0,',','.')."<br />
- <b>Saldo Yang Didapat :</b> $balance_amount
- <hr>
- Silakan transfer biaya sebesar <span style='color: red'><b>Rp. ".number_format($post_quantity,0,',','.')."</b></span> ke Nomor ".$json_result['tujuan']." <br /><br>
- <span style='color: red'>Wajib sesuai dengan Nominal. </span>.";
- } else {
- $msg_type = "error";
- $msg_content = "<b>Failed:</b> System error.";
- }
- }else{
- $msg_type = "error";
- $msg_content = "<b>Failed:</b>".$json_result['error'];
- }
- }
- }
- $check_user = mysqli_query($db, "SELECT * FROM users WHERE username = '$sess_username'");
- $data_user = mysqli_fetch_assoc($check_user);
- if(isset($_POST['delet'])) {
- $post_code = $_POST['kode'];
- $select = mysqli_query($db, "SELECT * FROM history_topup WHERE kode = '$post_code'");
- $datana = mysqli_fetch_assoc($select);
- if(mysqli_num_rows($select) == 0) {
- $msg_type = "error";
- $msg_content = "</span></button><b>Gagal:</b> Data tidak di temukan. ";
- } else if($datana['status'] == "YES") {
- $msg_type = "error";
- $msg_content = "</span></button><b>Gagal:</b> Data tidak bisa di batalkan. ";
- } else {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://serverh2h.id/status/deposit_cancel");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=Apikeymu&code=$post_code&provider=XL");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $chresult = curl_exec($ch);
- //echo $chresult;
- curl_close($ch);
- $json_result = json_decode($chresult, true);
- $update = mysqli_query($db, "UPDATE history_topup set status = 'CANCEL' WHERE kode = '$post_code'");
- if($update == TRUE) {
- $msg_type = "success";
- $msg_content = "</span></button> Berhasil membatalkan!";
- } else {
- $msg_type = "error";
- $msg_content = "</span></button>GAGAL MEMBATALKAN #1";
- }
- }
- }if(isset($_POST['confirm'])) {
- $post_code = $_POST['kode'];
- $select = mysqli_query($db, "SELECT * FROM history_topup WHERE kode = '$post_code'");
- $datana = mysqli_fetch_assoc($select);
- if(mysqli_num_rows($select) == 0) {
- $msg_type = "error";
- $msg_content = "</span></button><b>Gagal:</b> Data tidak di temukan. ";
- } else if($datana['status'] == "YES") {
- $msg_type = "error";
- $msg_content = "</span></button><b>Gagal:</b> Data tidak bisa di ubah. ";
- } else {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://serverh2h.id/status/deposit");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=Apikeymu&code=$post_code&provider=XL");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $chresult = curl_exec($ch);
- //echo $chresult;
- curl_close($ch);
- $json_result = json_decode($chresult, true);
- if($json_result['jumlah']==TRUE){
- $amount=$datana['amount'];
- $username=$datana['username'];
- $update = mysqli_query($db, "UPDATE history_topup set status = 'YES' WHERE kode = '$post_code'");
- $update = mysqli_query($db, "UPDATE users set balance = balance+$amount WHERE username = '$username'");
- $update_order = mysqli_query($db, "INSERT INTO balance_history (username, action, quantity, msg, date, time) VALUES ('username', 'Penambahan Saldo', '$amount', 'Deposit Otomatis anda Via Pulsa XL telah berhasil ditambahkan oleh Server Sebesar : $amount', '$date', '$time')");
- if($update == TRUE) {
- $msg_type = "success";
- $msg_content = "</span></button> Berhasil Saldo Telah Di Tambahkan!";
- } else {
- $msg_type = "error";
- $msg_content = "</span></button>GAGAL KONFIRMASI #1";
- }
- }else{
- $msg_type = "error";
- $msg_content = "</span></button>".$json_result['error'];
- }
- }
- }
- ?>
- <!-- Script Deposit CURL By Atlantic-Group(DhifoAksa) -->
- <div class="row">
- <div class="col-lg-6">
- <div class="ibox float-e-margins">
- <div class="ibox-title">
- <h5><i class="fa fa-credit-card"></i> Deposit Otomatis</h5>
- </div>
- <div class="ibox-content">
- <?php
- if ($msg_type == "success") {
- ?>
- <div class="alert alert-success" role="alert">
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- <i class="fa fa-check-circle"></i>
- <?php echo $msg_content; ?>
- </div>
- <?php
- } else if ($msg_type == "error") {
- ?>
- <div class="alert alert-danger" role="alert">
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- <i class="fa fa-times-circle"></i>
- <?php echo $msg_content; ?>
- </div>
- <?php
- }
- ?>
- <form class="form-horizontal" role="form" method="POST">
- <div class="form-group">
- <label>Tipe</label>
- <select class="form-control" name="method" id="depomethod">
- <option value="0">Pilih salah satu...</option>
- <option value="XL">XL</option> <!-- ///MASUKIN NOMOR LO -->
- </select>
- </div>
- <div class="form-group">
- <label>Nomer Pengirim</label>
- <input type="number" name="nopengirim" class="form-control" placeholder="081xxx" >
- </div>
- <div id="rates1"></div>
- <input type="hidden" id="rate" value="0">
- <div class="form-group">
- <label>Jumlah Deposit</label>
- <input type="number" name="quantity" class="form-control" placeholder="Jumlah" onkeyup="get_total(this.value).value;">
- </div>
- <input type="hidden" id="rate" value="0">
- <div class="form-group">
- <label>Total Saldo</label>
- <div class="input-group">
- <div class="input-group-prepend">
- <span class="input-group-text">Rp</span>
- </div>
- <input type="number" class="form-control" id="total" value="0" readonly>
- </div>
- </div>
- <button type="submit" class="pull-right btn btn-success btn-bordered waves-effect w-md waves-light" name="submit">Buat Permintaan Deposit</button>
- </form>
- <div class="clearfix"></div>
- </div>
- </div>
- <!-- /.tab-pane -->
- </div>
- <div class="col-lg-6">
- <div class="ibox float-e-margins">
- <div class="ibox-title">
- <h5><i class="fa fa-info-circle"></i> INFORMASI</h5>
- <div class="ibox-tools">
- <a class="collapse-link">
- <i class="fa fa-chevron-up"></i>
- </a>
- <a class="close-link">
- <i class="fa fa-times"></i>
- </a>
- </div>
- </div>
- <div class="ibox-content">
- <ul>
- <li><dt>Tipe</dt></li>
- Pilih Tipe Jenis auto
- <li><dt>Jenis Pembayaran</dt></li>
- Pilih Jenis Pembayaran deposit yang diinginkan
- <li><dt>Jumlah</dt></li>
- Masukan jumlah deposit yang akan diisi
- <li><dt>Klik 'Kirim'</dt></li>
- Setelah data diisi semua, klik 'Kirim'.untuk memproses pengiriman saldo tersebut, Silakan lihat tabel dibawah ini dan lakukan transfer pulsa/bank sesuai nominal yang ditentukan.
- <li><dt>Lihat daftar permintaan deposit anda</dt></li>
- Untuk melihat daftar permintaan deposit telah dikirim klik <a href="<?php echo $cfg_baseurl; ?>deposit/history/">Daftar Deposit</a>
- </dl>
- </div>
- </div>
- </div>
- <div class="col-lg-12">
- <div class="ibox float-e-margins">
- <div class="ibox-title">
- <h5><i class="fa fa-credit-card"></i> Riwayat Deposit</h5>
- </div>
- <div class="ibox-content">
- <form method="get" action="/deposit/history/index.php">
- <div class="row">
- <div class="form-group col-lg-5">
- <label>Filter Status</label>
- <select class="form-control" name="status">
- <option value="">Semua</option>
- <option value="Pending">Pending</option>
- <option value="Success">Success</option>
- <option value="Error">Error</option>
- </select>
- </div>
- <div class="form-group col-lg-5">
- <label>Kata Kunci Cari</label>
- <input type="text" class="form-control" name="search" placeholder="Kata Kunci..." value="">
- </div>
- <div class="form-group col-lg-2">
- <label>Submit</label>
- <button type="submit" class="btn btn-block btn-dark">Filter</button>
- </div>
- </div>
- </form>
- <div class="table-responsive">
- <table class="table table-bordered table-hover">
- <thead>
- <tr>
- <th>Tanggal/Waktu</th>
- <th>Provider</th>
- <th>Nomer Pengirim</th>
- <th>Jumlah</th>
- <th>Saldo didapat</th>
- <th>Status</th>
- <th>Action</th>
- </tr>
- </thead>
- <tbody>
- <?php
- // start paging config
- $query_order = "SELECT * FROM history_topup WHERE username = '$sess_username' ORDER BY id DESC"; // edit
- $records_per_page = 30; // edit
- $starting_position = 0;
- if(isset($_GET["page_no"])) {
- $starting_position = ($_GET["page_no"]-1) * $records_per_page;
- }
- $new_query = $query_order." LIMIT $starting_position, $records_per_page";
- $new_query = mysqli_query($db, $new_query);
- // end paging config
- while ($data_order = mysqli_fetch_assoc($new_query)) {
- if($data_order['status'] == "NO") {
- $statusnya="Waiting";
- $label = "warning";
- } else if($data_order['status'] == "CANCEL") {
- $statusnya="Canceled";
- $label = "danger";
- } else if($data_order['status'] == "YES") {
- $statusnya="Success";
- $label = "success";
- }
- $no_pengirimnya=$data_order['no_pengirim'];
- $no_pengrim_asli=str_replace('62','0',$no_pengirimnya);
- ?>
- <tr>
- <th><?php echo $data_order['datetime']; ?></th>
- <td><?php echo $data_order['provider']; ?></td>
- <td><?php echo $no_pengrim_asli; ?></td>
- <td>Rp <?php echo number_format($data_order['jumlah_transfer'],0,',','.'); ?></td>
- <td>Rp <?php echo number_format($data_order['amount'],0,',','.'); ?></td>
- <td><label class="badge badge-<?php echo $label; ?>"><?php echo $statusnya; ?></label></td>
- <?php if($data_order['status'] == "NO") { ?>
- <td> <form action="" method="POST">
- <input type="hidden" name="kode" value="<?php echo $data_order['kode']; ?>">
- <button type="submit" class="btn btn-danger btn-xs"name="delet"><strong><span class="fa fa-remove"></span> Cancel</strong></button></form>
- <form action="" method="POST">
- <input type="hidden" name="kode" value="<?php echo $data_order['kode']; ?>">
- <button type="submit" class="btn btn-success btn-xs"name="confirm"><strong><span class="fa fa-check"></span> Confirm</strong></button></form>
- </td> <?php } else { ?>
- <td><span class="badge badge-success"><strong>Not Action</strong></span> </td>
- <?php } ?>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- <ul class="pagination">
- <?php
- // start paging link
- $self = $_SERVER['PHP_SELF'];
- $query_order = mysqli_query($db, $query_order);
- $total_no_of_records = mysqli_num_rows($query_order);
- echo "<li class='page-item disabled'><a class='page-link' href='#'>Total: ".$total_no_of_records."</a></li>";
- if($total_no_of_records > 0) {
- $total_no_of_pages = ceil($total_no_of_records/$records_per_page);
- $current_page = 1;
- if(isset($_GET["page_no"])) {
- $current_page = $_GET["page_no"];
- }
- if($current_page != 1) {
- $previous = $current_page-1;
- echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=1'>← First</a></li>";
- echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=".$previous."'>Previous</a></li>";
- }
- for($i=1; $i<=$total_no_of_pages; $i++) {
- if($i==$current_page) {
- echo "<li class='page-item active'><a class='page-link' href='".$self."?page_no=".$i."'>".$i." <span class='sr-only'>(current)</span></a></li>";
- } else {
- echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=".$i."'>".$i."</a></li>";
- }
- }
- if($current_page!=$total_no_of_pages) {
- $next = $current_page+1;
- echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=".$next."'>Next</a></li>";
- echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=".$total_no_of_pages."'>Last →</a></li>";
- }
- }
- // end paging link
- ?>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
- <script type="text/javascript">
- var htmlobjek;
- $(document).ready(function(){
- $("#depomethod").change(function(){
- var depomethod = $("#depomethod").val();
- $.ajax({
- url: '<?php echo $cfg_baseurl; ?>inc/deposit_method.php',
- data: 'depomethod='+depomethod,
- type: 'POST',
- dataType: 'html',
- success: function(msg){
- $("#rates1").html(msg);
- }
- });
- });
- });
- function get_total(quantity) {
- var rate = $("#rate").val();
- var result = eval(quantity)*0.88;
- $('#total').val(result);
- }
- </script>
- <!-- end row -->
- <?php
- include("../../lib/footer.php");
- } else {
- header("Location: ".$cfg_baseurl);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement