Browse Source

update tambah peti reset packing no

master
Gunawan19621 3 months ago
parent
commit
b04a26c5b2
  1. 17
      app/Http/Controllers/PetiController.php
  2. 2
      database/seeders/CustomerSeeder.php
  3. 12
      database/seeders/DatabaseSeeder.php
  4. 2
      database/seeders/Kondisi_PetiSeeder.php
  5. 4
      database/seeders/PetiSeeder.php
  6. 9
      database/seeders/RoleSeeder.php
  7. 2
      database/seeders/TipePetiSeeder.php
  8. 30
      database/seeders/UserSeeder.php
  9. 11
      database/seeders/WarehouseSeeder.php

17
app/Http/Controllers/PetiController.php

@ -29,7 +29,7 @@ class PetiController extends Controller
$perPage = $request->input('perPage', 5); $perPage = $request->input('perPage', 5);
$query = Peti::with(['customer', 'warehouse', 'tipe_peti', 'kondisipeti', 'transfer', 'assetStatuses']) $query = Peti::with(['customer', 'warehouse', 'tipe_peti', 'kondisipeti', 'transfer', 'assetStatuses'])
->orderBy('created_at', 'desc'); ->orderBy('id', 'desc');
// Tambahkan logika pencarian // Tambahkan logika pencarian
$search = $request->input('search') ?? ''; $search = $request->input('search') ?? '';
if ($search) { if ($search) {
@ -118,9 +118,18 @@ class PetiController extends Controller
for ($i = 0; $i < $request->jumlah; $i++) { for ($i = 0; $i < $request->jumlah; $i++) {
$validatedData = $request->except('_token'); $validatedData = $request->except('_token');
// Ambil nomor urutan otomatis untuk packing_no $customerId = $validatedData['customer_id'];
$latestPackingNo = Peti::max('packing_no');
$nextPackingNo = $latestPackingNo + 1; // Get the latest packing_no for the specific customer
$latestPackingNo = Peti::where('customer_id', $customerId)->max('packing_no');
if ($latestPackingNo) {
$latestPackingNo = ltrim($latestPackingNo, '0'); // Remove leading zeros
$nextPackingNo = intval($latestPackingNo) + 1; // Increment the latest packing_no
} else {
$nextPackingNo = 1; // Start from 1 if no packing_no exists for the customer
}
// Generate packing_no with leading zero
$validatedData['packing_no'] = '0' . $nextPackingNo; $validatedData['packing_no'] = '0' . $nextPackingNo;
$code_customer = Customer::where('id', $validatedData['customer_id'])->first()->code_customer; $code_customer = Customer::where('id', $validatedData['customer_id'])->first()->code_customer;

2
database/seeders/CustomerSeeder.php

@ -34,7 +34,7 @@ class CustomerSeeder extends Seeder
'updated_by' => 'Seeder', 'updated_by' => 'Seeder',
]); ]);
for ($i = 3; $i <= 100; $i++) { for ($i = 3; $i <= 10; $i++) {
Customer::create([ Customer::create([
'name' => 'Customer ' . $i, 'name' => 'Customer ' . $i,
'code_customer' => 'Code ' . $i, // Adjust the length as needed 'code_customer' => 'Code ' . $i, // Adjust the length as needed

12
database/seeders/DatabaseSeeder.php

@ -34,14 +34,10 @@ class DatabaseSeeder extends Seeder
RoleSeeder::class, RoleSeeder::class,
WarehouseSeeder::class, WarehouseSeeder::class,
UserSeeder::class, UserSeeder::class,
//batas ke bawah tidak terlalu penting CustomerSeeder::class,
// TipePetiSeeder::class, TipePetiSeeder::class,
// CustomerSeeder::class, Kondisi_PetiSeeder::class,
// Kondisi_PetiSeeder::class, PetiSeeder::class,
// PetiSeeder::class,
// DisposalSeeder::class,
// TransferSeeder::class,
// AssetStatusSeeder::class,
]); ]);
} }
} }

2
database/seeders/Kondisi_PetiSeeder.php

