diff --git a/hesabixCore/src/Controller/AdminController.php b/hesabixCore/src/Controller/AdminController.php index ef86e72..4bb2507 100644 --- a/hesabixCore/src/Controller/AdminController.php +++ b/hesabixCore/src/Controller/AdminController.php @@ -503,7 +503,7 @@ class AdminController extends AbstractController #[Route('/api/admin/logs/last', name: 'api_admin_logs_last')] public function api_admin_logs_last(Jdate $jdate, EntityManagerInterface $entityManager): JsonResponse { - $logs = $entityManager->getRepository(\App\Entity\Log::class)->findBy([], ['id' => 'DESC'], 250); + $logs = $entityManager->getRepository(\App\Entity\Log::class)->findBy([], ['id' => 'ASC'], 250); $temps = []; foreach ($logs as $log) { $temp = []; diff --git a/hesabixCore/src/Controller/PersonsController.php b/hesabixCore/src/Controller/PersonsController.php index de61514..ee1c19c 100644 --- a/hesabixCore/src/Controller/PersonsController.php +++ b/hesabixCore/src/Controller/PersonsController.php @@ -683,7 +683,8 @@ class PersonsController extends AbstractController $this->renderView('pdf/person_card.html.twig', [ 'page_title' => 'کارت حساب' . ' ' . $person->getNikename(), 'bid' => $acc['bid'], - 'items' => $transactions + 'items' => $transactions, + 'person' => $person ]) ); return $this->json(['id' => $pid]); diff --git a/hesabixCore/src/Service/Twig.php b/hesabixCore/src/Service/Twig.php new file mode 100644 index 0000000..49bad3b --- /dev/null +++ b/hesabixCore/src/Service/Twig.php @@ -0,0 +1,16 @@ +getProjectDir()); + + parent::__construct($loader); + } +} \ No newline at end of file diff --git a/hesabixCore/src/Service/pdfMGR.php b/hesabixCore/src/Service/pdfMGR.php index 99ae09f..4a3479a 100644 --- a/hesabixCore/src/Service/pdfMGR.php +++ b/hesabixCore/src/Service/pdfMGR.php @@ -3,21 +3,27 @@ namespace App\Service; use App\Entity\PrinterQueue; -use Dompdf\Dompdf; -use Symfony\Component\HttpFoundation\Response; +use App\Service\Twig; + use Twig\Environment; class pdfMGR { private $twig; - public function __construct(Environment $twig) + public function __construct(Twig $twig) { $this->twig = $twig; } public function streamTwig2PDF(PrinterQueue $printQueue,$configs = []){ + // Load Twig File + $template = $this->twig->load('pdf/footer.html.twig'); + // Render HTML + $footer = $template->render([ + + ]); $defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults(); $fontDirs = $defaultConfig['fontDir']; $mpdf = new \Mpdf\Mpdf([ @@ -37,9 +43,10 @@ class pdfMGR 'tempDir' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mpdf', 'autoArabic' => true, ]); - $mpdf->AddFontDirectory(__DIR__ . '../Fonts'); + $mpdf->SetHTMLFooter($footer); $mpdf->WriteHTML($printQueue->getView()); + $mpdf->SetAutoPageBreak(true); $mpdf->Output(); } diff --git a/hesabixCore/templates/pdf/base.html.twig b/hesabixCore/templates/pdf/base.html.twig index 0e2a6c3..04c8ee0 100644 --- a/hesabixCore/templates/pdf/base.html.twig +++ b/hesabixCore/templates/pdf/base.html.twig @@ -1,12 +1,57 @@ - + + + + +
- -{{ page_title }}
-
+ |
+
+ {{bid.name}}+{{ page_title }}+ |
+
+ + تاریخ: + {{ Jdate.GetTodayDate() }} + + |
+