IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card">
<div class="header">
<h2><strong>@if(isset($doc))Edit @else Upload Document @endif</strong> to Bus No : {{$bus->busNo}}</h2>
</div>
<div class="body">
@if(isset($doc))
{!! Form::model( $doc, ['route' => ['buses.update', $doc->idBusDoc], 'method' => 'put','class'=>'form-horizontal'] ) !!}
@else
{!! Form::open(['url' => 'school/busdocs','class'=>'form-horizontal','files'=>true]) !!}
@endif
<input type="hidden" name="idBus" value="{{$bus->idBus}}">
<div class="row clearfix">
<table class="table table-bordered">
<thead>
<tr>
<th>S.NO.</th>
<th>Document Type</th>
<th>Expiray Date</th>
<th>Upload Document</th>
<th></th>
</tr>
</thead>
<tbody id="optional_list">
<tr>
<td class="sno">1</td>
<td>
{!! Form::select('busdoc[1][idDocType]',$doctypes,null,['class' => 'form-control show-tick ms','required'=>'required']) !!}
</td>
<td>
<input class="form-control datepicker" type="text" name = "busdoc[1][expirayDate]" required="required">
</td>
<td>
<input type="file" name = "busdoc[1][document]" required="required" onkeypress = 'return isNumber(event)'>
</td>
</tr>
</tbody>
<tr>
<td colspan="4" style="text-align: right"><input type="button" class="add-row btn btn-sm btn-success" value="Add Row"></td>
</tr>
</table>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
@if(isset($doc))
{!! 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']) !!}
@endif
{!! Form::close() !!}
</div>
</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 Documents</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>Document Type</th>
<th>Expiray Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
@foreach($busdocs as $var)
<tr>
<td>{{ $i }}</td>
<td>{{$var->doctype->documentType}}</td>
<td>{{$var->expirayDate}}</td>
<td>
<a href='{{url('/school/busdocs/'.$var->idBusDoc)}}' target="_blank" class="btn btn-raised btn-info waves-effect btn-round"><i class="fa fa-edit"></i>View</a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$var->idBusDoc}}" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
var i = 1;
$(".add-row").click(function(){
i++;
var markup = '<tr><td class="sno">'+i+'</td>\
<td><select name="busdoc['+i+'][idDocType]" required = "required" class = "form-control show-tick ms">@foreach($doctypes as $key=>$value)<option value="{{$key}}">{{$value}}</option>@endforeach</select></td>\n\
<td><input class="form-control datepicker" type="text" name="busdoc['+i+'][expirayDate]" required="required"></td>\n\
<td><input type="file" name="busdoc['+i+'][document]" required="required"></td>\n\
<td style="text-align:right;vertical-align: middle;"><input type="button" required="required" class="btn btn-sm btn-danger" value="Delete" id="remove_row"></td></tr>';
setTimeout(function(){
$('.datepicker').datepicker({
autoclose: true,
format: 'dd-mm-yyyy',
todayBtn:true,
todayHighlight:true,
orientation: 'auto'
});
}, 100);
$("#optional_list").append(markup);
});
$('#optional_list').on('click', 'input[type="button"]', function () {
$(this).closest('tr').remove();
i = $('.sno:last').text();
});
//Add Input field if others is selecyted
});
$(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 Document!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "{{url('/school/busdocs/')}}" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Bus Document 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 -