<?php
require_once ("../core/entity/Request.php");
require_once ("../core/entity/UserAccount.php");
require_once ("../core/entity/ActiveLang.php");
require_once ("../core/utils/Utils.php");
$entity = new Request();
$utils = new Utils();
$user = new UserAccount();
$lang = new ActiveLang();
$list = $entity->GetHooks();
$map = array();
foreach ($list as $item) {
  $user->Id = $item["UserAccount"];
  $us = $user->GetRecord();
  $lang->Id = $item["FromLang"];
  $from = $lang->GetRecord();
  $lang->Id = $item["ToLang"];
  $to = $lang->GetRecord();
  array_push($map, array(
   "id" => $item["Id"],
   "data" => array(
     "Client"=>$us["FullName"],
     "Email"=>$us["Email"],
     "Phone"=>$us["Phone"],
     "CompanyName"=>$us["CompanyName"],
     "DeliveryMethod"=>$item["Delivery"],
     "FullAddress"=>$item["FullAddress"]." ".$item["City"]." ".$item["State"]." ".$item["Zip"],
     "InteriorAddress"=>$item["InteriorAddress"],
     "SubmissionDate"=>$item["SubmissionDate"],
     "DeliveryDate"=>$item["DeliveryDate"],
     "PaymentToken"=>$item["PaymentToken"],
     "EstimatedPrice"=>$item["EstimatedPrice"],
     "EstimatedDelivery"=>$item["EstimatedDelivery"],
     "NeedCertification"=>$item["Certification"],
     "IsUrgent"=>$item["Urgent"],
     "FromLang"=>$utils->getNameTranslation($from["LangName"]),
     "ToLang"=>$utils->getNameTranslation($to["LangName"]),
     "Pages"=>$item["Words"],
     "Status"=>$item["Status"]
   )
  ));
}
echo json_encode($map);