Update: 2026-05-07 01:47:01

This commit is contained in:
Hamza-Ayed
2026-05-07 01:47:01 +03:00
parent f206591c01
commit e5b70a01ef
4 changed files with 38 additions and 73 deletions

View File

@@ -12,6 +12,7 @@ use App\Core\Database;
use App\Core\AI;
use App\Core\Encryption;
use App\Middleware\QuotaMiddleware;
use App\Services\NotificationService;
// Prevent multiple instances (Lock file)
$lockFile = STORAGE_PATH . '/logs/process_batches.lock';
@@ -138,12 +139,18 @@ try {
}
// Check if batch is complete
$stmt = $db->prepare("SELECT total_images, processed_images FROM invoice_batches WHERE id = ?");
$stmt = $db->prepare("SELECT total_images, processed_images, uploaded_by FROM invoice_batches WHERE id = ?");
$stmt->execute([$batchId]);
$batch = $stmt->fetch();
if ($batch && $batch['processed_images'] >= $batch['total_images']) {
$db->prepare("UPDATE invoice_batches SET status = 'done', completed_at = NOW() WHERE id = ?")->execute([$batchId]);
echo "Batch $batchId Complete!\n";
// Send Notification to user
$notifier = new NotificationService();
$title = "اكتملت معالجة الدفعة";
$body = "تمت معالجة جميع الفواتير بنجاح. يمكنك الآن مراجعتها وتدقيقها في لوحة التحكم قبل اعتمادها.";
$notifier->sendNotification($batch['uploaded_by'], $title, $body, ['batch_id' => $batchId]);
}
}