diff --git a/hesabixCore/src/Controller/AvatarController.php b/hesabixCore/src/Controller/AvatarController.php index 4eb3192..1225a7c 100644 --- a/hesabixCore/src/Controller/AvatarController.php +++ b/hesabixCore/src/Controller/AvatarController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Entity\Business; use App\Service\Access; use App\Service\Log; use Doctrine\ORM\EntityManagerInterface; @@ -16,6 +17,18 @@ use Symfony\Component\String\Slugger\SluggerInterface; class AvatarController extends AbstractController { + #[Route('/front/avatar/file/get/{id}', name: 'front_avatar_file_get')] + public function front_avatar_file_get(string $id,EntityManagerInterface $entityManager,$code = 0): BinaryFileResponse + { + $bid = $entityManager->getRepository(Business::class)->find($id); + if(! $bid) + throw $this->createNotFoundException(); + $fileAdr = dirname(__DIR__,3) . '/hesabixArchive/avatars/'. $bid->getAvatar(); + if(!$bid->getAvatar()) return new BinaryFileResponse(dirname(__DIR__,3) . '/hesabixArchive/avatars/default.png'); + $response = new BinaryFileResponse($fileAdr); + return $response; + } + #[Route('/api/avatar/get', name: 'api_avatar_get')] public function api_avatar_get(Access $access): Response { diff --git a/hesabixCore/src/Controller/Front/ShortlinksController.php b/hesabixCore/src/Controller/Front/ShortlinksController.php index 1d2e5ea..5d40926 100644 --- a/hesabixCore/src/Controller/Front/ShortlinksController.php +++ b/hesabixCore/src/Controller/Front/ShortlinksController.php @@ -5,6 +5,8 @@ namespace App\Controller\Front; use App\Entity\Business; use App\Entity\HesabdariDoc; use App\Entity\HesabdariRow; +use App\Entity\PrintOptions; +use App\Service\Provider; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; @@ -52,10 +54,63 @@ class ShortlinksController extends AbstractController return $this->render('shortlinks/sell.html.twig', [ 'bid' => $doc->getBid(), 'doc' => $doc, + 'link'=>$link, 'rows' => $items, 'person'=> $person, 'totalPays'=>$totalPays, 'msg'=>$msg ]); } + + #[Route('/slpdf/sell/{bid}/{link}', name: 'shortlinks_pdf')] + public function shortlinks_pdf(string $bid, string $link, EntityManagerInterface $entityManager, Provider $provider): Response + { + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'type' => 'sell', + 'id' => $link + ]); + if (!$doc) throw $this->createNotFoundException(); + $bid = $entityManager->getRepository(Business::class)->find($bid); + if (!$bid) throw $this->createNotFoundException(); + $person = null; + $discount = 0; + $transfer = 0; + foreach ($doc->getHesabdariRows() as $item) { + if ($item->getPerson()) { + $person = $item->getPerson(); + } elseif ($item->getRef()->getCode() == 104) { + $discount = $item->getBd(); + } elseif ($item->getRef()->getCode() == 61) { + $transfer = $item->getBs(); + } + } + $printOptions = [ + 'bidInfo' => true, + 'pays' =>true, + 'taxInfo' =>true, + 'discountInfo' =>true, + 'note' =>true, + 'paper' =>'A4-L' + ]; + $note = ''; + $printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$bid]); + if($printSettings){$note = $printSettings->getSellNoteString();} + $pdfPid = $provider->createPrint( + $bid, + $this->getUser(), + $this->renderView('pdf/printers/sell.html.twig', [ + 'bid' => $bid, + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + 'person' => $person, + 'discount' => $discount, + 'transfer' => $transfer, + 'printOptions'=> $printOptions, + 'note'=> $note + ]), + false, + $printOptions['paper'] + ); + return $this->redirectToRoute('app_front_print',['id'=>$pdfPid]); + } } diff --git a/hesabixCore/templates/shortlinks/sell.html.twig b/hesabixCore/templates/shortlinks/sell.html.twig index 56f288c..5dec56b 100644 --- a/hesabixCore/templates/shortlinks/sell.html.twig +++ b/hesabixCore/templates/shortlinks/sell.html.twig @@ -10,13 +10,10 @@
+

مشاهده فاکتور

- - - ورود به حسابیکس -
@@ -36,10 +33,10 @@
- + {% if (totalPays < doc.amount) and bid.walletEnable %} @@ -177,6 +174,10 @@
+ جمع کل فاکتور: + {{ doc.amount | number_format }} +
+
توضیحات: {{ doc.des }}