unknown 1 year ago
parent
commit
5d111f9e23
  1. 25
      app/Http/Controllers/CustomerController.php
  2. 30
      app/Http/Controllers/DisposalController.php
  3. 25
      app/Http/Controllers/KondisiPetiController.php
  4. 38
      app/Http/Controllers/PeminjamanController.php
  5. 133
      app/Http/Controllers/PetiController.php
  6. 63
      app/Http/Controllers/Report/PetternLotPetiController.php
  7. 29
      app/Http/Controllers/TransferController.php
  8. 25
      app/Http/Controllers/TypePetiController.php
  9. 58
      app/Http/Controllers/WarehouseController.php
  10. 56
      app/Imports/CustomerImport.php
  11. 56
      app/Imports/KondisiPetiImport.php
  12. 86
      app/Imports/PetiImport.php
  13. 56
      app/Imports/TipePetiImport.php
  14. 56
      app/Imports/WarehouseImport.php
  15. 58
      resources/views/dashboard/Disposal/create.blade.php
  16. 139
      resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/index.blade.php
  17. 71
      resources/views/dashboard/Master_Data/Report/Pattern_lot_peti/index.blade.php
  18. 1
      resources/views/dashboard/Master_Data/Warehouse/index.blade.php
  19. 147
      resources/views/dashboard/Peminjaman/create.blade.php
  20. 56
      resources/views/dashboard/Transfer/create.blade.php
  21. 6
      resources/views/layouts/components/alert-prompt.blade.php
  22. 3
      routes/web.php

25
app/Http/Controllers/CustomerController.php

@ -113,7 +113,28 @@ class CustomerController extends Controller
public function importCustomer(Request $request) public function importCustomer(Request $request)
{ {
Excel::import(new CustomerImport, request()->file('file')); $import = new CustomerImport;
return redirect()->route('dashboard.customer.index')->with('success', 'Data customer berhasil Di Import');
try {
Excel::import($import, request()->file('file'));
if ($import->getRowCount() > 0) {
return redirect()->route('dashboard.customer.index')->with('success', 'Data Customer berhasil diimport');
} else {
$errors = $import->getErrors();
if (!empty($errors)) {
session()->flash('error', $errors);
}
return redirect()->back()->with('import', $import)->with('error', 'Data Customer gagal di import.');
}
} catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
$failures = $e->failures();
foreach ($failures as $failure) {
session()->flash('error', ['Baris ' . $failure->row() => implode(', ', $failure->errors())]);
}
}
} }
} }

30
app/Http/Controllers/DisposalController.php

@ -6,7 +6,9 @@ use App\Models\Peti;
use App\Models\Customer; use App\Models\Customer;
use App\Models\Disposal; use App\Models\Disposal;
use App\Models\m_warehouse; use App\Models\m_warehouse;
use Illuminate\Http\Request;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use App\Http\Requests\Disposal\ValidasiCreateDisposal; use App\Http\Requests\Disposal\ValidasiCreateDisposal;
use App\Http\Requests\Disposal\ValidasiUpdateDisposal; use App\Http\Requests\Disposal\ValidasiUpdateDisposal;
@ -164,4 +166,32 @@ class DisposalController extends Controller
return redirect()->back()->with('error', 'Data disposal peti gagal dihapus'); return redirect()->back()->with('error', 'Data disposal peti gagal dihapus');
} }
} }
/**
* Search peti by fix_lot
*/
public function autoCompleteSearch(Request $request): JsonResponse
{
$petiData = [];
$customerData = [];
if ($request->filled('q')) {
$petiData = Peti::select("fix_lot", "id")
->where('fix_lot', 'LIKE', '%' . $request->get('q') . '%')
->where(function ($query) {
$query->whereHas('assetStatuses', function ($subquery) {
$subquery->where('status', '!=', 0)
->where('created_at', '=', function ($maxQuery) {
$maxQuery->selectRaw('MAX(created_at)')
->from('asset_statuses')
->whereColumn('peti_id', 'petis.id');
});
})->orWhereDoesntHave('assetStatuses');
})
->where('status', 'AKTIF')
->get();
}
return response()->json(['peti' => $petiData, 'customer' => $customerData]);
}
} }

25
app/Http/Controllers/KondisiPetiController.php

@ -69,7 +69,28 @@ class KondisiPetiController extends Controller
public function importKondisiPeti(Request $request) public function importKondisiPeti(Request $request)
{ {
Excel::import(new KondisiPetiImport, request()->file('file')); $import = new KondisiPetiImport;
return redirect()->route('dashboard.kondisipeti.index')->with('success', 'Data kondisi peti berhasil di import');
try {
Excel::import($import, request()->file('file'));
if ($import->getRowCount() > 0) {
return redirect()->route('dashboard.kondisipeti.index')->with('success', 'Data Kondisi Peti berhasil diimport');
} else {
$errors = $import->getErrors();
if (!empty($errors)) {
session()->flash('error', $errors);
}
return redirect()->back()->with('import', $import)->with('error', 'Data Kondisi Peti gagal di import.');
}
} catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
$failures = $e->failures();
foreach ($failures as $failure) {
session()->flash('error', ['Baris ' . $failure->row() => implode(', ', $failure->errors())]);
}
}
} }
} }

38
app/Http/Controllers/PeminjamanController.php

@ -9,6 +9,7 @@ use App\Models\asset_status;
use App\Models\Kondisi_Peti; use App\Models\Kondisi_Peti;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use App\Http\Requests\ValidasiCreatePeminjaman; use App\Http\Requests\ValidasiCreatePeminjaman;
@ -19,18 +20,6 @@ class PeminjamanController extends Controller
/** /**
* Display a listing of the resource. * Display a listing of the resource.
*/ */
// public function index()
// {
// $data = [
// // 'peminjaman' => asset_status::get(),
// 'peminjaman' => asset_status::orderBy('created_at', 'desc')->get(),
// 'warehouse' => m_warehouse::get(),
// 'active' => 'menu-peminjaman',
// ];
// return view('dashboard.Peminjaman.index', $data);
// }
public function index(Request $request) public function index(Request $request)
{ {
$perPage = $request->input('perPage', 5); $perPage = $request->input('perPage', 5);
@ -220,4 +209,29 @@ class PeminjamanController extends Controller
]; ];
return view('dashboard.Peminjaman.pengembalian', $data); return view('dashboard.Peminjaman.pengembalian', $data);
} }
public function autoCompleteSearch(Request $request): JsonResponse
{
$petiData = [];
$customerData = [];
if ($request->filled('q')) {
$petiData = Peti::select("fix_lot", "id")
->where('fix_lot', 'LIKE', '%' . $request->get('q') . '%')
->where(function ($query) {
$query->whereHas('assetStatuses', function ($subquery) {
$subquery->where('status', '!=', 0)
->where('created_at', '=', function ($maxQuery) {
$maxQuery->selectRaw('MAX(created_at)')
->from('asset_statuses')
->whereColumn('peti_id', 'petis.id');
});
})->orWhereDoesntHave('assetStatuses');
})
->where('status', 'AKTIF')
->get();
}
return response()->json(['peti' => $petiData, 'customer' => $customerData]);
}
} }

133
app/Http/Controllers/PetiController.php

