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

$table = "existing_game_wingo";
$condition = " where periods='$periods'";
$getResult = $dd->check($table,$condition);
if($getResult['status'] == "success")
{
    
    $table = "account_history";
    $condition = " where periods='$periods' AND userKey='$userKey'";
    $getOrderDetails = $dd->check($table,$condition);
    
    if($getOrderDetails['status'] == "success")
    {
      $lossorprofit = round($getOrderDetails['data']['lossorprofit'],2);
      $gameNumber = $getOrderDetails['data']['gameNumber'];
      $result_number = $getOrderDetails['data']['result_number'];
      $amount = $getOrderDetails['data']['result_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")));    
    }else{
      print_r(json_encode(array("status" => "success","userorder" => "0","winorloss" => "$winLoss","amount" => "$lossorprofit","periods" => "$periods","result" => "0")));    
    }
    
}
?>