IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Add Transport Feehead</strong> </h2>
</div>
<div class="body">
@if(isset($feehead))
{!! Form::model($feehead, ['method' => 'PATCH', 'action' => ['School\BusFeeheadController@update', $feehead->idBusFeehead], 'class' => 'form-horizontal']) !!}
@else
{!! Form::open(['url' => 'school/busfeehead', 'class' => 'form-horizontal','id'=>'feehead_form']) !!}
@endif
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">Select Route</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::select('idRoute',$busroutes,null,['class' => 'form-control show-tick ms','required'=>'required']) !!}
@if ($errors->has('idRoute'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idRoute') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-2 form-control-label required">
<label for="classname">Select Stop</label>
</div>
<div class="col-sm-3">
<div class="form-group">
@if(isset($feehead))
{!! Form::select('idStop',$stops,null,['class' => 'form-control show-tick ms']) !!}
@else
<div id="idStop" style="border:1px solid #ccc; width:300px; height: 110px; overflow-y: scroll;">
</div>
@if ($errors->has('idStop'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idStop') }}</strong>
</label>
@endif
<span id='sectionerror'></span>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">Fee Header Name</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('feeheadName',null,['class' => 'form-control']) !!}
@if ($errors->has('feeheadName'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('feeheadName') }}</strong>
</label>
@endif
<span id='feeheaderror'></span>
</div>
</div>
<div class="col-sm-2 form-control-label required">
<label for="classname">Fee ID</label>
</div>
<div class="col-sm-3">
<div class="form-group">
@if(auth()->user()->idSchool == 25 || auth()->user()->idSchool == 163)
{!! Form::select('feeheadLabel',['' => 'Not Applicable','Plan A' => 'Plan A','Plan B' => 'Plan B','Plan C' => 'Plan C',],null,['class' => 'form-control show-tick ms select2']) !!}
@else
{!! Form::select('feeheadLabel',['' => 'Not Applicable','Plan A' => 'Installment','Plan B' => 'Six Month Installment'],null,['class' => 'form-control show-tick ms select2']) !!}
@endif
<span id='feeheaderror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">From Date</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('fromDate',null,['class' => 'form-control datepicker']) !!}
@if ($errors->has('fromDate'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('fromDate') }}</strong>
</label>
@endif
<span id='fdate_error'></span>
</div>
</div>
<div class="col-sm-2 form-control-label required">
<label for="classname">To Date</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('toDate',null,['class' => 'form-control datepicker']) !!}
@if ($errors->has('toDate'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('toDate') }}</strong>
</label>
@endif
<span id='todate_error'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">Amount</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('amount',null,['class' => 'form-control','onkeypress'=>'return onlyNumbersandSpecialChar(event)']) !!}
@if ($errors->has('amount'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('amount') }}</strong>
</label>
@endif
<span id='amounterror'></span>
</div>
</div>
<div class="col-sm-2 form-control-label">
<input type="radio" name="fines" value="per" class="fineradio"> <label for="classname">Fine Per Day</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('fine',null,['class' => 'form-control','onkeypress'=>'return onlyNumbersandSpecialChar(event)']) !!}
@if ($errors->has('fine'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('fine') }}</strong>
</label>
@endif
<span id='fineerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label">
<label for="classname">Description</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::textarea('description',null,['class' => 'form-control','size'=>'30x2']) !!}
@if ($errors->has('description'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('description') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-2 form-control-label">
<input type="radio" name="fines" value="flat" class="fineradio">
<label for="classname">Flat Fine</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('flatFine',null,['class' => 'form-control','onkeypress'=>'return onlyNumbersandSpecialChar(event)']) !!}
@if ($errors->has('flatFine'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('flatFine') }}</strong>
</label>
@endif
<span id='flatfineerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
@if(isset($feehead))
{!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
@else
{!! Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']) !!}
@endif
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>List Of Transport Fee Header</strong></h2>
</div>
<div class="body table-responsive">
{!! Form::open(['method' => 'GET', 'action' => ['School\BusFeeheadController@index'], 'class' => 'form-horizontal']) !!}
<div class="row clearfix">
<div class="col-sm-2"></div>
<div class="col-sm-2 form-control-label">
<label for="classname">Financial Year</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms']) !!}
</div>
</div>
<div class="col-sm-2">
{!! Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
</div>
</div>
{!! Form::close() !!}
<br>
<table class="table table-bordered table-striped table-hover js-exportable-fee dataTable">
<thead>
<tr>
<th>S. No.</th>
<th>Fee Header</th>
<th>Route</th>
<th>Stop</th>
<th>Amount</th>
<th>Date</th>
<th>Fine Per Day</th>
<th>Flat Fine</th>
<th>Description</th>
<th>Created By</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
@foreach($feeheads as $value)
<tr>
<th scope="row">{{$i}}</th>
<td>{{$value->feeheadName}}</td>
<td>{{$value->route->routeName}}</td>
<td>{{$value->stop->stopName}}</td>
<td>{{$value->amount}}</td>
<td>{{$value->fromDate}} To {{$value->toDate}}</td>
<td>{{$value->fine}}</td>
<td>{{$value->flatFine}}</td>
<th>{{$value->description}}</th>
<th>{{$value->name}}</th>
<td>
<a href="{{ url('school/busfeehead/' . $value->idBusFeehead . '/edit') }}" class="btn btn-raised btn-info waves-effect btn-round">Edit </a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->idBusFeehead}}" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).on('change', '.fineradio', function() {
if (this.value == 'flat') {
$('input[type=text][name=flatFine]').show();
$('input[type=text][name=fine]').hide();
}
else if (this.value == 'per') {
$('input[type=text][name=fine]').show();
$('input[type=text][name=flatFine]').hide();
}
});
$(document).ready(function() {
$('.js-exportable-fee').DataTable({
dom: 'Bfrtip',
scrollY: "500px",
scrollX: true,
scrollCollapse: true,
fixedColumns: {
left: 1
},
buttons: [
{ extend: 'csv', text: 'Export to Excel',title:'Bus Feehead List',
exportOptions: {
columns: [0,1,2,3,4,5,6,7,8,9]
}
}
]
});
$('select[name="idRoute"]').on('change', function() {
var routeID = $(this).val();
if(routeID) {
$.ajax({
url: "{{url('/school/routes') }}"+'/' +routeID + "/stops",
type: "GET",
dataType: "json",
success:function(data) {
$('#idStop').empty();
$('#idStop').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-all" id="selectall"></div>');
$.each(data, function(key, value) {
$('#idStop').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:100px;">'+value+'</label><input type="checkbox" name="stops[]" value="'+key+'" class="sectionclass"></div>');
});
}
});
}else{
$('select[name="idStop"]').empty();
}
});
});
$(document).on('click', '.select-all', function(){
var checkAll = this.checked;
if(checkAll === true){
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
var sectionIds = [];
$("input:checkbox[name='stops[]']:checked").each(function () {
sectionIds.push($(this).val());
});
}else{
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}
});
// Delete Feehead
$(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 feeheader!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "{{url('/school/busfeehead/')}}" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Feehead has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
// Saving form data
$('#feehead_form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#feehead_form')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "{{url('school/busfeehead') }}",
processData: false,
contentType: false,
data:formData,
dataType: 'json',
success:function(data){
if( data[Object.keys(data)[0]] === 'SUCCESS' ){
$("#submit-btn").prop('disabled', true);
window.location = "{{url('school/busfeehead')}}";
}
else { //False Case: With error msg
$("#msg").html(data); //$msg is the id of empty msg
}
},
error: function(data){
if( data.status === 422 ) {
$("#submit-btn").prop('disabled', false);
var errors = data.responseJSON.errors;
var errorHtml = '<div class="alert alert-danger"><ul>';
$('#formerrors').html(errorHtml);
if(errors['idStop']=== undefined){
$( '#sectionerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idStop']+'</strong></span>';
$( '#sectionerror' ).html( errorname );
}
if(errors['feeheadName']=== undefined){
$( '#feeheaderror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['feeheadName']+'</strong></span>';
$( '#feeheaderror' ).html( errorname );
}
if(errors['fromDate']=== undefined){
$( '#fdate_error' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['fromDate']+'</strong></span>';
$( '#fdate_error' ).html( errorname );
}
if(errors['toDate']=== undefined){
$( '#todate_error' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['toDate']+'</strong></span>';
$( '#todate_error' ).html( errorname );
}
if(errors['amount']=== undefined){
$( '#amounterror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['amount']+'</strong></span>';
$( '#amounterror' ).html( errorname );
}
if(errors['fine']=== undefined){
$( '#fineerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['fine']+'</strong></span>';
$( '#fineerror' ).html( errorname );
}
}
}
});
return false;
});
</script>
@stop
Copyright © 2021 -