@ -24,81 +24,60 @@ class PetiController extends Controller
/** /**
* Display a listing of the resource. * Display a listing of the resource.
*/ */
// public function index()
// {
// $data = [
// // 'peti' => Peti::orderBy('created_at', 'desc')->get(),
// 'peti' => Peti::orderBy('created_at', 'desc')->get(),
// 'kondisiPeti' => Kondisi_Peti::all(),
// 'active' => 'menu-peti',
// ];
// return view('dashboard.Master_Data.Manajemen_Peti.Peti.index', $data);
// }
// public function index()
// {
// // $perPage = 10; // Jumlah data per halaman, sesuaikan dengan kebutuhan Anda
// // $peti = Peti::orderBy('created_at', 'desc')->paginate($perPage);
// $peti = Peti::orderBy('created_at', 'desc')->get();
// $kondisiPeti = Kondisi_Peti::all();
// $data = [
// 'peti' => $peti,
// 'kondisiPeti' => $kondisiPeti,
// 'active' => 'menu-peti',
// ];
// return view('dashboard.Master_Data.Manajemen_Peti.Peti.index', $data);
// }
public function index(Request $request) public function index(Request $request)
{ {
$perPage = $request->input('perPage', 5); $perPage = $request->input('perPage', 5);
$query = Peti::select(['petis.*', 'customers.code_customer', 'customers.lot_no', 'type_petis.type', 'type_petis.size_peti', 'm_warehouses.name as warehouse_name']) $query = Peti::with(['customer', 'warehouse', 'tipe_peti', 'kondisipeti', 'transfer', 'assetStatuses'])
->join('customers', 'customers.id', '=', 'petis.customer_id') ->orderBy('created_at', 'desc');
->join('type_petis', 'type_petis.id', '=', 'petis.tipe_peti_id') // Tambahkan logika pencarian
->join('m_warehouses', 'm_warehouses.id', '=', 'petis.warehouse_id') $search = $request->input('search') ?? '';
->join('kondisi_petis', 'kondisipeti_id', '=', 'petis.kondisipeti_id')
->orderBy('petis.created_at', 'desc');
// Tambahkan logika pencarian // Tambahkan logika pencarian
$search = $request->input('search') ?? ''; $search = $request->input('search') ?? '';
if ($search) { if ($search) {
$query->where(function ($q) use ($search) { $query->where(function ($q) use ($search) {
$q->where('petis.fix_lot', 'like', "%$search%") $q->where('fix_lot', 'like', "%$search%")
->orWhere('petis.created_by', 'like', "%$search%") ->orWhere('created_by', 'like', "%$search%")
->orWhere('customers.name', 'like', "%$search%") ->orWhereHas('customer', function ($customerQuery) use ($search) {
->orWhere('m_warehouses.name', 'like', "%$search%") $customerQuery->where('name', 'like', "%$search%")
->orWhere('customers.code_customer', 'like', "%$search%") ->orWhere('code_customer', 'like', "%$search%")
->orWhere('type_petis.type', 'like', "%$search%") ->orWhere('lot_no', 'like', "%$search%");
->orWhere('type_petis.size_peti', 'like', "%$search%") })
->orWhere('customers.lot_no', 'like', "%$search%") ->orWhereHas('warehouse', function ($warehouseQuery) use ($search) {
->orWhere('kondisi_petis.nama_kondisi', 'like', "%$search%") $warehouseQuery->where('name', 'like', "%$search%");
->orWhere('petis.packing_no', 'like', "%$search%") })
->orWhere('petis.status', 'like', "%$search%"); ->orWhereHas('tipe_peti', function ($tipePetiQuery) use ($search) {
$tipePetiQuery->where('type', 'like', "%$search%")
->orWhere('size_peti', 'like', "%$search%");
})
->orWhereHas('kondisipeti', function ($kondisiPetiQuery) use ($search) {
$kondisiPetiQuery->where('nama_kondisi', 'like', "%$search%");
})
->orWhere('packing_no', 'like', "%$search%")
->orWhere('status', 'like', "%$search%");
}); });
} }
if ($perPage == 'Semua') { if ($perPage == 'Semua') {
$chunkSize = 100; $chunkSize = 100;
$stores = new Collection(); $petis = new Collection();
$currentPage = 1; $currentPage = 1;
$query->chunk($chunkSize, function ($storesChunk) use ($stores, &$currentPage) { $query->chunk($chunkSize, function ($petiChunk) use ($petis, &$currentPage) {
foreach ($storesChunk as $store) { foreach ($petiChunk as $peti) {
$store->setAttribute('i', ($currentPage - 1) * $storesChunk->perPage() + 1); $peti->setAttribute('i', ($currentPage - 1) * $petiChunk->perPage() + 1);
$stores->push($store); $petis->push($peti);
$currentPage++; $currentPage++;
} }
}); });
} else { } else {
$stores = $query->paginate($perPage); $petis = $query->paginate($perPage);
} }
$data = [ $data = [
// 'peti' => Peti::orderBy('created_at', 'desc')->paginate(10), 'peti' => $petis,
'peti' => $stores,
'kondisiPeti' => Kondisi_Peti::all(), 'kondisiPeti' => Kondisi_Peti::all(),
'i' => ($stores->currentPage() - 1) * $stores->perPage() + 1, 'i' => ($petis->currentPage() - 1) * $petis->perPage() + 1,
'search' => $search, 'search' => $search,
'active' => 'menu-peti', 'active' => 'menu-peti',
]; ];
@ -343,9 +322,55 @@ class PetiController extends Controller
); );
} }
// public function importPeti(Request $request)
// {
// $import = new PetiImport;
// Excel::import($import, request()->file('file'));
// // Cek apakah ada data yang berhasil diimpor
// if ($import->getRowCount() > 0) {
// return redirect()->route('dashboard.peti.index')->with('success', 'Data Peti berhasil diimport');
// } else {
// $errors = $import->getErrors();
// if ($errors) {
// foreach ($errors as $error) {
// foreach ($error->all() as $message) {
// // Tampilkan pesan kesalahan untuk setiap baris
// // Simpan pesan flash dengan kategori 'error'
// session()->flash('error', $message);
// }
// }
// }
// // Redirect back with import data and error message
// return redirect()->back()->with('import', $import)->with('error', 'Data Import Peti gagal di import.');
// }
// }
public function importPeti(Request $request) public function importPeti(Request $request)
{ {
Excel::import(new PetiImport, request()->file('file')); $import = new PetiImport;
return redirect()->route('dashboard.peti.index')->with('success', 'Data peti berhasil di import');
try {
Excel::import($import, request()->file('file'));
if ($import->getRowCount() > 0) {
return redirect()->route('dashboard.peti.index')->with('success', 'Data Peti berhasil diimport');
} else {
$errors = $import->getErrors();
if (!empty($errors)) {
session()->flash('error', $errors);
}
return redirect()->back()->with('import', $import)->with('error', 'Data Peti gagal di import.');
}
} catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
$failures = $e->failures();
foreach ($failures as $failure) {
session()->flash('error', ['Baris ' . $failure->row() => implode(', ', $failure->errors())]);
}
}
} }
} }

63
app/Http/Controllers/Report/PetternLotPetiController.php

