Poprawienie widoku wyjazdów - wyświetlanie tabel wyjazdów, wyświetlanie formularzy edycji/dodawania wyjazdu, naprawa buga związanego z edycją pojazdów biorących udział w akcji

This commit is contained in:
czup 2020-01-22 00:54:08 +01:00
parent 2513a41e0a
commit 0e9456afcc
7 changed files with 335 additions and 282 deletions

View File

@ -97,12 +97,16 @@
<path value="$PROJECT_DIR$/vendor/jakub-onderka/php-console-color" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/vlucas/phpdotenv" />
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
<path value="$PROJECT_DIR$/vendor/nexmo/client-core" />
<path value="$PROJECT_DIR$/vendor/codedge/laravel-fpdf" />
<path value="$PROJECT_DIR$/vendor/twbs/bootstrap" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.1" />
<component name="PhpUnit">
<phpunit_settings>
<PhpUnitSettings load_method="CUSTOM_LOADER" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
</phpunit_settings>
</component>
</project>

View File

@ -1,32 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="adc1032e-2c5f-4e68-bc22-d140f965f9d5" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<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$/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" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings">
<component name="ComposerSettings" doNotAsk="true">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
<execution>
<executable />
</execution>
</component>
<component name="FileEditorManager">
<leaf />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/test.php" />
</list>
</option>
</component>
<component name="PhpWorkspaceProjectConfiguration">
<include_path>
<path value="$PROJECT_DIR$/vendor/monolog/monolog" />
@ -124,53 +121,41 @@
<path value="$PROJECT_DIR$/vendor/jakub-onderka/php-console-color" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/vlucas/phpdotenv" />
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
<path value="$PROJECT_DIR$/vendor/nexmo/client-core" />
<path value="$PROJECT_DIR$/vendor/codedge/laravel-fpdf" />
<path value="$PROJECT_DIR$/vendor/twbs/bootstrap" />
</include_path>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="293" />
<option name="y" value="53" />
<option name="width" value="1400" />
<option name="height" value="1000" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="eOSP" type="b2602c69:ProjectViewProjectNode" />
<item name="eOSP" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="eOSP" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="bcb0276e:PhpExternalLibrariesNodePatcher$PatchedExternalLibrariesNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
<component name="ProjectId" id="1W91DnkrissSXi0FRsBOInYJNVt" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/database/migrations/x" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="nodejs_package_manager_path" value="npm" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/database/migrations/x" />
<recent name="$PROJECT_DIR$" />
</key>
</component>
<component name="ServiceViewManager">
<option name="viewStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
<serviceView>
<treeState>
<expand />
<select />
</treeState>
</serviceView>
</list>
</option>
</component>
@ -187,40 +172,38 @@
<workItem from="1562880823859" duration="7000" />
<workItem from="1562880905757" duration="737000" />
<workItem from="1562881688607" duration="256000" />
<workItem from="1578546881124" duration="357000" />
<workItem from="1578547239701" duration="64632000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="1000000" />
</component>
<component name="ToolWindowManager">
<frame x="67" y="25" width="1853" height="1055" extended-state="6" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.255119" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" order="8" />
<window_info anchor="bottom" id="Version Control" order="9" weight="0.32937366" />
<window_info active="true" anchor="bottom" id="Terminal" order="10" visible="true" weight="0.32937366" />
<window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Database" order="3" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/test.php" />
<component name="WindowStateProjectService">
<state x="703" y="357" width="559" height="390" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1578547861249">
<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">
<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="167" y="125" width="1653" height="855" key="DiffContextDialog" timestamp="1579394466035">
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="167" y="125" width="1653" height="855" key="DiffContextDialog/67.27.1853.1053@67.27.1853.1053" timestamp="1579394466035" />
<state x="776" y="310" width="424" height="484" key="FileChooserDialogImpl" timestamp="1578547803408">
<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="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>
<state x="647" y="170" width="683" height="764" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser/67.27.1853.1053@67.27.1853.1053" timestamp="1579395082597" />
<state x="657" y="253" key="run.anything.popup" timestamp="1579650286067">
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="657" y="253" key="run.anything.popup/67.27.1853.1053@67.27.1853.1053" timestamp="1579650286067" />
</component>
</project>

View File

