1
0
forked from s421507/eOSP2

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/jakub-onderka/php-console-color" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" /> <path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/vlucas/phpdotenv" /> <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> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.1" /> <component name="PhpProjectSharedConfiguration" php_language_level="7.1" />
<component name="PhpUnit"> <component name="PhpUnit">
<phpunit_settings> <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> </phpunit_settings>
</component> </component>
</project> </project>

View File

@ -1,32 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="adc1032e-2c5f-4e68-bc22-d140f965f9d5" name="Default Changelist" comment="" /> <list default="true" id="adc1032e-2c5f-4e68-bc22-d140f965f9d5" name="Default Changelist" comment="">
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <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="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="ComposerSettings"> <component name="ComposerSettings" doNotAsk="true">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath> <pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
<execution> <execution>
<executable /> <executable />
</execution> </execution>
</component> </component>
<component name="FileEditorManager">
<leaf />
</component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/test.php" />
</list>
</option>
</component>
<component name="PhpWorkspaceProjectConfiguration"> <component name="PhpWorkspaceProjectConfiguration">
<include_path> <include_path>
<path value="$PROJECT_DIR$/vendor/monolog/monolog" /> <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/jakub-onderka/php-console-color" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" /> <path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/vlucas/phpdotenv" /> <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> </include_path>
</component> </component>
<component name="ProjectFrameBounds" extendedState="6"> <component name="ProjectId" id="1W91DnkrissSXi0FRsBOInYJNVt" />
<option name="x" value="293" /> <component name="ProjectViewState">
<option name="y" value="53" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="width" value="1400" /> <option name="showExcludedFiles" value="true" />
<option name="height" value="1000" /> <option name="showLibraryContents" value="true" />
</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> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" /> <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_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" /> <property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="nodejs_package_manager_path" value="npm" /> <property name="nodejs_package_manager_path" value="npm" />
</component> </component>
<component name="RunDashboard"> <component name="RecentsManager">
<option name="ruleStates"> <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> <list>
<RuleState> <serviceView>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" /> <treeState>
</RuleState> <expand />
<RuleState> <select />
<option name="name" value="StatusDashboardGroupingRule" /> </treeState>
</RuleState> </serviceView>
</list> </list>
</option> </option>
</component> </component>
@ -187,40 +172,38 @@
<workItem from="1562880823859" duration="7000" /> <workItem from="1562880823859" duration="7000" />
<workItem from="1562880905757" duration="737000" /> <workItem from="1562880905757" duration="737000" />
<workItem from="1562881688607" duration="256000" /> <workItem from="1562881688607" duration="256000" />
<workItem from="1578546881124" duration="357000" />
<workItem from="1578547239701" duration="64632000" />
</task> </task>
<servers /> <servers />
</component> </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"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" /> <option name="version" value="1" />
</component> </component>
<component name="editorHistoryManager"> <component name="WindowStateProjectService">
<entry file="file://$PROJECT_DIR$/test.php" /> <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> </component>
</project> </project>

View File

@ -87,12 +87,18 @@ class operationsController extends Controller
->get(); ->get();
$operationsTrucks = DB::table('vehicles')->where("vehicles.fireStationID", "=", auth()->user()->fireStationID ) // $operationsTrucks = DB::table('vehicles')->where("vehicles.fireStationID", "=", auth()->user()->fireStationID )
->leftJoin('operationsTrucks', function ($join) use($id){ // ->leftJoin('operationsTrucks', function ($join) use($id){
$join->on('vehicles.id', '=', 'operationsTrucks.truckID'); // $join->on('vehicles.id', '=', 'operationsTrucks.truckID');
$join->where('operationsTrucks.operationID', '=', $id); // $join->where('operationsTrucks.operationID', '=', $id);
}) // })
->leftJoin('users', 'operationsTrucks.driverID', '=', 'users.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') ->select('vehicles.*', 'operationsTrucks.truckID', 'operationsTrucks.driverID', 'users.name as driverName', 'users.surname as driverSurname')
->get(); ->get();
@ -191,7 +197,8 @@ class operationsController extends Controller
'transport.*' => 'required', '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">--}} {{-- <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" />--}} {{-- <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://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>--}}
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
</head> </head>

View File

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

View File

