info('Starting regeneration of all reports...'); // Determine date range if ($this->option('start-date') && $this->option('end-date')) { $startDate = Carbon::parse($this->option('start-date')); $endDate = Carbon::parse($this->option('end-date')); } else { $days = $this->option('days'); $endDate = Carbon::yesterday(); $startDate = Carbon::yesterday()->subDays($days - 1); } if ($startDate->gt($endDate)) { $this->error('Start date must be before or equal end date'); return Command::FAILURE; } $totalAnswered = 0; $totalMissed = 0; $totalOutbound = 0; while ($startDate->lte($endDate)) { $date = $startDate->format('Y-m-d'); $this->info("Processing date: {$date}"); $this->info(" Processing answered calls..."); $answeredCount = $answeredService->generateDailyAnsweredCalls($date); $totalAnswered += $answeredCount; $this->info(" -> {$answeredCount} answered calls"); $this->info(" Processing missed calls..."); $missedCount = $missedService->generateDailyMissedCalls($date); $totalMissed += $missedCount; $this->info(" -> {$missedCount} missed calls"); $this->info(" Processing outbound calls..."); $outboundCount = $outboundService->generateDailyOutboundCalls($date); $totalOutbound += $outboundCount; $this->info(" -> {$outboundCount} outbound calls"); $this->newLine(); $startDate->addDay(); } $total = $totalAnswered + $totalMissed + $totalOutbound; $this->info("Report Generation Summary:"); $this->info(" Answered Calls: {$totalAnswered}"); $this->info(" Missed Calls: {$totalMissed}"); $this->info(" Outbound Calls: {$totalOutbound}"); $this->info(" Total: {$total}"); if (CompanySettings::get(SettingsHelper::S_COMPANY_CONSOLE_DEBUG_LOGS)) { \Log::info("All reports regenerated", [ 'answered_calls' => $totalAnswered, 'missed_calls' => $totalMissed, 'outbound_calls' => $totalOutbound, 'total' => $total, ]); } return Command::SUCCESS; } }