2021-11-11 11:57:13 +00:00
|
|
|
@extends('layouts.app')
|
|
|
|
|
|
|
|
@section('htmlheader_title')
|
|
|
|
Register System
|
|
|
|
@endsection
|
|
|
|
|
2024-06-03 12:31:38 +00:00
|
|
|
@php
|
|
|
|
use App\Models\{Setup,System};
|
|
|
|
@endphp
|
|
|
|
|
2021-11-11 11:57:13 +00:00
|
|
|
@section('content')
|
2024-04-22 04:27:48 +00:00
|
|
|
<form class="needs-validation" method="post" autocomplete="off" novalidate>
|
2021-11-11 11:57:13 +00:00
|
|
|
@csrf
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-12">
|
|
|
|
<div class="greyframe titledbox shadow0xb0">
|
|
|
|
<h2 class="cap">Register System</h2>
|
|
|
|
|
2022-01-01 14:52:21 +00:00
|
|
|
<div id="create">
|
2021-11-11 11:57:13 +00:00
|
|
|
<div class="row">
|
2022-03-11 12:49:15 +00:00
|
|
|
<!-- Name -->
|
2021-11-11 11:57:13 +00:00
|
|
|
<div class="col-4">
|
|
|
|
<label for="system" class="form-label">BBS Name</label>
|
|
|
|
<div class="input-group has-validation">
|
2023-10-05 00:11:21 +00:00
|
|
|
<span class="input-group-text"><i class="bi bi-laptop-fill"></i></span>
|
|
|
|
<select style="width: 80%;" class="form-select @error('system_id') is-invalid @enderror" id="system" name="id" required>
|
|
|
|
<option value=""> </option>
|
2024-06-03 12:31:38 +00:00
|
|
|
@foreach (System::select(['systems.id','systems.name'])
|
2023-10-05 00:11:21 +00:00
|
|
|
->active()
|
2024-06-03 12:31:38 +00:00
|
|
|
->where('id','<>',Setup::findOrFail(config('app.id'))->system_id)
|
2023-10-05 00:11:21 +00:00
|
|
|
->whereRaw('id NOT IN (SELECT system_id FROM system_user)')
|
|
|
|
->cursor() as $oo)
|
|
|
|
<option value="{{ $oo->id }}" @if(old('id')===$oo->id)selected @endif>{{ $oo->name }}</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
2021-11-11 11:57:13 +00:00
|
|
|
<span class="invalid-feedback" role="alert">
|
2023-10-05 00:11:21 +00:00
|
|
|
@error('system_id')
|
2021-11-11 11:57:13 +00:00
|
|
|
{{ $message }}
|
|
|
|
@else
|
|
|
|
BBS Name is required.
|
|
|
|
@enderror
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-04-26 02:23:55 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-12 pb-2">
|
|
|
|
<button type="button" name="submit" class="btn btn-success">Next</button><span id="next" class="m-2"><i class="spinner-border spinner-border-sm text-light d-none"></i></span>
|
2021-11-11 11:57:13 +00:00
|
|
|
</div>
|
2024-04-26 02:23:55 +00:00
|
|
|
</div>
|
2021-11-11 11:57:13 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2022-01-01 14:52:21 +00:00
|
|
|
|
|
|
|
<div class="modal fade" id="no-auth" tabindex="-1">
|
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header bg-danger">
|
|
|
|
<h5 class="modal-title">ERROR: No authorisation</h5>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p>It appears that you are not allowed to create this entry.</p>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-11 11:57:13 +00:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section('page-css')
|
2023-10-05 00:11:21 +00:00
|
|
|
@css('select2')
|
2021-11-11 11:57:13 +00:00
|
|
|
@append
|
|
|
|
@section('page-scripts')
|
2023-10-05 00:11:21 +00:00
|
|
|
@js('select2')
|
|
|
|
|
2024-04-26 02:23:55 +00:00
|
|
|
<script type='text/javascript'>
|
2023-10-05 00:11:21 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
$('#system').select2({
|
|
|
|
placeholder: 'See if your BBS exists',
|
|
|
|
tags: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2024-04-26 02:23:55 +00:00
|
|
|
<script type='text/javascript'>
|
2021-11-11 11:57:13 +00:00
|
|
|
var system_id;
|
2022-01-01 14:52:21 +00:00
|
|
|
var noauth = new bootstrap.Modal(document.getElementById('no-auth'), {});
|
|
|
|
|
|
|
|
function validation(item,message) {
|
|
|
|
var attr = $('input[id='+item+']');
|
|
|
|
attr.addClass('is-invalid')
|
|
|
|
attr.parent().find('.invalid-feedback').empty().append(message);
|
|
|
|
}
|
|
|
|
|
2024-04-26 02:23:55 +00:00
|
|
|
/**
|
|
|
|
* We have selected a BBS from the link/register form, and it's either a new entry or an existing one
|
|
|
|
* @param icon
|
|
|
|
*/
|
2022-01-01 14:52:21 +00:00
|
|
|
function getform(icon) {
|
|
|
|
$.ajax({
|
|
|
|
url : '{{ url('user/system/register') }}',
|
|
|
|
type : 'POST',
|
2023-10-05 00:11:21 +00:00
|
|
|
data : { system_id: system_id,name: $('#system').val(),action: 'register',old: {!! json_encode(old()) !!} },
|
2022-01-01 14:52:21 +00:00
|
|
|
dataType : 'json',
|
|
|
|
async : true,
|
|
|
|
cache : false,
|
|
|
|
beforeSend : function() {
|
|
|
|
if (icon)
|
|
|
|
icon.toggleClass('d-none');
|
|
|
|
},
|
|
|
|
complete : function(data) {
|
|
|
|
switch (data.status) {
|
|
|
|
case 200:
|
|
|
|
// if json is null, means no match, won't do again.
|
2023-04-14 09:47:33 +00:00
|
|
|
if(data.responseText===null || (data.responseText.length===0)) return;
|
2022-01-01 14:52:21 +00:00
|
|
|
$('#create').empty().append(data.responseText);
|
|
|
|
|
|
|
|
@if($errors->count())
|
|
|
|
@foreach($errors->keys() as $key)
|
2023-10-05 00:11:21 +00:00
|
|
|
validation('{{ $key }}','{{ $errors->first($key) }}');
|
2022-01-01 14:52:21 +00:00
|
|
|
@endforeach
|
|
|
|
@endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 403:
|
|
|
|
if (icon)
|
|
|
|
icon.toggleClass('d-none');
|
|
|
|
noauth.show();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 419:
|
|
|
|
location.reload();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 422:
|
|
|
|
validation('name',data.responseJSON.errors.name[0]);
|
|
|
|
|
|
|
|
if (icon)
|
|
|
|
icon.toggleClass('d-none');
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-04-14 09:47:33 +00:00
|
|
|
if ({{ old('submit') === 'create' ? 'true' : 'false' }}) {
|
2022-01-01 14:52:21 +00:00
|
|
|
getform();
|
|
|
|
}
|
2021-11-11 11:57:13 +00:00
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
$('button[name=submit]').on('click',function() {
|
|
|
|
icon = $(this).parent().find('i');
|
|
|
|
|
2023-10-05 00:11:21 +00:00
|
|
|
if (! $('#system').val())
|
2021-11-11 11:57:13 +00:00
|
|
|
return;
|
|
|
|
|
2022-01-01 14:52:21 +00:00
|
|
|
getform(icon);
|
2021-11-11 11:57:13 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
@append
|