|
|
|
|
|
|
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Controller\Backend; |
|
|
|
|
|
|
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
|
use FOS\UserBundle\Model\UserManagerInterface; |
|
|
|
|
|
use Lc\ShopBundle\Context\DocumentInterface; |
|
|
|
|
|
use Lc\ShopBundle\Context\MerchantUtilsInterface; |
|
|
|
|
|
use Lc\ShopBundle\Context\OrderUtilsInterface; |
|
|
|
|
|
use Lc\ShopBundle\Services\Utils; |
|
|
|
|
|
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; |
|
|
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
|
|
|
|
use Symfony\Component\Security\Core\Security; |
|
|
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
|
|
|
|
|
|
|
|
|
|
class DocumentController extends AdminController |
|
|
|
|
|
{ |
|
|
|
|
|
protected $documentRepository ; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils, TranslatorInterface $translator) |
|
|
|
|
|
{ |
|
|
|
|
|
parent::__construct($security, $userManager, $em, $utils, $merchantUtils, $mailjetTransport, $orderUtils, $translator); |
|
|
|
|
|
$this->documentRepository = $this->em->getRepository($this->em->getClassMetadata(DocumentInterface::class)->getName()) ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function downloadInvoiceAction() |
|
|
|
|
|
{ |
|
|
|
|
|
$idDocument = $this->request->get('id') ; |
|
|
|
|
|
$document = $this->documentRepository->find($idDocument) ; |
|
|
|
|
|
|
|
|
|
|
|
$orderShop = null ; |
|
|
|
|
|
if($document) { |
|
|
|
|
|
$orderShops = $document->getOrderShops() ; |
|
|
|
|
|
$orderShop = (isset($orderShops[0])) ? $orderShops[0] : null ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if($document && $orderShop) { |
|
|
|
|
|
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
throw new NotFoundHttpException('Document introuvable') ; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |