<?php
include "include.php";
//pt("ff");die;
if($o->psa_status=="0"){
    $result['error'] = 1;
    $result['error_msg'] = "Please Active Your Psa Id Contact Super Admin.";  
}
if($o->psa_id==""){
    $result['error'] = 1;
    $result['error_msg'] = "Please Active Your Psa Id Contact Super Admin.";  
}
if ($o->psa_status == 1) {
    $userservice_check = check_userServices('UTI PAN',$o);
    //pt($userservice_check);die;
    if($userservice_check['error'] == '1'){
    $o1 = new wallet;
    $o1->coupon_qty = $_POST['coupon_qty'];
    $o1->amount = $o1->coupon_qty * $o->coupon_price;
    $o1->total_amount = $o1->amount;
    $o1->mobile_number = $o->psa_id;
    $o1->provider_id = "98";
    $o1->circle_name = "Pan India";
    $o1->circle_id = "0";
    $o1->commission_rt = "0";
    $o1->api_id = "12";
    $o1->api_amount = $o1->amount;
    $o1->transaction_type = "Recharge";
    $o1->status == "Pending";
    $o1->status == "App";
    $o1->opid = "PC". reference_number();
    $o1->comment = "Pan Coupon Purchase" . " - " . todaysDate();
    $o1->api_number = "PC". reference_number();
    $o1->api_response = "";
    
        if ($o1->amount <= $o->amount_balance) {
            $o1 = wallet_insert($o, $o1);
            $result['error'] = 0;
            $result['error_msg'] = "Request has been forwarded to Super Admin will respond shortly";
        }else{
            $result['error'] = 1;
            $result['error_msg'] = "Sorry, Your Wallet Balance is less than Required Amount";
        }
    }else{
        $result['error'] = 1;
        $result['error_msg'] = "You are not authorized for Pan service";
    }

}else{
    $result['error'] = 1;
    $result['error_msg'] = "Something Went Wrong";
}
echo json_encode($result);
?>