clrghouz/resources/views/echoarea/addedit.blade.php

209 lines
8.6 KiB
PHP

<!-- $o=Echoarea::class -->
@use(App\Models\Domain)
@extends('layouts.app')
@section('htmlheader_title')
@if($o->exists) Update @else Add @endif Echoarea
@endsection
@section('content')
<form class="needs-validation" method="post" autocomplete="off" novalidate>
@csrf
<div class="row">
<div class="col-12">
<div class="greyframe titledbox shadow0xb0">
<h2 class="cap">@if($o->exists) Update @else Add @endif Echoarea</h2>
<div class="row">
<div class="col-3">
@php
$helper = (! $o->domain_id)
? sprintf('Add a <a href="%s">NEW Domain</a>',url('domain/addedit'))
: NULL;
@endphp
<x-form.select name="domain_id" icon="bi-tag-fill" label="Domain" feedback="Domain is required" :helper="$helper" :value="$o->domain_id" :options="Domain::active()->orderBy('name')->cursor()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])" required/>
</div>
<div class="col-3">
<label for="name" class="form-label">Name</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
<input type="text" class="form-control @error('name') is-invalid @enderror" id="name" placeholder="Name" name="name" value="{{ old('name',$o->name) }}" required @cannot('admin',$o)disabled @endcannot autofocus>
<span class="invalid-feedback" role="alert">
@error('name')
{{ $message }}
@else
A name is required.
@enderror
</span>
</div>
</div>
@can('admin',$o)
<div class="col-2">
<label for="active" class="form-label">Active</label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active ?? FALSE))checked @endif>
<label class="btn btn-outline-success" for="active_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active ?? FALSE))checked @endif>
<label class="btn btn-outline-danger" for="active_no">No</label>
</div>
</div>
</div>
<div class="col-2">
<label for="show" class="form-label">Show <i class="bi bi-info-circle" title="Show this area in the activity reports"></i></label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="show" id="show_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('show',$o->show ?? FALSE))checked @endif>
<label class="btn btn-outline-success" for="show_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="show" id="show_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('show',$o->show ?? FALSE))checked @endif>
<label class="btn btn-outline-danger" for="show_no">No</label>
</div>
</div>
</div>
<div class="col-2">
<label for="automsgs" class="form-label">Auto Messages <i class="bi bi-info-circle" title="Automatically respond to some messages"></i></label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="automsgs" id="automsgs_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('automsgs',$o->automsgs ?? FALSE))checked @endif>
<label class="btn btn-outline-success" for="automsgs_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="automsgs" id="automsgs_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('automsgs',$o->automsgs ?? FALSE))checked @endif>
<label class="btn btn-outline-danger" for="automsgs_no">No</label>
</div>
</div>
</div>
@endcan
</div>
<div class="row">
<div class="col-8">
<label for="description" class="form-label">Description</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-file-text-fill"></i></span>
<input type="text" class="form-control @error('description') is-invalid @enderror" id="description" placeholder="Description" name="description" value="{{ old('description',$o->description) }}" @cannot('admin',$o)disabled @endcannot>
<span class="invalid-feedback" role="alert">
@error('description')
{{ $message }}
@enderror
</span>
</div>
</div>
@can('admin',$o)
<div class="col-2">
<label for="sec_read" class="form-label">Read <i class="bi bi-info-circle" title="Min security level required for read access"></i></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-eyeglasses"></i></span>
<input type="text" class="form-control text-end @error('sec_read') is-invalid @enderror" id="sec_read" placeholder="#" name="sec_read" value="{{ old('sec_read',$o->sec_read) }}" required @cannot('admin',$o)disabled @endcannot autofocus>
<span class="invalid-feedback" role="alert">
@error('sec_read')
{{ $message }}
@enderror
</span>
</div>
</div>
<div class="col-2">
<label for="sec_write" class="form-label">Write <i class="bi bi-info-circle" title="Min security level required for write access"></i></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-pencil"></i></span>
<input type="text" class="form-control text-end @error('sec_write') is-invalid @enderror" id="sec_write" placeholder="#" name="sec_write" value="{{ old('sec_write',$o->sec_write) }}" required @cannot('admin',$o)disabled @endcannot autofocus>
<span class="invalid-feedback" role="alert">
@error('sec_write')
{{ $message }}
@enderror
</span>
</div>
</div>
@endcan
</div>
@can('admin',$o)
<div class="row">
<div class="col-12">
<x-form.notes name="notes" label="Notes" rows=3 placeholder="Notes..." :value="$o->notes"/>
</div>
</div>
<div class="row">
<div class="col-12">
<a href="{{ url('echoarea') }}" class="btn btn-danger">Cancel</a>
<button type="submit" name="submit" class="btn btn-success float-end">@if ($o->exists)Save @else Add @endif</button>
</div>
</div>
@endcan
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<h4>Info</h4>
<p>There are <strong class="highlight">{{ number_format($o->echomail->count()) }}</strong> messages in this area, and the oldest message in this area is <strong class="highlight">{{ ($x=$o->echomail->min('datetime')) ? $x->format('Y-m-d H:i:s') : 'None' }}</strong>.
The most recent is <strong class="highlight">{{ ($x=$o->echomail->max('datetime')) ? $x->format('Y-m-d H:i:s') : 'None' }}</strong>.</p>
</div>
</div>
@can('admin',$o)
@if($o->addresses->count())
<div class="row">
<div class="col-12">
<h3>Exporting to the following adresses:</h3>
<table class="table monotable" id="systems">
<thead>
<tr>
<th>System</th>
<th>Address</th>
<th>Last Session</th>
<th>Oldest Message</th>
<th class="text-end">Messages Waiting</th>
</tr>
</thead>
<tbody>
@foreach ($o->addresses as $ao)
<tr>
<td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->is_hosted)<sup>{{ $ao->is_default ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td>
<td>{{ $ao->ftn4d }}</td>
<td>{{ $ao->system->last_seen?->format('Y-m-d H:i') ?: '-' }}</td>
<td>{{ ($x=$o->waiting($ao))->count() ? $x->first()->datetime->format('Y-m-d H:i') : '-' }}</td>
<td class="text-end">{{ number_format($x->count()) }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endif
@endcan
</form>
@endsection
@pa(datatables,conditionalpaging)
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
$('#systems').DataTable({
paging: true,
pageLength: 25,
searching: true,
ordering: true,
order: [1,'asc'],
conditionalPaging: {
style: 'fade',
speed: 500 // optional
},
});
});
</script>
@append