@ -5,16 +5,75 @@ namespace App\Http\Controllers\Report;
use App\Models\Peti; use App\Models\Peti;
use App\Models\asset_status; use App\Models\asset_status;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use App\Exports\PetternLotPetiExport; use App\Exports\PetternLotPetiExport;
class PetternLotPetiController extends Controller class PetternLotPetiController extends Controller
{ {
public function index() // public function index()
// {
// $data = [
// 'peti' => Peti::withTrashed()->get(),
// 'active' => 'menu-Pettern_Lot_Peti'
// ];
// return view('dashboard.Master_Data.Report.Pattern_lot_peti.index', $data);
// }
public function index(Request $request)
{ {
$perPage = $request->input('perPage', 5);
$query = Peti::with(['customer', 'warehouse', 'tipe_peti', 'kondisipeti', 'transfer', 'assetStatuses'])
->orderBy('created_at', 'desc');
// Tambahkan logika pencarian
$search = $request->input('search') ?? '';
// Tambahkan logika pencarian
$search = $request->input('search') ?? '';
if ($search) {
$query->where(function ($q) use ($search) {
$q->where('fix_lot', 'like', "%$search%")
->orWhere('created_by', 'like', "%$search%")
->orWhereHas('customer', function ($customerQuery) use ($search) {
$customerQuery->where('name', 'like', "%$search%")
->orWhere('code_customer', 'like', "%$search%")
->orWhere('lot_no', 'like', "%$search%");
})
->orWhereHas('warehouse', function ($warehouseQuery) use ($search) {
$warehouseQuery->where('name', 'like', "%$search%");
})
->orWhereHas('tipe_peti', function ($tipePetiQuery) use ($search) {
$tipePetiQuery->where('type', 'like', "%$search%")
->orWhere('size_peti', 'like', "%$search%");
})
->orWhereHas('kondisipeti', function ($kondisiPetiQuery) use ($search) {
$kondisiPetiQuery->where('nama_kondisi', 'like', "%$search%");
})
->orWhere('packing_no', 'like', "%$search%")
->orWhere('status', 'like', "%$search%");
});
}
if ($perPage == 'Semua') {
$chunkSize = 100;
$petis = new Collection();
$currentPage = 1;
$query->chunk($chunkSize, function ($petiChunk) use ($petis, &$currentPage) {
foreach ($petiChunk as $peti) {
$peti->setAttribute('i', ($currentPage - 1) * $petiChunk->perPage() + 1);
$petis->push($peti);
$currentPage++;
}
});
} else {
$petis = $query->paginate($perPage);
}
$data = [ $data = [
'peti' => Peti::withTrashed()->get(), 'peti' => $petis,
'i' => ($petis->currentPage() - 1) * $petis->perPage() + 1,
'search' => $search,
'active' => 'menu-Pettern_Lot_Peti' 'active' => 'menu-Pettern_Lot_Peti'
]; ];
return view('dashboard.Master_Data.Report.Pattern_lot_peti.index', $data); return view('dashboard.Master_Data.Report.Pattern_lot_peti.index', $data);

29
app/Http/Controllers/TransferController.php

@ -3,11 +3,12 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Peti; use App\Models\Peti;
use Symfony\Component\Uid\Uuid;
use App\Models\Customer; use App\Models\Customer;
use App\Models\Transfer; use App\Models\Transfer;
use App\Models\m_warehouse; use App\Models\m_warehouse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Symfony\Component\Uid\Uuid;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use App\Http\Requests\Transfer\ValidasiCreateTransfer; use App\Http\Requests\Transfer\ValidasiCreateTransfer;
use App\Http\Requests\Transfer\ValidasiUpdateTransfer; use App\Http\Requests\Transfer\ValidasiUpdateTransfer;
@ -220,4 +221,30 @@ class TransferController extends Controller
return redirect()->back()->with('error', 'Data transfer peti gagal dihapus'); return redirect()->back()->with('error', 'Data transfer peti gagal dihapus');
} }
} }
// Proses select2 autocomplete
public function autoCompleteSearch(Request $request): JsonResponse
{
$petiData = [];
$customerData = [];
if ($request->filled('q')) {
$petiData = Peti::select("fix_lot", "id")
->where('fix_lot', 'LIKE', '%' . $request->get('q') . '%')
->where(function ($query) {
$query->whereHas('assetStatuses', function ($subquery) {
$subquery->where('status', '!=', 0)
->where('created_at', '=', function ($maxQuery) {
$maxQuery->selectRaw('MAX(created_at)')
->from('asset_statuses')
->whereColumn('peti_id', 'petis.id');
});
})->orWhereDoesntHave('assetStatuses');
})
->where('status', 'AKTIF')
->get();
}
return response()->json(['peti' => $petiData, 'customer' => $customerData]);
}
} }

25
app/Http/Controllers/TypePetiController.php

@ -113,7 +113,28 @@ class TypePetiController extends Controller
public function importTipePeti(Request $request) public function importTipePeti(Request $request)
{ {
Excel::import(new TipePetiImport, request()->file('file')); $import = new TipePetiImport;
return redirect()->route('dashboard.typepeti.index')->with('success', 'Data tipe peti berhasil di import');
try {
Excel::import($import, request()->file('file'));
if ($import->getRowCount() > 0) {
return redirect()->route('dashboard.typepeti.index')->with('success', 'Data Tipe Peti berhasil diimport');
} else {
$errors = $import->getErrors();
if (!empty($errors)) {
session()->flash('error', $errors);
}
return redirect()->back()->with('import', $import)->with('error', 'Data Tipe Peti gagal di import.');
}
} catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
$failures = $e->failures();
foreach ($failures as $failure) {
session()->flash('error', ['Baris ' . $failure->row() => implode(', ', $failure->errors())]);
}
}
} }
} }

58
app/Http/Controllers/WarehouseController.php

@ -4,11 +4,14 @@ namespace App\Http\Controllers;
use App\Models\m_warehouse; use App\Models\m_warehouse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Imports\WarehouseImport;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Session;
use App\Http\Requests\ValidasiCreateWarehouse; use App\Http\Requests\ValidasiCreateWarehouse;
use App\Http\Requests\ValidasiUpdateWarehouse; use App\Http\Requests\ValidasiUpdateWarehouse;
use App\Imports\WarehouseImport; use Maatwebsite\Excel\Exceptions\NoTypeDetectedException;
use Illuminate\Support\Facades\Log;
class WarehouseController extends Controller class WarehouseController extends Controller
{ {
@ -26,10 +29,10 @@ class WarehouseController extends Controller
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
*/ */
public function create() // public function create()
{ // {
// return view('dashboard.Master_Data.Warehouse.create'); // // return view('dashboard.Master_Data.Warehouse.create');
} // }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
@ -54,20 +57,20 @@ class WarehouseController extends Controller
/** /**
* Display the specified resource. * Display the specified resource.
*/ */
public function show($id) // public function show($id)
{ // {
// dd('oke'); // // dd('oke');
// return view('dashboard.Master_Data.Warehouse.show'); // // return view('dashboard.Master_Data.Warehouse.show');
} // }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
*/ */
public function edit() // public function edit()
{ // {
// dd('oke'); // // dd('oke');
// return view('dashboard.Master_Data.Warehouse.edit'); // // return view('dashboard.Master_Data.Warehouse.edit');
} // }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
@ -104,7 +107,28 @@ class WarehouseController extends Controller
public function importWarehouse(Request $request) public function importWarehouse(Request $request)
{ {
Excel::import(new WarehouseImport, request()->file('file')); $import = new WarehouseImport;
return redirect()->route('dashboard.warehouse.index')->with('success', 'Data Warehouse berhasil diimport');
try {
Excel::import($import, request()->file('file'));
if ($import->getRowCount() > 0) {
return redirect()->route('dashboard.warehouse.index')->with('success', 'Data Warehouse berhasil diimport');
} else {
$errors = $import->getErrors();
if (!empty($errors)) {
session()->flash('error', $errors);
}
return redirect()->back()->with('import', $import)->with('error', 'Data Warehouse gagal di import.');
}
} catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
$failures = $e->failures();
foreach ($failures as $failure) {
session()->flash('error', ['Baris ' . $failure->row() => implode(', ', $failure->errors())]);
}
}
} }
} }

56
app/Imports/CustomerImport.php

@ -3,9 +3,11 @@
namespace App\Imports; namespace App\Imports;
use App\Models\Customer; use App\Models\Customer;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Events\AfterImport;
use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithHeadingRow;
class CustomerImport implements ToModel, WithHeadingRow class CustomerImport implements ToModel, WithHeadingRow
@ -15,11 +17,37 @@ class CustomerImport implements ToModel, WithHeadingRow
* *
* @return \Illuminate\Database\Eloquent\Model|null * @return \Illuminate\Database\Eloquent\Model|null
*/ */
private $rowCount = 0;
private $errors;
public function model(array $row) public function model(array $row)
{ {
// Pemeriksaan apakah semua kolom yang dibutuhkan ada dalam format yang benar
$requiredColumns = ['name', 'code_customer', 'lot_no', 'no_tlp', 'address'];
foreach ($requiredColumns as $column) {
if (!array_key_exists($column, $row) || empty($row[$column])) {
$this->errors[] = 'Kolom ' . $column . ' pada baris ' . $this->rowCount . ' tidak boleh kosong.';
return null; // Abaikan data dengan kolom yang tidak sesuai
}
}
// Mendapatkan informasi pengguna yang sedang login // Mendapatkan informasi pengguna yang sedang login
$user = Auth::user(); $user = Auth::user();
// Cek apakah nama warehouse sudah ada dalam database
$existingCustomer = Customer::where('name', $row['name'])->first();
if ($existingCustomer) {
// Jika nama warehouse sudah ada, tambahkan pesan kesalahan ke dalam array $errors
$this->errors[] = new MessageBag(['Row ' . $this->rowCount => 'Data Customer sudah ada dalam database.']);
return null; // Abaikan data yang sudah ada
}
// Increment rowCount setiap kali ada data yang diimpor
$this->rowCount++;
return new Customer([ return new Customer([
'name' => $row['name'], 'name' => $row['name'],
'code_customer' => $row['code_customer'], 'code_customer' => $row['code_customer'],
@ -29,4 +57,32 @@ class CustomerImport implements ToModel, WithHeadingRow
'created_by' => $user->fullname, 'created_by' => $user->fullname,
]); ]);
} }
public function registerEvents(): array
{
return [
AfterImport::class => function (AfterImport $event) {
// Setelah import selesai, kita bisa mengakses semua data yang diimpor
$importedData = $event->getReader()->getDelegate()->getActiveSheet()->toArray();
// Lakukan pemeriksaan apakah ada data yang bernilai null dan hapus dari hasil import
$filteredData = array_filter($importedData, function ($row) {
return $row[0] !== null; // Jika nilai kolom pertama tidak null, pertahankan baris tersebut
});
// Update hasil import dengan data yang telah difilter
$event->getReader()->getDelegate()->getActiveSheet()->fromArray($filteredData);
},
];
}
public function getErrors()
{
return $this->errors;
}
public function getRowCount()
{
return $this->rowCount;
}
} }

