From 24bdc36913038b779e97363c5b587b8749ed2e38 Mon Sep 17 00:00:00 2001 From: Vasyka Date: Sun, 6 Sep 2026 11:39:11 +0000 Subject: [PATCH] Expand diagnostic modal to show all companies with WO counts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Helps identify cross-tenant WO leakage — shows each company's slug, active count, deleted count, and whether it's the current tenant. Co-Authored-By: Claude Sonnet 4.6 --- .../Pages/ListWorkOrders.php | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/Filament/Tenant/Resources/WorkOrderResource/Pages/ListWorkOrders.php b/app/Filament/Tenant/Resources/WorkOrderResource/Pages/ListWorkOrders.php index 57b10a6..dcf4a83 100644 --- a/app/Filament/Tenant/Resources/WorkOrderResource/Pages/ListWorkOrders.php +++ b/app/Filament/Tenant/Resources/WorkOrderResource/Pages/ListWorkOrders.php @@ -42,13 +42,34 @@ class ListWorkOrders extends ListRecords ->color('gray') ->icon('heroicon-o-information-circle') ->modalHeading('Diagnostic fișe de lucru') - ->modalContent(function () use ($tenantId, $inTenant, $deletedTenant, $otherActive, $otherDeleted, $total) { + ->modalContent(function () use ($tenantId, $total) { + // All companies with WO counts + $companies = DB::table('companies') + ->select('companies.id', 'companies.name', 'companies.slug') + ->selectRaw('COUNT(wo.id) as active_count') + ->selectRaw('SUM(CASE WHEN wo.deleted_at IS NOT NULL THEN 1 ELSE 0 END) as deleted_count') + ->leftJoin('work_orders as wo', 'companies.id', '=', 'wo.company_id') + ->groupBy('companies.id', 'companies.name', 'companies.slug') + ->get(); + + $html = "

Companii & fișe

"; + $html .= ""; + $html .= ""; + foreach ($companies as $c) { + $isCurrent = $c->id === $tenantId; + $bg = $isCurrent ? '#dcfce7' : 'white'; + $html .= ""; + } + $html .= "
IDSlugNumeActiveȘterseCurent?
{$c->id}{$c->slug}{$c->name}{$c->active_count}{$c->deleted_count}" . ($isCurrent ? '✓ DA' : '') . "
"; + + // All WOs $rows = DB::table('work_orders') - ->select('id', 'number', 'company_id', 'master_id', 'status', 'deleted_at') + ->select('id', 'number', 'company_id', 'status', 'deleted_at') ->orderBy('id') ->get(); - $html = ""; + $html .= "

Toate fișele ({$total})

"; + $html .= "
"; $html .= ""; foreach ($rows as $r) { $isTenant = $r->company_id === $tenantId;
IDNr.company_idtenant?șters?