Browse Source

update QR

master
Gunawan19621 1 year ago
parent
commit
f606d46ba5
  1. 60
      app/Exports/PetternLotPetiExport.php
  2. 52
      app/Http/Controllers/HomeController.php
  3. 71
      app/Http/Controllers/PetiController.php
  4. 25
      app/Http/Controllers/PetternLotPetiController.php
  5. 35
      resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/show.blade.php
  6. 2
      resources/views/dashboard/Master_Data/Manajemen_Peti/Type_peti/create.blade.php
  7. 2
      resources/views/dashboard/Master_Data/Manajemen_Peti/Type_peti/edit.blade.php
  8. 73
      resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/index.blade.php
  9. 73
      resources/views/dashboard/index.blade.php
  10. 12
      resources/views/layouts/sidebar.blade.php
  11. 61
      routes/web.php

60
app/Exports/PetternLotPetiExport.php

@ -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',
];
}
}

52
app/Http/Controllers/HomeController.php

@ -12,7 +12,7 @@ class HomeController extends Controller
{
$data = [
'reminder' => \App\Models\asset_status::whereNull('enter_at')->count(),
'jumlahAsset' => \App\Models\m_asset::count(),
'jumlahPeti' => \App\Models\Peti::count(),
'jumlahPeminjaman' => \App\Models\asset_status::count(),
'jumlahPengembalian' => \App\Models\asset_status::whereNotNull('enter_at')->count(),
'active' => 'menu-admin',
@ -32,28 +32,58 @@ class HomeController extends Controller
return view('pages.user.index', $data);
}
public function generateChartData()
{
$months = [];
$years = [];
$exitData = [];
$enterData = [];
$monthNames = [
'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni',
'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'
];
for ($i = 1; $i <= 12; $i++) {
$months[] = date("F", mktime(0, 0, 0, $i, 1));
// Ambil data tahun dari kolom exit_at
$exitYears = \App\Models\asset_status::selectRaw('YEAR(exit_at) as year')
->distinct()
->orderBy('year', 'asc')
->get()
->pluck('year')
->toArray();
// Ambil data tahun dari kolom enter_at
$enterYears = \App\Models\asset_status::selectRaw('YEAR(enter_at) as year')
->distinct()
->orderBy('year', 'asc')
->get()
->pluck('year')
->toArray();
// Gabungkan dan sortir tahun-tahun dari kedua kolom
$years = array_merge($exitYears, $enterYears);
$years = array_unique($years);
sort($years);
foreach ($years as $year) {
$yearExitData = [];
$yearEnterData = [];
// Ambil data untuk setiap bulan dalam tahun tersebut
foreach ($monthNames as $monthName) {
$exitCount = \App\Models\asset_status::whereYear('exit_at', $year)
->whereMonth('exit_at', array_search($monthName, $monthNames) + 1)
->count();
$enterCount = \App\Models\asset_status::whereYear('enter_at', $year)
->whereMonth('enter_at', array_search($monthName, $monthNames) + 1)
->count();
$exitCount = \App\Models\asset_status::whereMonth('exit_at', $i)->count();
$enterCount = \App\Models\asset_status::whereMonth('enter_at', $i)->count();
$yearExitData[] = $exitCount;
$yearEnterData[] = $enterCount;
}
$exitData[] = $exitCount;
$enterData[] = $enterCount;
$exitData[] = $yearExitData;
$enterData[] = $yearEnterData;
}
return compact('months', 'exitData', 'enterData', 'monthNames');
return compact('years', 'exitData', 'enterData', 'monthNames');
}
}

71
app/Http/Controllers/PetiController.php

@ -95,40 +95,12 @@ class PetiController extends Controller
'active' => 'menu-peti',
];
$petiqr = Peti::find($id);
// $petiqr = Peti::find($id);
$qrcode = base64_encode(QrCode::format('svg')->size(150)->errorCorrection('H')->generate(
'Nama Customer : ' .
$petiqr->customer->name .
"\n" .
'Code Customer : ' .
$petiqr->customer->code_customer .
"\n" .
'ID Peti : ' .
$petiqr->tipe_peti->id .
"\n" .
'Type Peti : ' .
$petiqr->tipe_peti->type .
"\n" .
'ID Warehouse : ' .
$petiqr->warehouse->id .
"\n" .
'Warehouse : ' .
$petiqr->warehouse->name .
"\n" .
'Ukuran Peti : ' .
$petiqr->tipe_peti->size_peti .
"\n" .
'Lot Number : ' .
$petiqr->customer->lot_no .
"\n" .
'Paking Number : ' .
$petiqr->packing_no .
"\n" .
'Status Peti : ' .
$petiqr->status_disposal
));
return view('dashboard.Master_Data.Manajemen_Peti.Peti.show', compact('qrcode'), $data);
// $qrcode = base64_encode(QrCode::format('svg')->size(150)->errorCorrection('H')->generate(
// $petiqr->fix_lot . ";" . $petiqr->id . ";" . $petiqr->warehouse->id
// ));
return view('dashboard.Master_Data.Manajemen_Peti.Peti.show', $data);
}
/**
@ -204,38 +176,7 @@ class PetiController extends Controller
// Generate QR Code
$qrcode = base64_encode(QrCode::format('svg')->size(150)->errorCorrection('H')->generate(
'Nama Customer : ' .
$peti->customer->name .
"\n" .
'Code Customer : ' .
$peti->customer->code_customer .
"\n" .
'ID Peti : ' .
$peti->tipe_peti->id .
"\n" .
'Type Peti : ' .
$peti->tipe_peti->type .
"\n" .
'ID Warehouse : ' .
$peti->warehouse->id .
"\n" .
'Warehouse : ' .
$peti->warehouse->name .
"\n" .
'Ukuran Peti : ' .
$peti->tipe_peti->size_peti .
"\n" .
'Lot Number : ' .
$peti->customer->lot_no .
"\n" .
'Paking Number : ' .
$peti->packing_no .
"\n" .
'Fix Lot : ' .
$peti->fix_lot .
'Status Peti : ' .
$peti->status_disposal
$peti->fix_lot . ';' . $peti->id . ';' . $peti->warehouse->id
));
// Inisialisasi Dompdf

25
app/Http/Controllers/PetternLotPetiController.php

@ -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');
}
}

35
resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/show.blade.php

@ -36,40 +36,7 @@
<label for="fix_lot" class="col-form-label d-flex justify-content-center align-items-center">QR
Code:</label>
<div class="d-flex justify-content-center align-items-center mb-2">
{!! QrCode::size(150)->generate(
'Nama Customer : ' .
$peti->customer->name .
"\n" .
'Code Customer : ' .
$peti->customer->code_customer .
"\n" .
'ID Peti : ' .
$peti->tipe_peti->id .
"\n" .
'Type Peti : ' .
$peti->tipe_peti->type .
"\n" .
'ID Warehouse : ' .
$peti->warehouse->id .
"\n" .
'Warehouse : ' .
$peti->warehouse->name .
"\n" .
'Ukuran Peti : ' .
$peti->tipe_peti->size_peti .
"\n" .
'Lot Number : ' .
$peti->customer->lot_no .
"\n" .
'Paking Number : ' .
$peti->packing_no .
"\n" .
'Fix Lot : ' .
$peti->fix_lot .
"\n" .
'Status Peti : ' .
$peti->status_disposal,
) !!}
{!! QrCode::size(150)->generate($peti->fix_lot . ';' . $peti->id . ';' . $peti->warehouse->id) !!}
</div>
<div class="d-flex justify-content-center mt-2 mb-3">
<a href="{{ route('dashboard.peticetakpdf.cetakpdf', $peti->id) }}" class="btn btn-info"

2
resources/views/dashboard/Master_Data/Manajemen_Peti/Type_peti/create.blade.php

@ -21,7 +21,7 @@
<label for="size_peti" class="col-form-label">Ukuran Peti: <span class="text-danger">*</span></label>
<input class="form-control" name="size_peti" type="text" id="size_peti"
value="{{ old('size_peti') }}" placeholder="Masukkan Ukuran Peti (contoh: 5 x 5 x 5)"
pattern="\d+\s*x\s*\d+\s*x\s*\d+" title="Format yang diperbolehkan: 5 x 5 x 5" required>
title="Format yang diperbolehkan: 5 x 5 x 5" required>
<label for="description" class="col-form-label">Deskripsi Peti: <span
class="text-danger">*</span></label>

2
resources/views/dashboard/Master_Data/Manajemen_Peti/Type_peti/edit.blade.php

@ -23,7 +23,7 @@
<label for="size_peti" class="col-form-label">Ukuran Peti: <span class="text-danger">*</span></label>
<input class="form-control" name="size_peti" type="text" id="size_peti"
value="{{ $typepeti->size_peti }}" placeholder="Masukkan Ukuran Peti (contoh: 5 x 5 x 5)"
pattern="\d+\s*x\s*\d+\s*x\s*\d+" title="Format yang diperbolehkan: 5 x 5 x 5" required>
title="Format yang diperbolehkan: 5 x 5 x 5" required>
<label for="description" class="col-form-label">Deskripsi Peti: <span
class="text-danger">*</span></label>

73
resources/views/dashboard/Master_Data/Report/PATTERN LOT PETI/index.blade.php

@ -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

73
resources/views/dashboard/index.blade.php

@ -17,7 +17,7 @@
<strong>Pengadaan</strong>
</div>
<div class="h5 mb-0 font-weight-bold text-gray-800" style="font-size: 25px;">
{{ $jumlahAsset }}
{{ $jumlahPeti }}
</div>
</div>
<div class="col-auto">
@ -95,33 +95,25 @@
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Grafik Peminjaman VS Pengembalian</h6>
<div class="dropdown no-arrow">
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
</a>
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
aria-labelledby="dropdownMenuLink">
<div class="dropdown-header">Dropdown Header:</div>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
</div>
@php
$chartData = app('App\Http\Controllers\HomeController')->generateChartData();
@endphp
<div class="card-body">
<label for="yearFilter">Pilih Tahun:</label>
<select id="yearFilter" class="form-control">
<option value="" selected disabled>-- pilih tahun --</option>
@foreach ($chartData['years'] as $year)
<option value="{{ $year }}">{{ $year }}</option>
@endforeach
</select>
<canvas id="ChartAssetStatus" style="max-height: 500px;"></canvas> <!-- Atur tinggi chart -->
</div>
</div>
</div>
<!-- Pie Chart -->
<div class="col-xl-4 col-lg-5">
<div class="card shadow mb-4">
@ -164,25 +156,41 @@
</div>
</div>
</div>
@push('script')
<script>
document.addEventListener('DOMContentLoaded', function() {
var ctx = document.getElementById('ChartAssetStatus').getContext('2d');
var myChart;
var chartData = @json($chartData);
function updateChart(selectedYear) {
var selectedYearIndex = chartData.years.indexOf(selectedYear);
var myChart = new Chart(ctx, {
// Mengambil data berdasarkan tahun yang dipilih
var updatedExitData = chartData.exitData[selectedYearIndex];
var updatedEnterData = chartData.enterData[selectedYearIndex];
// Memperbarui chart hanya dengan data tahun yang dipilih
myChart.data.labels = chartData.monthNames; // Menggunakan label bulan
myChart.data.datasets[0].data = updatedExitData; // Menggunakan data peminjaman
myChart.data.datasets[1].data = updatedEnterData; // Menggunakan data pengembalian
myChart.update();
}
myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: {!! json_encode($chartData['monthNames']) !!},
labels: chartData.monthNames, // Menggunakan label bulan
datasets: [{
label: 'Peminjaman',
data: {!! json_encode($chartData['exitData']) !!},
data: chartData.exitData, // Menggunakan data peminjaman
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
}, {
label: 'Pengembalian',
data: {!! json_encode($chartData['enterData']) !!},
data: chartData.enterData, // Menggunakan data pengembalian
backgroundColor: 'rgba(255, 159, 64, 0.2)',
borderColor: 'rgba(255, 159, 64, 1)',
borderWidth: 1
@ -196,6 +204,27 @@
}
}
});
var yearFilter = document.getElementById('yearFilter');
yearFilter.addEventListener('change', function() {
var selectedYear = yearFilter.value;
updateChart(selectedYear);
// Simpan tahun yang dipilih ke local storage
localStorage.setItem('selectedYear', selectedYear);
});
// Kondisi Pertama: Setelah halaman dimuat
// Coba baca tahun yang disimpan di local storage
var selectedYear = localStorage.getItem('selectedYear');
if (selectedYear) {
yearFilter.value = selectedYear;
updateChart(selectedYear);
} else {
// Jika tidak ada tahun yang disimpan, pilih tahun saat ini
var currentYear = new Date().getFullYear();
yearFilter.value = currentYear;
updateChart(currentYear);
}
});
</script>
@endpush

12
resources/views/layouts/sidebar.blade.php

@ -97,12 +97,20 @@
<li class="nav-item">
<a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapsereport"
aria-expanded="{{ $isUserActive ? 'true' : 'false' }}" aria-controls="collapseTwo">
<i class="fas fa-fw fa-user"></i>
<i class="fas fa-fw fa-file-alt"></i>
<span>Report</span>
</a>
<div id="collapsereport" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
<div class="bg-white py-2 collapse-inner rounded">
<a class="collapse-item {{ $active == 'menu-user' ? 'active' : '' }}" href="#">Data Peti</a>
<a class="collapse-item {{ $active == 'menu-Pettern_Lot_Peti' ? 'active' : '' }}"
href="{{ route('dashboard.Pettern_Lot_Peti.index') }}">PATTERN LOT
PETI</a>
<a class="collapse-item {{ $active == 'menu-user' ? 'active' : '' }}" href="#">Report
Peti</a>
<a class="collapse-item {{ $active == 'menu-user' ? 'active' : '' }}" href="#">Report
Peminjaman</a>
<a class="collapse-item {{ $active == 'menu-user' ? 'active' : '' }}" href="#">Report
Pengembalian</a>
</div>
</div>
</li>

61
routes/web.php

@ -11,6 +11,7 @@ use App\Http\Controllers\TypePetiController;
use App\Http\Controllers\WarehouseController;
use App\Http\Controllers\PeminjamanController;
use App\Http\Controllers\PengembalianController;
use App\Http\Controllers\PetternLotPetiController;
/*
|--------------------------------------------------------------------------
@ -44,33 +45,6 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home.admin');
Route::get('/homeuser', [App\Http\Controllers\HomeController::class, 'indexUser'])->name('home.user');
//Halaman Warehouse
Route::controller(WarehouseController::class)->group(function () {
Route::get('warehouse', 'index')->name('warehouse.index');
Route::post('warehouse/store', 'store')->name('warehouse.store');
Route::put('warehouse/{id}', 'update')->name('warehouse.update');
Route::delete('warehouse/delete/{id}', 'destroy')->name('warehouse.destroy');
});
//Halaman Role
Route::controller(RoleController::class)->group(function () {
Route::get('role', 'index')->name('role.index');
Route::post('role/store', 'store')->name('role.store');
Route::put('role/{id}', 'update')->name('role.update');
Route::delete('role/delete/{id}', 'destroy')->name('role.destroy');
});
//Halaman User
Route::controller(M_userController::class)->group(function () {
Route::get('user', 'index')->name('user.index');
Route::get('user/create', 'create')->name('user.create');
Route::post('user/store', 'store')->name('user.store');
Route::get('user/{id}', 'show')->name('user.show');
Route::get('user/{id}/edit', 'edit')->name('user.edit');
Route::put('user/{id}', 'update')->name('user.update');
Route::delete('user/delete/{id}', 'destroy')->name('user.destroy');
});
//Halaman Peminjaman
Route::controller(PeminjamanController::class)->group(function () {
Route::get('peminjaman', 'index')->name('peminjaman.index');
@ -92,6 +66,25 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::delete('pengembalian/delete/{id}', 'destroy')->name('pengembalian.destroy');
});
//Halaman User
Route::controller(M_userController::class)->group(function () {
Route::get('user', 'index')->name('user.index');
Route::get('user/create', 'create')->name('user.create');
Route::post('user/store', 'store')->name('user.store');
Route::get('user/{id}', 'show')->name('user.show');
Route::get('user/{id}/edit', 'edit')->name('user.edit');
Route::put('user/{id}', 'update')->name('user.update');
Route::delete('user/delete/{id}', 'destroy')->name('user.destroy');
});
//Halaman Role
Route::controller(RoleController::class)->group(function () {
Route::get('role', 'index')->name('role.index');
Route::post('role/store', 'store')->name('role.store');
Route::put('role/{id}', 'update')->name('role.update');
Route::delete('role/delete/{id}', 'destroy')->name('role.destroy');
});
//Halaman Customer
Route::controller(CustomerController::class)->group(function () {
Route::get('customer', 'index')->name('customer.index');
@ -125,6 +118,20 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::delete('peti/delete/{id}', 'destroy')->name('peti.destroy');
Route::get('peticetak_pdf/{id}', 'cetakpdf')->name('peticetakpdf.cetakpdf');
});
//Halaman Warehouse
Route::controller(WarehouseController::class)->group(function () {
Route::get('warehouse', 'index')->name('warehouse.index');
Route::post('warehouse/store', 'store')->name('warehouse.store');
Route::put('warehouse/{id}', 'update')->name('warehouse.update');
Route::delete('warehouse/delete/{id}', 'destroy')->name('warehouse.destroy');
});
//halaman Report
Route::controller(PetternLotPetiController::class)->group(function () {
Route::get('Pettern_Lot_Peti', 'index')->name('Pettern_Lot_Peti.index');
Route::get('Pettern_Lot_Peti/export', 'export')->name('Pettern_Lot_Peti.export');
});
});

Loading…
Cancel
Save