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
+25
View File
@@ -2,6 +2,7 @@
// prevent direct access
use classes\backup_store;
use classes\economic;
use objects\bookings_o;
use objects\logs_o;
use objects\users_o;
@@ -57,6 +58,12 @@ $cron_tasks = [
'next_run' => 0,
'function' => 'backup',
],
'SyncEconomicInvoiceStatus' => [
'interval' => 60, // 1 minute
'last_run' => 0,
'next_run' => 0,
'function' => 'SyncEconomicInvoiceStatus',
],
];
function checkUnfulfilledBookings(): void
@@ -103,6 +110,24 @@ function SyncUserEconomicCustomerDetails(): void
$users_o->syncAllUsersEconomicCustomerDetails();
}
/**
* @throws Exception
*/
function SyncEconomicInvoiceStatus(): void
{
$economic = new economic();
try {
$economic->getTasks()->runCheckErrors();
} catch (Exception $e) {
// Do nothing, this is automatically running
}
try {
$economic->getTasks()->runCheckDrafts();
} catch (Exception $e) {
// Do nothing, this is automatically running
}
}
foreach ( $cron_tasks as $task => $data ) {
$lastRun = redis->get_last_crond_run($task) === null ? 0 : redis->get_last_crond_run($task);
$nextRun = $lastRun + $data['interval'];