From 943ad9f83192d82cc97cc1854cd2d71e5ef096c4 Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Thu, 8 Aug 2024 00:39:06 +0330 Subject: [PATCH] some progress in repservice plugin and add footer output on api --- .../Controller/Front/UiGeneralController.php | 11 + .../Plugins/PlugRepserviceController.php | 35 +--- hesabixCore/src/Entity/PrinterQueue.php | 15 ++ hesabixCore/src/Service/Provider.php | 3 +- hesabixCore/src/Service/pdfMGR.php | 8 +- hesabixCore/templates/avatar/index.html.twig | 20 -- hesabixCore/templates/general/about.html.twig | 2 +- hesabixCore/templates/hook/index.html.twig | 20 -- hesabixCore/templates/notes/index.html.twig | 20 -- .../pdf/printers/repservice/invoice.html.twig | 194 ++++++++++++++++++ 10 files changed, 238 insertions(+), 90 deletions(-) delete mode 100644 hesabixCore/templates/avatar/index.html.twig delete mode 100644 hesabixCore/templates/hook/index.html.twig delete mode 100644 hesabixCore/templates/notes/index.html.twig create mode 100644 hesabixCore/templates/pdf/printers/repservice/invoice.html.twig diff --git a/hesabixCore/src/Controller/Front/UiGeneralController.php b/hesabixCore/src/Controller/Front/UiGeneralController.php index 43ea3f4..cf58509 100644 --- a/hesabixCore/src/Controller/Front/UiGeneralController.php +++ b/hesabixCore/src/Controller/Front/UiGeneralController.php @@ -9,11 +9,13 @@ use App\Entity\ChangeReport; use App\Entity\HesabdariDoc; use App\Entity\PrinterQueue; use App\Entity\User; +use App\Entity\Settings; use App\Service\pdfMGR; use App\Service\Provider; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Mailer\Exception\TransportExceptionInterface; use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Routing\Annotation\Route; @@ -148,4 +150,13 @@ class UiGeneralController extends AbstractController return $this->render('general/hesabixbox.html.twig',); } + #[Route('/api/system/get/data', name: 'general_apps_get_data')] + public function general_apps_get_data(EntityManagerInterface $entityManager): JsonResponse + { + $settings = $entityManager->getRepository(Settings::class)->findAll()[0]; + return $this->json([ + 'footer' => $settings->getFooter() + ]); + } + } diff --git a/hesabixCore/src/Controller/Plugins/PlugRepserviceController.php b/hesabixCore/src/Controller/Plugins/PlugRepserviceController.php index 327fae8..927c9d9 100644 --- a/hesabixCore/src/Controller/Plugins/PlugRepserviceController.php +++ b/hesabixCore/src/Controller/Plugins/PlugRepserviceController.php @@ -287,8 +287,8 @@ class PlugRepserviceController extends AbstractController return $this->json(['result' => 1]); } - #[Route('/api/repservice/print/invoice', name: 'app_sell_print_invoice')] - public function app_sell_print_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + #[Route('/api/repservice/print/invoice', name: 'app_repservice_print_invoice')] + public function app_repservice_print_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse { $params = []; if ($content = $request->getContent()) { @@ -298,43 +298,26 @@ class PlugRepserviceController extends AbstractController $acc = $access->hasRole('plugRepservice'); if (!$acc) throw $this->createAccessDeniedException(); - $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + $doc = $entityManager->getRepository(PlugRepserviceOrder::class)->findOneBy([ 'bid' => $acc['bid'], 'code' => $params['code'] ]); if (!$doc) 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(); - } - } + $pdfPid = 0; - $note = ''; - $printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$acc['bid']]); - if($printSettings){$note = $printSettings->getSellNoteString();} + + $printOptions = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$acc['bid']]); $pdfPid = $provider->createPrint( $acc['bid'], $this->getUser(), - $this->renderView('pdf/printers/sell.html.twig', [ + $this->renderView('pdf/printers/repservice/invoice.html.twig', [ 'bid' => $acc['bid'], 'doc' => $doc, - 'rows' => $doc->getHesabdariRows(), - 'person' => $person, - 'printInvoice' => $params['printers'], - 'discount' => $discount, - 'transfer' => $transfer, 'printOptions'=> $printOptions, - 'note'=> $note ]), false, - $printOptions['paper'] + $printOptions->getRepservicePaper(), + false ); return $this->json(['id' => $pdfPid]); } diff --git a/hesabixCore/src/Entity/PrinterQueue.php b/hesabixCore/src/Entity/PrinterQueue.php index 6f18cf3..96d2f25 100644 --- a/hesabixCore/src/Entity/PrinterQueue.php +++ b/hesabixCore/src/Entity/PrinterQueue.php @@ -36,6 +36,9 @@ class PrinterQueue #[ORM\Column(length: 50, nullable: true)] private ?string $paperSize = null; + #[ORM\Column(nullable: true)] + private ?bool $footer = null; + public function getId(): ?int { return $this->id; @@ -124,4 +127,16 @@ class PrinterQueue return $this; } + + public function isFooter(): ?bool + { + return $this->footer; + } + + public function setFooter(?bool $footer): static + { + $this->footer = $footer; + + return $this; + } } diff --git a/hesabixCore/src/Service/Provider.php b/hesabixCore/src/Service/Provider.php index cb26572..470cd89 100644 --- a/hesabixCore/src/Service/Provider.php +++ b/hesabixCore/src/Service/Provider.php @@ -147,7 +147,7 @@ class Provider return $result; } - public function createPrint(Business $bid, User $user, String $data,$posPrint = false,$paperSize = 'A4-L') + public function createPrint(Business $bid, User $user, String $data,$posPrint = false,$paperSize = 'A4-L',$footer = true) { $print = new PrinterQueue(); $print->setDateSubmit(time()); @@ -156,6 +156,7 @@ class Provider $print->setPaperSize($paperSize); $print->setView($data); $print->setPosprint($posPrint); + $print->setFooter($footer); $print->setPid($this->RandomString(128)); $this->entityManager->persist($print); $this->entityManager->flush(); diff --git a/hesabixCore/src/Service/pdfMGR.php b/hesabixCore/src/Service/pdfMGR.php index d87d884..eccdaf1 100644 --- a/hesabixCore/src/Service/pdfMGR.php +++ b/hesabixCore/src/Service/pdfMGR.php @@ -48,10 +48,14 @@ class pdfMGR 'tempDir' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mpdf', 'autoArabic' => true, ]); - $mpdf->SetHTMLFooter($footer); + if($printQueue->isFooter()){ + $mpdf->SetHTMLFooter($footer); + } + $mpdf->WriteHTML($printQueue->getView()); $mpdf->SetAutoPageBreak(true); - $mpdf->Output(); + $mpdf->SetTitle('حسابیکس'); + $mpdf->Output('Hesabix PrintOut.pdf', 'I'); } public function streamTwig2PDFInvoiceType(PrinterQueue $printQueue, $configs = []) diff --git a/hesabixCore/templates/avatar/index.html.twig b/hesabixCore/templates/avatar/index.html.twig deleted file mode 100644 index 9a3a6f9..0000000 --- a/hesabixCore/templates/avatar/index.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Hello AvatarController!{% endblock %} - -{% block body %} - - -
-

