<?php
@session_start();
include "control/activity.php";
$dd = new activity();
@$userKey = $_REQUEST['userkey'];
$periods = $_REQUEST['periods'];
$game = $_REQUEST['game'];

$table = "k3existing_result";
$condition = " where periods='$periods' AND game_number='$game'";
$getResult = $dd->check($table,$condition);
if($getResult['status'] == "success")
{
    
    $table = "account_history";
    $condition = " where periods='$periods' AND userKey='$userKey' AND game_name='k3'";
    $getOrderDetails = $dd->check($table,$condition);
    
    if($getOrderDetails['status'] == "success")
    {
        $lossorprofit = $getOrderDetails['data']['lossorprofit'];
        $gameNumber = $getOrderDetails['data']['gameNumber'];
        $result_number = $getOrderDetails['data']['result_number'];
        $amount = $getOrderDetails['data']['amount'];
        $selected_number = $getOrderDetails['data']['result_number'];
        $bigsmall = $getOrderDetails['data']['selected_number'];
        if($lossorprofit > 0)
        {
            $winLoss = "1";
        }
        else{
            $winLoss = "0";
        }
      
     
      print_r(json_encode(array("status" => "success","userorder" => "1","winorloss" => "$winLoss","amount" => "$lossorprofit","periods" => "$periods","gameNumber" => "$gameNumber","result" => "$result_number","bigsmall" => $bigsmall)));    
    }else{
      print_r(json_encode(array("status" => "failed","userorder" => "0","winorloss" => "$winLoss","amount" => "$lossorprofit","periods" => "$periods","gameNumber" => "$gameNumber","result" => "$result_number","bigsmall" => $bigsmall)));  
    }
    
}
?>