<?php

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

namespace Apps\Immo\Entity;

use Core\Entity\Entity\Entity;
use Core\Entity\Entity\Property;
use Core\Entity\Entity\EntityProperty;
use Apps\Immo\Entity\ImmoProjectEvent;

class ImmoProject extends Entity {

    //Constructeur
    function __construct($core) {
        //Version
        $this->Version = "2.0.0.0";

        //Nom de la table 
        $this->Core = $core;
        $this->TableName = "ImmoProject";
        $this->Alias = "ImmoProject";

        $this->Name = new Property("Name", "Name", TEXTAREA, false, $this->Alias);
        $this->Description = new Property("Description", "Description", TEXTAREA, false, $this->Alias);
        $this->DateCreated = new Property("DateCreated", "DateCreated", DATEBOX, false, $this->Alias);

        //Creation de l entité 
        $this->Create();
    }

    /*     * *
     * Retoune les event du projet
     */

    function GetEvents() {

        $event = new ImmoProjectEvent($this->Core);
        $events = $event->Find("ProjectId=" . $this->IdEntite . " order by DateEvent desc");

        $view = "<ul>";

        foreach ($events as $event) {
            $view .= "<li class='chips'>";
            $view .= "<b>" . $event->Name->Value . "</b>";
            $view .= "<p>" . $event->DateEvent->Value . " " . $event->HourEvent->Value . "</p>";
            $view .= "<span id='" . $event->IdEntite . "' ><i class='fa fa-edit editEvent' ></i><i class='fa fa-trash removeEvent'></i></span>";

            $view .= "</li>";
        }

        $view .= "</ul>";

        return $view;
    }
}

?>