From a15baf88b44b80aef63bd921a0b8165a1ef45c8e Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 11 Jan 2026 17:07:31 +0000 Subject: [PATCH] Drukowane dokumenty pdf --- _bulk_print_attendance_list.php | 112 + _bulk_print_badges.php | 25 +- index.php | 29 + lib/tfpdf/font/courier.php | 8 + lib/tfpdf/font/courierb.php | 8 + lib/tfpdf/font/courierbi.php | 8 + lib/tfpdf/font/courieri.php | 8 + lib/tfpdf/font/helvetica.php | 19 + lib/tfpdf/font/helveticab.php | 19 + lib/tfpdf/font/helveticabi.php | 19 + lib/tfpdf/font/helveticai.php | 19 + lib/tfpdf/font/symbol.php | 19 + lib/tfpdf/font/times.php | 19 + lib/tfpdf/font/timesb.php | 19 + lib/tfpdf/font/timesbi.php | 19 + lib/tfpdf/font/timesi.php | 19 + lib/tfpdf/font/unifont/DejaVuSans-Bold.ttf | Bin 0 -> 705684 bytes .../font/unifont/DejaVuSans-BoldOblique.ttf | Bin 0 -> 643292 bytes .../font/unifont/DejaVuSans-ExtraLight.ttf | Bin 0 -> 355380 bytes lib/tfpdf/font/unifont/DejaVuSans-Oblique.ttf | Bin 0 -> 635416 bytes lib/tfpdf/font/unifont/DejaVuSans.ttf | Bin 0 -> 757076 bytes .../font/unifont/DejaVuSansCondensed-Bold.ttf | Bin 0 -> 665028 bytes .../DejaVuSansCondensed-BoldOblique.ttf | Bin 0 -> 611836 bytes .../unifont/DejaVuSansCondensed-Oblique.ttf | Bin 0 -> 599292 bytes .../font/unifont/DejaVuSansCondensed.ttf | Bin 0 -> 680264 bytes .../font/unifont/DejaVuSansMono-Bold.ttf | Bin 0 -> 331992 bytes .../unifont/DejaVuSansMono-BoldOblique.ttf | Bin 0 -> 253580 bytes .../font/unifont/DejaVuSansMono-Oblique.ttf | Bin 0 -> 251932 bytes lib/tfpdf/font/unifont/DejaVuSansMono.ttf | Bin 0 -> 340712 bytes lib/tfpdf/font/unifont/DejaVuSerif-Bold.ttf | Bin 0 -> 356088 bytes .../font/unifont/DejaVuSerif-BoldItalic.ttf | Bin 0 -> 347460 bytes lib/tfpdf/font/unifont/DejaVuSerif-Italic.ttf | Bin 0 -> 345996 bytes lib/tfpdf/font/unifont/DejaVuSerif.ttf | Bin 0 -> 380132 bytes .../unifont/DejaVuSerifCondensed-Bold.ttf | Bin 0 -> 331244 bytes .../DejaVuSerifCondensed-BoldItalic.ttf | Bin 0 -> 346508 bytes .../unifont/DejaVuSerifCondensed-Italic.ttf | Bin 0 -> 345324 bytes .../font/unifont/DejaVuSerifCondensed.ttf | Bin 0 -> 346664 bytes lib/tfpdf/font/unifont/DejaVu_LICENSE.txt | 99 + lib/tfpdf/font/unifont/ttfonts.php | 1090 ++++++++ lib/tfpdf/font/zapfdingbats.php | 19 + lib/tfpdf/tfpdf.php | 2371 +++++++++++++++++ 41 files changed, 3935 insertions(+), 13 deletions(-) create mode 100644 _bulk_print_attendance_list.php create mode 100644 lib/tfpdf/font/courier.php create mode 100644 lib/tfpdf/font/courierb.php create mode 100644 lib/tfpdf/font/courierbi.php create mode 100644 lib/tfpdf/font/courieri.php create mode 100644 lib/tfpdf/font/helvetica.php create mode 100644 lib/tfpdf/font/helveticab.php create mode 100644 lib/tfpdf/font/helveticabi.php create mode 100644 lib/tfpdf/font/helveticai.php create mode 100644 lib/tfpdf/font/symbol.php create mode 100644 lib/tfpdf/font/times.php create mode 100644 lib/tfpdf/font/timesb.php create mode 100644 lib/tfpdf/font/timesbi.php create mode 100644 lib/tfpdf/font/timesi.php create mode 100644 lib/tfpdf/font/unifont/DejaVuSans-Bold.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSans-BoldOblique.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSans-ExtraLight.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSans-Oblique.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSans.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSansCondensed-Bold.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSansCondensed-BoldOblique.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSansCondensed-Oblique.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSansCondensed.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSansMono-Bold.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSansMono-BoldOblique.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSansMono-Oblique.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSansMono.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSerif-Bold.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSerif-BoldItalic.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSerif-Italic.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSerif.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSerifCondensed-Bold.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSerifCondensed-BoldItalic.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSerifCondensed-Italic.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVuSerifCondensed.ttf create mode 100644 lib/tfpdf/font/unifont/DejaVu_LICENSE.txt create mode 100644 lib/tfpdf/font/unifont/ttfonts.php create mode 100644 lib/tfpdf/font/zapfdingbats.php create mode 100644 lib/tfpdf/tfpdf.php diff --git a/_bulk_print_attendance_list.php b/_bulk_print_attendance_list.php new file mode 100644 index 0000000..b9e1966 --- /dev/null +++ b/_bulk_print_attendance_list.php @@ -0,0 +1,112 @@ + ['message' => $error_message], 'correlation_id' => $correlation_id]); + exit; +} + +// Input validation +$person_ids = json_decode($_POST['person_ids'] ?? '[]', true); +error_log($correlation_id . ': Received ' . count($person_ids) . ' person_ids.'); + +if (empty($person_ids)) { + if (ob_get_length()) ob_end_clean(); + http_response_code(400); + header('Content-Type: application/json'); + $error_message = 'Nie wybrano żadnych osób.'; + error_log($correlation_id . ': ' . $error_message); + echo json_encode(['error' => ['message' => $error_message], 'correlation_id' => $correlation_id]); + exit; +} + +$workflowEngine = new WorkflowEngine(); +$peopleDetails = $workflowEngine->getPeopleDetails($person_ids); +error_log($correlation_id . ': Fetched ' . count($peopleDetails) . ' rows from database.'); + +class PDF extends tFPDF +{ + function __construct($orientation = 'P', $unit = 'mm', $size = 'A4') + { + parent::__construct($orientation, $unit, $size); + $this->AddFont('DejaVu', '', 'DejaVuSans.ttf', true); + $this->AddFont('DejaVu', 'B', 'DejaVuSans-Bold.ttf', true); + $this->SetFont('DejaVu', '', 14); + } + + function generateAttendanceList($people) + { + $this->AddPage(); + + // Title + $this->SetFont('DejaVu', 'B', 20); + $this->Cell(0, 10, 'Lista obecności', 0, 1, 'C'); + $this->Ln(2); + + // Subtitle - Date + $this->SetFont('DejaVu', '', 10); + $this->Cell(0, 10, date('Y-m-d H:i'), 0, 1, 'C'); + $this->Ln(10); + + // Table Header + $this->SetFont('DejaVu', 'B', 12); + $this->SetFillColor(240, 240, 240); + $this->Cell($this->GetPageWidth() * 0.7, 10, 'Imię i nazwisko', 1, 0, 'L', true); + $this->Cell($this->GetPageWidth() * 0.3 - $this->lMargin - $this->rMargin, 10, 'Podpis', 1, 1, 'L', true); + + // Table Body + $this->SetFont('DejaVu', '', 12); + foreach ($people as $person) { + $name = $person['first_name'] . ' ' . $person['last_name']; + $this->Cell($this->GetPageWidth() * 0.7, 15, $name, 1, 0, 'L'); + $this->Cell($this->GetPageWidth() * 0.3 - $this->lMargin - $this->rMargin, 15, '', 1, 1, 'L'); + } + } +} + +$pdf = new PDF(); +$pdf->generateAttendanceList($peopleDetails); + +$pdfData = $pdf->Output('S'); +error_log($correlation_id . ': PDF data generated. Length: ' . strlen($pdfData) . ' bytes.'); + +if (empty($pdfData)) { + if (ob_get_length()) ob_end_clean(); + http_response_code(500); + header('Content-Type: application/json'); + $error_message = 'Failed to generate PDF data.'; + error_log($correlation_id . ': ' . $error_message); + echo json_encode(['error' => ['message' => $error_message], 'correlation_id' => $correlation_id]); + exit; +} + +if (ob_get_length()) { + ob_end_clean(); +} + +header('Content-Type: application/pdf'); +header('Content-Disposition: attachment; filename="lista-obecnosci.pdf"'); +header('Content-Transfer-Encoding: binary'); +header('Cache-Control: private, max-age=0, must-revalidate'); +header('Pragma: public'); +header('Content-Length: ' . strlen($pdfData)); + +echo $pdfData; +exit; \ No newline at end of file diff --git a/_bulk_print_badges.php b/_bulk_print_badges.php index 8822d03..6e52f8d 100644 --- a/_bulk_print_badges.php +++ b/_bulk_print_badges.php @@ -1,17 +1,16 @@ getPeopleDetails($person_ids); error_log($correlation_id . ': Fetched ' . count($peopleDetails) . ' rows from database.'); -class PDF extends FPDF +class PDF extends tFPDF { function __construct($orientation='P', $unit='mm', $size='A4') { parent::__construct($orientation, $unit, $size); - $this->AddFont('DejaVu','','DejaVuSans.php'); - $this->AddFont('DejaVu','B','DejaVuSans-Bold.php'); + $this->AddFont('DejaVu','','DejaVuSans.ttf',true); + $this->AddFont('DejaVu','B','DejaVuSans-Bold.ttf',true); + $this->SetFont('DejaVu', '', 14); } function generateBadge($person) { diff --git a/index.php b/index.php index a2a65fa..2083052 100644 --- a/index.php +++ b/index.php @@ -108,6 +108,7 @@ $status_colors = [
  • Bulk Initialize Instances
  • Drukuj badge
  • +
  • Drukuj listę obecności