From f25b6ab8dc6c172dccc9ddc8084ee8eac6a10460 Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Wed, 16 Apr 2025 18:59:21 +0000 Subject: [PATCH] bug fix in cheque in custom footer text in documents --- .../src/Controller/ChequeController.php | 26 ++ .../src/Controller/PrintersController.php | 6 + .../src/Controller/StoreroomController.php | 33 ++ hesabixCore/src/Entity/PrintOptions.php | 30 ++ hesabixCore/src/Service/PluginService.php | 12 +- hesabixCore/src/Service/pdfMGR.php | 13 +- hesabixCore/src/Service/twigFunctions.php | 25 ++ hesabixCore/templates/pdf/footer.html.twig | 6 +- .../pdf/printers/storeroom/exist.html.twig | 167 +++++++++ .../src/components/forms/Hcommoditysearch.vue | 2 +- webUI/src/views/acc/cheque/input.vue | 62 +++- webUI/src/views/acc/cheque/output.vue | 72 ++-- webUI/src/views/acc/settings/print.vue | 54 ++- .../commodityCheck/checkByStoreroom.vue | 325 ++++++++++-------- 14 files changed, 639 insertions(+), 194 deletions(-) create mode 100644 hesabixCore/templates/pdf/printers/storeroom/exist.html.twig diff --git a/hesabixCore/src/Controller/ChequeController.php b/hesabixCore/src/Controller/ChequeController.php index a49dade..33e1769 100644 --- a/hesabixCore/src/Controller/ChequeController.php +++ b/hesabixCore/src/Controller/ChequeController.php @@ -64,6 +64,32 @@ class ChequeController extends AbstractController ->getQuery() ->getResult(); + $allCheques = array_merge($chequesInput, $chequesOutput); + foreach ($allCheques as $cheque) { + $rows = $entityManager->getRepository(HesabdariRow::class)->findBy(['cheque' => $cheque]); + foreach ($rows as $row) { + $doc = $row->getDoc(); + if(count($doc->getHesabdariRows()) == 1){ + $exrow = $doc->getHesabdariRows()[0]; + $newrow = new HesabdariRow(); + $newrow->setDoc($doc); + $newrow->setCheque($cheque); + $newrow->setYear($exrow->getYear()); + $newrow->setBid($acc['bid']); + $newrow->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 126])); + if($exrow->getBs() == '0'){ + $newrow->setBs($exrow->getBd()); + $newrow->setBd(0); + }else{ + $newrow->setBs(0); + $newrow->setBd($exrow->getBs()); + } + $newrow->setDes($exrow->getDes()); + $entityManager->persist($newrow); + $entityManager->flush(); + } + } + } return $this->json([ 'input' => Explore::SerializeCheques(array_reverse($chequesInput)), 'output' => Explore::SerializeCheques(array_reverse($chequesOutput)) diff --git a/hesabixCore/src/Controller/PrintersController.php b/hesabixCore/src/Controller/PrintersController.php index 8adeb2d..5fe1223 100644 --- a/hesabixCore/src/Controller/PrintersController.php +++ b/hesabixCore/src/Controller/PrintersController.php @@ -104,6 +104,9 @@ class PrintersController extends AbstractController $temp['rfsell']['paper'] = 'A4-L'; } + $temp['global']['leftFooter'] = $settings->getLeftFooter(); + $temp['global']['rightFooter'] = $settings->getRightFooter(); + return $this->json($temp); } @@ -168,6 +171,9 @@ class PrintersController extends AbstractController $settings->setFastsellInvoice($params['fastsell']['invoice']); $settings->setFastsellPdf($params['fastsell']['pdf']); + $settings->setLeftFooter($params['global']['leftFooter']); + $settings->setRightFooter($params['global']['rightFooter']); + $entityManager->persist($settings); $entityManager->flush(); $log->insert('تنظیمات چاپ', 'تنظیمات چاپ به روز رسانی شد.', $this->getUser(), $acc['bid']->getId()); diff --git a/hesabixCore/src/Controller/StoreroomController.php b/hesabixCore/src/Controller/StoreroomController.php index 502d017..931c30a 100644 --- a/hesabixCore/src/Controller/StoreroomController.php +++ b/hesabixCore/src/Controller/StoreroomController.php @@ -674,4 +674,37 @@ class StoreroomController extends AbstractController ); return $this->json(['id' => $pdfPid]); } + + #[Route('/api/storeroom/exist/print', name: 'app_storeroom_exist_print')] + public function app_storeroom_exist_print(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('store'); + if (!$acc) + throw $this->createAccessDeniedException(); + + // لود کردن اطلاعات انبار از دیتابیس + $storeroom = $entityManager->getRepository(Storeroom::class)->find($params['storeroom']); + if (!$storeroom) { + throw $this->createNotFoundException('انبار مورد نظر یافت نشد'); + } + + $pdfPid = 0; + $pdfPid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/printers/storeroom/exist.html.twig', [ + 'title' => 'سنجش موجودی انبار', + 'bid' => $acc['bid'], + 'storeroom' => $storeroom, + 'items' => $params['items'] + ]), + false + ); + return $this->json(['id' => $pdfPid]); + } } diff --git a/hesabixCore/src/Entity/PrintOptions.php b/hesabixCore/src/Entity/PrintOptions.php index 27f4db4..790cc1c 100644 --- a/hesabixCore/src/Entity/PrintOptions.php +++ b/hesabixCore/src/Entity/PrintOptions.php @@ -120,6 +120,12 @@ class PrintOptions #[ORM\Column(nullable: true)] private ?bool $fastsellCashdeskTicket = null; + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $leftFooter = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $rightFooter = null; + public function getId(): ?int { return $this->id; @@ -544,4 +550,28 @@ class PrintOptions return $this; } + + public function getLeftFooter(): ?string + { + return $this->leftFooter; + } + + public function setLeftFooter(?string $leftFooter): static + { + $this->leftFooter = $leftFooter; + + return $this; + } + + public function getRightFooter(): ?string + { + return $this->rightFooter; + } + + public function setRightFooter(?string $rightFooter): static + { + $this->rightFooter = $rightFooter; + + return $this; + } } diff --git a/hesabixCore/src/Service/PluginService.php b/hesabixCore/src/Service/PluginService.php index 3b84683..b0754d3 100644 --- a/hesabixCore/src/Service/PluginService.php +++ b/hesabixCore/src/Service/PluginService.php @@ -3,11 +3,8 @@ namespace App\Service; use App\Entity\Business; -use App\Entity\HesabdariDoc; use App\Entity\Plugin; -use App\Entity\PlugRepserviceOrder; -use App\Entity\User; -use App\Module\RemoteAddress; +use App\Entity\PluginProdect; use Doctrine\ORM\EntityManagerInterface; class PluginService @@ -22,6 +19,13 @@ class PluginService public function isActive(string $plugin, Business | string | null $bid = null ): bool { + // بررسی فعال بودن پلاگین به صورت پیش‌فرض + $pluginProduct = $this->em->getRepository(PluginProdect::class)->findOneBy(['code' => $plugin]); + if ($pluginProduct && $pluginProduct->isDefaultOn()) { + return true; + } + + // اگر پلاگین به صورت پیش‌فرض فعال نباشد، بررسی می‌کنیم که آیا برای این کسب‌وکار فعال است یا خیر if(is_string($bid)) $bid = $this->em->getRepository(Business::class)->find($bid); $ps = $this->em->getRepository(Plugin::class)->findBy([ diff --git a/hesabixCore/src/Service/pdfMGR.php b/hesabixCore/src/Service/pdfMGR.php index b95b448..680c639 100644 --- a/hesabixCore/src/Service/pdfMGR.php +++ b/hesabixCore/src/Service/pdfMGR.php @@ -7,20 +7,26 @@ use Twig\Environment; use Mpdf\Mpdf; use Mpdf\Config\ConfigVariables; use Mpdf\Config\FontVariables; +use App\Service\PluginService; class pdfMGR { private $twig; + private $pluginService; - public function __construct(Environment $twig) + public function __construct(Environment $twig, PluginService $pluginService) { $this->twig = $twig; + $this->pluginService = $pluginService; } public function generateTwig2PDF(PrinterQueue $printQueue, $configs = []): string { $template = $this->twig->load('pdf/footer.html.twig'); - $footer = $template->render([]); + $footer = $template->render([ + 'pluginService' => $this->pluginService, + 'bid' => $printQueue->getBid() + ]); $size = $printQueue->getPaperSize() ?: 'A4-L'; @@ -61,8 +67,7 @@ class pdfMGR $mpdf->SetAutoPageBreak(true); $mpdf->SetTitle('PDF Export'); - // به جای Output مستقیم، محتوا رو برگردونید - return $mpdf->Output('', 'S'); // 'S' برای برگرداندن به صورت رشته + return $mpdf->Output('', 'S'); } public function generateTwig2PDFInvoiceType(PrinterQueue $printQueue, $configs = []): string diff --git a/hesabixCore/src/Service/twigFunctions.php b/hesabixCore/src/Service/twigFunctions.php index b6be92a..4ed93fc 100644 --- a/hesabixCore/src/Service/twigFunctions.php +++ b/hesabixCore/src/Service/twigFunctions.php @@ -7,6 +7,7 @@ namespace App\Service; use App\Entity\ChangeReport; use App\Entity\Plugin; use App\Entity\Settings; +use App\Entity\PrintOptions; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -118,4 +119,28 @@ class twigFunctions return $this->request->getUri(); } + public function getFooterText(string $side, PluginService $pluginService, $bid): string + { + // اگر پلاگین accpro فعال نباشد، مقدار پیش‌فرض را برمی‌گرداند + if (!$pluginService->isActive('accpro', $bid)) { + return $side === 'left' ? $this->getStaticData('system', 'footerLeft') : $this->getStaticData('system', 'footerRight'); + } + + // دریافت تنظیمات چاپ + $printOptions = $this->em->getRepository(PrintOptions::class)->findOneBy(['bid' => $bid]); + + if (!$printOptions) { + return $side === 'left' ? $this->getStaticData('system', 'footerLeft') : $this->getStaticData('system', 'footerRight'); + } + + // دریافت متن پانویس بر اساس سمت + $footerText = $side === 'left' ? $printOptions->getLeftFooter() : $printOptions->getRightFooter(); + + // اگر متن null یا خالی باشد، مقدار پیش‌فرض را برمی‌گرداند + if ($footerText === null || $footerText === '') { + return $side === 'left' ? $this->getStaticData('system', 'footerLeft') : $this->getStaticData('system', 'footerRight'); + } + + return $footerText; + } } \ No newline at end of file diff --git a/hesabixCore/templates/pdf/footer.html.twig b/hesabixCore/templates/pdf/footer.html.twig index 7c66935..9868eac 100644 --- a/hesabixCore/templates/pdf/footer.html.twig +++ b/hesabixCore/templates/pdf/footer.html.twig @@ -12,7 +12,7 @@ - {{ twigFunctions.getStaticData('system', 'footerLeft') }} + {{ twigFunctions.getFooterText('right', pluginService, bid) }} صفحه: @@ -21,14 +21,14 @@ {nbpg} - {{ twigFunctions.getStaticData('system', 'footerRight') }} + {{ twigFunctions.getFooterText('left', pluginService, bid) }} - + diff --git a/hesabixCore/templates/pdf/printers/storeroom/exist.html.twig b/hesabixCore/templates/pdf/printers/storeroom/exist.html.twig new file mode 100644 index 0000000..9d37bca --- /dev/null +++ b/hesabixCore/templates/pdf/printers/storeroom/exist.html.twig @@ -0,0 +1,167 @@ + + + + + + + +
+
+
+ + + + + + + + +
+ + +

