Viewing File: /home/rareljzw/public_html/admin/edit-deposit.php

<?php




$pageName  = "Edit Deposit Transactions";
include($_SERVER['DOCUMENT_ROOT']."/admin/layout/header.php");

$id = $_GET['id'];
$sql = "SELECT * FROM wallet d LEFT JOIN users u ON d.username = u.username  WHERE refrence_id =:id";
$data = $conn->prepare($sql);
$data->execute([
        'id'=>$id
]);

$result = $data->fetch(PDO::FETCH_ASSOC);

$sql = "SELECT d.*, c.payment_name FROM wallet d INNER JOIN payment c ON d.payment_id = c.payment_id WHERE refrence_id='$id'";
$stmt = $conn->prepare($sql);
$stmt->execute();

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

$email = $result['acct_email'];



if($row['wallet_status'] == '0'){
    $tran_status = 'Processing';
}else if($row['wallet_status'] == '1'){
    $tran_status = 'Approved';
}else if($row['wallet_status']== '3'){
    $tran_status = 'Declined';
}else if($row['wallet_status']== '2') {
    $tran_status = 'On Hold';
}


if(isset($_POST['accept'])){
    $status_value = 1;
    $amount_balance = $row['amount'] + $result['balance'];
    $username = $row['username'];

    $refrence_id = $row['refrence_id'];
    $sql = "UPDATE wallet SET wallet_status=:wallet_status WHERE refrence_id=:id";
    $stmt = $conn->prepare($sql);
    $stmt->execute([
        'wallet_status' =>$status_value,
        'id'=>$id
    ]);

    if(true) {
        $sql = "UPDATE users SET balance=:balance WHERE username=:username";
        $stmt = $conn->prepare($sql);
        $stmt->execute([
            'balance' => $amount_balance,
            'username' => $username
        ]);

        if (true) { 
            $amount = $row['amount'];
            $payment_name = $row['payment_name'];
            // $APP_NAME = $pageTitle;
            
            $tran_status = "Approved";
            // $refrence_id = $row['refrence_id'];
            // $message = $sendMail->depositMsg($amount,$amount_balance, $payment_name, $APP_NAME,$tran_status,$refrence_id);
            // $subject = "[DEPOSIT APPROVED] - $APP_NAME";
            // $email_message->send_mail($email, $message, $subject);
            // $subject = "[DEPOSIT APPROVED] - $APP_NAME";
            // $email_message->send_mail(WEB_EMAIL, $message, $subject);

            if (true) {
                toast_alert('success', 'Deposit Approve Successfully', 'Approved');

            } else {
                toast_alert('error', 'Sorry Something Went Wrong');
            }
        }
    }
}


if(isset($_POST['decline'])){
    $status_value = 3;
    $refrence_id = $row['refrence_id'];
    $sql = "UPDATE wallet SET wallet_status=:wallet_status WHERE refrence_id=:id";
    $stmt = $conn->prepare($sql);
    $stmt->execute([
        'wallet_status' =>$status_value,
        'id'=>$id
    ]);


        if (true) { 
            $amount = $row['amount'];
            $payment_name = $row['payment_name'];
           // $APP_NAME = $pageTitle;
            
            // $tran_status = "Declined";
            // $refrence_id = $row['refrence_id'];
            // $message = $sendMail->depositMsg($amount,$amount_balance, $payment_name, $APP_NAME,$tran_status,$refrence_id);
            // $subject = "[DEPOSIT APPROVED] - $APP_NAME";
            // $email_message->send_mail($email, $message, $subject);
            // $subject = "[DEPOSIT APPROVED] - $APP_NAME";
            // $email_message->send_mail(WEB_EMAIL, $message, $subject);

        if (true) {
            toast_alert('success', 'Deposit Decline Successfully', 'Decline');

        } else {
            toast_alert('error', 'Sorry Something Went Wrong');
        }
    }
}