56
app/Imports/KondisiPetiImport.php

@ -4,8 +4,10 @@ namespace App\Imports;
use App\Models\Kondisi_Peti; use App\Models\Kondisi_Peti;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Events\AfterImport;
use Maatwebsite\Excel\Concerns\ToCollection; use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithHeadingRow;
@ -16,15 +18,69 @@ class KondisiPetiImport implements ToModel, WithHeadingRow
* *
* @return \Illuminate\Database\Eloquent\Model|null * @return \Illuminate\Database\Eloquent\Model|null
*/ */
private $rowCount = 0;
private $errors;
public function model(array $row) public function model(array $row)
{ {
// Pemeriksaan apakah semua kolom yang dibutuhkan ada dalam format yang benar
$requiredColumns = ['nama_kondisi', 'deskripsi_kondisi'];
foreach ($requiredColumns as $column) {
if (!array_key_exists($column, $row) || empty($row[$column])) {
$this->errors[] = 'Kolom ' . $column . ' pada baris ' . $this->rowCount . ' tidak boleh kosong.';
return null; // Abaikan data dengan kolom yang tidak sesuai
}
}
// Mendapatkan informasi pengguna yang sedang login // Mendapatkan informasi pengguna yang sedang login
$user = Auth::user(); $user = Auth::user();
// Cek apakah nama warehouse sudah ada dalam database
$existingKondisiPeti = Kondisi_Peti::where('nama_kondisi', $row['nama_kondisi'])->first();
if ($existingKondisiPeti) {
// Jika nama warehouse sudah ada, tambahkan pesan kesalahan ke dalam array $errors
$this->errors[] = new MessageBag(['Row ' . $this->rowCount => 'Data Kondisi Peti sudah ada dalam database.']);
return null; // Abaikan data yang sudah ada
}
// Increment rowCount setiap kali ada data yang diimpor
$this->rowCount++;
return new Kondisi_Peti([ return new Kondisi_Peti([
'nama_kondisi' => $row['nama_kondisi'], 'nama_kondisi' => $row['nama_kondisi'],
'deskripsi_kondisi' => $row['deskripsi_kondisi'], 'deskripsi_kondisi' => $row['deskripsi_kondisi'],
'created_by' => $user->fullname, 'created_by' => $user->fullname,
]); ]);
} }
public function registerEvents(): array
{
return [
AfterImport::class => function (AfterImport $event) {
// Setelah import selesai, kita bisa mengakses semua data yang diimpor
$importedData = $event->getReader()->getDelegate()->getActiveSheet()->toArray();
// Lakukan pemeriksaan apakah ada data yang bernilai null dan hapus dari hasil import
$filteredData = array_filter($importedData, function ($row) {
return $row[0] !== null; // Jika nilai kolom pertama tidak null, pertahankan baris tersebut
});
// Update hasil import dengan data yang telah difilter
$event->getReader()->getDelegate()->getActiveSheet()->fromArray($filteredData);
},
];
}
public function getErrors()
{
return $this->errors;
}
public function getRowCount()
{
return $this->rowCount;
}
} }

86
app/Imports/PetiImport.php

@ -3,35 +3,101 @@
namespace App\Imports; namespace App\Imports;
use App\Models\Peti; use App\Models\Peti;
use App\Models\Customer;
use App\Models\Type_peti;
use App\Models\m_warehouse;
use App\Models\Kondisi_Peti;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Events\AfterImport;
use Maatwebsite\Excel\Concerns\ToCollection; use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithHeadingRow;
class PetiImport implements ToModel, WithHeadingRow class PetiImport implements ToModel, WithHeadingRow
{ {
/** private $rowCount = 0;
* @param array $row private $errors;
*
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function model(array $row) public function model(array $row)
{ {
// Mendapatkan informasi pengguna yang sedang login // Pemeriksaan apakah semua kolom yang dibutuhkan ada dalam format yang benar
$requiredColumns = ['tipe_peti_id', 'warna', 'customer_id', 'warehouse_id', 'kondisipeti_id', 'packing_no', 'fix_lot', 'status'];
foreach ($requiredColumns as $column) {
if (!array_key_exists($column, $row) || empty($row[$column])) {
$this->errors[] = 'Kolom ' . $column . ' pada baris ' . $this->rowCount . ' tidak boleh kosong.';
return null; // Abaikan data dengan kolom yang tidak sesuai
}
}
$user = Auth::user(); $user = Auth::user();
$existingPeti = Peti::where('fix_lot', $row['fix_lot'])->first();
if ($existingPeti) {
$this->errors[] = new MessageBag(['Row ' . $this->rowCount => 'Data Peti sudah ada dalam database.']);
return null;
}
$tipePeti = Type_peti::firstOrCreate(
['type' => $row['tipe_peti_id']],
['size_peti' => 'Default Size', 'description' => 'Default Description']
);
$customer = Customer::firstOrCreate(
['name' => $row['customer_id']],
['code_customer' => 'Default Code', 'lot_no' => 'Default Lot No', 'no_tlp' => 'Default No Tlp', 'address' => 'Default Address']
);
$warehouse = m_warehouse::firstOrCreate(
['name' => $row['warehouse_id']],
['description' => 'Default Description', 'address' => 'Default Address']
);
$kondisiPeti = Kondisi_Peti::firstOrCreate(
['nama_kondisi' => $row['kondisipeti_id']],
['deskripsi_kondisi' => 'Default Deskripsi']
);
$this->rowCount++;
return new Peti([ return new Peti([
'created_by' => $user->fullname, 'created_by' => $user->fullname,
'tipe_peti_id' => $row['tipe_peti_id'], 'tipe_peti_id' => $tipePeti->id,
'warna' => $row['warna'], 'warna' => $row['warna'],
'customer_id' => $row['customer_id'], 'customer_id' => $customer->id,
'warehouse_id' => $row['warehouse_id'], 'warehouse_id' => $warehouse->id,
'date_pembuatan' => now(), 'date_pembuatan' => now(),
'kondisipeti_id' => $row['kondisipeti_id'], 'kondisipeti_id' => $kondisiPeti->id,
'packing_no' => $row['packing_no'], 'packing_no' => $row['packing_no'],
'fix_lot' => $row['fix_lot'], 'fix_lot' => $row['fix_lot'],
'status' => $row['status'], 'status' => $row['status'],
]); ]);
} }
public function registerEvents(): array
{
return [
AfterImport::class => function (AfterImport $event) {
$importedData = $event->getReader()->getDelegate()->getActiveSheet()->toArray();
$filteredData = array_filter($importedData, function ($row) {
return $row[0] !== null;
});
$event->getReader()->getDelegate()->getActiveSheet()->fromArray($filteredData);
},
];
}
public function getErrors()
{
return $this->errors;
}
public function getRowCount()
{
return $this->rowCount;
}
} }

56
app/Imports/TipePetiImport.php

@ -4,8 +4,10 @@ namespace App\Imports;
use App\Models\Type_peti; use App\Models\Type_peti;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Events\AfterImport;
use App\Models\Type_peti as ModelsType_peti; use App\Models\Type_peti as ModelsType_peti;
use Maatwebsite\Excel\Concerns\ToCollection; use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithHeadingRow;
@ -17,11 +19,37 @@ class TipePetiImport implements ToModel, WithHeadingRow
* *
* @return \Illuminate\Database\Eloquent\Model|null * @return \Illuminate\Database\Eloquent\Model|null
*/ */
private $rowCount = 0;
private $errors;
public function model(array $row) public function model(array $row)
{ {
// Pemeriksaan apakah semua kolom yang dibutuhkan ada dalam format yang benar
$requiredColumns = ['type', 'size_peti', 'description'];
foreach ($requiredColumns as $column) {
if (!array_key_exists($column, $row) || empty($row[$column])) {
$this->errors[] = 'Kolom ' . $column . ' pada baris ' . $this->rowCount . ' tidak boleh kosong.';
return null; // Abaikan data dengan kolom yang tidak sesuai
}
}
// Mendapatkan informasi pengguna yang sedang login // Mendapatkan informasi pengguna yang sedang login
$user = Auth::user(); $user = Auth::user();
// Cek apakah nama warehouse sudah ada dalam database
$existingTipePeti = Type_peti::where('type', $row['type'])->first();
if ($existingTipePeti) {
// Jika nama warehouse sudah ada, tambahkan pesan kesalahan ke dalam array $errors
$this->errors[] = new MessageBag(['Row ' . $this->rowCount => 'Data Tipe peti sudah ada dalam database.']);
return null; // Abaikan data yang sudah ada
}
// Increment rowCount setiap kali ada data yang diimpor
$this->rowCount++;
return new Type_peti([ return new Type_peti([
'type' => $row['type'], 'type' => $row['type'],
'size_peti' => $row['size_peti'], 'size_peti' => $row['size_peti'],
@ -29,4 +57,32 @@ class TipePetiImport implements ToModel, WithHeadingRow
'created_by' => $user->fullname, 'created_by' => $user->fullname,
]); ]);
} }
public function registerEvents(): array
{
return [
AfterImport::class => function (AfterImport $event) {
// Setelah import selesai, kita bisa mengakses semua data yang diimpor
$importedData = $event->getReader()->getDelegate()->getActiveSheet()->toArray();
// Lakukan pemeriksaan apakah ada data yang bernilai null dan hapus dari hasil import
$filteredData = array_filter($importedData, function ($row) {
return $row[0] !== null; // Jika nilai kolom pertama tidak null, pertahankan baris tersebut
});
// Update hasil import dengan data yang telah difilter
$event->getReader()->getDelegate()->getActiveSheet()->fromArray($filteredData);
},
];
}
public function getErrors()
{
return $this->errors;
}
public function getRowCount()
{
return $this->rowCount;
}
} }

