Gunawan19621
1 year ago
11 changed files with 303 additions and 163 deletions
@ -0,0 +1,60 @@
|
||||
<?php |
||||
|
||||
namespace App\Exports; |
||||
|
||||
use App\Models\Peti; |
||||
use Maatwebsite\Excel\Concerns\WithHeadings; |
||||
use Maatwebsite\Excel\Concerns\FromCollection; |
||||
|
||||
class PetternLotPetiExport implements FromCollection, WithHeadings |
||||
{ |
||||
public function collection() |
||||
{ |
||||
// Ambil data dari model Peti |
||||
$petis = Peti::select( |
||||
'customer_id', |
||||
'warehouse_id', |
||||
'jumlah', |
||||
'tipe_peti_id', |
||||
'packing_no', |
||||
'fix_lot', |
||||
)->get(); |
||||
|
||||
// Inisialisasi nomor awal |
||||
$nomor = 1; |
||||
|
||||
// Modifikasi data dan tambahkan nomor |
||||
$data = $petis->map(function ($peti) use (&$nomor) { |
||||
return [ |
||||
'No' => $nomor++, |
||||
'User' => 'ISTW', |
||||
'Customer' => $peti->customer->name, |
||||
'Warehouse' => $peti->warehouse->name, |
||||
'CODE CUSTOMER' => $peti->customer->code_customer, |
||||
'TYPE PETI' => $peti->tipe_peti->type, |
||||
'UKURAN PETI' => $peti->tipe_peti->size_peti, |
||||
'LOT NO' => $peti->customer->lot_no, |
||||
'PACKING NO' => $peti->packing_no, |
||||
'FIX LOT' => $peti->fix_lot, |
||||
]; |
||||
}); |
||||
|
||||
return $data; |
||||
} |
||||
|
||||
public function headings(): array |
||||
{ |
||||
return [ |
||||
'No', |
||||
'User', |
||||
'Customer', |
||||
'WH', |
||||
'CODE CUSTOMER', |
||||
'TYPE PETI', |
||||
'UKURAN PETI', |
||||
'LOT NO', |
||||
'PACKING NO', |
||||
'FIX LOT', |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
<?php |
||||
|
||||
namespace App\Http\Controllers; |
||||
|
||||
use App\Models\Peti; |
||||
use Illuminate\Http\Request; |
||||
use Maatwebsite\Excel\Facades\Excel; |
||||
use App\Exports\PetternLotPetiExport; |
||||
|
||||
class PetternLotPetiController extends Controller |
||||
{ |
||||
public function index() |
||||
{ |
||||
$data = [ |
||||
'peti' => Peti::get(), |
||||
'active' => 'menu-Pettern_Lot_Peti' |
||||
]; |
||||
return view('dashboard.Master_Data.Report.PATTERN LOT PETI.index', $data); |
||||
} |
||||
|
||||
public function export() |
||||
{ |
||||
return Excel::download(new PetternLotPetiExport, 'PATTERN LOT PETI.xlsx'); |
||||
} |
||||
} |
@ -0,0 +1,73 @@
|
||||
@extends('layouts.main') |
||||
@section('content') |
||||
@include('layouts.components.alert-prompt') |
||||
<style> |
||||
.table th { |
||||
white-space: nowrap; |
||||
} |
||||
|
||||
.table td { |
||||
white-space: nowrap; |
||||
} |
||||
</style> |
||||
|
||||
<div class="card shadow mb-4"> |
||||
<div class="card-header py-3"> |
||||
<div class="row"> |
||||
<div class="col-6"> |
||||
<h5 class="m-0 font-weight-bold text-primary mt-2">Report Pettern Lot Peti</h5> |
||||
</div> |
||||
<div class="col-6 text-right"> |
||||
<a href="#" class="btn btn-success btn-icon-split ml-auto" target="_blank"> |
||||
<span class="text">Cetak PDF</span> |
||||
</a> |
||||
<a href="{{ route('dashboard.Pettern_Lot_Peti.export') }}" class="btn btn-info btn-icon-split ml-auto" |
||||
target="_blank"> |
||||
<span class="text">Cetak Exel</span> |
||||
</a> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="card-body"> |
||||
<div class="table-responsive"> |
||||
<table class="table table-bordered" id="tablebarang" width="100%" cellspacing="0"> |
||||
<thead> |
||||
<tr> |
||||
<th>No</th> |
||||
<th>User</th> |
||||
<th>Customer</th> |
||||
<th>WH</th> |
||||
<th>CODE CUSTOMER</th> |
||||
<th>TYPE PETI</th> |
||||
<th>UKURAN PETI</th> |
||||
<th>LOT NO</th> |
||||
<th>PACKING NO</th> |
||||
<th>FIX LOT</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
@php |
||||
$noreport = 1; |
||||
@endphp |
||||
@forelse ($peti as $data_peti) |
||||
<tr> |
||||
<td>{{ $noreport++ }}</td> |
||||
<td>ISTW</td> |
||||
<td>{{ $data_peti->customer->name }}</td> |
||||
<td>{{ $data_peti->warehouse->name }}</td> |
||||
<td>{{ $data_peti->customer->code_customer }}</td> |
||||
<td>{{ $data_peti->tipe_peti->type }}</td> |
||||
<td>{{ $data_peti->tipe_peti->size_peti }}</td> |
||||
<td>{{ $data_peti->customer->lot_no }}</td> |
||||
<td class="text-right">{{ $data_peti->packing_no }}</td> |
||||
<td>{{ $data_peti->fix_lot }}</td> |
||||
</tr> |
||||
@empty |
||||
<p>Data Kosong</p> |
||||
@endforelse |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
@endsection |
Loading…
Reference in new issue