<?php

namespace ModulesGarden\HostingQuotaNotifications\App\UI\TicketTemplates\Pages\EditSubPages;


use ModulesGarden\HostingQuotaNotifications\App\UI\TicketTemplates\Buttons\EditSubPages\MassDeleteLangButton;
use ModulesGarden\HostingQuotaNotifications\Core\UI\Widget\DataTable\DataProviders\Providers\ArrayDataProvider;
use \ModulesGarden\HostingQuotaNotifications\Core\UI\Widget\DataTable\DataTable;
use \ModulesGarden\HostingQuotaNotifications\Core\UI\Interfaces\AdminArea;
use \ModulesGarden\HostingQuotaNotifications\Core\UI\Widget\DataTable\DataProviders\DataProvider;
use \ModulesGarden\HostingQuotaNotifications\Core\UI\Widget\DataTable\Column;
use \ModulesGarden\HostingQuotaNotifications\App\UI\TicketTemplates\Buttons\EditSubPages\DeleteLangButton;
use \ModulesGarden\HostingQuotaNotifications\App\UI\TicketTemplates\Buttons\EditSubPages\EditLangButton;
use \ModulesGarden\HostingQuotaNotifications\App\Helper\ScriptsHelper;
use \ModulesGarden\HostingQuotaNotifications\App\UI\TicketTemplates\Providers\TicketTemplatesLangsProvider;
use \ModulesGarden\HostingQuotaNotifications\App\UI\TicketTemplates\Buttons\EditSubPages\AddLangButton;


/**
 * 
 * Description of TicketTemplateLangs
 *
 * @author Artur Pilch <artur.pi@modulesgarden.com>
 */
class TicketTemplateLangs extends DataTable implements AdminArea
{
    protected $id    = 'templateSettings';
    protected $name  = 'templateSettings';
    protected $title = 'langs';

    public function __construct($baseId)
    {
        parent::__construct($baseId);
    }

    protected function loadHtml()
    {
        $this
                ->addColumn((new Column('id'))
                        ->setOrderable(DataProvider::SORT_ASC)
                        ->setSearchable(true, Column::TYPE_INT))
                ->addColumn((new Column('lang'))
                        ->setOrderable()
                        ->setSearchable(true))
                ->addColumn((new Column('subject'))
                        ->setOrderable()
                        ->setSearchable(true))
                ->addColumn((new Column('message'))
                        ->setOrderable()
                        ->setSearchable(true));
    }

    public function initContent()
    {
        $script = ScriptsHelper::getContentScript('sms_center_modal');
        $this->mainContainer->setScriptHtml($script);

        $this->addButton(new AddLangButton());

        $this->addActionButton(new EditLangButton());
        $this->addActionButton(new DeleteLangButton());
        $this->addMassActionButton(new MassDeleteLangButton());
    }

    public function loadData()
    {
        $provider = new TicketTemplatesLangsProvider();
        $query    = $provider->getTemplateLangs();
        $dataProv = new ArrayDataProvider();
        $dataProv->setData($query);
        $this->setDataProvider($dataProv);
    }
}
