我在网页中有一个链接,当我下载excel文件时,页面没有重新加载。
有人知道如何解决吗?
控制器
public function submission_list(Request $request)
{
})->download('xlsx');
return redirect('/batch-to-mbsb-process-2')->with('message', 'Submission list created successfully');
}
刀片
<div class="col-md-2 col-md-offset-10">
<button id="download-link" class="download btn btn-sm btn-success" type="submit"><i class="material-icons">file_download</i> Create Submission List</button>
</div>
答案 0 :(得分:0)
@extends('vadmin.tampilan')
@section('content')
<section class="content">
<div class="container-fluid">
<div class="row clearfix"> <!-- Breadcrumber -->
<div class="col-md-6">
<ol class="breadcrumb breadcrumb-col-pink">
<li><a href="javascript:void(0);"><i class="material-icons">donut_small</i> Ready to MBSB</a></li>
</ol>
</div>
</div> <!-- End of breadcrumber -->
@include('shared.notif')
<div id="message" style="display: none">
<div id="message-screen-mask" class="ui-widget-overlay ui-front"></div>
<div id="message-text" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-draggable ui-resizable waitmessage">please wait...</div>
</div>
<div class="row clearfix">
<div class="card">
<div class="header bg-red">
<h2>Ready to MBSB</h2>
</div>
<div class="body">
<div class="table-responsive">
<form method="POST" class="form-horizontal" id="popup-validation" action="{{ url('/submission_list')}}" >
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<table class="table table-hover dashboard-task-infos" id="example">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>IC</th>
<th>Phone</th>
<th>Status</th>
<th width="5%">Action</th>
<!-- <th>Batch Header</th> -->
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
@foreach($mbsb as $data)
<tr>
<td>{{$i++}}</td>
<td>{{$data->name}}</td>
<td>{{$data->ic}}</td>
<td>{{$data->notelp}}</td>
<!-- <td>
<button class="btn btn-success" aria-controls="collapse-{{$data->id}}" data-target="#collapseDetailOne{{$data->id}}" data-toggle="collapse" style="cursor:pointer;">Detail</button>
</td>-->
<td>
<span class="label bg-deep-orange">Ready to MBSB</span>
</td>
<!-- <td>
<button type="button" class="btn btn-success waves-effect m-r-20" data-toggle="modal" data-target="#largeModal{{$data->id}}">Detail</button>
</td> -->
<td>
<div class="demo-checkbox">
<input type="checkbox" class="invitation-friends" id="basic_checkbox_{{$i}}" name="id[]" value="{{$data->id}}" />
<label for="basic_checkbox_{{$i}}"></label>
<input type="hidden" name="cus_id[]" value="{{$data->id_cus}}">
<input type="hidden" name="ids[]" value="">
<input type="hidden" name="sta[]" value="">
</div>
</td>
<!-- <td>
@if($data->doc == 1)
<a href="{{url('/pdfbatchheader/'.$data->id_cus)}}" class="btn bg-pink btn-circle waves-effect" target="_blank"> <i class="material-icons">dns</i> </a>
@else
-
@endif
</td> -->
</tr>
@endforeach
</tbody>
<div class="col-md-2 col-md-offset-10">
<button id="download-link" class="download btn btn-sm btn-success" type="submit"><i class="material-icons">file_download</i> Create Submission List</button>
</div>
</form>
</table>
</div>
</div>
</div>
</div>
@foreach($mbsb as $datas)
<!-- Large Size -->
<div class="modal fade" id="largeModal{{$datas->id}}" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header bg-red">
<h4 class="modal-title" id="largeModalLabel">Detail</h4>
</div>
<div class="modal-body">
<p><b>Note :</b></p>
<textarea id="txtArea" name="notep6" class="form-control" rows="6" cols="5" readonly></textarea>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
@endforeach
<!-- /////////////////// Data Target //////////////// -->
@foreach($mbsb as $datas)
<div id="collapseDetailOne{{$datas->id}}" class="collapse" aria-expanded="false" data-collapse-group="collapse-group" aria-labelledby="headingFive" data-parent="#accordionExample">
<div class="row clearfix">
<div class="card">
<div class="header bg-red">
<h2>Detail {{$datas->name}}</h2>
</div>
<div class="body">
</div>
</div>
</div>
</div>
@endforeach
<!-- /////////////////// End Data Target //////////////// -->
</div>
</section>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.flash.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.print.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable();
});
</script>
<!-- Checkbox detect -->
<script type="text/javascript">
$( '#popup-validation' ).on('submit', function(e) {
if($( 'input[class^="invitation-friends"]:checked' ).length === 0) {
alert( 'Please! Select the application' );
e.preventDefault();
}
});
</script>
<script type="text/javascript">
$("#download-link").click(function(){
progressbar.hide();
});
</script>
@endsection
public function submission_list(Request $request)
{
$user = Auth::user()->id;
$username = Auth::user();
$item = array_map(null, $request->id, $request->cus_id, $request->ids, $request->sta);
$hariini = date('ymd');
$bc = Batch::latest('created_at')->limit('1')->first();
if(empty($bc->uniq_id)){
$l = 'B000-181003';
}
else{
$l = $bc->uniq_id;
}
$letter = substr($l,0,1);
$nu = substr($l,1,3);
if($nu == 999){
$letter++;
$nu=1;
}
else{
$nu++;
}
$cc= $letter.str_pad($nu,3,'0',STR_PAD_LEFT).$hariini;
$pra = praapplication::select('uniq_no')->get();
$today = date('Y-m-d H:i:s');
$format = date('Ymd-Hi');
$number = 'B'.$format;
$validate = Batch::latest('created_at')->where('uniq_id',$cc)->count();
if($validate==0){
$batch = new Batch;
$batch->uniq_id = $cc;
$batch->date = $today;
$batch->save();
foreach($item as $val) {
$pra = praapplication::Where('id',$val[0])->update([
"uniq_no" =>$cc,
"submission" =>'1',
"stage" => 'W17'
]);
$pra = Report::where('cus_id',$val[1])->update([
"submission" =>'1',
"date_submission" => $today
]);
}
}
//Dia Download
$current = date('Y-m-d H:i:s');
$excel = Excel::create('Submission'.$current, function($excel) use($cc, $item, $username, $current) {
$excel->setTitle('Global Submission');
// Chain the setters
$excel->setCreator('Global')->setCompany('Global');
$excel->sheet('Sheet 1', function($sheet) use($cc, $item, $username, $current) {
$submission = praapplication::join('emp', 'emp.id', '=', 'praapplication.emp_code')
->select(
'praapplication.updated_at',
'praapplication.name',
'praapplication.ic',
'praapplication.email',
'emp.Emp_Desc')
->orderBy('praapplication.created_at', 'desc')->where('praapplication.stage', '=', 'W17')->where('uniq_no',$cc)
->get();
$i = 1;
foreach($submission as $product) {
$data[] = array(
$i++,
$product->updated_at->toFormattedDateString(),
$product->name,
$product->ic,
$product->email,
$product->Emp_Desc,
);
}
$sheet->fromArray($data, null, 'A1', false, false);
$ir = $i-1;
$is = $i+1;
$range = "A1:F{$ir}";
$sheet->setBorder($range, 'thin');
$headings = array('No', 'Date','Customers Name','New IC', 'Email', 'Company');
$sheet->setBorder( "A{$is}:F{$is}" ,'none');
//$sheet->setBorder('A2:A10');
$sheet->prependRow(1, $headings);
// add header
$current = date('Y-m-d ');
$sheet->prependRow(1, ["MASTER AGENT : GLOBAL I EXCEED MANAGEMENT SDN BHD"]);
$sheet->mergeCells("A1:F1");
$sheet->prependRow(2, ["Batch Header : ".$cc]);
$sheet->mergeCells("A2:F2");
$sheet->prependRow(3, [""]);
$sheet->mergeCells("A3:F3");
$sheet->cell("A1:A3", function($cell) {
// change header color
$cell->setBackground('#ffffff')
->setFontColor('#000000')
->setFontWeight('bold')
->setAlignment('center')
->setValignment('center');
// ->setBorder('none', 'none', 'thin', 'thin');
});
$footerRow = count($submission) + 3;
$sheet->appendRow([ "Name : ".$username->name ]);
$sheet->appendRow([ "Date : ".$current ]);
$sheet->mergeCells("A{$footerRow}:B{$footerRow}");
$sheet->cell("A{$footerRow}:B{$footerRow}", function($cell) {
$cell->setAlignment('center')
->setValignment('center')
->setFontColor('#000000')
->setFontSize(10);
});
});
})->download('xlsx');
//return Redirect::to('/batch-to-mbsb-process-2')->with('message', 'Submission list created successfully');
return redirect('/batch-to-mbsb-process-2')->with('message', 'Submission list created successfully');
}