<?php 
require 'db.php';
$data = json_decode(file_get_contents('php://input'), true);
if($data['mobile'] == ''  || $data['password'] == '' || $data['shop_id'] == '')
{
    $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went Wrong!");
}
else
{
    $mobile = strip_tags(mysqli_real_escape_string($con,$data['mobile']));
    $imei = strip_tags(mysqli_real_escape_string($con,$data['imei']));
    $password = strip_tags(mysqli_real_escape_string($con,$data['password']));
    $shop_id = strip_tags(mysqli_real_escape_string($con,$data['shop_id']));
    $shop_code = strip_tags(mysqli_real_escape_string($con,$data['shop_code']));
    
    $chek = $con->query("select * from user where (mobile='$mobile' or email='$mobile') and password='$password' and shop_id = '$shop_id' and shop_code = '$shop_code'");
    $status = $con->query("select * from user where status = '1' and (mobile='$mobile' or email='$mobile') and shop_id = '$shop_id' and shop_code = '$shop_code'");

    if($chek->num_rows != 0)
    {
        if($status->num_rows !=0)
        {
            $c = $con->query("select * from user where (mobile='$mobile' or email='$mobile')  and status = 1 and password='$password' and shop_id = '$shop_id' and shop_code = '$shop_code'");
            $c = $c->fetch_assoc();
            $returnArr = array("user"=>$c,"ResponseCode"=>"200","Result"=>"true","ResponseMsg"=>"Login successfully!");
        }
        else
        {
            $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Your Account Deactivated!");
        }
    }
    else  
    {
        $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Invalid Email/Mobile No or Password!!!");
    }
}

echo json_encode($returnArr);
?>