<?php

require_once __DIR__ . '/DBConnect.php';
$response = array();


if(isset($_POST['clientId'])&& isset($_POST['PName']) && isset($_POST['Paddress']) && isset($_POST['PDesc'])&& isset($_POST['CompanyNumber'])&& isset($_POST['PEmail'])&& isset($_POST['PWebsite']) && isset($_POST['NameOfPerson'])){
    
    	 
    	    	$ClientId  =     $_POST['clientId'];
  		        $CompanyName  =   $_POST['PName'];
  		        $CompanyAddrss =$_POST['Paddress'];
  		        $CompanyDesc=$_POST['PDesc'];
  		        $CompanyNumber  =     $_POST['CompanyNumber'];
  		        $Email  =   $_POST['PEmail'];
  		        $Website =$_POST['PWebsite'];
  		        $NameOfPerson=$_POST['NameOfPerson'];
  		       // $UpdatedDate = date("Y-m-d H:i:s");
  		
    	 
    	   	$sql = "UPDATE Client SET CompanyName='$CompanyName', CompanyAddress='$CompanyAddrss', BusinessDescriptions='$CompanyDesc', CompanyNumber='$CompanyNumber', Email='$Email', WebSite='$Website', NameOfPerson='$NameOfPerson' WHERE ClientID = $ClientId";
       	      
       	
       		$result=0;
				try{	
					$stmt = $conn->prepare($sql);
					$stmt->execute();
					$result= $stmt->rowCount();
				}
				catch(PDOException $e){
					echo $sql . "<br>" . $e->getMessage();
				}
				if ( $result!= 0) {
						
						$response["success"] = 1;
						//$response["roweffected"] = $result;
					
				     	$response["message"] = "Update Successfully";
						// echoing JSON response
						echo json_encode($response);
				}else{
						$response["success"] = 0;
					//	$response["roweffected"] = $result;      
						$response["message"] = "Not updated row ";
						// echoing JSON response
						echo json_encode($response);
				}              
    
}else{
    
	                    $response["success"] = -1;
						     
				        $response["message"] = "All Fields are Required";

}

?>