<?php

namespace Modules\ProjetAchat\Controller;

use Skeleton\Controller\Controller;
use Helpers\Ariane\Ariane;

class TableOperationController extends Controller
{
    public function tableOperationAction() : string
    {
        $post = $this->request->getParsedBody();
        
        // TRADUCTION DES TEXTES
        
        $trad = $this->getTranslationService();
        

        if (!$post) {
            $post['tri_CODE_OPE']='asc';
        }

        
        $DoarOp = new \Entity\Model\DoarOpe($this->pdo);
        $listeTableOperation = $DoarOp->fetchAll([], $post);
        

        Ariane::generate(0, $trad->t('Gestion'), $post, count($listeTableOperation));
        
        $paginator = new \Helpers\Pagination\Paginator();
        $infopagination = $paginator->generate($listeTableOperation, 0, $post, $this->renderer);
        
        
        return $this->renderer->render('@tableOperation/index', [
            'menuActive'             => 'ProjetAchat',
            
            'infoPagination'         => $infopagination,
            'listeTableOperation'    => $listeTableOperation,
        ]);
    }
}
