diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 8d3f0ae..b21531e 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; @@ -242,4 +243,51 @@ class HomeController extends Controller return view('setup') ->with('o',$o); } + + public function status() + { + $date = Carbon::now()->yesterday()->endOfday(); + + // Nodes with uncollected mail + $e = Address::select(['addresses.id',DB::raw('count(*) as e'),DB::raw('0 as n'),DB::raw('0 as f')]) + ->join('echomail_seenby',['echomail_seenby.address_id'=>'addresses.id']) + ->join('echomails',['echomails.id'=>'echomail_seenby.echomail_id']) + ->whereNotNull('export_at') + ->whereNull('sent_at') + ->where('datetime','<',$date) + ->groupBy('addresses.id'); + + $n = Address::select(['addresses.id',DB::raw('0 as e'),DB::raw('count(*) as n'),DB::raw('0 as f')]) + ->join('netmails',['netmails.tftn_id'=>'addresses.id']) + ->whereNull('sent_at') + ->where('datetime','<',$date) + ->groupBy('addresses.id'); + + $f = Address::select(['addresses.id',DB::raw('0 as e'),DB::raw('0 as n'),DB::raw('count(*) as f')]) + ->join('file_seenby',['file_seenby.address_id'=>'addresses.id']) + ->join('files',['files.id'=>'file_seenby.file_id']) + ->whereNotNull('export_at') + ->whereNull('sent_at') + ->where('datetime','<',$date) + ->groupBy('addresses.id'); + + $r = Address::select([ + 'a.id', + 'system_id', + 'zone_id', + 'host_id', + 'node_id', + DB::raw('sum(a.e) as e'), + DB::raw('sum(a.n) as n'), + DB::raw('sum(a.f) as f') + ]) + ->from($e->union($n)->union($f),'a') + ->join('addresses',['addresses.id'=>'a.id']) + ->groupBy('system_id','a.id','zone_id','host_id','node_id') + ->with(['system','zone.domain']); + + return view('status') + ->with('date',$date) + ->with('uncollected',$r->get()); + } } \ No newline at end of file diff --git a/resources/views/layouts/partials/topmenu.blade.php b/resources/views/layouts/partials/topmenu.blade.php index e70ca66..b1c56cc 100644 --- a/resources/views/layouts/partials/topmenu.blade.php +++ b/resources/views/layouts/partials/topmenu.blade.php @@ -6,6 +6,7 @@
Nodes with uncollected mail as at {{ $date }}:
+ +Network | +System | +Address | +Echomails | +Netmails | +Files | +Last Session | +Poll Mode | +Auto Hold | +
---|---|---|---|---|---|---|---|---|
{{ $o->zone->domain->name }} | +{{ $o->system->name }} | +{{ $o->ftn4d }} | +{{ number_format($o->e ?? 0) }} | +{{ number_format($o->n ?? 0) }} | +{{ number_format($o->f ?? 0) }} | +{{ $o->system->last_session?->format('Y-m-d H:i') }} | +{{ is_null($o->system->pollmode) ? 'HOLD' : ($o->system->pollmode ? 'CRASH' : 'DAILY') }} | +{{ $o->system->autohold ? 'YES' : 'NO' }} | +