diff --git a/hesabixCore/src/Controller/HesabdariController.php b/hesabixCore/src/Controller/HesabdariController.php index 6528590..76cd6a1 100644 --- a/hesabixCore/src/Controller/HesabdariController.php +++ b/hesabixCore/src/Controller/HesabdariController.php @@ -20,6 +20,7 @@ use App\Entity\StoreroomTicket; use App\Service\Access; use App\Service\AccountingPermissionService; use App\Service\Explore; +use App\Service\Extractor; use App\Service\Jdate; use App\Service\JsonResp; use App\Service\Log; @@ -1091,5 +1092,46 @@ class HesabdariController extends AbstractController return $this->json(['result' => 1, 'id' => $code]); } + #[Route('/api/hesabdari/print/{id}', name: 'app_hesabdari_print', methods: ['POST'])] + public function app_hesabdari_print(Request $request, Provider $provider, Extractor $extractor, Access $access, EntityManagerInterface $entityManager, $id): JsonResponse + { + $acc = $access->hasRole('accounting'); + if (!$acc) { + throw $this->createAccessDeniedException(); + } + $params = $request->getPayload()->all(); + + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy(['bid' => $acc['bid'], 'code' => $id]); + if (!$doc) { + return $this->json($extractor->notFound()); + } + + $printOptions = [ + 'paper' => 'A4-L' + ]; + if (array_key_exists('printOptions', $params)) { + if (array_key_exists('paper', $params['printOptions'])) { + $printOptions['paper'] = $params['printOptions']['paper']; + } + } + + $pdfPid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/printers/doc.html.twig', [ + 'doc' => $doc, + 'bid' => $acc['bid'], + 'page_title' => 'سند حسابداری', + 'rows' => $doc->getHesabdariRows(), + 'printOptions' => $printOptions, + 'invoiceDate' => $doc->getDate(), + ]), + false, + $printOptions['paper'] + ); + + return $this->json($extractor->operationSuccess($pdfPid)); + + } } diff --git a/hesabixCore/templates/pdf/base.html.twig b/hesabixCore/templates/pdf/base.html.twig index a638383..2348dc8 100644 --- a/hesabixCore/templates/pdf/base.html.twig +++ b/hesabixCore/templates/pdf/base.html.twig @@ -41,7 +41,11 @@
تاریخ: - {{ Jdate.GetTodayDate() }} + {% if invoiceDate is defined %} + {{ invoiceDate }} + {% else %} + {{ Jdate.GetTodayDate() }} + {% endif %}
+ + شماره سند: + {{ doc.code }} + + |
+
+ + نوع سند: + {% if doc.type == 'cost' %} + هزینه + {% elseif doc.type == 'income' %} + درآمد + {% elseif doc.type == 'sell' %} + فروش + {% elseif doc.type == 'buy' %} + خرید + {% elseif doc.type == 'rfbuy' %} + برگشت از خرید + {% elseif doc.type == 'rfsell' %} + برگشت از فروش + {% else %} + سند پایه + {% endif %} + + |
+
+ + توضیحات: + {{ doc.des }} + + |
+
ردیف | +جدول حساب | +مرجع | +تفضیل | +بستانکار | +بدهکار | +توضیحات | +
---|---|---|---|---|---|---|
{{ rowIndex }} | +{{ item.ref.name }} | ++ {% if item.person %} + شخص + {% elseif item.commodity %} + کالا و خدمات + {% elseif item.bank %} + بانک + {% elseif item.cashdesk %} + تنخواه گردان + {% elseif item.salary %} + صندوق + {% else %} + حسابها + {% endif %} + | ++ {% if item.person %} + {{item.person.nikename}} + {% elseif item.commodity %} + {{item.commodity.name}} + {% elseif item.bank %} + {{item.bank.name}} + {% elseif item.cashdesk %} + {{item.salary.name}} + {% elseif item.salary %} + {{item.cashdesk.name}} + {% else %} + {{item.ref.name}} + {% endif %} + | +{{ item.bs | number_format(0, '.', ',') }} | +{{ item.bd | number_format(0, '.', ',') }} | +{{ item.des }} | +
+ + مهر و امضا حسابدار ++ |
+
+ + مهر و امضا مدیر مالی +++ |
+