162 lines
6.2 KiB
PHP
162 lines
6.2 KiB
PHP
<?php
|
|
|
|
require_once (dirname(__FILE__) . '/../../x13allegro.php');
|
|
|
|
final class AdminXAllegroAssocController extends XAllegroController
|
|
{
|
|
private $categoriesController;
|
|
private $manufacturersController;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->table = 'xallegro_configuration';
|
|
$this->identifier = 'id_xallegro_configuration';
|
|
$this->className = 'XAllegroConfiguration';
|
|
|
|
parent::__construct();
|
|
|
|
$this->categoriesController = new AdminXAllegroAssocCategoriesController();
|
|
$this->categoriesController->token = $this->token;
|
|
$this->categoriesController->init();
|
|
|
|
$this->manufacturersController = new AdminXAllegroAssocManufacturersController();
|
|
$this->manufacturersController->token = $this->token;
|
|
$this->manufacturersController->init();
|
|
|
|
$this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, Tab::getIdFromClassName('AdminXAllegroAssoc'));
|
|
}
|
|
|
|
public function postProcess()
|
|
{
|
|
foreach ($_GET as $get => $value) {
|
|
// add, update, delete
|
|
if (preg_match('/^((?!id_).*)xallegro_(.*)$/', $get, $m)) {
|
|
if ($m[2] == 'category') {
|
|
$controller = $this->context->link->getAdminLink('AdminXAllegroAssocCategories');
|
|
$identifier = $this->categoriesController->identifier;
|
|
}
|
|
else if ($m[2] == 'manufacturer') {
|
|
$controller = $this->context->link->getAdminLink('AdminXAllegroAssocManufacturers');
|
|
$identifier = $this->manufacturersController->identifier;
|
|
}
|
|
else {
|
|
continue;
|
|
}
|
|
|
|
$url = $controller . '&' . $get . '&' . $identifier . '=' . Tools::getValue($identifier);
|
|
if (strpos($m[1], 'submitBulk') !== false) {
|
|
unset($_POST['token']);
|
|
$url .= '&' . http_build_query($_POST);
|
|
}
|
|
|
|
Tools::redirectAdmin($url);
|
|
}
|
|
|
|
unset($m);
|
|
}
|
|
|
|
return parent::postProcess();
|
|
}
|
|
|
|
public function initPageHeaderToolbar()
|
|
{
|
|
if (empty($this->display))
|
|
{
|
|
$this->page_header_toolbar_btn['allegro_current'] = array(
|
|
'href' => $this->context->link->getAdminLink('AdminXAllegroAssocCategories') . '&add' . $this->categoriesController->table,
|
|
'desc' => $this->l('Dodaj powiązanie kategorii'),
|
|
'icon' => 'process-icon-new'
|
|
);
|
|
|
|
$this->page_header_toolbar_btn['allegro_sold'] = array(
|
|
'href' => $this->context->link->getAdminLink('AdminXAllegroAssocManufacturers') . '&add' . $this->manufacturersController->table,
|
|
'desc' => $this->l('Dodaj powiązanie producenta'),
|
|
'icon' => 'process-icon-new'
|
|
);
|
|
}
|
|
|
|
parent::initPageHeaderToolbar();
|
|
}
|
|
|
|
public function init()
|
|
{
|
|
parent::init();
|
|
|
|
$this->getFieldsOptions();
|
|
}
|
|
|
|
public function beforeUpdateOptions()
|
|
{
|
|
$this->redirect_after = $this->context->link->getAdminLink('AdminXAllegroAssoc') . '&conf=6';
|
|
}
|
|
|
|
private function getFieldsOptions()
|
|
{
|
|
$this->fields_options = array(
|
|
'general' => array(
|
|
'title' => $this->l('Ustawienia globalnych powiązań'),
|
|
'image' => false,
|
|
'description' => $this->l('Dla poniższych parametrów moduł spróbuje ustawić wartość automatycznie, bazując na danych produktu PrestaShop.'),
|
|
'fields' => array(
|
|
'AUCTION_USE_EAN' => array(
|
|
'title' => $this->l('Automatyczne powiązanie pola "EAN"'),
|
|
'type' => 'bool'
|
|
),
|
|
'PARAMETERS_GLOBAL_ISBN' => array(
|
|
'title' => $this->l('Automatyczne powiązanie pola "ISBN"'),
|
|
'desc' => (version_compare(_PS_VERSION_, '1.7.0.0', '<')
|
|
? $this->l('Opcja dostępna od PrestaShop 1.7')
|
|
: $this->l('Bazuje na polu "ISBN" z PrestaShop. Powiązuje pola "ISBN" oraz "ISSN".')),
|
|
'type' => 'bool',
|
|
'disabled' => version_compare(_PS_VERSION_, '1.7.0.0', '<')
|
|
),
|
|
'PARAMETERS_GLOBAL_CONDITION' => array(
|
|
'title' => $this->l('Automatyczne powiązanie pola "Stan"'),
|
|
'type' => 'bool',
|
|
'desc' => $this->l('Bazuje na polu "Stan" z PrestaShop. Dotyczy tylko wartości "Nowy" i "Używany".')
|
|
),
|
|
'PARAMETERS_GLOBAL_REFERENCE' => array(
|
|
'title' => $this->l('Automatyczne powiązanie pola "Kod producenta"'),
|
|
'type' => 'bool',
|
|
'desc' => $this->l('Bazuje na polu "Indeks" z PrestaShop. Powiązuje pola "Kod producenta", "Numer katalogowy", "Numer katalogowy producenta", "Numer katalogowy części".')
|
|
),
|
|
'PARAMETERS_GLOBAL_MANUFACTURER' => array(
|
|
'title' => $this->l('Automatyczne powiązanie pola "Producent"'),
|
|
'type' => 'bool',
|
|
'desc' => $this->l('Bazuje na polu "Marka/Producent" z PrestaShop. Powiązuje pola "Marka", "Producent", "Producent części".')
|
|
)
|
|
),
|
|
'submit' => array(
|
|
'title' => $this->l('Zapisz')
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
public function initContent()
|
|
{
|
|
parent::initContent();
|
|
|
|
$messages = [
|
|
'confirmations',
|
|
'informations',
|
|
'warnings',
|
|
'errors'
|
|
];
|
|
|
|
foreach ($messages as $message) {
|
|
$this->{$message} = array_merge(
|
|
$this->{$message},
|
|
$this->categoriesController->{$message},
|
|
$this->manufacturersController->{$message}
|
|
);
|
|
}
|
|
}
|
|
|
|
public function renderList()
|
|
{
|
|
return $this->categoriesController->renderList() .
|
|
$this->manufacturersController->renderList();
|
|
}
|
|
}
|