گزارش موجودی انبار

+
+

+ تاریخ: + {{ "now"|date("Y/m/d H:i") }}

+
+

+ انبار: + {{ storeroom is defined and storeroom is not null ? storeroom.name : 'نامشخص' }}

+
+
+ +
+
+ اطلاعات انبار +
+ + + + + + + + +
+

+ نام انبار: + {{ storeroom is defined and storeroom is not null ? storeroom.name : 'نامشخص' }} +

+
+

+ انباردار: + {{ storeroom is defined and storeroom is not null ? storeroom.manager : 'نامشخص' }} +

+
+

+ آدرس: + {{ storeroom is defined and storeroom is not null ? storeroom.adr : 'نامشخص' }} +

+
+
+ +
+ + + + + + + + + + + + + + + + + {% for item in items %} + + + + + + + + + + + + + {% endfor %} + +
ردیفکد کالادسته بندینام کالاواحدورودیخروجیموجودینقطه سفارشوضعیت
{{ loop.index }}{{ item.commodity.code }}{{ item.commodity.cat.name }}{{ item.commodity.name }}{{ item.commodity.unit.name }}{{ item.input }}{{ item.output }} + {{ item.existCount|abs }} + {% if item.existCount < 0 %} + (منفی) + {% endif %} + {{ item.commodity.orderPoint }} + {% if item.existCount < item.commodity.orderPoint %} + نیاز به شارژ انبار + {% endif %} +
+
+ +
+ + + + + + + +
+

