1
0
forked from s421507/eOSP2

Jednostka - pobieranie ilości aktywnych członków

This commit is contained in:
czup 2020-01-15 11:47:40 +01:00
parent ecb5ab78fe
commit 2513a41e0a
6 changed files with 47 additions and 27 deletions

View File

@ -6,16 +6,21 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\fireStation; use App\fireStation;
use DB; use DB;
use Illuminate\Support\Facades\View;
class fireStationController extends Controller class fireStationController extends Controller
{ {
public function create(){ public function create(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){ if(auth()->user() != null && auth()->user()->fireStationID != null ){
$users = DB::table('users')
->where('fireStationID', '=', auth()->user()->fireStationID)
->count();
$fireStation = fireStation::find(auth()->user()->fireStationID); $fireStation = fireStation::find(auth()->user()->fireStationID);
return view('unit', ["fireStation" => $fireStation]); return View::make('unit')->with(compact('fireStation', 'users'));
} else{ } else{
$voivodeships = DB::table('wojewodztwa')->pluck("name","id"); $voivodeships = DB::table('wojewodztwa')->pluck("name","id");
return view('unit',compact('voivodeships')); return view('unit',compact('voivodeships'));
} }
} }
@ -24,12 +29,12 @@ class fireStationController extends Controller
if(auth()->user() != null && auth()->user()->fireStationID != null ) if(auth()->user() != null && auth()->user()->fireStationID != null )
{ {
$id = auth()->user()->fireStationID; $id = auth()->user()->fireStationID;
$fireStation = DB::table('fireStations')->where("id", $id)->first(); $fireStation = DB::table('fireStations')->where("id", $id)->first();
$voivodeships = DB::table('wojewodztwa')->pluck("name","id"); $voivodeships = DB::table('wojewodztwa')->pluck("name","id");
return view('fireStationEdit', ["fireStation" => $fireStation], compact('voivodeships')); return view('fireStationEdit', ["fireStation" => $fireStation], compact('voivodeships'));
} }
else else
return "Brak dostępu"; return "Brak dostępu";
} }
public function store() public function store()

View File

@ -85,9 +85,20 @@ class operationsController extends Controller
}) })
->select('users.*', 'operationsMembers.memberID', 'operationsMembers.privateTransport') ->select('users.*', 'operationsMembers.memberID', 'operationsMembers.privateTransport')
->get(); ->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')
->select('vehicles.*', 'operationsTrucks.truckID', 'operationsTrucks.driverID', 'users.name as driverName', 'users.surname as driverSurname')
->get();
// if($userFireStation == $fireFighterFireStation && auth()->user()->id == $fireStationCreatorId) { // if($userFireStation == $fireFighterFireStation && auth()->user()->id == $fireStationCreatorId) {
// return view('operationEdit', ["operation" => $operation], ["fireFighters" => $fireFighters], ["operationMembers" => $operationMembers] ); // return view('operationEdit', ["operation" => $operation], ["fireFighters" => $fireFighters], ["operationMembers" => $operationMembers] );
return View::make('/operationEdit')->with(compact('fireFighters','operation', 'operationMembers', 'vehicles')); return View::make('/operationEdit')->with(compact('fireFighters','operation', 'operationMembers', 'vehicles', 'operationsTrucks'));
// } else{ // } else{
// return "Brak dostepu"; // return "Brak dostepu";
// } // }

View File

@ -12,7 +12,4 @@ class operations extends Model
protected $fillable = ['fireStationID', 'operationDate', 'location', 'target', 'dangerType', 'description', 'commanderID']; protected $fillable = ['fireStationID', 'operationDate', 'location', 'target', 'dangerType', 'description', 'commanderID'];
public function getFromOperationsAttribute($value){
return \Carbon\Carbon::parse($value)->format('d-m-Y');
}
} }

View File

@ -16,7 +16,7 @@
{{ csrf_field() }} {{ csrf_field() }}
<div class="form-group"> <div class="form-group">
<label for="date">Data wyjazdu: </label> <label for="date">Data wyjazdu: </label>
<input type="datetime-local" id="operationDate" name="operationDate" value="1985-04-12T23:20"> <input type="datetime-local" id="operationDate" name="operationDate" >
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -51,23 +51,31 @@
</select> </select>
</div> </div>
@foreach($operationsTrucks as $operationTruck)
{{$operationTruck->driverName}}
@endforeach
<div class=form-group"> <div class=form-group">
<div id="drivers"> <div id="drivers">
{{-- <label for="location">Kierowca:</label>--}} @foreach($operationsTrucks as $operationTruck)
{{-- <select name="operationDriver" class="form-control">--}} <div id="singleDriver">
{{-- <option value="">--- Wybierz kierowcę ---</option>--}} {{$operationTruck->driverName}}
{{-- @foreach ($fireFighters as $fireFighter)--}} <label for="location">Kierowca:</label>
{{-- <option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>--}} <select name="operationDriver" class="form-control">
{{-- @endforeach--}} <option value="">--- Wybierz kierowcę ---</option>
{{-- </select>--}} @foreach ($fireFighters as $fireFighter)
{{-- <label for="location">Pojazd:</label>--}} <option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
{{-- <select name="operationVehicle" class="form-control">--}} @endforeach
{{-- <option value="">--- Wybierz pojazd ---</option>--}} </select>
{{-- @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 value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>
@endforeach
</select>
</div>
@endforeach
</div> </div>
</div> </div>
@ -104,7 +112,6 @@
$(document).ready(function(){ $(document).ready(function(){
{{--document.getElementById("operationDate").defaultValue = "{{\Carbon\Carbon::parse($operation->operationDate)->format('d.m.Y H:i')}}";--}}
var count = 1; var count = 1;
dynamic_field(count); dynamic_field(count);

View File

@ -29,7 +29,7 @@
<p><b>Telefon:</b> {{ $fireStation-> phoneNumber }}</p> <p><b>Telefon:</b> {{ $fireStation-> phoneNumber }}</p>
<p><b>E-mail:</b> {{ $fireStation-> email }}</p> <p><b>E-mail:</b> {{ $fireStation-> email }}</p>
<hr> <hr>
<p><b>Liczba członków:</b> 40</p> <p><b>Liczba członków:</b> {{$users}}</p>
</div> </div>
<div> <div>
@endif @endif