Dodanie widoku

This commit is contained in:
czup 2019-12-11 20:28:53 +01:00
parent 5a840b7819
commit deea1c22aa
2 changed files with 63 additions and 10 deletions

View File

@ -24,7 +24,30 @@ class operationsController extends Controller
->select('operations.id', 'operations.operationDate', 'operations.location', 'operations.target', 'operations.dangerType', 'operations.description', 'operations.commanderID', 'operations.fireStationID', 'users.name', 'users.surname')
->get();
return view('operation', ["operations" => $operations]);
foreach($operations as $operation){
$id =$operation->id;
$fireFighters[$id] = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
->leftJoin('operationsMembers', function ($join) use($id){
$join->on('users.id', '=', 'operationsMembers.memberID');
$join->where('operationsMembers.operationID', '=', $id);
})
->select('users.*', 'operationsMembers.memberID', 'operationsMembers.privateTransport')
->get();
$trucks[$id] = 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();
}
// return view('operation', ["operations" => $operations], ["fireFighters" => $fireFighters], ["trucks" => $trucks]);
return View::make('/operation')->with(compact('operations', 'fireFighters', 'trucks'));
} else{
return view('operation');
}
@ -179,8 +202,8 @@ class operationsController extends Controller
for($count = 0; $count < count($operationDriver); $count++){
$operationsTrucks = operationsTrucks::create([
'operationID' => $request->operationID,
'truckID' => $operationDriver[$count],
'driverID' => $operationVehicle[$count]
'truckID' => $operationVehicle[$count],
'driverID' => $operationDriver[$count]
]);
}

View File

@ -35,24 +35,54 @@
<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="display:none;" bgcolor="#C0C0C0">
<tr id="moreInformation{{$operation->id}}" style="visibility:collapse;" bgcolor="#C0C0C0">
<td colspan="5">
<center>
<table>
<tr class='table-header' colspan="5">
<td colspan="5">Opis {{$operation->id}}</td>
<tr class='table-header'>
<td colspan="8">Opis Akcji</td>
</tr>
<tr>
<td>{{$operation->description}}</td>
</tr>
<tr class='table-header' colspan="5">
<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)
<tr>
<td>{{$truck->name}} {{$truck->codename }} {{$truck->brand}} {{$truck->registrationNumber}}</td>
<td>{{$truck->driverName }} {{ $truck->driverSurname}}</td>
</tr>
@endif
@endforeach
<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)
<tr>
<td>{{$fireFighter->name}} {{$fireFighter->surname }}</td>
<td>{{($fireFighter->privateTransport == 1) ? "Tak" : "Nie"}}</td>
</tr>
@endif
@endforeach
</table>
</center>
</td>
</tr>
@endforeach
</table>"
</table>
@endif
@else
@ -66,10 +96,10 @@
if( $('#more'+operationID).val() == "Więcej"){
$('#more'+operationID).val("Ukryj");
$("#moreInformation"+operationID).css('display', 'block');
$("#moreInformation"+operationID).css('visibility', 'visible');
} else{
$('#more'+operationID).val("Więcej");
$("#moreInformation"+operationID).css('display', 'none');
$("#moreInformation"+operationID).css('visibility', 'collapse');
}
}