<?php

error_reporting(E_ERROR | E_PARSE);
// sql data connection 

$DB_Host = "localhost";
$DB_Name = "mrcode_FMdatabase";
$DB_Table = "MOOBOQ";
$DB_User = "mrcode_User";
$DB_Pass = "o;1fT@L+cB&P";


$Level = $_GET['Level'];
$BOQ =  $_GET['BOQ'];
$urn = $_GET['urn'];
$sumCurrent = $_GET['sumCurrent'];
$sumCumulative = $_GET['sumCumulative'];


if($Level != null && $BOQ != null && $urn != null){
    
    
// connect to sql 
$conn = new mysqli($DB_Host, $DB_User, $DB_Pass,$DB_Name);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
//"', NOW() ,'". $username ."'
    $sql = 'UPDATE `MOOBOQ` SET `Certified Qty`="' .$sumCurrent . '",`Total Certified`="' . $sumCumulative . '" WHERE Level = "'.$Level.'" AND BOQ = "' .$BOQ.'"' ;

if ($conn->query($sql) === TRUE) {
        
        $myObj->updated = "OK";
        $myArray[] = $myObj;
        $myJSON = json_encode(array('Certified' =>$myArray));
        echo $myJSON;
        
    } 
    else {
        
        $myObj->updated = null;
        $myArray[] = $myObj;
        $myJSON = json_encode(array('Certified' =>$myArray));
        echo $myJSON;
    }

$conn->close();


}
else{
    
    $myObj->updated = null;
        $myArray[] = $myObj;
        $myJSON = json_encode(array('Certified' =>$myArray));
        echo $myJSON;
}

?>
