<?php

namespace Apps\Shop\Widget\OneProductWidget;

use Core\Control\Form\Form;
use Core\View\View;
use Core\View\ElementView;

use Apps\Shop\Entity\ShopProduct;

use Apps\Shop\Helper\ProductHelper;


class OneProductWidget extends Form {

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

        $this->Init($data);
    }

    /**
     * Initialisation 
     */
    function Init($data) {

            echo $data;

     }

    /*     * *
     * Render the html form
     */

    function Render($data="") {
   
        $product = new ShopProduct($this->Core);
        $product->GetById($data);

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

        $view->AddElement(new ElementView("Product", $product));

        $caracteristiques = ProductHelper::GetCaracteristiqueByProduct($this->Core, $product->IdEntite, "entity");
        $view->AddElement(new ElementView("Caracteristiques", $caracteristiques));
            
        return $view->Render();

    }
}
