<?php

/*
 * PuzzleApp
 * Webemyos
 * Jérôme Oliva
 * GNU Licence
 */

namespace Apps\DownloadManager\Entity;

use Core\Entity\Entity\Entity;
use Core\Entity\Entity\Property;

class DmDocument extends Entity {

    function __construct($core) {

        $this->Version = "1.0.0.0";

        $this->Core      = $core;
        $this->TableName = "DmDocument";
        $this->Alias     = "DmDocument";

        $this->CategoryId   = new Property("CategoryId",   "CategoryId",   NUMERICBOX, false, $this->Alias);
        $this->Name         = new Property("Name",         "Name",         TEXTBOX,    true,  $this->Alias);
        $this->Code         = new Property("Code",         "Code",         TEXTBOX,    true,  $this->Alias);
        $this->Description  = new Property("Description",  "Description",  TEXTAREA,   false, $this->Alias);
        $this->FileType     = new Property("FileType",     "FileType",     TEXTBOX,    false, $this->Alias);
        $this->FileSize     = new Property("FileSize",     "FileSize",     TEXTBOX,    false, $this->Alias);
        $this->Status       = new Property("Status",       "Status",       NUMERICBOX, true,  $this->Alias);
        $this->DateCreated  = new Property("DateCreated",  "DateCreated",  TEXTBOX,    false, $this->Alias);

        $this->DirectoryDocument = "Data/Apps/DownloadManager/Document/";
        $this->DirectoryImage    = "Data/Apps/DownloadManager/Thumbnail/";

        $this->Create();
    }

    /**
     * Retourne le chemin complet du fichier
     */
    public function GetFilePath() {
        return $this->DirectoryDocument . $this->IdEntite . "/";
    }

    /**
     * Retourne le chemin de la miniature
     */
    public function GetThumbnailPath() {
        $path = $this->DirectoryDocument . $this->IdEntite . "/thumb.png";
        if (file_exists($path)) {
            return $this->Core->GetPath("/" . $path);
        }
        return $this->Core->GetPath("/images/nophoto.png");
    }
}

?>
