From 2d3fda57b7a3a9bc073a1df3dded547a5cf4900d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:14:30 +0530 Subject: [PATCH] Added characteristic approval function for testing purpose --- app/Jobs/SendApprover1MailJob.php | 51 +++++++++++++++++++++++++++ app/Jobs/SendApprover2MailJob.php | 58 +++++++++++++++++++++++++++++++ app/Jobs/SendApprover3MailJob.php | 56 +++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 app/Jobs/SendApprover1MailJob.php create mode 100644 app/Jobs/SendApprover2MailJob.php create mode 100644 app/Jobs/SendApprover3MailJob.php diff --git a/app/Jobs/SendApprover1MailJob.php b/app/Jobs/SendApprover1MailJob.php new file mode 100644 index 0000000..c42136b --- /dev/null +++ b/app/Jobs/SendApprover1MailJob.php @@ -0,0 +1,51 @@ +request->approver_status1)) return; + + if ($this->request->approver1_mail_sent) return; + + $approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id) + ->where('machine_id', $this->request->machine_id) + ->first(); + + if (! $approver || ! $approver->mail1) return; + + Mail::to($approver->mail1) + ->queue(new CharacteristicApprovalMail( + $this->request, + $approver->name1, + 1 + )); + + $this->request->update(['approver1_mail_sent' => 1]); + + SendApprover2MailJob::dispatch($this->request) + ->delay(now()->addMinutes(5)); + } +} diff --git a/app/Jobs/SendApprover2MailJob.php b/app/Jobs/SendApprover2MailJob.php new file mode 100644 index 0000000..744bdeb --- /dev/null +++ b/app/Jobs/SendApprover2MailJob.php @@ -0,0 +1,58 @@ +request->approver_status1)) return; + + // If approver-2 already approved → STOP + if (!is_null($this->request->approver_status2)) return; + + if ($this->request->approver2_mail_sent) return; + + $approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id) + ->where('machine_id', $this->request->machine_id) + ->first(); + + if (! $approver || ! $approver->mail2) return; + + Mail::to($approver->mail2) + ->queue(new CharacteristicApprovalMail( + $this->request, + $approver->name2, + 2 + )); + + $this->request->update(['approver2_mail_sent' => 1]); + + // Schedule Approver-3 after 5 minutes + SendApprover3MailJob::dispatch($this->request) + ->delay(now()->addMinutes(5)); + } +} diff --git a/app/Jobs/SendApprover3MailJob.php b/app/Jobs/SendApprover3MailJob.php new file mode 100644 index 0000000..9113a85 --- /dev/null +++ b/app/Jobs/SendApprover3MailJob.php @@ -0,0 +1,56 @@ +request->approver_status1) || + !is_null($this->request->approver_status2) || + !is_null($this->request->approver_status3) + ) { + return; + } + + if ($this->request->approver3_mail_sent) return; + + $approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id) + ->where('machine_id', $this->request->machine_id) + ->first(); + + if (! $approver || ! $approver->mail3) return; + + Mail::to($approver->mail3) + ->queue(new CharacteristicApprovalMail( + $this->request, + $approver->name3, + 3 + )); + + $this->request->update(['approver3_mail_sent' => 1]); + } +}