@ -28,7 +28,7 @@ class Kondisi_PetiSeeder extends Seeder
'updated_by' => 'Seeder', 'updated_by' => 'Seeder',
]); ]);
for ($i = 3; $i <= 100; $i++) { for ($i = 3; $i <= 5; $i++) {
Kondisi_Peti::create([ Kondisi_Peti::create([
'nama_kondisi' => 'Kondisi ' . $i, 'nama_kondisi' => 'Kondisi ' . $i,
'deskripsi_kondisi' => 'Description for Kondisi ' . $i, 'deskripsi_kondisi' => 'Description for Kondisi ' . $i,

4
database/seeders/PetiSeeder.php

@ -12,11 +12,11 @@ class PetiSeeder extends Seeder
*/ */
public function run() public function run()
{ {
for ($i = 1; $i <= 100; $i++) { for ($i = 1; $i <= 4; $i++) {
Peti::create([ Peti::create([
'tipe_peti_id' => $i, 'tipe_peti_id' => $i,
'warna' => 'Warna ' . $i, 'warna' => 'Warna ' . $i,
'fix_lot' => 'Dummy Fix Lot ' . $i, 'fix_lot' => 'Dy Fix Lot ' . $i,
'packing_no' => $i, 'packing_no' => $i,
'customer_id' => $i, 'customer_id' => $i,
'jumlah' => $i, 'jumlah' => $i,

9
database/seeders/RoleSeeder.php

@ -27,14 +27,5 @@ class RoleSeeder extends Seeder
'created_by' => 'Seeder', 'created_by' => 'Seeder',
'updated_by' => 'Seeder', 'updated_by' => 'Seeder',
]); ]);
// for ($i = 3; $i <= 100; $i++) {
// m_role::create([
// 'name' => 'Role ' . $i,
// 'description' => 'Description ' . $i,
// 'created_by' => 'Seeder',
// 'updated_by' => 'Seeder',
// ]);
// }
} }
} }

2
database/seeders/TipePetiSeeder.php

@ -27,7 +27,7 @@ class TipePetiSeeder extends Seeder
'updated_by' => 'Seeder', 'updated_by' => 'Seeder',
]); ]);
for ($i = 3; $i <= 100; $i++) { for ($i = 3; $i <= 5; $i++) {
Type_peti::create([ Type_peti::create([
'type' => 'Type ' . $i, 'type' => 'Type ' . $i,
'size_peti' => $this->generateSize(), 'size_peti' => $this->generateSize(),

30
database/seeders/UserSeeder.php

@ -17,7 +17,7 @@ class UserSeeder extends Seeder
'username' => 'admin', 'username' => 'admin',
'fullname' => 'Admin System', 'fullname' => 'Admin System',
'nip' => '1234567890123456', 'nip' => '1234567890123456',
'email' => 'admin@gmail.com', 'email' => 'admin@admin.com',
'no_hp' => '085159079010', 'no_hp' => '085159079010',
'divisi' => 'Admin Division', 'divisi' => 'Admin Division',
'tgl_lahir' => '1990-01-01', 'tgl_lahir' => '1990-01-01',
@ -28,7 +28,7 @@ class UserSeeder extends Seeder
'warehouse_id' => 1, // Menghasilkan UUID versi 4 'warehouse_id' => 1, // Menghasilkan UUID versi 4
'address' => 'Jalan Ciwatu', 'address' => 'Jalan Ciwatu',
'email_verified_at' => now(), 'email_verified_at' => now(),
'password' => bcrypt('admin'), 'password' => bcrypt('password'),
'created_by' => 'Seeder', 'created_by' => 'Seeder',
'updated_by' => 'Seeder', 'updated_by' => 'Seeder',
]); ]);
@ -38,7 +38,7 @@ class UserSeeder extends Seeder
'username' => 'Operator', 'username' => 'Operator',
'fullname' => 'Operator System', 'fullname' => 'Operator System',
'nip' => '6543210987654321', 'nip' => '6543210987654321',
'email' => 'operator@gmail.com', 'email' => 'operator@operator.com',
'no_hp' => '087779767603', 'no_hp' => '087779767603',
'divisi' => 'Operator Gudang', 'divisi' => 'Operator Gudang',
'tgl_lahir' => '1985-05-15', 'tgl_lahir' => '1985-05-15',
@ -49,31 +49,9 @@ class UserSeeder extends Seeder
'warehouse_id' => 2, // Menghasilkan UUID versi 4 'warehouse_id' => 2, // Menghasilkan UUID versi 4
'address' => 'Jalan Gelarmendala', 'address' => 'Jalan Gelarmendala',
'email_verified_at' => now(), 'email_verified_at' => now(),
'password' => bcrypt('operator'), 'password' => bcrypt('password'),
'created_by' => 'Seeder', 'created_by' => 'Seeder',
'updated_by' => 'Seeder', 'updated_by' => 'Seeder',
]); ]);
// for ($i = 3; $i <= 100; $i++) {
// User::create([
// 'username' => 'user' . $i,
// 'fullname' => 'User ' . $i,
// 'nip' => '1234567890123' . $i,
// 'email' => 'user' . $i . '@example.com',
// 'no_hp' => '1234567890' . $i,
// 'divisi' => 'Division ' . $i,
// 'tgl_lahir' => now(),
// 'jenis_kelamin' => ($i % 2 == 0) ? 'Laki-laki' : 'Perempuan',
// 'agama' => ($i % 2 == 0) ? 'Islam' : 'Kristen',
// 'foto' => '', // Ganti dengan nama berkas foto jika diperlukan
// 'role_id' => $i,
// 'warehouse_id' => $i,
// 'address' => 'Address ' . $i,
// 'email_verified_at' => now(),
// 'password' => bcrypt('password'),
// 'created_by' => 'Seeder',
// 'updated_by' => 'Seeder',
// ]);
// }
} }
} }

11
database/seeders/WarehouseSeeder.php

@ -48,16 +48,5 @@ class WarehouseSeeder extends Seeder
'created_by' => 'Seeder', 'created_by' => 'Seeder',
'updated_by' => 'Seeder', 'updated_by' => 'Seeder',
]); ]);
// Use a loop to add 1000 warehouses
// for ($i = 5; $i <= 100; $i++) {
// m_warehouse::create([
// 'name' => 'Warehouse ' . $i,
// 'description' => 'Description for Warehouse ' . $i,
// 'address' => 'Address for Warehouse ' . $i,
// 'created_by' => 'Seeder',
// 'updated_by' => 'Seeder',
// ]);
// }
} }
} }
Loading…
Cancel
Save