<?php
require("../snippets/autoload.php");

$entity = new Request();
$client = new UserAccount();
$mail = new Mail();

$entity->Id = $utils->SanitizeString($_POST["Id"]);
$entity->EstimatedDelivery = $utils->SanitizeString($_POST["EstimatedDelivery"]);
if($entity->UpdateEstimatedDelivery()){
    $data = $entity->GetRecord();
    $client->Id = $data["UserAccount"];
    $data_client = $client->GetRecord();
    $mail->ShortDescription = "Tu proyecto Precise Translations - #".$entity->Id;
    $mail->LongDescription = "Se ha cambiado la fecha de entrega de tu proyecto de precise translations a ".$utils->SanitizeString($_POST["EstimatedDelivery"]).", por favor ingresa al siguiente link para ver la información del mismo.";
    $mail->DestinationName = $data_client["FullName"];
    $mail->Url = "https://roc.work/precisetranslations/client/project.php?uk=".$entity->Id;
    $mail->DirectMessage($data_client["Email"], "Precise translations - Nueva fecha de entrega a ".$utils->SanitizeString($_POST["EstimatedDelivery"]));
    $response_request["type"] = "success";
    $response_request["title"] = _("Success update");
    $response_request["content"] = _("This date was updated successfully!");
}else{
  $response_request["type"] = "error";
  $response_request["title"] = _("Presented error");
  $response_request["content"] = _("Try again, an error has ocurred!");
}
echo json_encode($response_request);