Hello {{ controller_name }}! ✅

- - This friendly message is coming from: - -
-{% endblock %} diff --git a/hesabixCore/templates/general/about.html.twig b/hesabixCore/templates/general/about.html.twig index 2d2e850..4c3389d 100644 --- a/hesabixCore/templates/general/about.html.twig +++ b/hesabixCore/templates/general/about.html.twig @@ -148,7 +148,7 @@

- حسابیکس به صورت متن‌باز ارايه شده و دسترسی به کد منبع محصولات از طریق GitHub در دسترس می‌باشد. + حسابیکس به صورت متن‌باز ارائه شده و دسترسی به کد منبع محصولات از طریق GitHub در دسترس می‌باشد.

diff --git a/hesabixCore/templates/hook/index.html.twig b/hesabixCore/templates/hook/index.html.twig deleted file mode 100644 index ba08a42..0000000 --- a/hesabixCore/templates/hook/index.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Hello HookController!{% endblock %} - -{% block body %} - - -
-

Hello {{ controller_name }}! ✅

- - This friendly message is coming from: - -
-{% endblock %} diff --git a/hesabixCore/templates/notes/index.html.twig b/hesabixCore/templates/notes/index.html.twig deleted file mode 100644 index 6ac030a..0000000 --- a/hesabixCore/templates/notes/index.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Hello NotesController!{% endblock %} - -{% block body %} - - -
-

Hello {{ controller_name }}! ✅

- - This friendly message is coming from: - -
-{% endblock %} diff --git a/hesabixCore/templates/pdf/printers/repservice/invoice.html.twig b/hesabixCore/templates/pdf/printers/repservice/invoice.html.twig new file mode 100644 index 0000000..68017d2 --- /dev/null +++ b/hesabixCore/templates/pdf/printers/repservice/invoice.html.twig @@ -0,0 +1,194 @@ + + + + + + + +
+
+
+ + + + + + + + + + + +
+ + +

{{ bid.name }}

+
+

رسید تحویل کالا

+
+

+ تاریخ: + {{ doc.date }}

+
+

+ شماره: + {{ doc.code }}

+ +
+

+ آدرس: + + استان + {{ bid.ostan }}، شهر + {{ bid.shahrestan }}، + {{ bid.address }} +

+

+ تلفن تماس:{{ bid.tel }} +

+
+
+
+
+ مشتری +
+ + + + + + + + + + +
+

+ نام: + + {{ doc.person.nikename }} +

+
+

+ تلفن همراه + {{ doc.person.mobile }} +

+
+

+ آدرس: + + {{ doc.person.address }} +

+
+
+
+
+ اطلاعات +
+ + + + + + + + + + + + + + +
+

+ نام کالا: + + {{ doc.commodity.name }} +

+
+

+ مدل: + + {{ doc.model }} +

+
+

+ رنگ: + + {{ doc.color }} +

+
+

+ سریال: + + {{ doc.serial }} +

+
+

+ پلاک: + + {{ doc.pelak }} +

+
+

+ شرح: + + {{ doc.des }} +

+
+

+ متعلقات: + + {{ doc.motaleghat }} +

+
+
+
+ + + + + + +
+

+ مهر و امضا تحویل گیرنده +
+ {{ doc.submitter.fullname }} +

+
+
+ +
+ + + + + + +
+ {{ printOptions.repserviceNoteString}} +
+
+
+ + + +