<?php

namespace FacturaScripts\Plugins\Partes\Lib\Widget;

use FacturaScripts\Core\Lib\AssetManager;
use FacturaScripts\Core\Lib\Widget\WidgetSelect;
use FacturaScripts\Dinamic\Model\TareaProyecto;
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;

/**
 * Description of WidgetHtml
 *
 * @author Carlos Garcia Gomez <carlos@facturascripts.com>
 */
class WidgetMostrarInfoPartes extends WidgetSelect
{

    /**
     * 
     * @param array $data
     */
    public function __construct($data)
    {
        parent::__construct($data);
    }

    /**
     * Adds needed assets to the asset manager.
     */
    protected function assets()
    {

    }

    /**
     * 
     * @param string $type
     * @param string $extraClass
     *
     * @return string
     */
    protected function inputHtml($type = 'text', $extraClass = '')
	{
        return parent::inputHtml($type, $extraClass);
    }

    /**
     *
     * @return string
     */
	protected function show()
	{
                $idtarea = $this->value;

                $tarea = new \FacturaScripts\Dinamic\Model\TareaProyecto();
                if (false === $tarea->loadFromCode($idtarea)) {
                        return '';
                }

                $parte = new \FacturaScripts\Dinamic\Model\Partes();
                if (false === $parte->loadFromCode($tarea->idorden)) {
                        return '';
                }

                return '<a href="' . $parte->url() . '">' . $parte->nombre . '</a>';
        }

}
