Update: 2026-05-07 02:01:59
This commit is contained in:
@@ -122,16 +122,31 @@ try {
|
||||
|
||||
// Mark queue item done
|
||||
$db->prepare("UPDATE invoice_processing_queue SET status = 'done', invoice_id = ?, processed_at = NOW() WHERE id = ?")->execute([$invoiceId, $queueId]);
|
||||
|
||||
|
||||
// Update batch progress
|
||||
$db->prepare("UPDATE invoice_batches SET processed_images = processed_images + 1 WHERE id = ?")->execute([$batchId]);
|
||||
|
||||
$db->commit();
|
||||
echo "Success: Created Invoice $invoiceId\n";
|
||||
|
||||
// Send silent push update for progress
|
||||
$stmt = $db->prepare("SELECT total_images, processed_images, uploaded_by FROM invoice_batches WHERE id = ?");
|
||||
$stmt->execute([$batchId]);
|
||||
$currentBatch = $stmt->fetch();
|
||||
if ($currentBatch) {
|
||||
$notifier = new NotificationService();
|
||||
$notifier->sendDataNotification($currentBatch['uploaded_by'], [
|
||||
'type' => 'batch_progress',
|
||||
'batch_id' => $batchId,
|
||||
'processed' => $currentBatch['processed_images'],
|
||||
'total' => $currentBatch['total_images']
|
||||
]);
|
||||
}
|
||||
|
||||
// Increment Quota
|
||||
QuotaMiddleware::incrementInvoiceUsage($tenantId);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$db->rollBack();
|
||||
echo "DB Error: " . $e->getMessage() . "\n";
|
||||
|
||||
Reference in New Issue
Block a user