= $opn && $nowTime <= $cls )){ $ins = query("INSERT INTO `games` (`user`, `game`, `bazar`,`game_sc`, `date`, `number`, `housing`, `ending`, `h_amount`, `e_amount`, `g_amount`, `status`, `created_at`, `is_loss`) VALUES ('$user', '$game', '$bazar','$game_sc', '$date','$number' ,'$housing', '$ending', '$h_amount', '$e_amount', '$g_amount', '0', '$timestamp', '0')"); if($ins){ $walletcheck = query("select wallet from users where mobile='$user'"); if(rows($walletcheck)>0){ $bl = fetch($walletcheck); if($h_amount>0 && $e_amount>0){ $amts = (int)($h_amount+$e_amount); $bls = ((int)$bl['wallet']-(int)($h_amount+$e_amount)); }else if($h_amount>0){ $amts=(int)($h_amount); $bls = (int)$bl['wallet']-(int)($h_amount); }else if($e_amount>0){ $amts=(int)($e_amount); (int)$bls = (int)($bl['wallet']-$e_amount); }else{ $bls = $bl['wallet']; } $upd = query("update users set wallet='$bls' where mobile='$user'"); if($upd){ query("INSERT INTO `transactions` ( `user`, `amount`, `type`, `remark`, `owner`, `created_at`, `game_id`, `batch_id`,`status`) VALUES ( '$user', '$amts', '0', 'Game Deduct', '$user', '$timestamp', '$mrktId', '0','1');"); $data['success'] = "1"; $data['msg'] = "Game saved successfully"; }else{ $data['success'] = "0"; $data['msg'] = "Unable to save game wallet"; } } } else{ $data['success'] = "0"; $data['msg'] = "Unable to save game ins"; } }else if(($nowTime >= $opn1 && $nowTime <= $cls1)){ $ins = query("INSERT INTO `games` (`user`, `game`, `bazar`,`game_sc`, `date`, `number`, `housing`, `ending`, `h_amount`, `e_amount`, `g_amount`, `status`, `created_at`, `is_loss`) VALUES ('$user', '$game', '$bazar','$game_sc', '$date','$number' ,'$housing', '$ending', '$h_amount', '$e_amount', '$g_amount', '0', '$timestamp', '0')"); if($ins){ $walletcheck = query("select wallet from users where mobile='$user'"); if(rows($walletcheck)>0){ $bl = fetch($walletcheck); if($h_amount>0 && $e_amount>0){ $amts = (int)($h_amount+$e_amount); $bls = ((int)$bl['wallet']-(int)($h_amount+$e_amount)); }else if($h_amount>0){ $amts=(int)($h_amount); $bls = (int)$bl['wallet']-(int)($h_amount); }else if($e_amount>0){ $amts=(int)($e_amount); (int)$bls = (int)($bl['wallet']-$e_amount); }else{ $bls = $bl['wallet']; } $upd = query("update users set wallet='$bls' where mobile='$user'"); if($upd){ query("INSERT INTO `transactions` ( `user`, `amount`, `type`, `remark`, `owner`, `created_at`, `game_id`, `batch_id`,`status`) VALUES ( '$user', '$amts', '0', 'Game Deduct', '$user', '$timestamp', '$mrktId', '0','1');"); $data['success'] = "1"; $data['msg'] = "Game saved successfully"; }else{ $data['success'] = "0"; $data['msg'] = "Unable to save game wallet"; } } } else{ $data['success'] = "0"; $data['msg'] = "Unable to save game ins"; } }else{ $data['success'] = "-1"; $data['msg'] = "Sorry Game Has Already Ended. Please choose another game"; } }else if($type=='jodi'){ $bzrSn = query("select * from gametime_manual where market='$bazar'"); $mrkData = fetch($bzrSn); $mrktId = $mrkData['sn']; $opn = strtotime($mrkData['open']); $cls = strtotime($mrkData['close']); $opn1 = strtotime($mrkData['open1']); $cls1 = strtotime($mrkData['close1']); $nowTime = strtotime(date("h:i A")); if(($nowTime >= $opn && $nowTime <= $cls )){ $ins = query("INSERT INTO `games` (`user`, `game`, `bazar`,`game_sc`, `date`, `number`, `housing`, `ending`, `h_amount`, `e_amount`, `g_amount`, `status`, `created_at`, `is_loss`) VALUES ('$user', '$game', '$bazar','$game_sc', '$date','$number' ,'$housing', '$ending', '$h_amount', '$e_amount', '$g_amount', '0', '$timestamp', '0')"); if($ins){ $walletcheck = query("select wallet from users where mobile='$user'"); if(rows($walletcheck)>0){ $bl = fetch($walletcheck); if($h_amount>0 && $e_amount>0){ $amts = (int)($h_amount+$e_amount); $bls = ((int)$bl['wallet']-(int)($h_amount+$e_amount)); }else if($h_amount>0){ $amts=(int)($h_amount); $bls = (int)$bl['wallet']-(int)($h_amount); }else if($e_amount>0){ $amts=(int)($e_amount); (int)$bls = (int)($bl['wallet']-$e_amount); }else{ $bls = $bl['wallet']; } $upd = query("update users set wallet='$bls' where mobile='$user'"); if($upd){ query("INSERT INTO `transactions` ( `user`, `amount`, `type`, `remark`, `owner`, `created_at`, `game_id`, `batch_id`,`status`) VALUES ( '$user', '$amts', '0', 'Game Deduct', '$user', '$timestamp', '$mrktId', '0','1');"); $data['success'] = "1"; $data['msg'] = "Game saved successfully"; }else{ $data['success'] = "0"; $data['msg'] = "Unable to save game wallet"; } } } else{ $data['success'] = "0"; $data['msg'] = "Unable to save game ins"; } }else if(($nowTime >= $opn1 && $nowTime<= $cls1 )){ $ins = query("INSERT INTO `games` (`user`, `game`, `bazar`,`game_sc`, `date`, `number`, `housing`, `ending`, `h_amount`, `e_amount`, `g_amount`, `status`, `created_at`, `is_loss`) VALUES ('$user', '$game', '$bazar','$game_sc', '$date','$number' ,'$housing', '$ending', '$h_amount', '$e_amount', '$g_amount', '0', '$timestamp', '0')"); if($ins){ $walletcheck = query("select wallet from users where mobile='$user'"); if(rows($walletcheck)>0){ $bl = fetch($walletcheck); if($h_amount>0 && $e_amount>0){ $amts = (int)($h_amount+$e_amount); $bls = ((int)$bl['wallet']-(int)($h_amount+$e_amount)); }else if($h_amount>0){ $amts=(int)($h_amount); $bls = (int)$bl['wallet']-(int)($h_amount); }else if($e_amount>0){ $amts=(int)($e_amount); (int)$bls = (int)($bl['wallet']-$e_amount); }else{ $bls = $bl['wallet']; } $upd = query("update users set wallet='$bls' where mobile='$user'"); if($upd){ query("INSERT INTO `transactions` ( `user`, `amount`, `type`, `remark`, `owner`, `created_at`, `game_id`, `batch_id`,`status`) VALUES ( '$user', '$amts', '0', 'Game Deduct', '$user', '$timestamp', '$mrktId', '0','1');"); $data['success'] = "1"; $data['msg'] = "Game saved successfully"; }else{ $data['success'] = "0"; $data['msg'] = "Unable to save game wallet"; } } } else{ $data['success'] = "0"; $data['msg'] = "Unable to save game ins"; } }else{ $data['success'] = "-1"; $data['msg'] = "jodi Sorry Game Has Already Ended. Please choose another game"; } } echo json_encode($data);