41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace KupShop\OrderingBundle\Controller;
|
|
|
|
use KupShop\ContentBundle\View\OrderView;
|
|
use KupShop\KupShopBundle\Routing\TranslatedRoute;
|
|
use KupShop\OrderingBundle\Util\Discount\DiscountGenerator;
|
|
use Query\Operator;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
class PDFCouponController extends AbstractController
|
|
{
|
|
/**
|
|
* @TranslatedRoute(path="/#orderView#/{id_order}/coupon/{id_coupon}", requirements={"id_order": "\d+", "id_coupon": "\d+"}, name="kupshop_orderingbundle_pdfcoupon")
|
|
*
|
|
* @return RedirectResponse
|
|
*/
|
|
public function getCouponPDF(DiscountGenerator $discountGenerator, Request $request, $id_order, $id_coupon)
|
|
{
|
|
OrderView::checkOrderOwnership($id_order, $request->get('cf'));
|
|
|
|
$id_coupon = sqlQueryBuilder()
|
|
->select('id')
|
|
->from('discounts_coupons')
|
|
->where(Operator::equals(['id' => $id_coupon, 'id_order_purchased' => $id_order]))
|
|
->execute()
|
|
->fetchColumn();
|
|
if (!$id_coupon) {
|
|
return new RedirectResponse(createScriptURL([
|
|
'URL' => 'launch.php',
|
|
's' => 'orders',
|
|
'ESCAPE' => 'NO',
|
|
]));
|
|
}
|
|
|
|
return $discountGenerator->getPDFResponse($id_coupon);
|
|
}
|
|
}
|