if(isset($_POST['hold'])){
        $status_value = 2;
    $refrence_id = $row['refrence_id'];
    $sql = "UPDATE wallet SET wallet_status=:wallet_status WHERE refrence_id=:id";
    $stmt = $conn->prepare($sql);
    $stmt->execute([
        'wallet_status' =>$status_value,
        'id'=>$id
    ]);


        if (true) { 
            $amount = $row['amount'];
            $payment_name = $row['payment_name'];
            // $APP_NAME = $pageTitle;
            
           // $tran_status = "Hold";
            // $refrence_id = $row['refrence_id'];
            // $message = $sendMail->depositMsg($amount,$amount_balance, $payment_name, $APP_NAME,$tran_status,$refrence_id);
            // $subject = "[DEPOSIT APPROVED] - $APP_NAME";
            // $email_message->send_mail($email, $message, $subject);
            // $subject = "[DEPOSIT APPROVED] - $APP_NAME";
            // $email_message->send_mail(WEB_EMAIL, $message, $subject);


        if (true) {
            toast_alert('success', 'Deposied on Hold Successfully', 'Hold');
            // header("location:./dashboard.php");

        } else {
            toast_alert('error', 'Sorry Something Went Wrong');
        }
    }
}



?>



<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Edit Deposit Transactions 
        </h1>
        <ol class="breadcrumb">
            <li><a href="./dashboard"><i class="fa fa-dashboard"></i> Dashboard</a></li>
        </ol>
    </section>



    <!-- Main content -->
    <section class="content">

        <!-- SELECT2 EXAMPLE -->
        <div class="box box-default">
            <form method="POST">
                <div class="box-header with-border">
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i></button>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <div class="row">
                    
                        <div class="col-md-6">
                            
                            <table class="table table-bordered mb-4">
                                                <tbody>
                                                <tr>
                                                    <th>Name</th>
                                                    <th><?= $result['username'] ?></th>
                                                </tr>
                                                <tr>
                                                    <th>Amount</th>
                                                    <th>$<?=$row['amount'] ?></th>
                                                </tr>

                                                <tr>
                                                    <th>Transaction ID</th>
                                                    <th><?= $row['refrence_id'] ?></th>
                                                </tr>

                                                <tr>
                                                    <th>Wallet Address</th>
                                                    <th><?= $row['wallet_address'] ?></th>
                                                </tr>
                                                
                                                </tbody>
                                            </table>
                            
                            
                            <!-- /.form-group -->
                        </div>
                        <!-- /.col -->
                        <div class="col-md-6">
                            
                            <table class="table table-bordered mb-4">
                                                <tbody>
                                                
                                                <tr>
                                                    <th>Crypto Name</th>
                                                    <th><?= $row['payment_name'] ?></th>
                                                </tr>
                                                <tr>
                                                    <th>Receipt</th>
                                                    <th><?php
                                                        if(empty($row['image'])) {
                                                            echo "<p>No Receipt Submitted</p>"
                                                        ?>
                                                        <?php
                                                        }
                                                        ?>

                                                        <a href="../assets/front/img/uploads/<?=$row['image']?>" target="_blank"><img src="../assets/front/img/uploads/<?=$row['image']?>" width="20%" alt=""></a>
                                                    </th>

                                                </tr>
                                                <tr>
                                                    <th>Created At</th>
                                                    <th><?= $row['createdAt'] ?></th>
                                                </tr>
                                                <tr>
                                                    <th>Status</th>
                                                    <th><?= $tran_status ?></th>
                                                </tr>
                                                </tbody>
                                            </table>
                            
                            

                        </div>
                        <!-- /.col -->
                    </div>
                    <!-- /.row -->
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="submit" name="accept" class="btn btn-success">Accept</button>
                
                    <button type="submit" name="hold" class="btn btn-warning">Hold</button></form>
                    <button type="submit" name="decline" class="btn btn-danger">Decline</button>
                    
          
        </div>
        </form>
</div>
<!-- /.box -->




</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->



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

?>
Back to Directory File Manager
<