<?php 
		header("Access-Control-Allow-Origin: *");
		header("Access-Control-Allow-Headers: access");
		header("Access-Control-Allow-Methods: GET");
		header("Access-Control-Allow-Credentials: true");
		header("Content-Type: application/json; charset=UTF-8");
		
		

include_once '../Database.php';
include_once 'cliente.php';

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

$client = new CLIENTE($db);
try{
	$clienteid = isset($_GET['id'])?$_GET['id']:die();
	$campo = isset($_GET['campo'])?$_GET['campo']:die();
	$valor = isset($_GET['valor'])?$_GET['valor']:die();
	
	$query = "UPDATE ".$client->table_name." SET ".$campo."=:valor WHERE id=:id";
	$stm = $client->conn->prepare($query);
	$stm->bindParam(":id",$clienteid);
	$stm->bindParam(":valor",$valor);
	$stmt = $client->Update($stm);
	if($stmt !==false){
		echo json_encode(array("Mensaje"=>"El campo ".$campo." se ha Actualizado"));
	}else{
		echo json_encode(array("Error"=>"No se ha podido actualizar el campo"));
	}
}catch(Exception $ex){
	echo json_encode(array("Error"=>"No se ha podido procesar la solicitud"));
}

?>