<?php

include("includes/header.php"); 
include("includes/sidebar.php");

if(isset($_POST['create'])){
    if (!isset($_POST['csrf_token']) || !$csrf->validateToken($_POST['csrf_token'])) {
        die("CSRF token validation failed!");
    }
    $bank_name = $db_handle->sanitize($_POST['bank_name']);
    $acc_no = $db_handle->sanitize($_POST['acc_no']);
    $acc_name = $db_handle->sanitize($_POST['acc_name']);
    $date = date("d-m-Y h:i:sa");

   

    $insert = $db_handle->insertRecord("INSERT INTO bank_details(bank_name,acc_no,acc_name,date_added) VALUES(?,?,?,?)","ssss",array($bank_name,$acc_no,$acc_name,$date));

if($insert){

$_SESSION['msg-s'] = "Bank Details added successfully";
}else{
$_SESSION['msg-e'] = "Could not add bank details";
}
}

 ?>
 <div class="main-content app-content">
<div class="container-fluid">
                            
                            <!--Modal: order-modal-->
                            
                               
    <div class="row settings mt-3">

        

        <?php if (isset($_SESSION['msg-s'])) { ?>
        <div class="alert alert-success alert-dismissible">
                    <button type="button" class="close" data-bs-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-check"></i> Success!</h4> <?php echo $_SESSION['msg-s']; ?>
                </div>
<?php unset($_SESSION['msg-s']); } ?>

<?php if (isset($_SESSION['msg-e'])) { ?>
        <div class="alert alert-danger alert-dismissible" role="alert">
                    <button type="button" class="close" data-bs-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-check"></i> Error!</h4> <?php echo $_SESSION['msg-e']; ?>
                </div>
<?php unset($_SESSION['msg-e']); } ?>
        
        <div class="col-xl-12">
            <div id="settingmenuContent">
                
                                <div id="editprofile">
                    <div class="row mb-5">
                        <div class="col-12">
                            <div class="card border-0 box-shadow">
                                <div class="card-body pb-0">
                                    <div class="d-flex align-items-center mb-3">
                                        <h5 class="text-uppercase">Create Bank Details</h5>
                                    </div>
                                    <form method="POST"
                                        action=""
                                        enctype="multipart/form-data">
                                         <?php echo $csrf->csrfInput(); ?>                                        
                                            <div class="form-group mb-3">
                                                <label class="form-label">Bank Name<span
                                                        class="text-danger"> * </span></label>
                                                <input type="text" class="form-control modern-input" name="bank_name"
                                                    value=""
                                                    placeholder="Bank Name" required>

                                            </div>
                                            
                                            <div class="form-group mb-3">
                                                <label class="form-label">Account Number<span
                                                        class="text-danger"> * </span></label>
                                                <input type="text" class="form-control modern-input" name="acc_no"
                                                    value=""
                                                    placeholder="Account Number" required>

                                            </div>

                                            <div class="form-group mb-3">
                                                <label class="form-label">Account Name<span
                                                        class="text-danger"> * </span></label>
                                                <input type="text" class="form-control modern-input" name="acc_name"
                                                    value=""
                                                    placeholder="Account Name" required>

                                            </div>
                                                 
                                               
                                                
                                                                                        <div class="form-group text-end">
                                                <button
                                                    class="btn btn-secondary  "
                                                     type="submit" name="create"  >Add Bank Details</button>
                                            </div>
                                        
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
               



                                                                                                                                                                                                                                                                                                    <div id="delete_profile">
                        
                    </div>
                  
                               

            </div>
        </div>
    </div>
    
    
                        </div>
                    </div>
                </div>
  <?php

include("includes/footer.php"); 
 ?>