Dodanie paginacji

This commit is contained in:
czup 2020-01-24 23:05:55 +01:00
parent 8a200c43aa
commit 406605de39
9 changed files with 73 additions and 61 deletions

View File

@ -2,13 +2,15 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="adc1032e-2c5f-4e68-bc22-d140f965f9d5" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/php.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/php.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/operationsController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/operationsController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/layout/app.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/layout/app.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/operations.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/operations.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database/migrations/2019_11_12_235707_create_operations_table.php" beforeDir="false" afterPath="$PROJECT_DIR$/database/migrations/2019_11_12_235707_create_operations_table.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/operation.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/operation.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/operationAdd.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/operationAdd.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/operationEdit.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/operationEdit.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/trainings.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/trainings.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/trainingsAddFireFighters.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/trainingsAddFireFighters.blade.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/routes/web.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/web.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -173,7 +175,8 @@
<workItem from="1562880905757" duration="737000" />
<workItem from="1562881688607" duration="256000" />
<workItem from="1578546881124" duration="357000" />
<workItem from="1578547239701" duration="64632000" />
<workItem from="1578547239701" duration="71154000" />
<workItem from="1579902704711" duration="802000" />
</task>
<servers />
</component>
@ -185,10 +188,10 @@
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="703" y="357" width="559" height="390" key="#com.intellij.fileTypes.FileTypeChooser/67.27.1853.1053@67.27.1853.1053" timestamp="1578547861249" />
<state x="726" y="310" width="524" height="484" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1579085081395">
<state x="726" y="310" width="524" height="484" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1579901649291">
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="726" y="310" width="524" height="484" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/67.27.1853.1053@67.27.1853.1053" timestamp="1579085081395" />
<state x="726" y="310" width="524" height="484" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/67.27.1853.1053@67.27.1853.1053" timestamp="1579901649290" />
<state x="167" y="125" width="1653" height="855" key="DiffContextDialog" timestamp="1579394466035">
<screen x="67" y="27" width="1853" height="1053" />
</state>
@ -197,6 +200,10 @@
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="776" y="310" width="424" height="484" key="FileChooserDialogImpl/67.27.1853.1053@67.27.1853.1053" timestamp="1578547803408" />
<state x="649" y="380" key="com.intellij.ide.util.TipDialog" timestamp="1579902711879">
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="649" y="380" key="com.intellij.ide.util.TipDialog/67.27.1853.1053@67.27.1853.1053" timestamp="1579902711879" />
<state x="647" y="170" width="683" height="764" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser" timestamp="1579395082597">
<screen x="67" y="27" width="1853" height="1053" />
</state>

View File

@ -20,10 +20,10 @@ class operationsController extends Controller
public function create(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
$operations = DB::table('operations')->where('operations.fireStationID', "=", auth()->user()->fireStationID)
->whereNull('deleted_at')
->leftJoin('users', 'operations.commanderID', '=', 'users.id')
->select('operations.id', 'operations.operationDate', 'operations.location', 'operations.target', 'operations.dangerType', 'operations.description', 'operations.commanderID', 'operations.fireStationID', 'users.name', 'users.surname')
->get();
->paginate(10);
$fireFighters = array();
$trucks = array();
foreach($operations as $operation){
@ -257,4 +257,13 @@ class operationsController extends Controller
return operationsController::create();
}
public function destroy($id)
{
operations::find($id)->delete($id);
return response()->json([
'success' => 'Record deleted successfully!'
]);
}
}

View File

@ -4,12 +4,13 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\SoftDeletes;
class operations extends Model
{
//
use SoftDeletes;
protected $primaryKey = 'id';
protected $fillable = ['fireStationID', 'operationDate', 'location', 'target', 'dangerType', 'description', 'commanderID'];
}

View File

@ -21,6 +21,7 @@ class CreateOperationsTable extends Migration
$table->string('dangerType', 100);
$table->string('description');
$table->integer('commanderID');
$table->softDeletes();
$table->timestamps();
});
}

View File

@ -1,5 +1,6 @@
@extends('layout.app')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent<ul>
@ -8,6 +9,7 @@
@stop
@section('center-area')
<meta name="csrf-token" content="{{ csrf_token() }}">
@parent
@if( auth()->check())
@if( auth()->user()->fireStationID == NULL)
@ -39,8 +41,13 @@
<td id="operationTarget{{ $operation->id }}">{{ $operation->target }}</td>
<td id="operationDangerType{{ $operation->id }}">{{ $operation->dangerType }}</td>
<td id="operationCommander{{ $operation->id }}">{{$operation->name}} {{$operation->surname}}</td>
<td><a href="{{ URL::asset('wyjazdy/edit/'.$operation->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
<td><input type="button" onclick="showMoreInformation('{{$operation->id}}')" id="more{{$operation->id}}" value="Więcej"></td>
<td>
<a href="{{ URL::asset('wyjazdy/edit/'.$operation->id) }}"><input type="button" onclick="" value="Edytuj"> </a>
<button class="btn btn-danger btn-delete" type="submit" id="{{$operation->id}}" onclick="deleteButton('{{$operation->id}}')">Usuń</button>
</td>
<td>
<input type="button" onclick="showMoreInformation('{{$operation->id}}')" id="more{{$operation->id}}" value="Więcej">
</td>
</tr>
<tr id="moreInformation{{$operation->id}}" style="visibility:collapse;">
{{-- bgcolor="#C0C0C0"--}}
@ -110,7 +117,7 @@
@endforeach
</tbody>
</table>
{{ $operations->links() }}
@endif
@else
Brak autoryzacji
@ -129,6 +136,39 @@
}
}
function deleteButton(operationID){
swal.fire({
title: "Czy chcesz usunąć wyjazd?",
width: 'auto',
confirmButtonText: 'Tak',
cancelButtonText: 'Nie',
showCancelButton: true,
}).then((result) => {
if(result.value){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "wyjazdy/"+operationID,
type: 'DELETE',
data: {
"id": operationID,
},
success: function (){
console.log("it Works");
location.reload();
}
});
}
})
}
</script>

View File

@ -53,20 +53,7 @@
<div class=form-group">
<div id="drivers">
{{-- <label for="location">Kierowca:</label>--}}
{{-- <select name="operationDriver" class="form-control">--}}
{{-- <option value="">--- Wybierz kierowcę ---</option>--}}
{{-- @foreach ($fireFighters as $fireFighter)--}}
{{-- <option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>--}}
{{-- @endforeach--}}
{{-- </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>
</br>
<button type="button" name="add" id="add" class="btn btn-success">Dodaj Pojazd</button>
@ -173,36 +160,6 @@
});
});
{{--$('#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>

View File

@ -1,7 +1,6 @@
@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>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
<meta name="csrf-token" content="{{ csrf_token() }}">

View File

@ -1,8 +1,5 @@
@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>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
<meta name="csrf-token" content="{{ csrf_token() }}">

View File

@ -37,6 +37,7 @@ Route::get('/wyjazdy/add/', 'operationsController@addForm');
Route::post('/wyjazdy', 'operationsController@store')->name('operationController.store');
Route::post('/wyjazdy/edit/', 'operationsController@update')->name('operationController.update');
Route::get('/wyjazdy/edit/{id}', 'operationsController@editForm');
Route::delete('wyjazdy/{id}', 'operationsController@destroy')->name('operationController.destroy');
Route::get('/register', 'RegistrationController@create');
Route::post('/register', 'RegistrationController@store');