IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>@if(isset($template))Edit @else Add @endif</strong>UPLOAD EXCEL</h2>
</div>
<div class="body">
@if(isset($template))
{!! Form::model( $template, ['route' => ['examtemplates.update', $template->idTemplate], 'method' => 'put','class'=>'form-horizontal'] ) !!}
@else
{!! Form::open(['url' => 'school/exam/import','class'=>'form-horizontal','id'=>'form']) !!}
@endif
<div class="row clearfix">
@if(isset($template))
<div class="col-sm-4 form-control-label required">
<label for="classname">File Name</label>
</div>
<div class="col-sm-6">
<div class="form-group">
{!! Form::text('templateName',null,['class' => 'form-control','required'=>'required']) !!}
@if ($errors->has('templateName'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('templateName') }}</strong>
</label>
@endif
</div>
</div>
@else
<table class="table">
<thead>
<tr>
<th></th>
<th>Exam Type</th>
<th>Select Class</th>
<th>Select Section</th>
<th>FileName</th>
<th>File</th>
</tr>
</thead>
<tbody id="optional_list">
<?php $i =1;?>
<tr>
<td></td>
<td>
{!! Form::select('idExamType',$types,null,['class' => 'form-control select2 show-tick ms','required'=>'required']) !!}
</td>
<td>
{!! Form::select('idClass[]',$classes,null,['required'=>'required','multiple'=>'multiple']) !!}
</td>
<td>
{!! Form::select('idSection[]',$section,null,['required'=>'required','multiple'=>'multiple']) !!}
</td>
<td>
{!! Form::text('fileName',null,['class' => 'form-control','required'=>'required','placeholder'=>'Enter Name']) !!}
</td>
<td>{!! Form::file('image',null,['class' => 'form-control']) !!}</td>
</tr>
<?php $i++ ; ?>
</tbody>
</table>
@endif
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
@if(isset($template))
{!! 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 class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>List Of Excel Upload </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>Exam Name</th>
<th>For Class</th>
<th>For Section</th>
<th>Upload Date</th>
<th><th>
</tr>
</thead>
<tbody>
<?php $i = 1;?>
@foreach($imports as $var)
<tr>
<td>{{ $i }}</td>
<td>{{$var->typeName}}</td>
<td>{{$var->idClass}}</td>
<td>{{$var->idSection}}</td>
<td>{{$var->created_at}}</td>
<td>
<a href='{{url('/school/exam/import/'.$var->idExcel.'/edit')}}' class="btn btn-raised btn-info waves-effect btn-round"><i class="fa fa-edit"></i>Edit</a>
<a href='{{url('/school/exam/import/'.$var->idExcel.'/view')}}' 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->idExcel}}" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
//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 Template!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "{{url('/school/exam/import/')}}" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Template 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
$('#form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#form')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "{{url('school/exam/import') }}",
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/exam/import')}}";
}
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);
$.each(errors, function (key, value) {
if (key.split(".")[1] + '.templateName' === key.split(".")[1] + '.' + key.split(".")[2])
{
errordept = '<span class="help-block">' + value + '</span>';
$('#depterror' + key.split(".")[1]).html(errordept);
}
});
}
}
});
return false;
});
</script>
@stop
Copyright © 2021 -