我将Laravel项目托管到000webhost,我的项目可以以pdf格式进行报告。我使用dompdf来做所有的pdf事情。在我的本地主机服务器(xampp)中,dompdf可以正常工作,没有错误,并且可以很好地呈现html。在实时服务器中,我收到错误500“糟糕,我们的服务器出了点问题。”。我找不到任何解决方案,我认为这是执行时间,我将其提高到2000秒仍然有500。
这是我的控制器
public function retur_preport(Request $request)
{
ini_set('max_execution_time', '2000');
ini_set('memory_limit','512M');
$tgl1 = date('Y-m-d', strtotime($request->input('tanggal_mulai')));
$tgl2 = date('Y-m-d', strtotime($request->input('sampai_tanggal')));
if($tgl1 > date('Y-m-d') || $tgl2 > date('Y-m-d')){
return redirect('upper/laporan/retur')->with('error','Tanggal yang diinput tidak bisa lebih besar dari '.date('d M Y').' (hari ini)');
}elseif($tgl2 != '1970-01-01' && $tgl1 > $tgl2){
return redirect('upper/laporan/retur')->with('error','Tanggal mulai tidak bisa lebih besar dari inputan tanggal sampai');
}elseif($tgl1 == '1970-01-01' && $tgl2 == '1970-01-01'){
return redirect('upper/laporan/retur')->with('error','Salah satu dari kedua tanggal harus diisi');
}elseif($tgl1 == '1970-01-01'){
$r = \App\Retur::whereDate('tgl_retur',$tgl2)->orderBy('tgl_retur','desc')->get();
$pdf = PDF::loadview('pimpinan/laporan/retur/report', compact('r','tgl1','tgl2'))->setPaper('a4','landscape');
return $pdf->download('laporan retur tanggal '.date('d-M-Y', strtotime($tgl2)).'.pdf');
}elseif($tgl2 == '1970-01-01'){
$r = \App\Retur::whereBetween('tgl_retur',[$tgl1, date('Y-m-d')])->orderBy('tgl_retur','desc')->get();
$pdf = PDF::loadview('pimpinan/laporan/retur/report',compact('r','tgl1','tgl2'))->setPaper('a4','landscape');
return $pdf->download('laporan retur tanggal '.date('d-M-Y', strtotime($tgl1)).' sampai tanggal '.date('d-M-Y').'.pdf');
}else{
$r = \App\Retur::whereBetween('tgl_retur',[$tgl1,$tgl2])->orderBy('tgl_retur','desc')->get();
$pdf = PDF::loadview('pimpinan/laporan/retur/report', compact('r','tgl1','tgl2'))->setPaper('a4','landscape');
return $pdf->download('laporan retur tanggal '.date('d-M-Y', strtotime($tgl1)).' sampai tanggal '.date('d-M-Y', strtotime($tgl2)).'.pdf');
}
}
这是我从控制器呈现的html
<html>
<head>
<link rel="stylesheet" href="{{ asset('assets') }}/bower_components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="{{ asset('assets') }}/bower_components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="{{ asset('assets') }}/bower_components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="{{ asset('assets') }}/dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="{{ asset('assets') }}/dist/css/skins/_all-skins.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
<style>
.no-gutters {
margin-right: 0;
margin-left: 0;
> .col,
> [class*="col-"] {
padding-right: 0;
padding-left: 0;
}
}
table, td, th, tr, thead, tbody {
border: 1px solid black !important;
}
</style>
</head>
<body>
<div class="content-header row text-center">
<img src="{{ asset('uploads') }}/kadatuan_logo/logo.jpg" width="120" height="120"><br>
Jl. Karawitan No. 48, Bandung
</div>
<section class="content">
<div class="box box-primary box-solid">
<div class="box-header">
Laporan Retur
@if($tgl1 == '1970-01-01')
Tanggal <strong>{{ date('d-M-Y', strtotime($tgl2)) }}</strong>
@elseif($tgl2 == '1970-01-01')
Tanggal <strong>{{ date('d-M-Y', strtotime($tgl1)) }}</strong> Sampai <strong>{{ date('d-M-Y') }}</strong>
@else
Tanggal <strong>{{ date('d-M-Y', strtotime($tgl1)) }}</strong> Sampai <strong>{{ date('d-M-Y', strtotime($tgl2)) }}</strong>
@endif
<div class="pull-right">Dicetak pada tanggal <strong>{{ date('d-M-Y') }}</strong></div>
</div>
<div class="box-body">
<div class="d-flex justify-content-center">
<table class="table text-center">
<thead>
<tr>
<th>No</th>
<th>ID Pemesanan</th>
<th>ID Retur</th>
<th>Tanggal Retur</th>
<th>Nama Mitra</th>
<th>Barang Retur</th>
<th>Jumlah Retur</th>
<th>Status Retur</th>
<th>Keterangan</th>
</tr>
</thead>
<tbody>
@foreach ($r as $row)
<tr>
<td rowspan="{{ \App\DRetur::where('id_retur',$row->id_retur)->count() }}">{{ !empty($i) ? ++$i : $i = 1}}</td>
<td rowspan="{{ \App\DRetur::where('id_retur',$row->id_retur)->count() }}">{{ $row->id_pemesanan }}</td>
<td rowspan="{{ \App\DRetur::where('id_retur',$row->id_retur)->count() }}">{{ $row->id_retur }}</td>
<td rowspan="{{ \App\DRetur::where('id_retur',$row->id_retur)->count() }}">{{ date('d-M-Y', strtotime($row->tgl_retur)) }}</td>
<td rowspan="{{ \App\DRetur::where('id_retur',$row->id_retur)->count() }}">{{ $row->mitra->nama_mitra }}</td>
@foreach (\App\DRetur::where('id_retur',$row->id_retur)->limit(1)->get() as $row2)
<td>{{ \App\TPemesanan::join('t_dpemesanan','t_tpemesanan.id_dpemesanan','=','t_dpemesanan.id_dpemesanan')->join('t_stock','t_dpemesanan.id_stock','=','t_stock.id_stock')->where('t_tpemesanan.id_tpemesanan',$row2->id_tpemesanan)->first()->nama_stock }}</td>
<td>{{ $row2->jumlah_dretur }}{{ \App\TPemesanan::join('t_dpemesanan','t_tpemesanan.id_dpemesanan','=','t_dpemesanan.id_dpemesanan')->join('t_stock','t_dpemesanan.id_stock','=','t_stock.id_stock')->where('t_tpemesanan.id_tpemesanan',$row2->id_tpemesanan)->first()->satuan }}</td>
@if( $row2->status_dretur == 1 )
<td>Menunggu Diperiksa</td>
@elseif( $row2->status_dretur == 2 )
<td>Diterima</td>
@elseif( $row2->status_dretur == 3 )
<td>Ditolak</td>
@endif
<td>{{ $row2->keterangan }}</td>
</tr>
@foreach(\App\DRetur::where('id_retur',$row->id_retur)->get() as $row3)
@if($row2->id_dretur != $row3->id_dretur)
<tr>
<td>{{ \App\TPemesanan::join('t_dpemesanan','t_tpemesanan.id_dpemesanan','=','t_dpemesanan.id_dpemesanan')->join('t_stock','t_dpemesanan.id_stock','=','t_stock.id_stock')->where('t_tpemesanan.id_tpemesanan',$row3->id_tpemesanan)->first()->nama_stock }}</td>
<td>{{ $row3->jumlah_dretur }}{{ $row2->jumlah_dretur }}{{ \App\TPemesanan::join('t_dpemesanan','t_tpemesanan.id_dpemesanan','=','t_dpemesanan.id_dpemesanan')->join('t_stock','t_dpemesanan.id_stock','=','t_stock.id_stock')->where('t_tpemesanan.id_tpemesanan',$row3->id_tpemesanan)->first()->satuan }}</td>
@if( $row3->status_dretur == 1 )
<td>Menunggu Diperiksa</td>
@elseif( $row3->status_dretur == 2 )
<td>Diterima</td>
@elseif( $row3->status_dretur == 3 )
<td>Ditolak</td>
@endif
<td>{{ $row3->keterangan }}</td>
</tr>
@endif
@endforeach
@endforeach
@endforeach
</tbody>
</table>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
Sistem Informasi Supply
<div class="pull-right">
Hormat Saya, <strong>Reyhan (Admin)</strong>
</div>
</div>
<!-- /.box-footer-->
</div>
<!-- /.box -->
</section>
<!-- jQuery 3 -->
<script src="{{ asset('assets') }}/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="{{ asset('assets') }}/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="{{ asset('assets') }}/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="{{ asset('assets') }}/bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="{{ asset('assets') }}/dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="{{ asset('assets') }}/dist/js/demo.js"></script>
<script>
$(document).ready(function () {
$('.sidebar-menu').tree()
})
</script>