* @copyright Copyright (c) 2018-2024 - www.x13.pl * @license Commercial license, only to use on restricted domains */ if (!defined('_PS_VERSION_')) { exit; } require_once _PS_MODULE_DIR_ . '/x13gpsr/x13gpsr.ion.php'; class AdminX13GPSRMonitoringController extends x13gpsr\GPSRModuleAdminControllerCustomList { public $multishop_context = Shop::CONTEXT_ALL; public function getCustomListProductsWithNoBrand() { return $this->getCustomList( 'no_brand_products', $this->l('List of products without a brand'), 'AND a.`id_manufacturer` = 0', [], [ 'assignToBrand' => [ 'text' => $this->l('Assign brand to products'), 'icon' => 'icon-cogs xgpsr-bulk-assign-button xgpsr-bulk-assign-button-type-brand' ] ] ); } public function getCustomListProductsNoResponsibleManufacturer() { $productsWithNoResponsibleManufacturer = implode(',', array_column($this->productsWithNoResponsibleManufacturer, 'id_product')); if ($productsWithNoResponsibleManufacturer) { $filter = 'AND a.id_product IN (' . $productsWithNoResponsibleManufacturer . ')'; } else { $filter = 'AND a.id_product IN (0)'; } $return = $this->getCustomList( 'no_responsible_manufacturer_products', $this->l('List of products without a responsible manufacturer'), $filter, [ 'manufacturer_name' => [ 'title' => $this->l('Brand'), 'filter_key' => 'm!name', ], ], [ 'assignToManufacturer' => [ 'text' => $this->l('Assign responsible manufacturer to products'), 'icon' => 'icon-building xgpsr-bulk-assign-button xgpsr-bulk-assign-button-type-responsible_manufacturer', ] ] ); return $return; } public function getCustomListProductsNoResponsiblePerson() { $productsWithNoResponsiblePerson = implode(',', array_column($this->productsWithNoResponsiblePerson, 'id_product')); if ($productsWithNoResponsiblePerson) { $filter = 'AND a.id_product IN (' . $productsWithNoResponsiblePerson . ')'; } else { $filter = 'AND a.id_product IN (0)'; } $return = $this->getCustomList( 'no_responsible_person_products', $this->l('List of products without a responsible person'), $filter, [ 'manufacturer_name' => [ 'title' => $this->l('Brand'), 'filter_key' => 'm!name', ], ], [ 'assignToPerson' => [ 'text' => $this->l('Assign responsible person to products'), 'icon' => 'icon-user xgpsr-bulk-assign-button xgpsr-bulk-assign-button-type-responsible_person', ] ] ); return $return; } protected function clearFilters() { $filterIds = [ 'no_responsible_manufacturer_products', 'no_brand_products', 'no_responsible_person_products', ]; foreach ($filterIds as $filterId) { if (Tools::isSubmit('submitReset' . $filterId)) { $this->processResetFilters($filterId); } } } protected function getCustomInfoByList($listId) { $hasDefaultResponsibleManufacturerAssigned = \Configuration::get(ConfigKeys::MANUFACTURER_NO_BRAND); $defaultResponsibleManufacturerName = false; if ($hasDefaultResponsibleManufacturerAssigned) { $defaultResponsibleManufacturerName = (new XGpsrResponsibleManufacturer(\Configuration::get(ConfigKeys::MANUFACTURER_NO_BRAND), $this->context->language->id))->private_name; } $this->context->smarty->assign([ 'hasDefaultResponsibleManufacturerAssigned' => $hasDefaultResponsibleManufacturerAssigned, 'defaultResponsibleManufacturerName' => $defaultResponsibleManufacturerName, ]); $info = [ 'no_responsible_manufacturer_products' => $this->context->smarty->fetch( _PS_MODULE_DIR_ . 'x13gpsr/views/templates/admin/monitoring/info_no_responsible_manufacturer_products.tpl' ), 'no_brand_products' => $this->context->smarty->fetch( _PS_MODULE_DIR_ . 'x13gpsr/views/templates/admin/monitoring/info_no_brand_products.tpl' ), 'no_responsible_person_products' => $this->context->smarty->fetch( _PS_MODULE_DIR_ . 'x13gpsr/views/templates/admin/monitoring/info_no_responsible_person_products.tpl' ), ]; return array_key_exists($listId, $info) ? $info[$listId] : ''; } protected function addRowActionByListId($listId) { switch ($listId) { case 'no_responsible_manufacturer_products': $this->addRowAction('xGpsrProductUpdateResponsibleManufacturer'); break; case 'no_brand_products': $this->addRowAction('xGpsrProductUpdateBrand'); break; case 'no_responsible_person_products': $this->addRowAction('xGpsrProductUpdateResponsiblePerson'); break; } } }