<?php
	// required headers
	header("Access-Control-Allow-Origin: *");
	//header("Content-Type: application/json; charset=UTF-8");
	header("Access-Control-Allow-Methods: POST");
	header("Access-Control-Max-Age: 3600");
	header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

	include_once '../config/database.php';
	include_once '../objects/installation.php';
	include_once '../objects/installation_detail.php';
	include_once '../objects/ont.php';

	$database = new Database();
	$db = $database->getConnection();

	$installation = new Installation($db);
	$installation_detail = new InstallationDetail($db);
	$ont = new ONT($db);
	$data = json_decode(file_get_contents("php://input"));

	$installation->id = $data->id;
	$installation_detail->installation_id = $data->id;
	 
	$installation_detail->delete();
	if($installation->delete()){
		$ont->deleteFromInstallation();
	    echo 'deleted';
	}else{
	    echo 'error';
	}
?>