<?php include "head.php" ; ?>
<?php
   session_start();
   date_default_timezone_set('Asia/Kolkata');
   if(isset($_SESSION['user_id']) && isset($_SESSION['user_name']) && $_SESSION['user_cate'] === "vendor"){
       $user_id = $_SESSION['user_id'] ;
       $username = $_SESSION['user_name'] ;
       $email = $_SESSION['user_email'] ;
       $phone = $_SESSION['user_phone'] ;
       $ticket = $_SESSION['last_ticket'] ;
       $company = $_SESSION['company'] ;
       $vendor_image = $_SESSION['vendor_image'] ;
   }else{
       header("Location:vendor_login.php") ;
   }
   if(isset($_POST["pay_request"])){
    $cus_id = $_POST['cus_id'];
    $pay_amount = $_POST['pay_amount'];
    $cus_name = $username;
    $cus_mobile = $phone;
    $cus_email = $email;
    $request_on = date('Y-m-d h-i-s');
    if($pay_amount > 0){
        $sql = "INSERT INTO v_payout_request(payout_customer_id, payout_customer_name, payout_customer_mobile, payout_customer_email, payout_request_on, payout_request_amount, payout_status)
                VALUES('$cus_id', '$cus_name', '$cus_mobile', '$cus_email', '$request_on', '$pay_amount', 1)" ;
        if($config->query($sql) === TRUE){
            $_SESSION['status'] = "Requested Successfully" ;
            $_SESSION['alert'] = "success";
        }else{
            $_SESSION['status'] = "Failed" ;
            $_SESSION['alert'] = "error";
        }
    }else{
        $_SESSION['status'] = "Low Balanace" ;
        $_SESSION['alert'] = "error";
    }
    header('Location: wallet_request.php');
    die();

}
?>