diff --git a/app/Console/Commands/CreateAtasCommand.php b/app/Console/Commands/CreateAtasCommand.php new file mode 100644 index 0000000..5271c8b --- /dev/null +++ b/app/Console/Commands/CreateAtasCommand.php @@ -0,0 +1,74 @@ +info('Migration started..'); + + $migrate = Artisan::call('migrate'); + + $this->info('Migrate successfully.'); + + $this->info('Truncate started..'); + // Nonaktifkan constraint + DB::statement('SET FOREIGN_KEY_CHECKS=0;'); + + $this->info('Foreign key check disabled.'); + + DB::statement('TRUNCATE table roles'); + $this->info('Truncate roles successfully.'); + DB::statement('TRUNCATE table model_has_roles'); + $this->info('Truncate model_has_roles successfully.'); + DB::statement('TRUNCATE table model_has_permissions'); + $this->info('Truncate model_has_permissions successfully.'); + DB::statement('TRUNCATE table permissions'); + $this->info('Truncate permissions successfully.'); + DB::statement('TRUNCATE table role_has_permissions'); + $this->info('Truncate role_has_permissions successfully.'); + // Aktifkan kembali constraint + DB::statement('SET FOREIGN_KEY_CHECKS=1;'); + $this->info('Foreign key check enabled.'); + $this->info('Truncate successfully.'); + + $this->info('Permission started..'); + Artisan::call('route:clear'); + $this->info('Route cache cleared successfully.'); + Artisan::call('permission:cache-reset'); + $this->info('Permission cache reset successfully.'); + Artisan::call('permission:create-permission-routes'); + $this->info('Permission successfully.'); + + $this->info('Seeder started..'); + Artisan::call('db:seed', [ + '--class' => 'GenerateAtasSeeder', + '--force' => true + ]); + $this->info('Seeder successfully.'); + } +} diff --git a/app/Console/Commands/CreateFreshCommand.php b/app/Console/Commands/CreateFreshCommand.php new file mode 100644 index 0000000..8345e10 --- /dev/null +++ b/app/Console/Commands/CreateFreshCommand.php @@ -0,0 +1,46 @@ +info('Migration started..'); + + $migrate = Artisan::call('migrate:fresh --seed'); + + $this->info('Migrate successfully.'); + + $this->info('Permission started..'); + Artisan::call('permission:create-permission-routes'); + $this->info('Permission successfully.'); + + $this->info('Seeder started..'); + Artisan::call('db:seed', [ + '--class' => 'GenerateFreshSeeder', + '--force' => true + ]); + $this->info('Seeder successfully.'); + } +} diff --git a/app/Console/Commands/CreateRoutePermissionCommand.php b/app/Console/Commands/CreateRoutePermissionCommand.php index 7274239..fcef81e 100644 --- a/app/Console/Commands/CreateRoutePermissionCommand.php +++ b/app/Console/Commands/CreateRoutePermissionCommand.php @@ -42,10 +42,11 @@ class CreateRoutePermissionCommand extends Command } if (is_null($permission)) { permission::create(['name' => $data, 'group_name' => $first_group, 'desc' => $comment]); + $this->info('Permission routes ' . $route->getName() . ' added successfully.'); } } } - $this->info('Permission routes added successfully.'); + $this->info('All Permission routes added successfully.'); } } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index c27babb..bdab3a1 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -25,14 +25,14 @@ class RedirectIfAuthenticated $role = Auth::user()->role; switch ($role[0]->name) { case 'Admin': - return '/dashboard'; + return redirect('/dashboard'); break; case 'Kasir': - return '/transaksi'; + return redirect('/transaksi'); break; default: - return '/transaksi'; + return redirect('/transaksi'); break; } } diff --git a/database/seeders/GenerateAtasSeeder.php b/database/seeders/GenerateAtasSeeder.php new file mode 100644 index 0000000..45bbc7c --- /dev/null +++ b/database/seeders/GenerateAtasSeeder.php @@ -0,0 +1,22 @@ +call($class); + } +} diff --git a/database/seeders/GenerateFreshSeeder.php b/database/seeders/GenerateFreshSeeder.php new file mode 100644 index 0000000..eaedddf --- /dev/null +++ b/database/seeders/GenerateFreshSeeder.php @@ -0,0 +1,21 @@ +call($class); + } +} diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php index c5e1419..f752f6f 100644 --- a/database/seeders/PermissionSeeder.php +++ b/database/seeders/PermissionSeeder.php @@ -13,10 +13,8 @@ class PermissionSeeder extends Seeder public function run(): void { $classes = [ - UserSeeder::class, - KasirSeeder::class, - // AddRoles::class, - // RoleSeeder::class, + GenerateAtasSeeder::class, + // GenerateFreshSeeder::class, ]; foreach ($classes as $class) $this->call($class); } diff --git a/database/seeders/RoleSeeder.php b/database/seeders/RoleSeeder.php index 429209f..18741ca 100644 --- a/database/seeders/RoleSeeder.php +++ b/database/seeders/RoleSeeder.php @@ -17,6 +17,7 @@ class RoleSeeder extends Seeder */ public function run(): void { + // admin $role = Role::create(['name' => 'Admin']); $permissions = Permission::pluck('id', 'id')->all(); @@ -27,6 +28,7 @@ class RoleSeeder extends Seeder $user->assignRole([$role->id]); + // kasir $role = Role::create(['name' => 'Kasir']); $permissions = Permission::pluck('id', 'id')->all(); diff --git a/resources/views/pages/Kasir/js.blade.php b/resources/views/pages/Kasir/js.blade.php index 2e4860b..6b2b2ce 100644 --- a/resources/views/pages/Kasir/js.blade.php +++ b/resources/views/pages/Kasir/js.blade.php @@ -190,7 +190,7 @@
${(diskonSatuan > 0) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''}
- +
`; @@ -201,7 +201,7 @@
${(diskonSatuan > 0) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''}
- +
`; @@ -213,7 +213,7 @@ - + @@ -223,7 +223,7 @@ table.rows[index].cells[2].innerHTML = `
- +
`; @@ -252,7 +252,7 @@
Rp. ${params.harga_produk}
- +
@@ -260,7 +260,7 @@ - + @@ -268,7 +268,7 @@
- +
@@ -286,7 +286,7 @@
Rp. ${params.harga_produk}
- +
@@ -294,7 +294,7 @@ - + @@ -302,7 +302,7 @@
- +
@@ -394,14 +394,15 @@ table.rows[index].setAttribute('data-total', totalLama); table.rows[index].cells[0].innerHTML = ` - - ${nama_produk} -
- ${(diskonSatuan > 0) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''} -
- -
- `; + + ${nama_produk} +
+ ${(diskonSatuan > 0) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''} +
+ +
+ + `; table.rows[index].cells[1].innerHTML = ` @@ -409,7 +410,7 @@ - + @@ -455,7 +456,7 @@
${(diskonSatuan > 0) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''}
- +
`; @@ -466,7 +467,7 @@ - + @@ -515,7 +516,7 @@
${(diskonSatuan >= 1) ? 'Rp. ' + (harga * qty) + ' | Rp. ' + total + '' : 'Rp. ' + totalLama + ''}
- +
`; @@ -543,6 +544,7 @@ dengan_rupiah.value = formatRupiah(this.value, 'Rp. '); }); + /* Fungsi */ function formatRupiah(angka, prefix) { var number_string = angka.replace(/[^,\d]/g, '').toString(), @@ -598,6 +600,21 @@ }) }) + // bayar uang pas + $(document).ready(function() { + $('#bayar_uang_pas').on('click', function() { + // Mengambil teks dari elemen dengan menggunakan innerText + let grandTotalText = document.getElementById('total-diskon').innerText; + + // Mengisi nilai ke input dengan format Rupiah + $("#nominal-bayar").val(formatRupiah(grandTotalText, 'Rp. ')); + calculatekembali(); + }); + }); + + + + // kirim pembayaran $(document).ready(function() { $('#pesan-bayar-tunai').on('click', function() { diff --git a/resources/views/pages/Kasir/transaksi.blade.php b/resources/views/pages/Kasir/transaksi.blade.php index 6c03cb1..3f1364b 100644 --- a/resources/views/pages/Kasir/transaksi.blade.php +++ b/resources/views/pages/Kasir/transaksi.blade.php @@ -387,8 +387,8 @@
- - +
+ @@ -400,7 +400,7 @@ - + @@ -433,7 +433,7 @@ @@ -448,20 +448,25 @@ + + + @@ -469,7 +474,7 @@
Menu Qty
Total @@ -415,7 +415,7 @@ Diskon (%)
- +
Bayar
-
+ +
-