<?php
// array for JSON response
$response = array();
//check for required fields
if (isset($_POST['BookingID']) && isset($_POST['ClientName']) && isset($_POST['ClientMobile']) && isset($_POST['ClientAddress']) && isset($_POST['ClientNic']) && isset($_POST['EventName'])
    && isset($_POST['BookingDate']) && isset($_POST['EventDate']) && isset($_POST['ArrangePersons']) && isset($_POST['ChargesTotal']) && isset($_POST['Description']) && isset($_POST['ClientID'])
    && isset($_POST['ClientUserID']) && isset($_POST['NetCode']) && isset($_POST['SysCode']) && isset($_POST['Shift'])) {

      $BookingID = $_POST['BookingID'];
      $ClientName = $_POST['ClientName'];
  		$ClientMobile = $_POST['ClientMobile'];
  		$ClientAddress = $_POST['ClientAddress'];
  		$ClientNic = $_POST['ClientNic'];
  		$EventName = $_POST['EventName'];
  		$BookingDate = $_POST['BookingDate'];
  		$EventDate = $_POST['EventDate'];
  		$ArrangePersons = $_POST['ArrangePersons'];
  		$ChargesTotal = $_POST['ChargesTotal'];
  		$Description = $_POST['Description'];
  		$ClientID = $_POST['ClientID'];
  		$ClientUserID = $_POST['ClientUserID'];
  		$NetCode = $_POST['NetCode'];
  		$SysCode = $_POST['SysCode'];
      	//$DebitAccount = $_POST['DebitAccount'];
		$Shift = $_POST['Shift'];
  		//$CreditAccount = $_POST['CreditAccount'];
		//$BookingDate = date("Y-m-d", strtotime($Booking_Date));
		//$EventDate = date("Y-m-d", strtotime($Event_Date));
      // include db connect class
  		require_once __DIR__ . '/../DBConnect.php';

      $UpdatedDate = date("Y-m-d H:i:s");

      $sql = "UPDATE Booking SET Shift = '$Shift', ClientName = '$ClientName', ClientMobile = '$ClientMobile', ClientAddress = '$ClientAddress', ClientNic = '$ClientNic', EventName = '$EventName', BookingDate = '$BookingDate',
      EventDate = '$EventDate', ArrangePersons = '$ArrangePersons', ChargesTotal = '$ChargesTotal', Description = '$Description', ClientID = '$ClientID', ClientUserID = '$ClientUserID'
      , NetCode = '$NetCode', SysCode = '$SysCode', UpdatedDate = '$UpdatedDate' WHERE BookingID = $BookingID";
      $params = array();
	  
       $result=0;
		try{	
			$stmt = $conn->prepare($sql);
			$stmt->execute();
			$result= $stmt->rowCount();
		}
		catch(PDOException $e){
			echo $sql . "<br>" . $e->getMessage();
		}
		if ( $result!= 0) {
				$rows_affected= "No information available.";
				$response["success"] = 1;
				$response["roweffected"] = $result;
				$response["UpdatedDate"] = $UpdatedDate;
				$response["message"] = "Update Successfully";
				// echoing JSON response
				echo json_encode($response);
		}else{
				$response["success"] = 0;
				$response["roweffected"] = $result;      
				$response["message"] = "Not updated row ".$result;
				// echoing JSON response
				echo json_encode($response);
		}
   }else{
     // no number found
     $response["success"] = 0;
     $response["message"] = "No Update Set All Parameters";
     // echo no users JSON
     echo json_encode($response);
   }

?>
