IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card">
<div class="header">
<h2><strong>Assign Route to Bus</strong></h2>
</div>
<div class="body">
{!! Form::open(['url' => 'school/busroute', 'class' => 'form-horizontal','files'=>true]) !!}
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname" class="required">Select Bus</label>
</div>
<div class="col-sm-6">
<div class="form-group">
{!! Form::select('idBus',$buses,null,['class' => 'form-control show-tick ms','required'=>'required']) !!}
@if ($errors->has('idBus'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idBus') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname" class="required">Select Route</label>
</div>
<div class="col-sm-6">
<div class="form-group">
@if ($errors->has('route'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('route') }}</strong>
</label>
@endif
<div style="border:1px solid #ccc; width:250px; height: 150px; overflow-y: scroll;">
@foreach($routes as $key=>$value)
<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;">
<input type="checkbox" name="routes[]" value="{{$key}}">
<label>{{$value}}</label>
</div>
@endforeach
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
{!! Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-7">
<div class="card">
<div class="header">
<h2><strong>Buses with Routes</strong></h2>
</div>
<div class="body table-responsive">
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th>S. No.</th>
<th>Bus No.</th>
<th>Bus Route</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
@foreach($busroutes as $value)
<tr>
<th scope="row">{{$i}}</th>
<td>{{$value->bus->busNo}}</td>
<td>
<?php $routes = \App\BusRoute::where('idBus','=',$value->idBus)->get();?>
@foreach($routes as $v)
{{$v->route->routeName}},
@endforeach
</td>
<td>
<a href="{{url('/school/busroute/'.$value->idBus.'/edit')}}" class="btn btn-raised btn-info waves-effect btn-round"><i class="fa fa-edit"></i>Edit</a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->idBusRoute}}" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).on('click', '.js-sweetalert', function (e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Are you sure?",
text: "Are You sure you want to delete this Bus Routes!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "{{url('/school/busroute/')}}" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Bus Route has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
</script>
@stop
Copyright © 2021 -