Expand diagnostic modal to show all companies with WO counts
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 <noreply@anthropic.com>
This commit is contained in:
@@ -42,13 +42,34 @@ class ListWorkOrders extends ListRecords
|
|||||||
->color('gray')
|
->color('gray')
|
||||||
->icon('heroicon-o-information-circle')
|
->icon('heroicon-o-information-circle')
|
||||||
->modalHeading('Diagnostic fișe de lucru')
|
->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 = "<h4 style='margin:0 0 8px;font-size:13px;font-weight:600'>Companii & fișe</h4>";
|
||||||
|
$html .= "<table style='width:100%;border-collapse:collapse;font-size:13px;margin-bottom:16px'>";
|
||||||
|
$html .= "<tr style='background:#f3f4f6'><th style='padding:4px 8px;text-align:left'>ID</th><th>Slug</th><th>Nume</th><th>Active</th><th>Șterse</th><th>Curent?</th></tr>";
|
||||||
|
foreach ($companies as $c) {
|
||||||
|
$isCurrent = $c->id === $tenantId;
|
||||||
|
$bg = $isCurrent ? '#dcfce7' : 'white';
|
||||||
|
$html .= "<tr style='background:{$bg}'><td style='padding:3px 8px'>{$c->id}</td><td><b>{$c->slug}</b></td><td>{$c->name}</td><td>{$c->active_count}</td><td>{$c->deleted_count}</td><td>" . ($isCurrent ? '✓ DA' : '') . "</td></tr>";
|
||||||
|
}
|
||||||
|
$html .= "</table>";
|
||||||
|
|
||||||
|
// All WOs
|
||||||
$rows = DB::table('work_orders')
|
$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')
|
->orderBy('id')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$html = "<table style='width:100%;border-collapse:collapse;font-size:13px'>";
|
$html .= "<h4 style='margin:0 0 8px;font-size:13px;font-weight:600'>Toate fișele ({$total})</h4>";
|
||||||
|
$html .= "<table style='width:100%;border-collapse:collapse;font-size:13px'>";
|
||||||
$html .= "<tr style='background:#f3f4f6'><th style='padding:4px 8px;text-align:left'>ID</th><th>Nr.</th><th>company_id</th><th>tenant?</th><th>șters?</th></tr>";
|
$html .= "<tr style='background:#f3f4f6'><th style='padding:4px 8px;text-align:left'>ID</th><th>Nr.</th><th>company_id</th><th>tenant?</th><th>șters?</th></tr>";
|
||||||
foreach ($rows as $r) {
|
foreach ($rows as $r) {
|
||||||
$isTenant = $r->company_id === $tenantId;
|
$isTenant = $r->company_id === $tenantId;
|
||||||
|
|||||||
Reference in New Issue
Block a user