diff --git a/Livewire/Branch/BranchModal.php b/Livewire/Branch/BranchModal.php index 790b180..f7fb1ef 100644 --- a/Livewire/Branch/BranchModal.php +++ b/Livewire/Branch/BranchModal.php @@ -42,13 +42,55 @@ if ($this->edit_mode) { // Emit a success event with a message $branch = Branch::find($this->id); - $branch->update($data); - $this->dispatch('success', __('Branch updated')); + $approval = [ + 'method' => 'update', + 'menu' => 'Parameter Cabang', + 'old_request' => json_encode($branch), + 'new_request' => json_encode($data), + 'description' => 'Update Parameter Cabang', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Cabang') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'update') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Update, Menunggu Approval'); + } } else { // Emit a success event with a message - Branch::create($data); - $this->dispatch('success', __('New Branch created')); + $approval = [ + 'method' => 'create', + 'menu' => 'Parameter Cabang', + 'new_request' => json_encode($data), + 'description' => 'Create Parameter Cabang', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Cabang') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'create') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + $this->reset(); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Input, Menunggu Approval'); + } } }); diff --git a/Livewire/Currency/CurrencyModal.php b/Livewire/Currency/CurrencyModal.php index a275bc2..3836111 100644 --- a/Livewire/Currency/CurrencyModal.php +++ b/Livewire/Currency/CurrencyModal.php @@ -42,13 +42,55 @@ if ($this->edit_mode) { // Emit a success event with a message $currency = Currency::find($this->id); - $currency->update($data); - $this->dispatch('success', __('Currency updated')); + $approval = [ + 'method' => 'update', + 'menu' => 'Parameter Mata Uang', + 'old_request' => json_encode($currency), + 'new_request' => json_encode($data), + 'description' => 'Update Parameter Mata Uang', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Mata Uang') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'update') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Update, Menunggu Approval'); + } } else { // Emit a success event with a message - Currency::create($data); - $this->dispatch('success', __('New Currency created')); + $approval = [ + 'method' => 'create', + 'menu' => 'Parameter Mata Uang', + 'new_request' => json_encode($data), + 'description' => 'Create Parameter Mata Uang', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Mata Uang') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'create') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + $this->reset(); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Input, Menunggu Approval'); + } } }); @@ -69,8 +111,8 @@ public function delete($id) { - $curency = Currency::find($id); - $curency->delete_by = auth()->user()->id; + $curency = Currency::find($id); + $curency->delete_by = auth()->user()->id; $curency->deleted_at = now(); $approval = [ diff --git a/Livewire/Debitur/DebiturModal.php b/Livewire/Debitur/DebiturModal.php index 7006a9e..c6f4758 100644 --- a/Livewire/Debitur/DebiturModal.php +++ b/Livewire/Debitur/DebiturModal.php @@ -51,17 +51,58 @@ 'registered_at' => $this->registered_at, ]; - if ($this->edit_mode) { // Emit a success event with a message $debitur = Debitur::find($this->id); - $debitur->update($data); - $this->dispatch('success', __('Debitur updated')); + $approval = [ + 'method' => 'update', + 'menu' => 'Parameter Debitur', + 'old_request' => json_encode($debitur), + 'new_request' => json_encode($data), + 'description' => 'Update Parameter Debitur', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Debitur') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'update') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Update, Menunggu Approval'); + } } else { // Emit a success event with a message - Debitur::create($data); - $this->dispatch('success', __('New Debitur created')); + $approval = [ + 'method' => 'create', + 'menu' => 'Parameter Debitur', + 'new_request' => json_encode($data), + 'description' => 'Create Parameter Debitur', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Debitur') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'create') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + $this->reset(); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Input, Menunggu Approval'); + } } }); diff --git a/Livewire/FacilityType/FacilityTypeModal.php b/Livewire/FacilityType/FacilityTypeModal.php index 6a89afe..6cbacde 100644 --- a/Livewire/FacilityType/FacilityTypeModal.php +++ b/Livewire/FacilityType/FacilityTypeModal.php @@ -41,14 +41,56 @@ if ($this->edit_mode) { // Emit a success event with a message - $facility_type = FacilityType::find($this->id); - $facility_type->update($data); + $facility = FacilityType::find($this->id); - $this->dispatch('success', __('Facility Type updated')); + $approval = [ + 'method' => 'update', + 'menu' => 'Parameter Jenis Fasilitas', + 'old_request' => json_encode($facility), + 'new_request' => json_encode($data), + 'description' => 'Update Parameter Jenis Fasilitas', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Jenis Fasilitas') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'update') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Update, Menunggu Approval'); + } } else { // Emit a success event with a message - FacilityType::create($data); - $this->dispatch('success', __('New Facility Type created')); + $approval = [ + 'method' => 'create', + 'menu' => 'Parameter Jenis Fasilitas', + 'new_request' => json_encode($data), + 'description' => 'Create Parameter Jenis Fasilitas', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Jenis Fasilitas') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'create') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + $this->reset(); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Input, Menunggu Approval'); + } } }); diff --git a/Livewire/GuaranteeType/GuaranteeTypeModal.php b/Livewire/GuaranteeType/GuaranteeTypeModal.php index 1f76ccc..e325fc9 100644 --- a/Livewire/GuaranteeType/GuaranteeTypeModal.php +++ b/Livewire/GuaranteeType/GuaranteeTypeModal.php @@ -41,14 +41,56 @@ if ($this->edit_mode) { // Emit a success event with a message - $guarantee_type = GuaranteeType::find($this->id); - $guarantee_type->update($data); + $guarante = GuaranteeType::find($this->id); - $this->dispatch('success', __('Guarante Type updated')); + $approval = [ + 'method' => 'update', + 'menu' => 'Parameter Jenis Jaminan', + 'old_request' => json_encode($guarante), + 'new_request' => json_encode($data), + 'description' => 'Update Parameter Jenis Jaminan', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Jenis Jaminan') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'update') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Update, Menunggu Approval'); + } } else { // Emit a success event with a message - GuaranteeType::create($data); - $this->dispatch('success', __('New Guarante Type created')); + $approval = [ + 'method' => 'create', + 'menu' => 'Parameter Jenis Jaminan', + 'new_request' => json_encode($data), + 'description' => 'Create Parameter Jenis Jaminan', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Jenis Jaminan') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'create') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + $this->reset(); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Input, Menunggu Approval'); + } } }); diff --git a/Livewire/LoanType/LoanTypeModal.php b/Livewire/LoanType/LoanTypeModal.php index 4f6e73e..09673f6 100644 --- a/Livewire/LoanType/LoanTypeModal.php +++ b/Livewire/LoanType/LoanTypeModal.php @@ -41,14 +41,56 @@ if ($this->edit_mode) { // Emit a success event with a message - $loan_type = LoanType::find($this->id); - $loan_type->update($data); + $loan = LoanType::find($this->id); - $this->dispatch('success', __('Loan Type updated')); + $approval = [ + 'method' => 'update', + 'menu' => 'Parameter Jenis Jaminan', + 'old_request' => json_encode($loan), + 'new_request' => json_encode($data), + 'description' => 'Update Parameter Jenis Jaminan', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Jenis Jaminan') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'update') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Update, Menunggu Approval'); + } } else { // Emit a success event with a message - LoanType::create($data); - $this->dispatch('success', __('New Loan Type created')); + $approval = [ + 'method' => 'create', + 'menu' => 'Parameter Jenis Jaminan', + 'new_request' => json_encode($data), + 'description' => 'Create Parameter Jenis Jaminan', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Jenis Jaminan') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'create') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + $this->reset(); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Input, Menunggu Approval'); + } } }); diff --git a/Livewire/Rekening/RekeningModal.php b/Livewire/Rekening/RekeningModal.php index 4962e0b..f959b43 100644 --- a/Livewire/Rekening/RekeningModal.php +++ b/Livewire/Rekening/RekeningModal.php @@ -73,13 +73,55 @@ if ($this->edit_mode) { // Emit a success event with a message $rekening = Rekening::find($this->id); - $rekening->update($data); - $this->dispatch('success', __('Rekening updated')); + $approval = [ + 'method' => 'update', + 'menu' => 'Parameter Rekening', + 'old_request' => json_encode($rekening), + 'new_request' => json_encode($data), + 'description' => 'Update Parameter Rekening', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Rekening') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'update') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Update, Menunggu Approval'); + } } else { // Emit a success event with a message - Rekening::create($data); - $this->dispatch('success', __('New Rekening created')); + $approval = [ + 'method' => 'create', + 'menu' => 'Parameter Rekening', + 'new_request' => json_encode($data), + 'description' => 'Create Parameter Rekening', + 'status' => '0', + 'ref' => $this->kode + ]; + + $is_approval = Approval::where('menu', 'Parameter Rekening') + ->where('ref', $this->kode) + ->where('status', '0') + ->where('method', 'create') + ->get() + ->first(); + + if ($is_approval) { + $this->dispatch('error', 'Data Sedang Menunggu Approval'); + $this->reset(); + } else { + Approval::create($approval); + $this->dispatch('success', 'Data Berhasil Di Input, Menunggu Approval'); + } } });