<?php

namespace Apps\Annonce\Widget\ListAnnonce;

use Core\View\View;
use Core\View\ElementView;

use Apps\Annonce\Entity\AnnonceAnnonce;

class ListAnnonce {

    /**
     * Constructeur
     */
    function __construct($core = "", $data = "") {
        $this->Core = $core;
        $this->Data = $data;
   }

    /*     * *
     * Render the html form
     */

    function Render() {

        $view = new View(__DIR__ . "/View/index.tpl", $this->Core);

        $caracteristicplugin = \Apps\EeApp\Helper\AppHelper::GetPluginType($this->Core, "Annonce" , "Caracteristic");
        
        if($caracteristicplugin != null){
            $filtersCaracteristics = $caracteristicplugin->RenderFilters("Annonce");
        }    

        $view->AddElement(new ElementView("Filters", $filtersCaracteristics ? $filtersCaracteristics : "" )); 
       
        $view->AddElement(new ElementView("Annonces", $this->GetList())); 

        return $view->Render();
    }

    /***
     * Returtn list of Annonce
     * Filtrer
     */
    function GetList(){

        $annonces = new AnnonceAnnonce($this->Core);


        return $annonces->Find("1 = 1");
    }

}