@ -87,12 +87,18 @@ class operationsController extends Controller
->get();
$operationsTrucks = DB::table('vehicles')->where("vehicles.fireStationID", "=", auth()->user()->fireStationID )
->leftJoin('operationsTrucks', function ($join) use($id){
$join->on('vehicles.id', '=', 'operationsTrucks.truckID');
$join->where('operationsTrucks.operationID', '=', $id);
})
->leftJoin('users', 'operationsTrucks.driverID', '=', 'users.id')
// $operationsTrucks = DB::table('vehicles')->where("vehicles.fireStationID", "=", auth()->user()->fireStationID )
// ->leftJoin('operationsTrucks', function ($join) use($id){
// $join->on('vehicles.id', '=', 'operationsTrucks.truckID');
// $join->where('operationsTrucks.operationID', '=', $id);
// })
// ->leftJoin('users', 'operationsTrucks.driverID', '=', 'users.id')
// ->select('vehicles.*', 'operationsTrucks.truckID', 'operationsTrucks.driverID', 'users.name as driverName', 'users.surname as driverSurname')
// ->get();
$operationsTrucks = DB::table('operationsTrucks')->where("operationsTrucks.operationID", "=", $id)
->join('users', 'operationsTrucks.driverID', '=', 'users.ID')
->join('vehicles', 'operationsTrucks.truckID', '=', 'vehicles.ID')
->select('vehicles.*', 'operationsTrucks.truckID', 'operationsTrucks.driverID', 'users.name as driverName', 'users.surname as driverSurname')
->get();
@ -191,7 +197,8 @@ class operationsController extends Controller
'transport.*' => 'required',
],
[
'required' => ':attribute jest wymagany(e)'
'required' => ':attribute jest wymagany(e)',
'operationTarget.required' => 'Cel jest wyma gany'
]);

View File

