Wyjazdy - dodano dodawanie kilku kierowcow
This commit is contained in:
parent
c503cec90d
commit
f137fb0759
@ -6,6 +6,7 @@ namespace App\Http\Controllers;
|
|||||||
use App\User;
|
use App\User;
|
||||||
use App\operations;
|
use App\operations;
|
||||||
use App\operationsMembers;
|
use App\operationsMembers;
|
||||||
|
use App\vehicle;
|
||||||
use App\operationsDrivers;
|
use App\operationsDrivers;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@ -28,7 +29,9 @@ class operationsController extends Controller
|
|||||||
//$fireStationID = auth()->user()->fireStationID;
|
//$fireStationID = auth()->user()->fireStationID;
|
||||||
// $fireFighters = User::pluck('fireStationID', $fireStationID);
|
// $fireFighters = User::pluck('fireStationID', $fireStationID);
|
||||||
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
|
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
|
||||||
return view("operationAdd", ["fireFighters" => $fireFighters]);
|
$vehicles = DB::table('vehicles')->where("fireStationID", '=', auth()->user()->fireStationID)
|
||||||
|
->get();
|
||||||
|
return view("operationAdd", ["fireFighters" => $fireFighters], ["vehicles" => $vehicles]);
|
||||||
} else return view("unit");
|
} else return view("unit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +63,6 @@ class operationsController extends Controller
|
|||||||
'dangerType' => $request-> operationDangerType,
|
'dangerType' => $request-> operationDangerType,
|
||||||
'description' => $request-> operationDescription,
|
'description' => $request-> operationDescription,
|
||||||
'commanderID' => $request-> operationLeader,
|
'commanderID' => $request-> operationLeader,
|
||||||
'driverID' => $request-> operationDriver,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return operationsController::create();
|
return operationsController::create();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
@extends('layout.app')
|
@extends('layout.app')
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
|
||||||
@section('left-menu')
|
@section('left-menu')
|
||||||
@parent<ul>
|
@parent<ul>
|
||||||
<a href="?addOperation"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
|
<a href="?addOperation"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
|
||||||
@ -11,8 +12,7 @@
|
|||||||
|
|
||||||
@section('center-area')
|
@section('center-area')
|
||||||
@parent
|
@parent
|
||||||
Strona w budowie - dodawanie
|
<form method="POST" action="/wyjazdy" id="dynamic_form">
|
||||||
<form method="POST" action="/wyjazdy">
|
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="date">Data wyjazdu: </label>
|
<label for="date">Data wyjazdu: </label>
|
||||||
@ -49,7 +49,9 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class=form-group">
|
<div class=form-group">
|
||||||
|
<div id="drivers">
|
||||||
<label for="location">Kierowca:</label>
|
<label for="location">Kierowca:</label>
|
||||||
<select name="operationDriver" class="form-control">
|
<select name="operationDriver" class="form-control">
|
||||||
<option value="">--- Wybierz kierowcę ---</option>
|
<option value="">--- Wybierz kierowcę ---</option>
|
||||||
@ -57,11 +59,103 @@
|
|||||||
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
|
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
<label for="location">Pojazd:</label>
|
||||||
|
<select name="operationVehicle" class="form-control">
|
||||||
|
<option value="">--- Wybierz pojazd ---</option>
|
||||||
|
@foreach ($vehicles as $vehicle)
|
||||||
|
<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button style="cursor:pointer" type="submit" class="btn btn-primary">Dodaj</button>
|
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zapisz</button>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@include('inc.formerrors')
|
@include('inc.formerrors')
|
||||||
</form>
|
</form>
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
var count = 1;
|
||||||
|
|
||||||
|
dynamic_field(count);
|
||||||
|
|
||||||
|
function dynamic_field(number)
|
||||||
|
{
|
||||||
|
|
||||||
|
html = '<div id="singleDriver"><label for="location">Kierowca:</label>';
|
||||||
|
html += '<select name="operationDriver[]" class="form-control">';
|
||||||
|
html += '<option value="">--- Wybierz kierowcę ---</option>';
|
||||||
|
html += '@foreach ($fireFighters as $fireFighter)';
|
||||||
|
html += '<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>';
|
||||||
|
html += '@endforeach';
|
||||||
|
html += '</select>';
|
||||||
|
html += '<label for="location">Pojazd:</label>';
|
||||||
|
html += '<select name="operationVehicle[]" class="form-control">';
|
||||||
|
html += '<option value="">--- Wybierz pojazd ---</option>';
|
||||||
|
html += '@foreach ($vehicles as $vehicle)';
|
||||||
|
html += '<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>';
|
||||||
|
html += '@endforeach';
|
||||||
|
html += '</select>';
|
||||||
|
|
||||||
|
if(number > 1)
|
||||||
|
{
|
||||||
|
html += '<button type="button" name="remove" id="" class="btn btn-danger remove">Usuń</button></br></div>';
|
||||||
|
$('#drivers').append(html);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
html += '<button type="button" name="add" id="add" class="btn btn-success">Dodaj</button></br></div>';
|
||||||
|
$('#drivers').html(html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on('click', '#add', function(){
|
||||||
|
count++;
|
||||||
|
dynamic_field(count);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.remove', function(){
|
||||||
|
count--;
|
||||||
|
$(this).closest("#singleDriver").remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
{{--$('#dynamic_form').on('submit', function(event){--}}
|
||||||
|
{{-- event.preventDefault();--}}
|
||||||
|
{{-- $.ajax({--}}
|
||||||
|
{{-- url:'{{ route("operationController.store") }}',--}}
|
||||||
|
{{-- method:'post',--}}
|
||||||
|
{{-- data:$(this).serialize(),--}}
|
||||||
|
{{-- dataType:'json',--}}
|
||||||
|
{{-- beforeSend:function(){--}}
|
||||||
|
{{-- $('#save').attr('disabled','disabled');--}}
|
||||||
|
{{-- },--}}
|
||||||
|
{{-- success:function(data)--}}
|
||||||
|
{{-- {--}}
|
||||||
|
{{-- if(data.error)--}}
|
||||||
|
{{-- {--}}
|
||||||
|
{{-- var error_html = '';--}}
|
||||||
|
{{-- for(var count = 0; count < data.error.length; count++)--}}
|
||||||
|
{{-- {--}}
|
||||||
|
{{-- error_html += '<p>'+data.error[count]+'</p>';--}}
|
||||||
|
{{-- }--}}
|
||||||
|
{{-- $('#result').html('<div class="alert alert-danger">'+error_html+'</div>');--}}
|
||||||
|
{{-- }--}}
|
||||||
|
{{-- else--}}
|
||||||
|
{{-- {--}}
|
||||||
|
{{-- dynamic_field(1);--}}
|
||||||
|
{{-- $('#result').html('<div class="alert alert-success">'+data.success+'</div>');--}}
|
||||||
|
{{-- }--}}
|
||||||
|
{{-- $('#save').attr('disabled', false);--}}
|
||||||
|
{{-- }--}}
|
||||||
|
{{-- })--}}
|
||||||
|
{{--});--}}
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ Route::get('/pojazdy', function(){
|
|||||||
|
|
||||||
Route::get('/wyjazdy', 'operationsController@create');
|
Route::get('/wyjazdy', 'operationsController@create');
|
||||||
Route::get('/wyjazdy/add/', 'operationsController@addForm');
|
Route::get('/wyjazdy/add/', 'operationsController@addForm');
|
||||||
Route::post('/wyjazdy', 'operationsController@store');
|
Route::post('/wyjazdy', 'operationsController@store')->name('operationController.store');
|
||||||
|
|
||||||
Route::get('/register', 'RegistrationController@create');
|
Route::get('/register', 'RegistrationController@create');
|
||||||
Route::post('/register', 'RegistrationController@store');
|
Route::post('/register', 'RegistrationController@store');
|
||||||
|
Loading…
Reference in New Issue
Block a user