<?php

namespace Modules\Additional\Specifique\Client112\Html;

use Helpers\Trad\ITrad;

class GestionFacture
{
    public $router;
    private $contenaire;
    private $pdo;
    
    public function __construct($router, $contenaire, \PDO $pdo)
    {
        $this->router = $router;
        $this->contenaire = $contenaire;
        $this->pdo = $pdo;
    }
    public function filterTableFacture($array)
    {
        $extensionFilter = new \TwigExtension\FilterTableExtension($this->router);

        $html = '   
        <td>
            '.$extensionFilter->filterSelect($array['CDE_REGUL'], ($array['post']['infoPagination.filter.filter_'.$array['CDE_REGUL']]) ?? '', $array['listeSelect'], '', '', '', '', '').'
        </td>';

        return $html;
    }
    public function triTableFacture($array)
    {

        $extensionTrie = new \TwigExtension\TriTableExtension();
        
        $html = '<th>'. $extensionTrie->triTable($array['CDE_REGUL'], ($array['post']['infoPagination.filter.tri_'.$array['CDE_REGUL']]) ?? '', $array['titreTri'], '', '', $array['nomForm']);
        '</th>';


        return $html;
    }
    public function infoBull($array)
    {
        $html = "<span class='white-tooltip existCde'>
        <span class='infos_tooltip top-left'>
            <span class='tooltip-arrow'></span>".
                $array['titreInfoBull']."
        </span>
        </span>";

        return $html;
    }

    public function inputSelectCde($array)
    {
        
        $array['value'] = $array['post']['CDE_REGUL']??'';
        
        $array['bulle'] = true;
        
        $extensionTrie = new \TwigExtension\FormExtension($this->router, $this->pdo, $this->contenaire);
        $html = "<div class='filtre'>
            <div class='row'>
                ".$extensionTrie->inputAdvance('SELECT', $array)."
            </div>
        </div>";


       
        return $html;
    }
    public function lienMail($array)
    {
        $trad = $this->getTranslationService();
        $html =
        "<li>
            <a class ='mail_pref' href= ".$this->router->generateUri('Specifique112.GestionFacture.specMail', ['numFact' => $array['NUM_FACT'], 'codeSte' => $array['CODE_STE']]).">
                ".$trad->t('Mail CDE régul')."        
            </a>
        </li>";
        return $html;
    }

    public function getTranslationService() :ITrad
    {
        return $this->contenaire->get(ITrad::class);
    }
}
