46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
use KupShop\KupShopBundle\Context\PosContext;
|
|
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
|
use KupShop\KupShopBundle\Util\Contexts;
|
|
use KupShop\POSBundle\Event\PosPaymentEvent;
|
|
use KupShop\POSBundle\Util\PosPaymentUtil;
|
|
use Query\Operator;
|
|
|
|
class PosCustom extends Payment
|
|
{
|
|
public static $name = '[Pokladna] Nastavitelná platba';
|
|
protected ?string $defaultIcon = '../../common/static/payments/prodejna_hotove.svg';
|
|
|
|
public $class = 'PosCustom';
|
|
|
|
public $method;
|
|
|
|
protected $pay_method = Payment::METHOD_UNKNOWN;
|
|
|
|
public function createPayment($session, $price = null, $data = [])
|
|
{
|
|
$pos = Contexts::get(PosContext::class)->getActive();
|
|
|
|
$posPaymentUtil = ServiceContainer::getService(PosPaymentUtil::class);
|
|
$posPaymentUtil->changeOrderDelivery($pos->getId(), $this->order, 'CUSTOM');
|
|
|
|
$idPayment = sqlQueryBuilder()
|
|
->select('id_payment')
|
|
->from('delivery_type', 'dt')
|
|
->andWhere(Operator::equals(['dt.id' => $pos->getCustomDeliveryType()]))
|
|
->execute()
|
|
->fetchOne();
|
|
|
|
$eventDispatcher = ServiceContainer::getService('event_dispatcher');
|
|
$eventDispatcher->dispatch(new PosPaymentEvent($pos, $price, $idPayment, $this->order), PosPaymentEvent::POS_CUSTOM_PAYMENT);
|
|
|
|
return true;
|
|
}
|
|
|
|
public static function isEnabled($className)
|
|
{
|
|
return findModule(Modules::NEW_POS);
|
|
}
|
|
}
|