2020-06-15 06:56:21 +00:00
|
|
|
@extends("admin.layout.base")
|
|
|
|
@extends("admin.layout.header")
|
|
|
|
|
|
|
|
@section("title")
|
|
|
|
Bruger - Opret
|
|
|
|
@endsection
|
|
|
|
|
2020-06-15 09:28:37 +00:00
|
|
|
@section("path")
|
2020-06-17 09:28:48 +00:00
|
|
|
<a href="{{ route('users.create') }}" class="text-white">Opret Bruger</a> /
|
2020-06-15 09:28:37 +00:00
|
|
|
@endsection
|
|
|
|
|
2020-06-15 06:56:21 +00:00
|
|
|
@section("content")
|
2020-08-17 06:23:48 +00:00
|
|
|
<h1 id="errormesseages" >Opret Bruger:</h1>
|
2020-08-18 06:16:25 +00:00
|
|
|
<form method="post" action="{{ route("users.store") }}" onsubmit="return checkInputs()">
|
2020-06-22 08:08:18 +00:00
|
|
|
@csrf
|
2020-06-15 06:56:21 +00:00
|
|
|
<label for="name_first">Fornavn:</label>
|
2020-06-29 07:57:21 +00:00
|
|
|
<input type="text" name="name_first" id="name_first" placeholder="Fornavn" required>
|
2020-06-15 06:56:21 +00:00
|
|
|
<label for="name_last">Efternavn:</label>
|
2020-06-29 07:57:21 +00:00
|
|
|
<input type="text" name="name_last" id="name_last" placeholder="Efternavn" required>
|
2020-06-15 06:56:21 +00:00
|
|
|
<label for="email">Email:</label>
|
2020-08-17 13:25:26 +00:00
|
|
|
<label hidden id="erroremail">Der findes allerede en bruger med denne email!</label>
|
2020-06-29 07:57:21 +00:00
|
|
|
<input type="email" name="email" id="email" placeholder="x@y.z" required>
|
2020-08-07 08:51:10 +00:00
|
|
|
<label for="password1">Adgangskode:</label>
|
2020-08-17 13:25:26 +00:00
|
|
|
<label hidden id="errornotsamepass" for="errormesseages">Der stod ikke det samme i `Adgangskode` & `Bekræft Adgangskode`!</label>
|
2020-08-03 08:36:57 +00:00
|
|
|
<div class="input-group text-left">
|
|
|
|
<input type="password" class="form-control" name="password" id="password1" placeholder="******" required>
|
|
|
|
<span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('password1', 'fa-new')"></span>
|
|
|
|
</div>
|
2020-08-07 08:51:10 +00:00
|
|
|
<label for="password2">Bekræft Adgangskode:</label>
|
2020-08-03 08:36:57 +00:00
|
|
|
<div class="input-group text-left">
|
|
|
|
<input type="password" class="form-control" name="password2" id="password2" placeholder="******" required>
|
|
|
|
<span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('password2', 'fa-confirm')"></span>
|
|
|
|
</div>
|
2020-08-17 06:23:48 +00:00
|
|
|
<label for="phone">Telefon nr:</label>
|
2020-08-17 13:25:26 +00:00
|
|
|
<label hidden id="errorphone">Der findes allerede en bruger med dette telefon nr!</label>
|
2020-08-17 06:23:48 +00:00
|
|
|
<input type="tel" name="phone" id="phone" placeholder="12345678" pattern="[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" required>
|
2020-06-30 11:22:02 +00:00
|
|
|
<label for="roles">Rolle:</label>
|
|
|
|
<select name="roles[]" id="roles" class="mb-2" multiple="multiple" required>
|
|
|
|
<option disabled selected value> -- Vælg Rolle(r) -- </option>
|
2020-07-01 07:27:54 +00:00
|
|
|
<option value="">Ingen Rolle</option>
|
2020-06-30 10:07:38 +00:00
|
|
|
@foreach($roles as $role)
|
|
|
|
<option value="{{ $role->name }}">{{ $role->name }}</option>
|
|
|
|
@endforeach
|
2020-06-30 06:03:42 +00:00
|
|
|
</select>
|
2020-08-17 13:25:26 +00:00
|
|
|
<input type="submit" class="btn btn-dark text-white" value="Opret">
|
2020-06-15 06:56:21 +00:00
|
|
|
</form>
|
|
|
|
@endsection
|
2020-08-03 08:36:57 +00:00
|
|
|
|
|
|
|
@section("scripts")
|
|
|
|
<script>
|
|
|
|
function show($passID, $faID) {
|
|
|
|
var inputPass = document.getElementById($passID);
|
|
|
|
var faEye = document.getElementById($faID);
|
|
|
|
|
|
|
|
if (inputPass.type === "password") {
|
|
|
|
inputPass.type = "text";
|
|
|
|
faEye.style.color = "#000";
|
|
|
|
} else {
|
|
|
|
inputPass.type = "password";
|
|
|
|
faEye.style.color = "#808080";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2020-08-11 08:54:01 +00:00
|
|
|
<script>
|
|
|
|
$(function() {
|
|
|
|
$('form').areYouSure(
|
|
|
|
{
|
|
|
|
message: 'It looks like you have been editing something. '
|
|
|
|
+ 'If you leave before saving, your changes will be lost.'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2020-08-17 06:23:48 +00:00
|
|
|
|
2020-08-18 06:16:25 +00:00
|
|
|
function checkInputs() {
|
2020-08-17 13:10:44 +00:00
|
|
|
var save = true;
|
2020-08-17 06:23:48 +00:00
|
|
|
$mail = $('#email').val();
|
|
|
|
$phone = $('#phone').val();
|
|
|
|
$.ajax({
|
2020-08-17 13:10:44 +00:00
|
|
|
'async': false,
|
2020-08-17 06:23:48 +00:00
|
|
|
type: 'get',
|
|
|
|
url: '{{route('users.nameCheck')}}',
|
2020-08-17 13:10:44 +00:00
|
|
|
data: {'mailCheck':$mail, 'phoneCheck':$phone},
|
2020-08-17 06:23:48 +00:00
|
|
|
success:function (data) {
|
2020-08-18 06:16:25 +00:00
|
|
|
if (data == 'both') {
|
2020-08-17 13:10:44 +00:00
|
|
|
$("#erroremail").show(100);
|
|
|
|
$("#erroremail").css('color', 'red');
|
|
|
|
$("#errorphone").show(100);
|
|
|
|
$("#errorphone").css('color', 'red');
|
|
|
|
save = false;
|
2020-08-18 06:16:25 +00:00
|
|
|
} else if(data == 'email'){
|
2020-08-17 13:10:44 +00:00
|
|
|
$("#errorphone").hide();
|
|
|
|
$("#erroremail").show(100);
|
|
|
|
$("#erroremail").css('color', 'red');
|
|
|
|
save = false;
|
2020-08-18 06:16:25 +00:00
|
|
|
} else if (data == 'phone') {
|
2020-08-17 13:10:44 +00:00
|
|
|
$("#erroremail").hide();
|
|
|
|
$("#errorphone").show(100);
|
|
|
|
$("#errorphone").css('color', 'red');
|
|
|
|
save = false;
|
|
|
|
} else {
|
2020-08-17 13:25:26 +00:00
|
|
|
$("#errorphone").hide();
|
2020-08-17 13:10:44 +00:00
|
|
|
$("#erroremail").hide();
|
2020-08-17 06:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
error:function (data) {
|
|
|
|
console.log(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-08-17 13:25:26 +00:00
|
|
|
// If passwords is not the same. Then show an error message and make save false
|
|
|
|
if ($('#password1').val() != $('#password2').val()) {
|
|
|
|
$("#errornotsamepass").show(100);
|
|
|
|
$("#errornotsamepass").css('color', 'red');
|
|
|
|
save = false;
|
|
|
|
} else
|
|
|
|
$("#errornotsamepass").hide();
|
|
|
|
|
2020-08-17 13:10:44 +00:00
|
|
|
if (save)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2020-08-11 08:54:01 +00:00
|
|
|
</script>
|
2020-08-03 08:36:57 +00:00
|
|
|
@endsection
|