+ توضیحات: +
+ تعداد کل کالاها: {{ items|length }} +

+
+

+ چاپ شده توسط: + {{ app.user.fullname }} +

+
+
+ +
+ + + + + + + +
+

+ مهر و امضا انباردار +

+
+

+ مهر و امضا مدیر: +

+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/webUI/src/components/forms/Hcommoditysearch.vue b/webUI/src/components/forms/Hcommoditysearch.vue index 3abc1a8..6f3be6a 100644 --- a/webUI/src/components/forms/Hcommoditysearch.vue +++ b/webUI/src/components/forms/Hcommoditysearch.vue @@ -385,7 +385,7 @@ export default defineComponent({ async fetchData() { this.loading = true try { - const response = await axios.post('/api/commodity/list', { + const response = await axios.post('/api/commodity/list/search', { page: this.currentPage, itemsPerPage: this.itemsPerPage, search: this.searchQuery, diff --git a/webUI/src/views/acc/cheque/input.vue b/webUI/src/views/acc/cheque/input.vue index 31caddb..8ef839c 100644 --- a/webUI/src/views/acc/cheque/input.vue +++ b/webUI/src/views/acc/cheque/input.vue @@ -30,45 +30,63 @@ - + - + + required :disabled="loading"> + required :disabled="loading"> + required :disabled="loading"> + required :disabled="loading"> + required :disabled="loading"> - + + + + {{ snackbar.text }} + + \ No newline at end of file