56
app/Imports/WarehouseImport.php

@ -3,9 +3,12 @@
namespace App\Imports; namespace App\Imports;
use App\Models\m_warehouse; use App\Models\m_warehouse;
use Illuminate\Validation\Rule;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Events\AfterImport;
use Maatwebsite\Excel\Concerns\ToCollection; use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithHeadingRow;
@ -16,11 +19,36 @@ class WarehouseImport implements ToModel, WithHeadingRow
* *
* @return \Illuminate\Database\Eloquent\Model|null * @return \Illuminate\Database\Eloquent\Model|null
*/ */
private $rowCount = 0;
private $errors;
public function model(array $row) public function model(array $row)
{ {
$requiredColumns = ['name', 'description', 'address'];
foreach ($requiredColumns as $column) {
if (!array_key_exists($column, $row) || empty($row[$column])) {
$this->errors[] = 'Kolom ' . $column . ' pada baris ' . $this->rowCount . ' tidak boleh kosong.';
return null; // Abaikan data dengan kolom yang tidak sesuai
}
}
// Mendapatkan informasi pengguna yang sedang login // Mendapatkan informasi pengguna yang sedang login
$user = Auth::user(); $user = Auth::user();
// Cek apakah nama warehouse sudah ada dalam database
$existingWarehouse = m_warehouse::where('name', $row['name'])->first();
if ($existingWarehouse) {
// Jika nama warehouse sudah ada, tambahkan pesan kesalahan ke dalam array $errors
$this->errors[] = new MessageBag(['Row ' . $this->rowCount => 'Data warehouse sudah ada dalam database.']);
return null; // Abaikan data yang sudah ada
}
// Increment rowCount setiap kali ada data yang diimpor
$this->rowCount++;
// Buat model baru jika nama warehouse belum ada
return new m_warehouse([ return new m_warehouse([
'name' => $row['name'], 'name' => $row['name'],
'description' => $row['description'], 'description' => $row['description'],
@ -28,4 +56,32 @@ class WarehouseImport implements ToModel, WithHeadingRow
'created_by' => $user->fullname, 'created_by' => $user->fullname,
]); ]);
} }
public function registerEvents(): array
{
return [
AfterImport::class => function (AfterImport $event) {
// Setelah import selesai, kita bisa mengakses semua data yang diimpor
$importedData = $event->getReader()->getDelegate()->getActiveSheet()->toArray();
// Lakukan pemeriksaan apakah ada data yang bernilai null dan hapus dari hasil import
$filteredData = array_filter($importedData, function ($row) {
return $row[0] !== null; // Jika nilai kolom pertama tidak null, pertahankan baris tersebut
});
// Update hasil import dengan data yang telah difilter
$event->getReader()->getDelegate()->getActiveSheet()->fromArray($filteredData);
},
];
}
public function getErrors()
{
return $this->errors;
}
public function getRowCount()
{
return $this->rowCount;
}
} }

58
resources/views/dashboard/Disposal/create.blade.php