@ -3,10 +3,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <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="/wyjazdy/"><li>Wróć<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> </ul>
@stop @stop
@ -14,9 +11,11 @@
@parent @parent
<form method="POST" action="/wyjazdy" id="dynamic_form"> <form method="POST" action="/wyjazdy" id="dynamic_form">
{{ csrf_field() }} {{ csrf_field() }}
<div class="form-group"> <div class="form-group row">
<label for="date">Data wyjazdu: </label> <div class="col-auto">
<input type="datetime-local" id="operationDate" name="operationDate" > <label for="date">Data wyjazdu: </label>
<input type="datetime-local" id="operationDate" name="operationDate" class="form-control">
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -39,14 +38,16 @@
<textarea class="form-control" id="'operationDescription" name="operationDescription" placeholder="Opis akcji..."></textarea> <textarea class="form-control" id="'operationDescription" name="operationDescription" placeholder="Opis akcji..."></textarea>
</div> </div>
<div class=form-group"> <div class="form-group row">
<label for="location">Dowodzący:</label> <div class="col-auto">
<select name="operationLeader" class="form-control"> <label for="location">Dowodzący:</label>
<option value="">--- Wybierz dowódcę ---</option> <select name="operationLeader" class="form-control">
@foreach ($fireFighters as $fireFighter) <option value="">--- Wybierz dowódcę ---</option>
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option> @foreach ($fireFighters as $fireFighter)
@endforeach <option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
</select> @endforeach
</select>
</div>
</div> </div>
@ -67,24 +68,39 @@
{{-- @endforeach--}} {{-- @endforeach--}}
{{-- </select>--}} {{-- </select>--}}
</div> </div>
</br>
<button type="button" name="add" id="add" class="btn btn-success">Dodaj Pojazd</button>
</div> </div>
</br>
<div class="form-group"> <div class="form-group">
<table> <table class="table table-hover">
<tr> <thead>
<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)
<tr> <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> </tr>
</thead>
<tbody>
@php @php
$i++; $i = 0;
@endphp @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> </table>
</div> </div>
@ -106,13 +122,18 @@
function dynamic_field(number) 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 += '<select name="operationDriver[]" class="form-control">';
html += '<option value="">--- Wybierz kierowcę ---</option>'; html += '<option value="">--- Wybierz kierowcę ---</option>';
html += '@foreach ($fireFighters as $fireFighter)'; html += '@foreach ($fireFighters as $fireFighter)';
html += '<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>'; html += '<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>';
html += '@endforeach'; html += '@endforeach';
html += '</select>'; html += '</select>';
html += '</div>';
html += '<div class="col-auto">';
html += '<label for="location">Pojazd:</label>'; html += '<label for="location">Pojazd:</label>';
html += '<select name="operationVehicle[]" class="form-control">'; html += '<select name="operationVehicle[]" class="form-control">';
html += '<option value="">--- Wybierz pojazd ---</option>'; html += '<option value="">--- Wybierz pojazd ---</option>';
@ -120,17 +141,15 @@
html += '<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>'; html += '<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>';
html += '@endforeach'; html += '@endforeach';
html += '</select>'; 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(){ $(document).on('click', '#add', function(){
@ -140,7 +159,18 @@
$(document).on('click', '.remove', function(){ $(document).on('click', '.remove', function(){
count--; 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){--}} {{--$('#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> <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="/wyjazdy/"><li>Wróc<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> </ul>
@stop @stop
@section('center-area') @section('center-area')
@parent @parent
<form method="POST" action="/wyjazdy/edit" id="dynamic_form"> <form method="POST" action="/wyjazdy/edit" id="dynamic_form" >
{{ csrf_field() }} {{ csrf_field() }}
<input type="hidden" class="form-control" name="operationID" value="{{ $operation->id }}"> <input type="hidden" class="form-control" name="operationID" value="{{ $operation->id }}">
<div class="form-group"> <div class="form-group row">
<label for="date">Data wyjazdu: </label> <div class="col-auto">
<input type="datetime-local" id="operationDate" name="operationDate" value="{{ \Carbon\Carbon::parse($operation->operationDate)->format('Y-m-d\TH:i') }}"> <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>
<div class="form-group"> <div class="form-group">
<label for="location">Miejsce akcji:</label> <label for="location">Miejsce akcji:</label>
<input type="text" class="form-control" id="operationLocation" name="operationLocation" value="{{ $operation->location}}"> <input type="text" class="form-control" id="operationLocation" name="operationLocation" value="{{ $operation->location}}">
</div> </div>
<div class="form-group"> <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 }}"> <input type="text" class="form-control" id="operationTarget" name="operationTarget" value="{{ $operation->target }}">
</div> </div>
@ -41,65 +41,85 @@
<textarea class="form-control" id="'operationDescription" name="operationDescription">{{ $operation->description }}</textarea> <textarea class="form-control" id="'operationDescription" name="operationDescription">{{ $operation->description }}</textarea>
</div> </div>
<div class=form-group"> <div class="form-group row">
<label for="location">Dowodzący:</label> <div class="col-auto">
<select name="operationLeader" class="form-control"> <label for="location">Dowodzący:</label>
<option value="">--- Wybierz dowódcę ---</option> <select name="operationLeader" class="form-control">
@foreach ($fireFighters as $fireFighter) <option value="">--- Wybierz dowódcę ---</option>
<option value="{{$fireFighter->id}}" {{$fireFighter->id == $operation->commanderID ? 'selected' : ''}}>{{ $fireFighter->name }} {{$fireFighter->surname }}</option> @foreach ($fireFighters as $fireFighter)
@endforeach <option value="{{$fireFighter->id}}" {{$fireFighter->id == $operation->commanderID ? 'selected' : ''}}>{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
</select> @endforeach
</select>
</div>
</div> </div>
@foreach($operationsTrucks as $operationTruck)
{{$operationTruck->driverName}}
@endforeach
<div class=form-group"> <div class=form-group">
<div id="drivers"> <div id="drivers">
@foreach($operationsTrucks as $operationTruck) @foreach($operationsTrucks as $operationTruck)
<div id="singleDriver"> <div id="singleDriver">
{{$operationTruck->driverName}} <div class="row align-items-end">
<label for="location">Kierowca:</label> <div class="col-auto">
<select name="operationDriver" class="form-control"> <label for="location">Kierowca:</label>
<option value="">--- Wybierz kierowcę ---</option> <select name="operationDriver[]" class="form-control">
@foreach ($fireFighters as $fireFighter) <option value="">--- Wybierz kierowcę ---</option>
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option> @foreach ($fireFighters as $fireFighter)
@endforeach <option {{$fireFighter->id == $operationTruck->driverID ? 'selected' : ''}} value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
</select> @endforeach
<label for="location">Pojazd:</label> </select>
<select name="operationVehicle" class="form-control"> </div>
<option value="">--- Wybierz pojazd ---</option> <div class="col-auto">
@foreach ($vehicles as $vehicle) <label for="location">Pojazd:</label>
<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option> <select name="operationVehicle[]" class="form-control">
@endforeach <option value="">--- Wybierz pojazd ---</option>
</select> @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> </div>
@endforeach @endforeach
</div> </div>
</br>
<button type="button" name="add" id="add" class="btn btn-success">Dodaj Pojazd</button>
</div> </div>
</br>
<div class="form-group"> <div class="form-group">
<table> <table class="table table-hover">
<tr> <thead>
<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)
<tr> <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> </tr>
</thead>
<tbody>
@php @php
$i++; $i = 0;
@endphp @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> </table>
</div> </div>
<div class="form-group"> <div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zapisz</button> <button style="cursor:pointer" type="submit" class="btn btn-primary">Zapisz</button>
</div> </div>
@ -114,18 +134,21 @@
var count = 1; var count = 1;
dynamic_field(count);
function dynamic_field(number) function dynamic_field(number)
{ {
html = '<div id="singleDriver">';
html = '<div id="singleDriver"><label for="location">Kierowca:</label>'; 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 += '<select name="operationDriver[]" class="form-control">';
html += '<option value="">--- Wybierz kierowcę ---</option>'; html += '<option value="">--- Wybierz kierowcę ---</option>';
html += '@foreach ($fireFighters as $fireFighter)'; html += '@foreach ($fireFighters as $fireFighter)';
html += '<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>'; html += '<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>';
html += '@endforeach'; html += '@endforeach';
html += '</select>'; html += '</select>';
html += '</div>';
html += '<div class="col-auto">';
html += '<label for="location">Pojazd:</label>'; html += '<label for="location">Pojazd:</label>';
html += '<select name="operationVehicle[]" class="form-control">'; html += '<select name="operationVehicle[]" class="form-control">';
html += '<option value="">--- Wybierz pojazd ---</option>'; html += '<option value="">--- Wybierz pojazd ---</option>';
@ -133,17 +156,14 @@
html += '<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>'; html += '<option value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>';
html += '@endforeach'; html += '@endforeach';
html += '</select>'; 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) $('#drivers').append(html);
{
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(){ $(document).on('click', '#add', function(){
@ -153,39 +173,19 @@
$(document).on('click', '.remove', function(){ $(document).on('click', '.remove', function(){
count--; count--;
$(this).closest("#singleDriver").remove();
});
{{--$('#dynamic_form').on('submit', function(event){--}} swal.fire({
{{-- event.preventDefault();--}} html: "Czy na pewno chcesz usunąć pojazd?",// this will output "Error 422: Unprocessable Entity"
{{-- $.ajax({--}} width: 'auto',
{{-- url:'{{ route("operationController.store") }}',--}} confirmButtonText: 'Tak',
{{-- method:'post',--}} cancelButtonText: 'Nie',
{{-- data:$(this).serialize(),--}} showCancelButton: true,
{{-- dataType:'json',--}} }).then((result) => {
{{-- beforeSend:function(){--}} if (result.value) {
{{-- $('#save').attr('disabled','disabled');--}} $(this).closest("#singleDriver").remove();
{{-- },--}} }
{{-- 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> </script>