70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace KupShop\BalikonosBundle\Admin\Tabs;
|
|
|
|
use KupShop\AdminBundle\Admin\WindowTab;
|
|
use KupShop\BalikonosBundle\Balikobot;
|
|
use KupShop\KupShopBundle\Query\JsonOperator;
|
|
use Query\Operator;
|
|
|
|
class BalikobotSuppliersTab extends WindowTab
|
|
{
|
|
protected $title = 'flapBalikobotSuppliers';
|
|
|
|
protected $template = 'window/suppliers.balikobot.tpl';
|
|
|
|
public static function getTypes()
|
|
{
|
|
return [
|
|
'suppliers' => 1,
|
|
];
|
|
}
|
|
|
|
public static function isAllowed()
|
|
{
|
|
return findModule(\Modules::BALIKONOS, 'provider') === 'balikobot';
|
|
}
|
|
|
|
public function getVars($smarty_tpl_vars)
|
|
{
|
|
$packages = sqlQueryBuilder()
|
|
->select('*')
|
|
->from('balikonos')
|
|
->andWhere('close >= 1')
|
|
->andWhere(
|
|
Operator::equals(
|
|
[
|
|
JsonOperator::value('data', 'type') => Balikobot::TYPE_CUSTOM,
|
|
]
|
|
)
|
|
)
|
|
->andWhere(
|
|
Operator::like(
|
|
[
|
|
JsonOperator::value('data', 'id_supplier') => $this->getID(),
|
|
]
|
|
)
|
|
)->orderBy('id', 'DESC')
|
|
->execute()->fetchAll();
|
|
|
|
$packages = array_map(function ($x) {
|
|
$x['data'] = json_decode($x['data'], true);
|
|
$time = explode('_', $x['data']['balikobot_array']['eid']);
|
|
$time = end($time);
|
|
$x['date'] = (new \DateTime())->setTimestamp($time);
|
|
|
|
return $x;
|
|
}, $packages);
|
|
|
|
return [
|
|
'packages' => $packages,
|
|
'deliveries' => \Delivery::getAll(),
|
|
];
|
|
}
|
|
|
|
public function getLabel()
|
|
{
|
|
return translate('balikobot', 'suppliers');
|
|
}
|
|
}
|