identifier = 'id_publication'; $this->lang = true; $this->table = 'ads_publication'; $this->className = 'Publication'; $this->bootstrap = true; $this->addRowAction('edit'); $this->_group .= ' GROUP BY app.id_publication'; $this->_select .= ' GROUP_CONCAT(app.page_name) as page_list'; $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'ads_publication_page` app ON (app.`id_publication` = a.`id_publication`)'; parent::__construct(); } public function setMedia() { parent::setMedia(); $this->addJS(_PS_MODULE_DIR_.'blockadshooks/js/admin.js'); } public function renderList() { $this->fields_list = array( 'id_publication' => array( 'title' => 'ID', 'width' => 25, 'class' => 'text-center', ), 'date_from' => array( 'title' => $this->l('Date début'), ), 'date_to' => array( 'title' => $this->l('Date fin'), ), 'page_list' => array( 'title' => 'list des pages' ) ); return parent::renderList(); } public function postProcess() { parent::postProcess(); if(Tools::isSubmit('submitAddads_publication')) { $pages = Tools::getValue('pages'); $this->object->setPages($pages); foreach($pages as $page) { $this->object->setPageInfo($page, Tools::getValue('input-'.$page.'', array())); } } } public function renderForm() { $pages = Publication::getAllPages(); foreach($pages as &$page) { $page = array( 'id' => $page, 'name' => Publication::getPageNameTranslated($page) ); } $this->fields_form = array( 'multilang' => true, 'tinymce' => true, 'legend' => array( 'title' => $this->l('Ads'), ), 'submit' => array( 'title' => $this->l('Save'), ), 'input' => array( array( 'type' => 'textarea', 'label' => $this->l('Contenu de la publicité'), 'name' => 'content', 'lang' => true ), array( 'type' => 'date', 'label' => $this->l('Date de début'), 'name' => 'date_from', ), array( 'type' => 'date', 'label' => $this->l('Date de fin'), 'name' => 'date_to', ), array( 'type' => 'select', 'multiple' => true, 'label' => $this->l('Liste des pages'), 'name' => 'pages', 'options' => array( 'query' => $pages, 'id' => 'id', 'name' => 'name' ) ), array( 'type' => 'relation_posts_cms', 'name' => 'input-postcms', 'label' => $this->l('Sélectionner des articles'), 'id' => 'postcms', 'query' => $this->object->getInfos('postcms'), 'form_group_class' => 'form-group-page form-group-postcms', ), array( 'type' => 'relation_posts_edito', 'name' => 'input-postedito', 'label' => $this->l('Sélectionner des éditos'), 'id' => 'postedito', 'query' => $this->object->getInfos('postedito'), 'form_group_class' => 'form-group-page form-group-postedito', ), array( 'type' => 'relation_category_cms', 'name' => 'input-categorycms', 'label' => $this->l("Sélectionner les catégories d article"), 'id' => 'categorycms', 'query' => $this->object->getInfos('categorycms'), 'form_group_class' => 'form-group-page form-group-categorycms', ), ) ); return parent::renderForm(); } }