ok
Direktori : /home2/selectio/www/wedding-info-new/admin/api/ |
Current File : /home2/selectio/www/wedding-info-new/admin/api/wallet-amount.php |
<?php include_once('config/config.php'); include_once('config/custom-functions.php'); include 'config/send-sms.php'; $fn = new custom_functions(); if(isset($_POST['type']) && $_POST['type']=="wallet_amount" ){ try{ $statement = $pdo->prepare("SELECT wallet_balance FROM `client` where id='".$_POST['client_id']."'"); $statement->execute(); $result= $statement->fetchAll(PDO::FETCH_ASSOC); $totalFiltered = $statement->rowCount(); if($totalFiltered>0){ $response['error']=false; $response['wallet_amount']=$result[0]['wallet_balance']; }else{ $response['error']=false; $response['wallet_amount']=0; } echo json_encode($response); }catch(Exception $e){ $response['error']=true; $response['wallet_amount']=0; echo json_encode($response); } }else if(isset($_POST['type']) && $_POST['type']=="credit_wallet" ){ try{ $statement = $pdo->prepare("UPDATE `client` SET `wallet_balance`=wallet_balance+? WHERE id=?"); $results = $statement->execute(array($_POST['input_wallet_amount'],$_POST['client_id'])); if($results){ $response['error']=false; $response['message']="Wallet Amount Added Successfully"; }else{ $response['error']=false; $response['message']="Somthing Went Wrong..."; } echo json_encode($response); }catch(Exception $e){ $response['error']=true; $response['message']="Somthing Went Wrong..."; echo json_encode($response); } }else{ $response['error']=true; $response['wallet_amount']=0; echo json_encode($response); } ?>