<?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();
$map = array();
$id = $utils->SanitizeString($_GET["id"]);
$entity->Id = $id;
$item = $entity->GetRecord();
$user->Id = $item["UserAccount"];
$us = $user->GetRecord();
$lang->Id = $item["FromLang"];
$from = $lang->GetRecord();
$lang->Id = $item["ToLang"];
$to = $lang->GetRecord();

?>
<table>
  <tr><th align="right">Id</th><td><?=$item["Id"]?></td></tr>
  <tr><th align="right">Client</th><td><?=$us["FullName"]?></td></tr>
  <tr><th align="right">Email</th><td><?=$us["Email"]?></td></tr>
  <tr><th align="right">Phone</th><td><?=$us["Phone"]?></td></tr>
  <tr><th align="right">CompanyName</th><td><?=$us["CompanyName"]?></td></tr>
  <tr><th align="right">DeliveryMethod</th><td><?=$item["Delivery"]?></td></tr>
  <tr><th align="right">FullAddress</th><td><?=$item["FullAddress"]." ".$item["City"]." ".$item["State"]." ".$item["Zip"]?></td></tr>
  <tr><th align="right">InteriorAddress</th><td><?=$item["InteriorAddress"]?></td></tr>
  <tr><th align="right">SubmissionDate</th><td><?=$item["SubmissionDate"]?></td></tr>
  <tr><th align="right">DeliveryDate</th><td><?=$item["DeliveryDate"]?></td></tr>
  <tr><th align="right">PaymentToken</th><td><?=$item["PaymentToken"]?></td></tr>
  <tr><th align="right">EstimatedPrice</th><td><?=$item["EstimatedPrice"]?></td></tr>
  <tr><th align="right">EstimatedDelivery</th><td><?=$item["EstimatedDelivery"]?></td></tr>
  <tr><th align="right">NeedCertification</th><td><?=$item["Certification"]?></td></tr>
  <tr><th align="right">IsUrgent</th><td><?=$item["Urgent"]?></td></tr>
  <tr><th align="right">FromLang</th><td><?=$utils->getNameTranslation($from["LangName"])?></td></tr>
  <tr><th align="right">ToLang</th><td><?=$utils->getNameTranslation($to["LangName"])?></td></tr>
  <tr><th align="right">Pages</th><td><?=$item["Words"]?></td></tr>
  <tr><th align="right">Status</th><td><?=$item["Status"]?></td></tr>
  <tr><th align="right">Files</th><td>
      <ul>
        <?php
        function getDirContents($dir, &$results = array()) {
          $files = scandir($dir);

          foreach ($files as $key => $value) {
            $path = $dir . DIRECTORY_SEPARATOR . $value;
            $fake = $dir . DIRECTORY_SEPARATOR . $value;
            if (!is_dir($path)) {
              $results[] = $path;
            } else if ($value != "." && $value != "..") {
              getDirContents($path, $results);
              //$results[] = $path;
            }
          }

          return $results;
        }
        $path    = '../uploads/projects/'.$item["Id"]."/";
        $files = getDirContents($path);
        foreach($files as $file){
          echo "<li><a href='$file'>$file</a></li>";
        }
        ?>
      </ul>

    </td></tr>
</table>
