60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
use KupShop\AdminBundle\AdminList\BaseList;
|
|
use KupShop\AdminBundle\Query\Invert;
|
|
|
|
class VatsList extends BaseList
|
|
{
|
|
protected $tableDef = [
|
|
'id' => 'id',
|
|
'fields' => [
|
|
'Popis DPH' => ['field' => 'descr'],
|
|
'Procento' => ['field' => 'vat'],
|
|
'Priorita' => ['field' => 'is_default', 'render' => 'renderDefault'],
|
|
],
|
|
];
|
|
|
|
public function customizeTableDef($tableDef)
|
|
{
|
|
$tableDef = parent::customizeTableDef($tableDef);
|
|
|
|
if (findModule(Modules::OSS_VATS)) {
|
|
$tableDef['fields']['Země'] = ['field' => 'name'];
|
|
$this->orderParam = [
|
|
'sort' => 'Země',
|
|
'direction' => 'ASC',
|
|
];
|
|
}
|
|
|
|
return $tableDef;
|
|
}
|
|
|
|
public function renderDefault($values, $column)
|
|
{
|
|
$value = $this->getListRowValue($values, $column['field']);
|
|
|
|
return ($value == 'Y') ? 'Hlavní' : '';
|
|
}
|
|
|
|
public function getQuery()
|
|
{
|
|
$qb = sqlQueryBuilder()->select('v.id, v.descr, v.vat, v.is_default')->from('vats', 'v');
|
|
|
|
if (findModule(Modules::OSS_VATS)) {
|
|
$qb->leftJoin('v', 'countries', 'c', 'c.id = v.id_country')->addSelect('c.name');
|
|
|
|
$countries = getVal('country', $_GET);
|
|
$countries_invert = getVal('country_invert', $_GET);
|
|
if (!empty($countries)) {
|
|
$qb->andWhere(Invert::checkInvert(\Query\Operator::inStringArray($countries, 'id_country'), isset($countries_invert)));
|
|
}
|
|
|
|
if ($automanaged = getVal('automanaged')) {
|
|
$qb->andWhere(\Query\Operator::inIntArray($automanaged, 'v.automanaged'));
|
|
}
|
|
}
|
|
|
|
return $qb;
|
|
}
|
|
}
|