Badania - wstępnie, bez obsługi błędów ajaxa, z niezformatowanym widokiem

This commit is contained in:
czup 2019-12-23 06:26:14 +01:00
parent eff141d91c
commit c2dd5a8929
2 changed files with 0 additions and 215 deletions

View File

@ -1,117 +0,0 @@
@extends('layout.app')
<title>Add Edit Delete Table Row Example using JQuery - ItSolutionStuff.com</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
@section('left-menu')
@parent
<ul>
<a href="sprzet/add"><li>Dodaj<img src="../img/left_menu_icon/add.png"></li></a>
<li>Edytuj<img src="../img/left_menu_icon/edit.png"></li>
<li>Usuń<img src="../img/left_menu_icon/delete.png"></li>
</ul>
@stop
@section('center-area')
@parent
@if( auth()->check())
@if( auth()->user()->fireStationID == NULL)
Jednostka nie istnieje
@else
<center><h1>{{$training->trainingName}}</h1></center>
<table id="editableTable" class='table table-bordered'>
<thead>
<tr>
<td>Imię i Nazwisko</td>
<td>Ważne od:</td>
<td>Ważne do:</td>
<td>Akcje</td>
</tr>
</thead>
<tbody>
@foreach($fireFighters as $fireFighter)
<tr id="{{$fireFighter->id}}">
<td>{{$fireFighter->name}} {{$fireFighter->surname}}</td>
<td>{{$fireFighter->dateOfComplete}}</td>
<td>{{$fireFighter->dateOfExpiry}}</td>
<td><button class="btn btn-info" type="submit">Edytuj</button> <button class="btn btn-danger btn-delete" type="submit">Usuń</button></td>
</tr>
@endforeach
</tbody>
</table>
@endif
@else
Brak autoryzacji
@endif
@stop
<script type="text/javascript">
// $("form").submit(function(e){
// e.preventDefault();
// var name = $("input[name='name']").val();
// var email = $("input[name='email']").val();
//
// $(".data-table tbody").append("<tr data-name='"+name+"' data-email='"+email+"'><td>"+name+"</td><td>"+email+"</td><td><button class='btn btn-info btn-xs btn-edit'>Edit</button><button class='btn btn-danger btn-xs btn-delete'>Delete</button></td></tr>");
//
// $("input[name='name']").val('');
// $("input[name='email']").val('');
// });
//
// $("body").on("click", ".btn-delete", function(){
// $(this).parents("tr").remove();
// });
//
// $("body").on("click", ".btn-edit", function(){
// var name = $(this).parents("tr").attr('data-name');
// var email = $(this).parents("tr").attr('data-email');
//
// $(this).parents("tr").find("td:eq(0)").html('<input name="edit_name" value="'+name+'">');
// $(this).parents("tr").find("td:eq(1)").html('<input name="edit_email" value="'+email+'">');
//
// $(this).parents("tr").find("td:eq(2)").prepend("<button class='btn btn-info btn-xs btn-update'>Update</button><button class='btn btn-warning btn-xs btn-cancel'>Cancel</button>")
// $(this).hide();
// });
//
// $("body").on("click", ".btn-cancel", function(){
// var name = $(this).parents("tr").attr('data-name');
// var email = $(this).parents("tr").attr('data-email');
//
// $(this).parents("tr").find("td:eq(0)").text(name);
// $(this).parents("tr").find("td:eq(1)").text(email);
//
// $(this).parents("tr").find(".btn-edit").show();
// $(this).parents("tr").find(".btn-update").remove();
// $(this).parents("tr").find(".btn-cancel").remove();
// });
//
// $("body").on("click", ".btn-update", function(){
// var name = $(this).parents("tr").find("input[name='edit_name']").val();
// var email = $(this).parents("tr").find("input[name='edit_email']").val();
//
// $(this).parents("tr").find("td:eq(0)").text(name);
// $(this).parents("tr").find("td:eq(1)").text(email);
//
// $(this).parents("tr").attr('data-name', name);
// $(this).parents("tr").attr('data-email', email);
//
// $(this).parents("tr").find(".btn-edit").show();
// $(this).parents("tr").find(".btn-cancel").remove();
// $(this).parents("tr").find(".btn-update").remove();
// });
</script>

View File

@ -1,98 +0,0 @@
@extends('layout.app')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent
<ul>
<a href="sprzet/add"><li>Dodaj<img src="../img/left_menu_icon/add.png"></li></a>
<li>Edytuj<img src="../img/left_menu_icon/edit.png"></li>
<li>Usuń<img src="../img/left_menu_icon/delete.png"></li>
</ul>
@stop
@section('center-area')
@parent
@if( auth()->check())
@if( auth()->user()->fireStationID == NULL)
Jednostka nie istnieje
@else
<form method="POST" action="/szkolenia" id="dynamic_form">
{{ csrf_field() }}
<div class=form-group">
<div id="fireFightersTrainings">
</div>
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zapisz badania</button>
</div>
@include('inc.formerrors')
</form>
@endif
@else
Brak autoryzacji
@endif
@stop
<script>
$(document).ready(function(){
var count = 1;
dynamic_field(count);
function dynamic_field(number)
{
html = '<div id="singleFireFighter"><label for="location">Strażak:</label>';
html += '<select name="fireFighterTraining[]" class="form-control">';
html += '<option value="">--- Wybierz strażaka ---</option>';
html += '@foreach ($fireFighters as $fireFighter)';
html += '<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>';
html += '@endforeach';
html += '</select>';
html += '<label>Data ukończenia: </label><input type="date" name="dateOfComplete[]">'
html += '<label> Koniec ważności: </label><input type="date" id="dateOfExpiry">'
html += 'Bezterminowo: <input type="checkbox" id="lifeless">'
if(number > 1)
{
html += '<button type="button" name="remove" id="" class="btn btn-danger remove">Usuń</button></br></div>';
$('#fireFightersTrainings').append(html);
}
else
{
html += '<button type="button" name="add" id="add" class="btn btn-success">Dodaj</button></br></div>';
$('#fireFightersTrainings').html(html);
}
}
$(document).on('click', '#add', function(){
count++;
dynamic_field(count);
});
$(document).on('click', '.remove', function(){
count--;
$(this).closest("#singleFireFighter").remove();
});
$('#lifeless').change(function(){
if($(this).is(':checked'))
$('#dateOfExpiry').prop('disabled', true)
else
$('#dateOfExpiry').prop('disabled', false)
})
});
</script>