<?php

require_once __DIR__ . '/../../require.php';

use SwissStyle\Viewer\Controller\Viewer;

/**
 * Class AdminDesignsController
 * @extends ModuleAdminControllerCore
 * @property ContextCore $context
 * @property array $toolbar_btn
 * @property array $breadcrumbs
 * @property array $tpl_view_vars
 * @method l
 * @method createTemplate
 */
class AdminDesignsController extends ModuleAdminController {

	protected $buttons_status = array();

	public function __construct() {
		$this->table = 'admin_designs';
		$this->className = 'AdminDesignsController';
		$this->identifier = 'admin_designs';

		$this->buttons_status['new']      = true;
		$this->buttons_status['back']     = true;

		$this->addJquery();
		$this->addJqueryUI(array(
			'ui.core',
			'ui.widget'
		));
		$this->addjQueryPlugin(array(
			'autocomplete',
			'ajaxfileupload',
			'date',
			'tagify',
			'select2',
			'validate',
			'tablednd'
		));

		$this->addJS(array(
			_PS_JS_DIR_.'admin-dnd.js',
		));

		$this->page_header_toolbar_btn['new_clipart'] = array(
			'href' => 'index.php?tab=AdminDesigns&addclipart=1&token=' . Tools::getValue('token') .
				((isset($_REQUEST['category_id']) ? '&category_id=' . $_REQUEST['category_id'] : '' )),
			'desc' => $this->l('Add new clipart', null, null, false),
			'icon' => 'process-icon-new'
		);

		parent::__construct();

		$this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, Tab::getIdFromClassName('AdminDesigns'));
		$this->renderView($_REQUEST);
	}

	public function renderView($args) {

		$this->bootstrap = true;
		$this->lang = true;

		$this->initToolbar();
		$this->initToolbarTitle();
		$this->content .= Viewer::renderBlock('adminStructure',[
			'content' => Viewer::renderBlock('adminDesigns',$args)
		]);

		return parent::renderView();
	}
}