first commit
This commit is contained in:
64
admin/printCenter/printCenter.Reclamations.php
Normal file
64
admin/printCenter/printCenter.Reclamations.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
use KupShop\ReclamationsBundle\Util\ReclamationsUtil;
|
||||
|
||||
class PrintCenterReclamations extends Base
|
||||
{
|
||||
protected $template = 'printCenter/reclamations_zebra.tpl';
|
||||
|
||||
protected function get_vars()
|
||||
{
|
||||
$vars = parent::get_vars();
|
||||
|
||||
/** @var ReclamationsUtil $reclamations */
|
||||
$reclamations = ServiceContainer::getService(ReclamationsUtil::class);
|
||||
|
||||
if ($ID = getVal('ID')) {
|
||||
$reclamation = $reclamations->getReclamation($ID);
|
||||
|
||||
$vars['reclamation'] = $reclamation;
|
||||
|
||||
$boughtDate = sqlQueryBuilder()
|
||||
->select('COALESCE(o.date_handle, o.date_created) as date')
|
||||
->from('order_items', 'oi')
|
||||
->join('oi', 'orders', 'o', 'o.id = oi.id_order')
|
||||
->where(\Query\Operator::equals(['oi.id' => $reclamation->getIdItem()]))
|
||||
->execute()->fetchColumn();
|
||||
|
||||
$vars['boughtDate'] = new DateTime($boughtDate);
|
||||
|
||||
$productEan = $reclamation->getItem()['ean'] ?? false;
|
||||
if (findModule(Modules::PRODUCTS_SUPPLIERS) && $productEan) {
|
||||
$vars['product_barcode_chars'] = formatEAN($productEan);
|
||||
}
|
||||
|
||||
$item = $reclamation->getItem();
|
||||
if (findModule(Modules::PRODUCTS_SUPPLIERS)) {
|
||||
$suppliersCodes = sqlQueryBuilder()->select('s.id, s.name, pos.code')
|
||||
->from('products_of_suppliers', 'pos')
|
||||
->leftJoin('pos', 'suppliers', 's', 's.id = pos.id_supplier')
|
||||
->where(\Query\Operator::equalsNullable(['id_product' => $item['id_product'], 'id_variation' => $item['id_variation']]))
|
||||
->execute()->fetchAll();
|
||||
|
||||
$vars['suppliers_codes'] = \KupShop\KupShopBundle\Util\Functional\Mapping::mapKeys($suppliersCodes, function ($k, $v) {
|
||||
return [$v['id'], $v];
|
||||
});
|
||||
}
|
||||
|
||||
if (findModule(\Modules::PRODUCTS_SERIAL_NUMBERS)) {
|
||||
$serialNumber = sqlQueryBuilder()
|
||||
->select('psn.serial_number')
|
||||
->from('products_serial_numbers', 'psn')
|
||||
->where(\Query\Operator::equalsNullable(['psn.id_product' => $item['id_product'], 'psn.id_variation' => $item['id_variation'], 'psn.id_order_item' => $item['id']]))
|
||||
->execute()->fetchOne();
|
||||
|
||||
$vars['serial_number'] = $serialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
||||
(new PrintCenterReclamations())->run();
|
||||
Reference in New Issue
Block a user