Integrate dynamic booking data and add Economic sync task

Enhanced PDF generation with dynamic booking, department, and customer data, improving template variability. Introduced a new cron job and script to sync Economic invoice statuses, ensuring data consistency and error handling in automated tasks.
This commit is contained in:
Jepp9350
2025-04-09 15:10:30 +02:00
parent 110ac5c28f
commit ce2e233e5f
4 changed files with 131 additions and 20 deletions
@@ -39,17 +39,23 @@ class wash_certificate extends html2pdf_template
//$html .= self::getSignature();
$html .= self::setDocumentFields(
'123',
'123',
'123',
'123',
self::getKey('time') . ' ' . self::getKey('date'),
self::getKey('carried_out_by'),
self::getKey('seal_number'),
);
$html .= self::setDocumentRegistrationNumberFields(
'123',
'123',
self::getKey('reg_1'),
self::getKey('reg_2'),
);
$html .= self::setDocumentCustomerSupplierFields(
'123',
'123',
[
self::getKey('customer_name'),
self::getKey('customer_address'),
],
[
self::getKey('department_name'),
self::getKey('department_address'),
],
);
$html .= self::setSignatureField(
'123',
@@ -106,23 +112,43 @@ class wash_certificate extends html2pdf_template
';
}
private function setDocumentCustomerSupplierFields(string $customer_details_column, string $supplier_details_column): string
private function setDocumentCustomerSupplierFields(array $customer_details_column, array $supplier_details_column): string
{
$column_width_px = 257;
$spacer_width_px = 32;
$column_2_additional_width_px = 12;
// Parse the customer details column
$customer_details_html = '';
foreach ( $customer_details_column as $key => $value ) {
// If the item is the first item, add a strong tag
if ($key === 0) {
$customer_details_html .= '<strong>' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '</strong><br>';
} else {
$customer_details_html .= htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '<br>';
}
}
// Parse the supplier details column
$supplier_details_html = '';
foreach ( $supplier_details_column as $key => $value ) {
// If the item is the first item, add a strong tag
if ($key === 0) {
$supplier_details_html .= '<strong>' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '</strong><br>';
} else {
$supplier_details_html .= htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '<br>';
}
}
return '
<table style="position: absolute; top: 720px; left: 0; width: 100%; border-collapse: collapse; margin-left: 72px; margin-right: 72px; align-content: space-between;">
<table style="position: absolute; top: 712px; left: 0; width: 100%; border-collapse: collapse; margin-left: 72px; margin-right: 72px; align-content: space-between;">
<tr>
<td style="width: ' . $column_width_px . 'px; align-content: center; text-align: center; border: 1px solid transparent;">
<strong>' . htmlspecialchars($customer_details_column, ENT_QUOTES, 'UTF-8') . '</strong>
' . $customer_details_html . '
</td>
<!-- Spacer -->
<td style="max-width: ' . $spacer_width_px . 'px; align-content: center; text-align: center; border: 1px solid transparent; min-width: ' . $spacer_width_px . 'px; padding: 0; margin: 0;">
<div style="width: ' . $spacer_width_px . 'px; height: 1px; background-color: transparent;"></div>
</td>
<td style="width: ' . ($column_width_px + $column_2_additional_width_px) . 'px; align-content: center; text-align: center; border: 1px solid transparent;">
<strong>' . htmlspecialchars($supplier_details_column, ENT_QUOTES, 'UTF-8') . '</strong>
' . $supplier_details_html . '
</td>
</tr>
</table>
@@ -132,12 +158,13 @@ class wash_certificate extends html2pdf_template
private function setSignatureField(string $column_1): string
{
$column_width_px = 219;
$column_height_px = 30;
$margin_left_px = 263;
$margin_right_px = $margin_left_px;
return '
<table style="position: absolute; top: 878px; left: 0; width: 100%; border-collapse: collapse; margin-left: ' . $margin_left_px . 'px; ' . $margin_right_px . 'px; align-content: space-between;">
<table style="position: absolute; top: 878px; left: 0; width: 100%; border-collapse: collapse; margin-left: ' . $margin_left_px . 'px; ' . $margin_right_px . 'px; align-content: space-between; max-height: ' . $column_height_px . 'px; min-height: ' . $column_height_px . 'px;">
<tr>
<td style="width: ' . $column_width_px . 'px; align-content: center; text-align: center; border: 1px solid black;">
<td style="width: ' . $column_width_px . 'px; align-content: center; text-align: center; border: 1px solid black; min-height: ' . $column_height_px . 'px; max-height: ' . $column_height_px . 'px;">
<strong>' . htmlspecialchars($column_1, ENT_QUOTES, 'UTF-8') . '</strong>
</td>
</tr>