1
0
forked from s421507/eOSP2

zawieszanie i odwieszanie pojazdów

This commit is contained in:
Krzysztof Strzelecki 2019-12-28 19:01:42 +01:00
parent 0538c51db9
commit 5f139cd425
7 changed files with 91 additions and 12 deletions

View File

@ -90,6 +90,7 @@ class VehiclesController extends Controller
'chassisPoductionYear' => $request-> chassisPoductionYear, 'chassisPoductionYear' => $request-> chassisPoductionYear,
'entryIntoServiceDate' => formatDate($request-> entryIntoServiceDate), 'entryIntoServiceDate' => formatDate($request-> entryIntoServiceDate),
'fireEnginePumpDescription' => $request-> fireEnginePumpDescription, 'fireEnginePumpDescription' => $request-> fireEnginePumpDescription,
'status' => $request-> status
]); ]);
return redirect()->to('/pojazdy'); return redirect()->to('/pojazdy');
@ -137,6 +138,7 @@ class VehiclesController extends Controller
$vehicle-> chassisPoductionYear = $request-> chassisPoductionYear; $vehicle-> chassisPoductionYear = $request-> chassisPoductionYear;
$vehicle-> entryIntoServiceDate = formatDate($request-> entryIntoServiceDate); $vehicle-> entryIntoServiceDate = formatDate($request-> entryIntoServiceDate);
$vehicle-> fireEnginePumpDescription = $request-> fireEnginePumpDescription; $vehicle-> fireEnginePumpDescription = $request-> fireEnginePumpDescription;
$vehicle-> status = $request-> status;
$vehicle->save(); $vehicle->save();
return redirect()->to('/pojazdy');; return redirect()->to('/pojazdy');;
@ -147,4 +149,22 @@ class VehiclesController extends Controller
vehicle::where('id',$id)->delete(); vehicle::where('id',$id)->delete();
return redirect()->to('/pojazdy'); return redirect()->to('/pojazdy');
} }
public function activate()
{
$request = request();
$vehicle = vehicle::find( $request-> vehicleID);
$vehicle-> status = 1;
$vehicle->save();
return redirect()->to('/pojazdy');
}
public function deactivate()
{
$request = request();
$vehicle = vehicle::find( $request-> vehicleID);
$vehicle-> status = 0;
$vehicle->save();
return redirect()->to('/pojazdy');
}
} }

View File

@ -12,7 +12,7 @@ class vehicle extends Model
protected $table = 'vehicles'; protected $table = 'vehicles';
protected $fillable = [ protected $fillable = [
'fireStationID','name', 'codename', 'brand', 'registrationNumber', 'productionYear', 'examExpirationDate', 'insuranceExpirationDate', 'driveType', 'chassisType', 'bodyProducer', 'crewNumber', 'foamAgent', 'enginePower', 'mass', 'chassisNumber', 'engineNumber', 'fuelType', 'chassisPoductionYear', 'entryIntoServiceDate', 'fireEnginePumpDescription', 'created_at', 'updated_at' 'fireStationID','name', 'codename', 'brand', 'registrationNumber', 'productionYear', 'examExpirationDate', 'insuranceExpirationDate', 'driveType', 'chassisType', 'bodyProducer', 'crewNumber', 'foamAgent', 'enginePower', 'mass', 'chassisNumber', 'engineNumber', 'fuelType', 'chassisPoductionYear', 'entryIntoServiceDate', 'fireEnginePumpDescription', 'created_at', 'updated_at', 'status'
]; ];
} }

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddStatusToVehiclesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('vehicles', function (Blueprint $table) {
//
$table->integer('status')->default('0');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('vehicles', function (Blueprint $table) {
//
});
}
}

View File