@ -16,7 +16,8 @@
<div class="form-group"> <div class="form-group">
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span <label for="peti_id" class="col-form-label">Pilih Detail Peti: <span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<select class="form-control" name="peti_id" type="text" id="peti_id" required> <select class="form-control" id="searchPeti" name="peti_id"></select>
{{-- <select class="form-control" name="peti_id" type="text" id="peti_id" required>
<option disabled selected>Pilih Detail Peti</option> <option disabled selected>Pilih Detail Peti</option>
@foreach ($peti as $data_peti) @foreach ($peti as $data_peti)
<option value="{{ $data_peti->id }}" data-warehouse-id="{{ $data_peti->warehouse_id }}" <option value="{{ $data_peti->id }}" data-warehouse-id="{{ $data_peti->warehouse_id }}"
@ -24,11 +25,11 @@
{{ $data_peti->fix_lot }} {{ $data_peti->fix_lot }}
</option> </option>
@endforeach @endforeach
</select> </select> --}}
<label for="customer_id" class="col-form-label">Customer: <span class="text-danger">*</span></label> <label for="customer_id" class="col-form-label">Customer: <span class="text-danger">*</span></label>
<select class="form-control" name="customer_id" type="text" id="customer_id" required> <select class="form-control" name="customer_id" type="text" id="customer_id" required>
<option disabled selected>Nama Customer akan otomatis terpilih ketika memilih detail peti.</option> <option disabled selected>Masukan Nama Customer</option>
@foreach ($customer as $data_customer) @foreach ($customer as $data_customer)
<option value="{{ $data_customer->id }}">{{ $data_customer->name }}</option> <option value="{{ $data_customer->id }}">{{ $data_customer->name }}</option>
@endforeach @endforeach
@ -41,7 +42,7 @@
<label for="warehouse_id" class="col-form-label">Asal Gudang: <span class="text-danger">*</span></label> <label for="warehouse_id" class="col-form-label">Asal Gudang: <span class="text-danger">*</span></label>
<select class="form-control" name="warehouse_id" type="text" id="warehouse_id" required> <select class="form-control" name="warehouse_id" type="text" id="warehouse_id" required>
<option disabled selected>Asal gudang akan otomatis terpilih ketika memilih detail peti.</option> <option disabled selected>Pilih Asal gudang</option>
@foreach ($warehouse as $data) @foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option> <option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach @endforeach
@ -67,6 +68,55 @@
</div> </div>
</div> </div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
{{-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"> --}}
<script type="text/javascript">
var path = "{{ route('dashboard.disposal.autoCompleteSearch') }}";
$('#searchPeti').select2({
placeholder: 'Pilih Detail Peti',
ajax: {
url: path,
dataType: 'json',
delay: 250,
processResults: function(data) {
return {
results: $.map(data.peti, function(item) {
return {
text: item.fix_lot,
id: item.id
}
})
};
},
cache: true
}
});
// Inisialisasi select2 untuk customer
// $('#searchCustomer').select2({
// placeholder: 'Pilih Detail Customer',
// ajax: {
// url: path,
// dataType: 'json',
// delay: 250,
// processResults: function(data) {
// return {
// results: $.map(data.customer, function(item) {
// return {
// text: item.name,
// id: item.id
// }
// })
// };
// },
// cache: true
// }
// });
</script>
<!-- auto disable form pada saat sudah di simpan--> <!-- auto disable form pada saat sudah di simpan-->
<script> <script>
document.getElementById('disposalForm').addEventListener('submit', function() { document.getElementById('disposalForm').addEventListener('submit', function() {

139
resources/views/dashboard/Master_Data/Manajemen_Peti/Peti/index.blade.php

@ -19,7 +19,7 @@
<div class="col-7"> <div class="col-7">
<h5 class="m-0 font-weight-bold text-primary mt-2">Data Peti</h5> <h5 class="m-0 font-weight-bold text-primary mt-2">Data Peti</h5>
</div> </div>
<div class="col-5 d-flex"> <div class="col-5 d-flex justify-content-end">
<a href="{{ route('dashboard.peti.create') }}" class="btn btn-success btn-icon-split ml-4"> <a href="{{ route('dashboard.peti.create') }}" class="btn btn-success btn-icon-split ml-4">
<span class="text">Tambah Peti</span> <span class="text">Tambah Peti</span>
</a> </a>
@ -33,7 +33,7 @@
</div> </div>
<a href="#" class="btn btn-info btn-icon-split" data-toggle="modal" <a href="#" class="btn btn-info btn-icon-split" data-toggle="modal"
data-target="#importDataModal"> data-target="#importDataModal">
<span class="text">Import Customer</span> <span class="text">Import Peti</span>
</a> </a>
</div> </div>
</div> </div>
@ -96,90 +96,40 @@
</thead> </thead>
<tbody> <tbody>
@forelse ($peti as $data_peti) @forelse ($peti as $data_peti)
@if ($search) <tr>
@if (stripos($data_peti->fix_lot, $search) !== false || <td>{{ $i++ }}</td>
stripos($data_peti->created_by, $search) !== false || <td><input type="checkbox" class="checkbox" value="{{ $data_peti->id }}">
stripos($data_peti->customer->name, $search) !== false || </td>
stripos($data_peti->warehouse->name, $search) !== false || <td>{{ $data_peti->fix_lot }}</td>
stripos($data_peti->customer->code_customer, $search) !== false || <td>{{ $data_peti->created_by }}</td>
stripos($data_peti->tipe_peti->type, $search) !== false || <td>{{ $data_peti->customer->name }}</td>
stripos($data_peti->tipe_peti->size_peti, $search) !== false || <td>{{ $data_peti->warehouse->name }}</td>
stripos($data_peti->customer->lot_no, $search) !== false || <td>{{ $data_peti->customer->code_customer }}</td>
stripos($data_peti->kondisipeti->nama_kondisi, $search) !== false || <td>{{ $data_peti->tipe_peti->type }}</td>
stripos($data_peti->packing_no, $search) !== false || <td>{{ $data_peti->tipe_peti->size_peti }}</td>
stripos($data_peti->status, $search) !== false) <td>{{ $data_peti->customer->lot_no }}</td>
<!-- Tampilkan data pencarian --> <td>{{ $data_peti->kondisipeti->nama_kondisi }}</td>
<tr> <td class="text-right">{{ $data_peti->packing_no }}</td>
<td>{{ $i++ }}</td> <td>{{ $data_peti->status }}</td>
<td><input type="checkbox" class="checkbox" value="{{ $data_peti->id }}"> <td class="text-center">
</td> <a href="{{ route('dashboard.peti.show', [$data_peti->id]) }}">
<td>{{ $data_peti->fix_lot }}</td> <i class="fa fa-eye mr-2" style="font-size: 20px"></i>
<td>{{ $data_peti->created_by }}</td> </a>
<td>{{ $data_peti->customer->name }}</td> <a href="{{ route('dashboard.peti.edit', [$data_peti->id]) }}">
<td>{{ $data_peti->warehouse->name }}</td> <i class="fa fa-edit mr-2" style="font-size: 20px"></i>
<td>{{ $data_peti->customer->code_customer }}</td> </a>
<td>{{ $data_peti->tipe_peti->type }}</td> <form action="{{ route('dashboard.peti.destroy', $data_peti->id) }}" method="POST"
<td>{{ $data_peti->tipe_peti->size_peti }}</td> style="display: inline;">
<td>{{ $data_peti->customer->lot_no }}</td> @csrf
<td>{{ $data_peti->kondisipeti->nama_kondisi }}</td> @method('DELETE')
<td class="text-right">{{ $data_peti->packing_no }}</td> <button type="submit"
<td>{{ $data_peti->status }}</td> onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')"
<td class="text-center"> style="border: none; background: none; cursor: pointer;">
<a href="{{ route('dashboard.peti.show', [$data_peti->id]) }}"> <i class="fa fa-trash text-danger" style="font-size: 20px"></i>
<i class="fa fa-eye mr-2" style="font-size: 20px"></i> </button>
</a> </form>
<a href="{{ route('dashboard.peti.edit', [$data_peti->id]) }}"> </td>
<i class="fa fa-edit mr-2" style="font-size: 20px"></i> </tr>
</a>
<form action="{{ route('dashboard.peti.destroy', $data_peti->id) }}"
method="POST" style="display: inline;">
@csrf
@method('DELETE')
<button type="submit"
onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')"
style="border: none; background: none; cursor: pointer;">
<i class="fa fa-trash text-danger" style="font-size: 20px"></i>
</button>
</form>
</td>
</tr>
@endif
@else
<!-- Tampilkan semua data jika tidak ada pencarian -->
<tr>
<td>{{ $i++ }}</td>
<td><input type="checkbox" class="checkbox" value="{{ $data_peti->id }}"></td>
<td>{{ $data_peti->fix_lot }}</td>
<td>{{ $data_peti->created_by }}</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>{{ $data_peti->kondisipeti->nama_kondisi }}</td>
<td class="text-right">{{ $data_peti->packing_no }}</td>
<td>{{ $data_peti->status }}</td>
<td class="text-center">
<a href="{{ route('dashboard.peti.show', [$data_peti->id]) }}">
<i class="fa fa-eye mr-2" style="font-size: 20px"></i>
</a>
<a href="{{ route('dashboard.peti.edit', [$data_peti->id]) }}">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a>
<form action="{{ route('dashboard.peti.destroy', $data_peti->id) }}"
method="POST" style="display: inline;">
@csrf
@method('DELETE')
<button type="submit"
onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')"
style="border: none; background: none; cursor: pointer;">
<i class="fa fa-trash text-danger" style="font-size: 20px"></i>
</button>
</form>
</td>
</tr>
@endif
@empty @empty
<tr> <tr>
<td colspan="14" class="text-center">Data Kosong</td> <td colspan="14" class="text-center">Data Kosong</td>
@ -189,28 +139,29 @@
</table> </table>
</div> </div>
<div class="row mt-3"> <div class="row mt-3">
<div class="col-md-6"> <div class="col-4">
<!-- Tampilkan jumlah data yang ditampilkan --> <!-- Tampilkan jumlah data yang ditampilkan -->
@if (!$peti->isEmpty()) @if (!$peti->isEmpty())
<p class="mb-0">Showing {{ $peti->firstItem() }} to {{ $peti->lastItem() }} of <p class="d-inline-block">Showing {{ $peti->firstItem() }} to
{{ $peti->lastItem() }} of
{{ $peti->total() }} entries</p> {{ $peti->total() }} entries</p>
@endif @endif
</div> </div>
<div class="col-md-6 d-flex justify-content-end"> <div class="col-8 d-flex justify-content-end">
@if ($peti->total() > $peti->perPage()) @if ($peti->total() > $peti->perPage())
<nav aria-label="Page navigation"> <nav aria-label="Page navigation">
<ul class="pagination justify-content-end mb-0"> <ul class="pagination justify-content-center">
<li class="page-item {{ $peti->onFirstPage() ? 'disabled' : '' }}"> <li class="page-item {{ $peti->onFirstPage() ? 'disabled' : '' }}">
<a class="page-link" <a class="page-link"
href="{{ $peti->appends(['perPage' => Request::get('perPage'), 'search' => $search])->url(1) }}" href="{{ $peti->appends(['perPage' => Request::get('perPage')])->url(1) }}"
aria-label="First"> aria-label="First">
<span aria-hidden="true">First</span> <span aria-hidden="true">First</span>
</a> </a>
</li> </li>
{{ $peti->appends(['perPage' => Request::get('perPage'), 'search' => $search])->links() }} {{ $peti->appends(['perPage' => Request::get('perPage')])->links() }}
<li class="page-item {{ $peti->hasMorePages() ? '' : 'disabled' }}"> <li class="page-item {{ $peti->hasMorePages() ? '' : 'disabled' }}">
<a class="page-link" <a class="page-link"
href="{{ $peti->appends(['perPage' => Request::get('perPage'), 'search' => $search])->url($peti->lastPage()) }}" href="{{ $peti->appends(['perPage' => Request::get('perPage')])->url($peti->lastPage()) }}"
aria-label="Last"> aria-label="Last">
<span aria-hidden="true">Last</span> <span aria-hidden="true">Last</span>
</a> </a>
@ -220,8 +171,6 @@
@endif @endif
</div> </div>
</div> </div>
</div> </div>
</div> </div>

71
resources/views/dashboard/Master_Data/Report/Pattern_lot_peti/index.blade.php

@ -25,12 +25,46 @@
</div> </div>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="row mb-3">
<div class="col-6">
<!-- Fitur page -->
<form method="GET" action="{{ route('dashboard.Pettern_Lot_Peti.index') }}">
<label for="perPage">Tampilkan:</label>
<select id="perPage" name="perPage" class="form-select" onchange="this.form.submit()">
<option value="5" {{ request('perPage', 5) == '5' ? 'selected' : '' }}>5</option>
<option value="10" {{ request('perPage', 5) == '10' ? 'selected' : '' }}>10</option>
<option value="25" {{ request('perPage', 5) == '25' ? 'selected' : '' }}>25</option>
<option value="50" {{ request('perPage', 5) == '50' ? 'selected' : '' }}>50</option>
<option value="100" {{ request('perPage', 5) == '100' ? 'selected' : '' }}>100</option>
<option value="500" {{ request('perPage', 5) == '500' ? 'selected' : '' }}>500</option>
<option value="1000" {{ request('perPage', 5) == '1000' ? 'selected' : '' }}>1000</option>
<option value="2500" {{ request('perPage', 5) == '2500' ? 'selected' : '' }}>2500
</option>
<option value="5000" {{ request('perPage', 5) == '5000' ? 'selected' : '' }}>5000
</option>
<option value="{{ $peti->total() }}"
{{ request('perPage', 5) == $peti->total() ? 'selected' : '' }}>Semua</option>
</select>
<input type="hidden" name="search" value="{{ $search }}">
<input type="hidden" name="page" value="{{ request('page', 1) }}">
</form>
</div>
<div class="col-6 d-flex justify-content-end mb-3">
<!-- Fitur search -->
<form method="GET" action="{{ route('dashboard.Pettern_Lot_Peti.index') }}" class="form-inline">
<input type="text" name="search" class="form-control mr-2" placeholder="Cari..."
value="{{ $search }}">
<input type="hidden" name="page" value="1">
<input type="hidden" name="perPage" value="{{ request('perPage', 5) }}">
<button type="submit" class="btn btn-primary">Cari</button>
</form>
</div>
</div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered" id="tablebarang" width="100%" cellspacing="0"> <table class="table table-bordered" width="100%" cellspacing="0">
<thead> <thead>
<tr> <tr>
<th>No</th> <th>No</th>
{{-- <th>User</th> --}}
<th>FIX LOT</th> <th>FIX LOT</th>
<th>Customer</th> <th>Customer</th>
<th>WH</th> <th>WH</th>
@ -68,6 +102,39 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="row mt-3">
<div class="col-4">
<!-- Tampilkan jumlah data yang ditampilkan -->
@if (!$peti->isEmpty())
<p class="d-inline-block">Showing {{ $peti->firstItem() }} to
{{ $peti->lastItem() }} of
{{ $peti->total() }} entries</p>
@endif
</div>
<div class="col-8 d-flex justify-content-end">
@if ($peti->total() > $peti->perPage())
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
<li class="page-item {{ $peti->onFirstPage() ? 'disabled' : '' }}">
<a class="page-link"
href="{{ $peti->appends(['perPage' => Request::get('perPage')])->url(1) }}"
aria-label="First">
<span aria-hidden="true">First</span>
</a>
</li>
{{ $peti->appends(['perPage' => Request::get('perPage')])->links() }}
<li class="page-item {{ $peti->hasMorePages() ? '' : 'disabled' }}">
<a class="page-link"
href="{{ $peti->appends(['perPage' => Request::get('perPage')])->url($peti->lastPage()) }}"
aria-label="Last">
<span aria-hidden="true">Last</span>
</a>
</li>
</ul>
</nav>
@endif
</div>
</div>
</div> </div>
</div> </div>
@endsection @endsection

1
resources/views/dashboard/Master_Data/Warehouse/index.blade.php

@ -3,6 +3,7 @@
@section('content') @section('content')
@include('layouts.components.alert-prompt') @include('layouts.components.alert-prompt')
@if (auth()->user()->role_id == 1) @if (auth()->user()->role_id == 1)
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<div class="card-header py-3"> <div class="card-header py-3">

147
resources/views/dashboard/Peminjaman/create.blade.php

@ -2,7 +2,8 @@
@section('title', 'Tambah Peminjaman') @section('title', 'Tambah Peminjaman')
@section('content') @section('content')
@include('layouts.components.alert-prompt') @include('layouts.components.alert-prompt')
<div class="card shadow mb-4"> <!-- Cara Lama -->
{{-- <div class="card shadow mb-4">
<div class="card-header py-3"> <div class="card-header py-3">
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
@ -15,6 +16,7 @@
id="peminjamanForm"> id="peminjamanForm">
@csrf @csrf
<div class="form-group"> <div class="form-group">
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span <label for="peti_id" class="col-form-label">Pilih Detail Peti: <span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<select class="form-control" name="peti_id" id="peti_id" required> <select class="form-control" name="peti_id" id="peti_id" required>
@ -68,8 +70,118 @@
</div> </div>
</form> </form>
</div> </div>
</div> --}}
<!-- Cara Baru -->
<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">Tambah Peminjaman</h5>
</div>
</div>
</div>
<div class="card-body">
<form action="{{ route('dashboard.peminjaman.store') }}" method="POST" enctype="multipart/form-data"
id="peminjamanForm">
@csrf
<div class="form-group">
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span
class="text-danger">*</span></label>
<select class="form-control" id="searchPeti" name="peti_id"></select>
<label for="customer_id" class="col-form-label">Customer:<span class="text-danger">*</span></label>
<select class="form-control" name="customer_id" type="text" id="customer_id" required>
<option disabled selected>Pilih Nama Customer</option>
@foreach ($customer as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
{{-- <select class="form-control" id="searchCustomer" name="customer_id"></select> --}}
<label for="exit_at" class="col-form-label">Tanggal Peminjaman: <span
class="text-danger">*</span></label>
<input class="form-control" name="exit_at" type="date" id="exit_at" value="{{ old('exit_at') }}"
required>
<label for="est_pengembalian" class="col-form-label">Estimasi Tanggal Pengembalian: <span
class="text-danger">*</span></label>
<input class="form-control" name="est_pengembalian" type="date" id="est_pengembalian" required>
<label for="warehouse_id" class="col-form-label">Asal Gudang:</label>
<select class="form-control" name="warehouse_id" type="text" id="warehouse_id" required>
<option disabled selected>Pilih Asal Gudang</option>
@foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
<label for="exit_warehouse" class="col-form-label">Tujuan Gudang: <span
class="text-danger">*</span></label>
<select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse" required>
<option disabled selected>Pilih Tujuan Gudang</option>
@foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
</div>
<div class="modal-footer d-flex justify-content-center">
<a href="{{ route('dashboard.peminjaman.index') }}" class="btn btn-secondary">Kembali</a>
<button type="submit" class="btn btn-primary" id="submitButton">Simpan</button>
</div>
</form>
</div>
</div> </div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
{{-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"> --}}
<script type="text/javascript">
var path = "{{ route('dashboard.peminjaman.autoCompleteSearch') }}";
$('#searchPeti').select2({
placeholder: 'Pilih Detail Peti',
ajax: {
url: path,
dataType: 'json',
delay: 250,
processResults: function(data) {
return {
results: $.map(data.peti, function(item) {
return {
text: item.fix_lot,
id: item.id
}
})
};
},
cache: true
}
});
// Inisialisasi select2 untuk customer
// $('#searchCustomer').select2({
// placeholder: 'Pilih Detail Customer',
// ajax: {
// url: path,
// dataType: 'json',
// delay: 250,
// processResults: function(data) {
// return {
// results: $.map(data.customer, function(item) {
// return {
// text: item.name,
// id: item.id
// }
// })
// };
// },
// cache: true
// }
// });
</script>
<!-- auto disable form pada saat sudah di simpan--> <!-- auto disable form pada saat sudah di simpan-->
<script> <script>
document.getElementById('peminjamanForm').addEventListener('submit', function() { document.getElementById('peminjamanForm').addEventListener('submit', function() {
@ -100,7 +212,7 @@
</script> </script>
<!-- otomatis asal gudang dan Customer berdasarkan detail peti --> <!-- otomatis asal gudang dan Customer berdasarkan detail peti -->
<script> {{-- <script>
// Mendapatkan elemen select detail peti // Mendapatkan elemen select detail peti
const petiSelect = document.getElementById('peti_id'); const petiSelect = document.getElementById('peti_id');
@ -124,6 +236,35 @@
// Memilih customer berdasarkan data-customer-id // Memilih customer berdasarkan data-customer-id
customerSelect.value = customerId; customerSelect.value = customerId;
}); });
</script> </script> --}}
<!-- Penambahan cara baru -->
{{-- <script>
// Mendapatkan elemen select detail peti
const petiSelect = $('#searchPeti');
// Mendapatkan elemen select warehouse
const warehouseSelect = $('#warehouse_id');
// Menambahkan event listener ke select detail peti
petiSelect.on('change', function() {
// Mendapatkan nilai peti_id yang terpilih
const selectedPetiId = $(this).val();
// Memilih warehouse berdasarkan peti_id yang terpilih
$.ajax({
url: `/api/peti/${selectedPetiId}/warehouse`, // Gantilah dengan URL endpoint yang sesuai
method: 'GET',
success: function(warehouseData) {
// Mengisi opsi warehouse
const warehouseOption = new Option(warehouseData.name, warehouseData.id, true,
true);
warehouseSelect.html('').append(warehouseOption).trigger('change');
},
error: function(error) {
console.error(error);
}
});
});
</script> --}}
@endsection @endsection

56
resources/views/dashboard/Transfer/create.blade.php

@ -16,7 +16,8 @@
<div class="form-group"> <div class="form-group">
<label for="peti_id" class="col-form-label">Pilih Detail Peti: <span <label for="peti_id" class="col-form-label">Pilih Detail Peti: <span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<select class="form-control" name="peti_id" type="text" id="peti_id" required> <select class="form-control" id="searchPeti" name="peti_id"></select>
{{-- <select class="form-control" name="peti_id" type="text" id="peti_id" required>
<option disabled selected>Pilih Detail Peti</option> <option disabled selected>Pilih Detail Peti</option>
@foreach ($peti as $data_peti) @foreach ($peti as $data_peti)
<option value="{{ $data_peti->id }}" data-warehouse-id="{{ $data_peti->warehouse_id }}" <option value="{{ $data_peti->id }}" data-warehouse-id="{{ $data_peti->warehouse_id }}"
@ -24,7 +25,7 @@
{{ $data_peti->fix_lot }} {{ $data_peti->fix_lot }}
</option> </option>
@endforeach @endforeach
</select> </select> --}}
<label for="date" class="col-form-label">Tanggal Transfer: <span <label for="date" class="col-form-label">Tanggal Transfer: <span
class="text-danger">*</span></label> class="text-danger">*</span></label>
@ -42,7 +43,7 @@
<label for="source_warehouse" class="col-form-label">Asal Gudang: <span <label for="source_warehouse" class="col-form-label">Asal Gudang: <span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<select class="form-control" name="source_warehouse" type="text" id="source_warehouse" required> <select class="form-control" name="source_warehouse" type="text" id="source_warehouse" required>
<option disabled selected>Asal gudang akan otomatis terpilih ketika memilih detail peti.</option> <option disabled selected>Pilih Asal gudang</option>
@foreach ($warehouse as $data) @foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option> <option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach @endforeach
@ -65,6 +66,55 @@
</div> </div>
</div> </div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
{{-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"> --}}
<script type="text/javascript">
var path = "{{ route('dashboard.transfer.autoCompleteSearch') }}";
$('#searchPeti').select2({
placeholder: 'Pilih Detail Peti',
ajax: {
url: path,
dataType: 'json',
delay: 250,
processResults: function(data) {
return {
results: $.map(data.peti, function(item) {
return {
text: item.fix_lot,
id: item.id
}
})
};
},
cache: true
}
});
// Inisialisasi select2 untuk customer
// $('#searchCustomer').select2({
// placeholder: 'Pilih Detail Customer',
// ajax: {
// url: path,
// dataType: 'json',
// delay: 250,
// processResults: function(data) {
// return {
// results: $.map(data.customer, function(item) {
// return {
// text: item.name,
// id: item.id
// }
// })
// };
// },
// cache: true
// }
// });
</script>
<!-- auto disable form pada saat sudah di simpan--> <!-- auto disable form pada saat sudah di simpan-->
<script> <script>
document.getElementById('transferForm').addEventListener('submit', function() { document.getElementById('transferForm').addEventListener('submit', function() {

6
resources/views/layouts/components/alert-prompt.blade.php

@ -14,6 +14,12 @@
</div> </div>
@endif @endif
@if (Session::has('error'))
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>{{ Session::get('error') }}</strong>
</div>
@endif
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {

3
routes/web.php

@ -64,6 +64,7 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::put('peminjaman/{id}', 'update')->name('peminjaman.update'); Route::put('peminjaman/{id}', 'update')->name('peminjaman.update');
Route::delete('peminjaman/delete/{id}', 'destroy')->name('peminjaman.destroy'); Route::delete('peminjaman/delete/{id}', 'destroy')->name('peminjaman.destroy');
Route::get('peminjaman/{id}/pengembalian', 'pengembalian')->name('peminjaman.pengembalian'); Route::get('peminjaman/{id}/pengembalian', 'pengembalian')->name('peminjaman.pengembalian');
Route::get('peminjaman/Search', 'autoCompleteSearch')->name('peminjaman.autoCompleteSearch');
}); });
//Halaman Pengembalian //Halaman Pengembalian
@ -96,6 +97,7 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::get('transfer/{id}/edit', 'edit')->name('transfer.edit'); Route::get('transfer/{id}/edit', 'edit')->name('transfer.edit');
Route::put('transfer/{id}', 'update')->name('transfer.update'); Route::put('transfer/{id}', 'update')->name('transfer.update');
Route::delete('transfer/delete/{id}', 'destroy')->name('transfer.destroy'); Route::delete('transfer/delete/{id}', 'destroy')->name('transfer.destroy');
Route::get('transfer/Search', 'autoCompleteSearch')->name('transfer.autoCompleteSearch');
}); });
//Halaman Disposal //Halaman Disposal
@ -106,6 +108,7 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
Route::get('disposal/{id}/edit', 'edit')->name('disposal.edit'); Route::get('disposal/{id}/edit', 'edit')->name('disposal.edit');
Route::put('disposal/{id}', 'update')->name('disposal.update'); Route::put('disposal/{id}', 'update')->name('disposal.update');
Route::delete('disposal/delete/{id}', 'destroy')->name('disposal.destroy'); Route::delete('disposal/delete/{id}', 'destroy')->name('disposal.destroy');
Route::get('disposal/Search', 'autoCompleteSearch')->name('disposal.autoCompleteSearch');
}); });
//Halaman History //Halaman History

Loading…
Cancel
Save