@ -8,10 +8,10 @@
{{-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">--}}
<script src="js/app.js"></script>.
<script src="js/app.js"></script>
{{-- <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>
</head>

View File

@ -3,10 +3,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent<ul>
<a href="wyjazdy/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>
<a href="/wyjazdy/add"><li>Dodaj<img src="/img/left_menu_icon/add.png"></li></a>
</ul>
@stop
@ -16,72 +13,102 @@
@if( auth()->user()->fireStationID == NULL)
Jednostka nie istnieje
@else
<table class='firefighterViewTable'>
<tr class='table-header'>
<td>Data</td>
<td>Miejsce</td>
<td>Cel</td>
<td>Rodzaj zagrożenia</td>
<td>Dowódca</td>
</tr>
@foreach($operations as $operation)
<table class='table'>
<thead>
<tr>
<td id="operationDate{{ $operation->id }}">{{ $operation->operationDate }}</td>
<td id="operationLocation{{ $operation->id }}">{{ $operation->location }}</td>
<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>
<th>#</th>
<th>Data</th>
<th>Miejsce</th>
<th>Cel</th>
<th>Rodzaj zagrożenia</th>
<th>Dowódca</th>
<th>Operacja</th>
<th>Szczegóły</th>
</tr>
<tr id="moreInformation{{$operation->id}}" style="visibility:collapse;" bgcolor="#C0C0C0">
</thead>
<td colspan="5">
<center>
<table>
<tr class='table-header'>
<td colspan="8">Opis Akcji</td>
</tr>
<tr>
<td>{{$operation->description}}</td>
</tr>
<tr><td></td></tr>
<tr class="table-header">
<td>Pojazdy</td>
<td>Kierowcy</td>
</tr>
@foreach($trucks[$operation->id] as $truck)
@if($truck->truckID != null)
<tbody>
@php
$i=1;
@endphp
@foreach($operations as $operation)
<tr>
<th>{{$i}}</th>
<td id="operationDate{{ $operation->id }}">{{ $operation->operationDate }}</td>
<td id="operationLocation{{ $operation->id }}">{{ $operation->location }}</td>
<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>
</tr>
<tr id="moreInformation{{$operation->id}}" style="visibility:collapse;">
{{-- bgcolor="#C0C0C0"--}}
<td colspan="8">
<center>
<table class="table table-dark">
<thead>
<tr>
<td>{{$truck->name}} {{$truck->codename }} {{$truck->brand}} {{$truck->registrationNumber}}</td>
<td>{{$truck->driverName }} {{ $truck->driverSurname}}</td>
<th colspan="8"><center>Opis Akcji</center></th>
</tr>
@endif
@endforeach
</thead>
<tr><td></td></tr>
<tr class='table-header' colspan="5">
<td>Członkowie Akcji</td>
<td>Transport Własny</td>
</tr>
@foreach($fireFighters[$operation->id] as $fireFighter)
@if($fireFighter->memberID != null)
<tbody>
<tr>
<td>{{$fireFighter->name}} {{$fireFighter->surname }}</td>
<td>{{($fireFighter->privateTransport == 1) ? "Tak" : "Nie"}}</td>
<td colspan="8">{{$operation->description}}</td>
</tr>
@endif
@endforeach
</table>
</center>
</td>
</tr>
@endforeach
<tr>
<td></td>
</tr>
<tr>
<th><center>Pojazdy</center></th>
<th><center>Kierowcy</center></th>
</tr>
@foreach($trucks[$operation->id] as $truck)
@if($truck->truckID != null)
<tr>
<td>{{$truck->name}} {{$truck->codename }} {{$truck->brand}} {{$truck->registrationNumber}}</td>
<td colspan="8">{{$truck->driverName }} {{ $truck->driverSurname}}</td>
</tr>
@endif
@endforeach
<tr>
<td></td>
<td></td>
</tr>
<tr>
<th><center>Członkowie Akcji</center></th>
<th><center>Transport Własny</center></th>
</tr>
@foreach($fireFighters[$operation->id] as $fireFighter)
@if($fireFighter->memberID != null)
<tr>
<td>{{$fireFighter->name}} {{$fireFighter->surname }}</td>
<td>{{($fireFighter->privateTransport == 1) ? "Tak" : "Nie"}}</td>
</tr>
@endif
@endforeach
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</center>
</td>
</tr>
@php
$i++;
@endphp
@endforeach
</tbody>
</table>
@endif
@ -103,3 +130,5 @@
}
</script>

View File

@ -3,10 +3,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent<ul>
<a href="?addOperation"><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>
<a href="/wyjazdy/"><li>Wróć<img src="/img/left_menu_icon/add.png"></li></a>
</ul>
@stop
@ -14,9 +11,11 @@
@parent
<form method="POST" action="/wyjazdy" id="dynamic_form">
{{ csrf_field() }}
<div class="form-group">
<label for="date">Data wyjazdu: </label>
<input type="datetime-local" id="operationDate" name="operationDate" >
<div class="form-group row">
<div class="col-auto">
<label for="date">Data wyjazdu: </label>
<input type="datetime-local" id="operationDate" name="operationDate" class="form-control">
</div>
</div>
<div class="form-group">
@ -39,14 +38,16 @@
<textarea class="form-control" id="'operationDescription" name="operationDescription" placeholder="Opis akcji..."></textarea>
</div>
<div class=form-group">
<label for="location">Dowodzący:</label>
<select name="operationLeader" class="form-control">
<option value="">--- Wybierz dowódcę ---</option>
@foreach ($fireFighters as $fireFighter)
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
@endforeach
</select>
<div class="form-group row">
<div class="col-auto">
<label for="location">Dowodzący:</label>
<select name="operationLeader" class="form-control">
<option value="">--- Wybierz dowódcę ---</option>
@foreach ($fireFighters as $fireFighter)
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
@endforeach
</select>
</div>
</div>
@ -67,24 +68,39 @@
{{-- @endforeach--}}
{{-- </select>--}}
</div>
</br>
<button type="button" name="add" id="add" class="btn btn-success">Dodaj Pojazd</button>
</div>
</br>
<div class="form-group">
<table>
<tr>
<td>Imię i nazwisko: </td><td></td><td>Obecność:</td><td></td><td>Transport własny:</td>
</tr>
@php
$i = 0;
@endphp
@foreach($fireFighters as $fireFighterChecklist)
<table class="table table-hover">
<thead>
<tr>
<td>{{ $fireFighterChecklist->name }} {{$fireFighterChecklist->surname }}</td><td></td><td><center><input type="checkbox" name="attendance[{{$i}}]" value="{{$fireFighterChecklist->id}}"></center></td> <td></td> <td><center><input type="checkbox" name="transport[{{$i}}]" value="{{$i}}"></center></td>
<th scope="col">#</th>
<th scope="col">Imię i Nazwisko</th>
<th scope="col">Obecność</th>
<th scope="col">Transport własny</th>
</tr>
</thead>
<tbody>
@php
$i++;
$i = 0;
@endphp
@endforeach
@foreach($fireFighters as $fireFighterChecklist)
<tr>
<th scope="row">{{$i+1}}</th>
<td>{{ $fireFighterChecklist->name }} {{$fireFighterChecklist->surname }}</td>
<td><input type="checkbox" name="attendance[{{$i}}]" value="{{$fireFighterChecklist->id}}"></td>
<td><input type="checkbox" name="transport[{{$i}}]" value="{{$i}}"></td>
</tr>
@php
$i++;
@endphp
@endforeach
</tbody>
</table>
</div>
@ -106,13 +122,18 @@
function dynamic_field(number)
{
html = '<div id="singleDriver"><label for="location">Kierowca:</label>';
html = '<div id="singleDriver">';
html += '<div class="row align-items-end">';
html += '<div class="col-auto">';
html += '<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 += '</div>';
html += '<div class="col-auto">';
html += '<label for="location">Pojazd:</label>';
html += '<select name="operationVehicle[]" class="form-control">';
html += '<option value="">--- Wybierz pojazd ---</option>';
@ -120,17 +141,15 @@
html += '<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>';
html += '@endforeach';
html += '</select>';
html += '</div>';
html += '<div class="col-auto">';
html += '<button type="button" name="remove" id="" class="btn btn-danger remove form-control">Usuń</button>';
html += '</div>';
html += '</div>';
html += '</div>';
$('#drivers').append(html);
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(){
@ -140,7 +159,18 @@
$(document).on('click', '.remove', function(){
count--;
$(this).closest("#singleDriver").remove();
swal.fire({
html: "Czy na pewno chcesz usunąć pojazd?",// this will output "Error 422: Unprocessable Entity"
width: 'auto',
confirmButtonText: 'Tak',
cancelButtonText: 'Nie',
showCancelButton: true,
}).then((result) => {
if (result.value) {
$(this).closest("#singleDriver").remove();
}
});
});
{{--$('#dynamic_form').on('submit', function(event){--}}

View File

@ -3,31 +3,31 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent<ul>
<a href="?addOperation"><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>
<a href="/wyjazdy/"><li>Wróc<img src="/img/left_menu_icon/add.png"></li></a>
</ul>
@stop
@section('center-area')
@parent
<form method="POST" action="/wyjazdy/edit" id="dynamic_form">
<form method="POST" action="/wyjazdy/edit" id="dynamic_form" >
{{ csrf_field() }}
<input type="hidden" class="form-control" name="operationID" value="{{ $operation->id }}">
<div class="form-group">
<label for="date">Data wyjazdu: </label>
<input type="datetime-local" id="operationDate" name="operationDate" value="{{ \Carbon\Carbon::parse($operation->operationDate)->format('Y-m-d\TH:i') }}">
<div class="form-group row">
<div class="col-auto">
<label for="date">Data wyjazdu: </label>
<input type="datetime-local" id="operationDate" name="operationDate" value="{{ \Carbon\Carbon::parse($operation->operationDate)->format('Y-m-d\TH:i') }}" class="form-control">
</div>
</div>
<div class="form-group">
<label for="location">Miejsce akcji:</label>
<input type="text" class="form-control" id="operationLocation" name="operationLocation" value="{{ $operation->location}}">
</div>
<div class="form-group">
<label for="location">Cel wyjazdu:</label>
<label for="location" >Cel wyjazdu:</label>
<input type="text" class="form-control" id="operationTarget" name="operationTarget" value="{{ $operation->target }}">
</div>
@ -41,65 +41,85 @@
<textarea class="form-control" id="'operationDescription" name="operationDescription">{{ $operation->description }}</textarea>
</div>
<div class=form-group">
<label for="location">Dowodzący:</label>
<select name="operationLeader" class="form-control">
<option value="">--- Wybierz dowódcę ---</option>
@foreach ($fireFighters as $fireFighter)
<option value="{{$fireFighter->id}}" {{$fireFighter->id == $operation->commanderID ? 'selected' : ''}}>{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
@endforeach
</select>
<div class="form-group row">
<div class="col-auto">
<label for="location">Dowodzący:</label>
<select name="operationLeader" class="form-control">
<option value="">--- Wybierz dowódcę ---</option>
@foreach ($fireFighters as $fireFighter)
<option value="{{$fireFighter->id}}" {{$fireFighter->id == $operation->commanderID ? 'selected' : ''}}>{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
@endforeach
</select>
</div>
</div>
@foreach($operationsTrucks as $operationTruck)
{{$operationTruck->driverName}}
@endforeach
<div class=form-group">
<div id="drivers">
@foreach($operationsTrucks as $operationTruck)
<div id="singleDriver">
{{$operationTruck->driverName}}
<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 class="row align-items-end">
<div class="col-auto">
<label for="location">Kierowca:</label>
<select name="operationDriver[]" class="form-control">
<option value="">--- Wybierz kierowcę ---</option>
@foreach ($fireFighters as $fireFighter)
<option {{$fireFighter->id == $operationTruck->driverID ? 'selected' : ''}} value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
@endforeach
</select>
</div>
<div class="col-auto">
<label for="location">Pojazd:</label>
<select name="operationVehicle[]" class="form-control">
<option value="">--- Wybierz pojazd ---</option>
@foreach ($vehicles as $vehicle)
<option {{$vehicle->id == $operationTruck->truckID ? 'selected' : ''}} value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>
@endforeach
</select>
</div>
<div class="col-auto">
<button type="button" name="remove" id="" class="btn btn-danger remove form-control">Usuń</button>
</div>
</div>
</div>
@endforeach
</div>
</br>
<button type="button" name="add" id="add" class="btn btn-success">Dodaj Pojazd</button>
</div>
</br>
<div class="form-group">
<table>
<tr>
<td>Imię i nazwisko: </td><td></td><td>Obecność:</td><td></td><td>Transport własny:</td>
</tr>
@php
$i = 0;
@endphp
@foreach($fireFighters as $fireFighterChecklist)
<table class="table table-hover">
<thead>
<tr>
<td>{{ $fireFighterChecklist->name }} {{$fireFighterChecklist->surname }}</td><td></td><td><center><input type="checkbox" name="attendance[{{$i}}]" value="{{$fireFighterChecklist->id}}" {{$fireFighterChecklist->memberID != null ? 'checked' : ''}} ></center></td> <td></td> <td><center><input type="checkbox" name="transport[{{$i}}]" value="{{$i}}" {{$fireFighterChecklist->privateTransport == 1 ? 'checked' : ''}}></center></td>
<th scope="col">#</th>
<th scope="col">Imię i Nazwisko</th>
<th scope="col">Obecność</th>
<th scope="col">Transport własny</th>
</tr>
</thead>
<tbody>
@php
$i++;
$i = 0;
@endphp
@endforeach
@foreach($fireFighters as $fireFighterChecklist)
<tr>
<th scope="row">{{$i+1}}</th>
<td>{{ $fireFighterChecklist->name }} {{$fireFighterChecklist->surname }}</td>
<td><input type="checkbox" name="attendance[{{$i}}]" value="{{$fireFighterChecklist->id}}" {{$fireFighterChecklist->memberID != null ? 'checked' : ''}} ></td>
<td><input type="checkbox" name="transport[{{$i}}]" value="{{$i}}" {{$fireFighterChecklist->privateTransport == 1 ? 'checked' : ''}}></td>
</tr>
@php
$i++;
@endphp
@endforeach
</tbody>
</table>
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zapisz</button>
</div>
@ -114,18 +134,21 @@
var count = 1;
dynamic_field(count);
function dynamic_field(number)
{
html = '<div id="singleDriver"><label for="location">Kierowca:</label>';
html = '<div id="singleDriver">';
html += '<div class="row align-items-end">';
html += '<div class="col-auto">';
html += '<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 += '</div>';
html += '<div class="col-auto">';
html += '<label for="location">Pojazd:</label>';
html += '<select name="operationVehicle[]" class="form-control">';
html += '<option value="">--- Wybierz pojazd ---</option>';
@ -133,17 +156,14 @@
html += '<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>';
html += '@endforeach';
html += '</select>';
html += '</div>';
html += '<div class="col-auto">';
html += '<button type="button" name="remove" id="" class="btn btn-danger remove form-control">Usuń</button>';
html += '</div>';
html += '</div>';
html += '</div>';
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);
}
$('#drivers').append(html);
}
$(document).on('click', '#add', function(){
@ -153,39 +173,19 @@
$(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);--}}
{{-- }--}}
{{-- })--}}
{{--});--}}
swal.fire({
html: "Czy na pewno chcesz usunąć pojazd?",// this will output "Error 422: Unprocessable Entity"
width: 'auto',
confirmButtonText: 'Tak',
cancelButtonText: 'Nie',
showCancelButton: true,
}).then((result) => {
if (result.value) {
$(this).closest("#singleDriver").remove();
}
});
});
});
</script>