@ -4,9 +4,6 @@
@parent @parent
<ul> <ul>
<a href="/pojazdy/add"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a> <a href="/pojazdy/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>
<li>Zawieś<img src="img/left_menu_icon/suspended.png"></li>
</ul> </ul>
@stop @stop
@ -46,12 +43,26 @@
<td id="driveType{{ $vehicle->id }}">{{ $vehicle->driveType }}</td> <td id="driveType{{ $vehicle->id }}">{{ $vehicle->driveType }}</td>
<td id="examExpirationDate{{ $vehicle->id }}">{{ $vehicle->examExpirationDate }}</td> <td id="examExpirationDate{{ $vehicle->id }}">{{ $vehicle->examExpirationDate }}</td>
<td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td> <td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td>
<td><a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td> <td><a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
<td>
{{ csrf_field() }} {{ csrf_field() }}
@method('DELETE') @method('DELETE')
<button class="btn btn-danger" type="submit">Usuń</button> <td><button class="btn btn-danger" type="submit">Usuń</button></td>
</form></td> </form>
@if ($vehicle->status == 1)
<form method="POST" action="/pojazdy/deactivate">
{{ csrf_field() }}
<input type="hidden" class="form-control" name="vehicleID" value="{{ $vehicle->id }}">
<td><button style="cursor:pointer" type="submit" class="btn btn-primary">Zawieś</button></td>
</form>
@elseif ($vehicle->status == 0)
<form method="POST" action="/pojazdy/activate">
{{ csrf_field() }}
<input type="hidden" class="form-control" name="vehicleID" value="{{ $vehicle->id }}">
<td><button style="cursor:pointer" type="submit" class="btn btn-primary">Przywróć do służby</button></td>
</form>
@endif
</tr> </tr>
@endforeach @endforeach
</table> </table>

View File

@ -3,10 +3,7 @@
@section('left-menu') @section('left-menu')
@parent @parent
<ul> <ul>
<a href="/pojazdy/add"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a> <a href="/pojazdy"><li>Przeglądaj<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>
<li>Zawieś<img src="img/left_menu_icon/suspended.png"></li>
</ul> </ul>
@stop @stop
@ -114,6 +111,14 @@
<input type="text" class="form-control" id="fireEnginePumpDescription" name="fireEnginePumpDescription" value="{{ old('fireEnginePumpDescription') }}"> <input type="text" class="form-control" id="fireEnginePumpDescription" name="fireEnginePumpDescription" value="{{ old('fireEnginePumpDescription') }}">
</div> </div>
<div class="form-group">
<label for="status">Stan:</label>
<select name="status" class="form-control">
<option value="1" selected='selected'>Aktywny</option>
<option value="0">Zawieszony</option>
</select>
</div>
<div class="form-group"> <div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zatwierdź</button> <button style="cursor:pointer" type="submit" class="btn btn-primary">Zatwierdź</button>
</div> </div>

View File

@ -116,6 +116,14 @@
<input type="text" class="form-control" id="fireEnginePumpDescription" name="fireEnginePumpDescription" value="{{ $vehicle->fireEnginePumpDescription }}"> <input type="text" class="form-control" id="fireEnginePumpDescription" name="fireEnginePumpDescription" value="{{ $vehicle->fireEnginePumpDescription }}">
</div> </div>
<div class="form-group">
<label for="status">Stan:</label>
<select name="status" class="form-control">
<option value="1" selected='selected'>Aktywny</option>
<option value="0">Zawieszony</option>
</select>
</div>
<div class="form-group"> <div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zatwierdź zmiany</button> <button style="cursor:pointer" type="submit" class="btn btn-primary">Zatwierdź zmiany</button>
</div> </div>

View File

@ -66,6 +66,8 @@ Route::post('/pojazdy', 'VehiclesController@store');
Route::get('/pojazdy/edit/{id}', 'VehiclesController@editForm'); Route::get('/pojazdy/edit/{id}', 'VehiclesController@editForm');
Route::post('/pojazdy/edit', 'VehiclesController@update'); Route::post('/pojazdy/edit', 'VehiclesController@update');
Route::resource('vehicles', 'VehiclesController'); Route::resource('vehicles', 'VehiclesController');
Route::post('pojazdy/activate', 'VehiclesController@activate');
Route::post('pojazdy/deactivate', 'VehiclesController@deactivate');
Route::get('/sprzet', 'EquipmentController@create'); Route::get('/sprzet', 'EquipmentController@create');
Route::get('/sprzet/add', 'EquipmentController@addForm'); Route::get('/sprzet/add', 'EquipmentController@addForm');