Browse Source

Backend : téléchargement de documents

feature/export_comptable
Guillaume 4 years ago
parent
commit
b4ecb7d4a3
1 changed files with 45 additions and 0 deletions
  1. +45
    -0
      ShopBundle/Controller/Backend/DocumentController.php

+ 45
- 0
ShopBundle/Controller/Backend/DocumentController.php View File

@@ -0,0 +1,45 @@
<?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') ;
}
}

}

Loading…
Cancel
Save