From 271592351b8c75e2147979c0fa1277ed2b6e3bbb Mon Sep 17 00:00:00 2001 From: Ravi Gulhane Date: Thu, 29 Oct 2026 08:25:14 +0530 Subject: [PATCH 1/2] Changes --- ...e937-cfb5-4679-989a-c3fea892568f.blade.php | 463 +++++++----------- 1 file changed, 164 insertions(+), 299 deletions(-) diff --git a/resources/views/form/rapport-lifemankind/preview-1792561624-4466e937-cfb5-4679-989a-c3fea892568f.blade.php b/resources/views/form/rapport-lifemankind/preview-1792561624-4466e937-cfb5-4679-989a-c3fea892568f.blade.php index 2b447580..05c39e2b 100644 --- a/resources/views/form/rapport-lifemankind/preview-1792561624-4466e937-cfb5-4679-989a-c3fea892568f.blade.php +++ b/resources/views/form/rapport-lifemankind/preview-1792561624-4466e937-cfb5-4679-989a-c3fea892568f.blade.php @@ -1,311 +1,176 @@ - @include('layouts.shared/title-meta', ['title' => "Form"]) - @include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? '']) - + @include('layouts.shared/title-meta', ['title' => $form->title ?? 'TGICS']) + @include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? '']) + -
- processing... -
- -
-
-
-
-
-
+ +@php + $skipCodes = [ + 'tgics_contact_id', + 'user_id', + 'hierarchy_id', + 'id', + 'execution_done', + 'execution_date', + 'no_of_attendees', + 'total_amount_spent_in_rs', + 'upload_photo_1', + 'upload_photo_2', + 'ziten_m_rx', + 'total_camp_rx', + 'no_of_strips_left_with_fso', + ]; - @if(Session::has('error'))
{{Session::get('error')}}
-
@endif - @if(session('success'))
{{ session('success') }} -
-
@endif -
-

{{$form->title}}

-
- @if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) ) -
- @if($form->link_type == 'form') - View History - @else - Back - @endif -
- @endif - @if(isset($form->user_info)) -
-
Submitted By: {{$form->user_info->name}}
-
- @endif - - @php - /* echo "
";
-                            print_r($submitted_formdata);
-                            echo "
"; */ - $skuData = []; + $qualification = ''; + foreach ($questions ?? [] as $question) { + if (($question->code ?? '') === 'qualification') { + $qualification = trim((string) ($question->value ?? '')); + break; + } + } + $showOtherQualification = strcasecmp($qualification, 'Others') === 0; - foreach($questions as $q){ - if($q->code === 'sku'){ - foreach($q->options as $opt){ - $skuData[$opt->value] = $opt->submitted_value ?? 0; - } - } - } - - @endphp - - -
- - - - @csrf - @if($id) - - @endif - @if(isset($form->manager_can_submit) && $form->manager_can_submit == true) -
- - - -
- @endif - - - @foreach($questions as $question) - @if (in_array($question->code, ['execution_date','executed_as_per_plan' ,'revised_start_time','patient_screened','patients_diagnosed','rxn_of_montair_lc_adult','rxn_of_montair_lc_kid_tab','rxn_of_montair_lc_kid_syrup','rxn_of_furamist','rxn_of_furamist_az','total_rxns'])) - @continue - @endif -
- - @switch($question->type) - @case('hidden') - - @break - @case('text') - @case('email') - @case('tel') - @case('date') - required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}"> - @break - @case('number') - required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}"> - @break - @case('textarea') - - @break - @case('dropdown') - - @break - @case('checkbox') - @foreach($question->options as $option) -
- value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}> - -
- @endforeach - @break - @case('file') - @if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) ) - required == 'yes'?'required':'' }}> - @elseif(isset($question->value)) - - @endif - - @break - {{-- @case('multitextbox') -
- @foreach($question->options as $option) -
{{$option->display}}
-
- -
- @endforeach -
- @break --}} - - @case('multitextbox') -
- @foreach($question->options as $option) -
{{ $option->display }}
-
- -
- @endforeach -
- @break - @endswitch -
- @endforeach - @if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) ) -
- -
- @endif -
- -
-
- - - - -
-
- -
- -
- - -@include('layouts.shared/footer-script') - - + - - \ No newline at end of file + From e957ce07034c40435f8a90cd4e739facaee8135a Mon Sep 17 00:00:00 2001 From: Ravi Gulhane Date: Fri, 30 Oct 2026 09:31:37 +0530 Subject: [PATCH 2/2] Changes --- .../NeblogisticreportController.php | 149 ++++++++++++++---- ...llocations_update_2026-10-28_aravind_m.sql | 92 +++++++++++ 2 files changed, 213 insertions(+), 28 deletions(-) create mode 100644 database/sql/incept_neb_allocations_update_2026-10-28_aravind_m.sql diff --git a/app/Http/Controllers/NeblogisticreportController.php b/app/Http/Controllers/NeblogisticreportController.php index 36c9ea6c..84ce6d0b 100644 --- a/app/Http/Controllers/NeblogisticreportController.php +++ b/app/Http/Controllers/NeblogisticreportController.php @@ -485,38 +485,54 @@ class NeblogisticreportController extends Controller $data = DB::table('neblogistic')->where('id', $params['record_id'])->first(); - + $emailWarnings = []; + if (isset($params['status'])) { if ($params['status'] == 'Rejected') { - - Mail::to($data->emp_email) - ->cc($data->abm_email) - ->send(new NeblogisticRejection((array)$data)); - Mail::to('ravigulhane1983@gmail.com')->send(new NeblogisticRejection((array)$data)); - - } - elseif (in_array($params['status'], ['Dispatched', 'Delivered'], true)) { + $rejectWarn = $this->sendNeblogisticMailSafely( + new NeblogisticRejection((array) $data), + $data->emp_email ?? null, + $data->abm_email ?? null, + ['id' => $data->id ?? null, 'mail' => 'rejection'] + ); + if ($rejectWarn !== null) { + $emailWarnings[] = $rejectWarn; + } + try { + Mail::to('ravigulhane1983@gmail.com')->send(new NeblogisticRejection((array) $data)); + } catch (\Throwable $e) { + Log::error('Neblogistic rejection debug email failed', [ + 'id' => $data->id ?? null, + 'message' => $e->getMessage(), + ]); + } + } elseif (in_array($params['status'], ['Dispatched', 'Delivered'], true)) { Log::info('Neblogistic status update email', [ 'data' => $data, ]); - // Send to TM (emp_email) - if (!empty($data->emp_email)) { - Mail::to($data->emp_email) - ->send(new NeblogisticStatusUpdate((array)$data, 'tm')); + $tmWarn = $this->sendNeblogisticMailSafely( + new NeblogisticStatusUpdate((array) $data, 'tm'), + $data->emp_email ?? null, + null, + ['id' => $data->id ?? null, 'mail' => 'status_tm'] + ); + if ($tmWarn !== null) { + $emailWarnings[] = $tmWarn; } - - // Send to ABM (abm_email) - if (!empty($data->abm_email)) { - Mail::to($data->abm_email) - ->send(new NeblogisticStatusUpdate((array)$data, 'abm')); + $abmWarn = $this->sendNeblogisticMailSafely( + new NeblogisticStatusUpdate((array) $data, 'abm'), + $data->abm_email ?? null, + null, + ['id' => $data->id ?? null, 'mail' => 'status_abm'] + ); + if ($abmWarn !== null) { + $emailWarnings[] = $abmWarn; } // Prevent cron from re-sending the same status email DB::table('neblogistic') ->where('id', $params['record_id']) ->update(['status_email_sent' => $params['status']]); - } else { - } } @@ -529,15 +545,22 @@ class NeblogisticreportController extends Controller $data->pin_code = $data->address_pin_code; $data->clinic_hospital_home_name = $data->clinic_hospital_name; - Mail::to($data->emp_email) - ->cc($data->abm_email) - ->send(new Neblogistic((array)$data)); + $editWarn = $this->sendNeblogisticMailSafely( + new Neblogistic((array) $data), + $data->emp_email ?? null, + $data->abm_email ?? null, + ['id' => $data->id ?? null, 'mail' => 'edit_notification'] + ); + if ($editWarn !== null) { + $emailWarnings[] = $editWarn; + } //Mail::to('arbaz@stratawiz.com')->send(new NeblogisticSupervisor((array)$data)); $user = Auth::user(); - - // echo "
";
-        // print_r($params);
+        $successMessage = 'Data Saved';
+        if (!empty($emailWarnings)) {
+            $successMessage .= '. ' . implode(' ', array_unique($emailWarnings));
+        }
 
         if(!$params['submission_id'] == ''){
         // return print_r($params);
@@ -546,7 +569,7 @@ class NeblogisticreportController extends Controller
             $history = LambdaRequest::signedrequest('post', 'form', 'formentity/submitform', $post, 120);
             Log::info('formsubmission after edit', [ 'history' => $history]);
             if ($history->status === 'success') {
-                return redirect()->back()->with('message', 'Data Saved');
+                return redirect()->back()->with('message', $successMessage);
             } else {
                 return redirect()->back()->with('error', 'Operation failed.');
             }
@@ -557,7 +580,7 @@ class NeblogisticreportController extends Controller
 
 
         if ($dataUpdate) {
-            return redirect()->back()->with('message', 'Data Saved');
+            return redirect()->back()->with('message', $successMessage);
         } else {
             return redirect()->back()->with('error', 'Operation failed.');
         }
@@ -2048,6 +2071,76 @@ class NeblogisticreportController extends Controller
         return is_object($response) && ($response->status ?? '') === 'success';
     }
 
+    /**
+     * True when value is a real mailbox (rejects empty / Vacant placeholders).
+     */
+    protected function isValidNeblogisticEmail($email): bool
+    {
+        $email = trim((string) $email);
+        if ($email === '' || stripos($email, 'vacant') !== false) {
+            return false;
+        }
+        return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
+    }
+
+    /**
+     * Send a mailable without letting invalid Vacant/CC addresses 500 the request.
+     * Returns a short user-facing warning, or null when send succeeded / nothing to warn.
+     *
+     * @param  mixed  $mailable
+     * @param  string|null  $to
+     * @param  string|null  $cc
+     * @param  array  $context
+     */
+    protected function sendNeblogisticMailSafely($mailable, $to, $cc = null, array $context = []): ?string
+    {
+        $validTo = $this->isValidNeblogisticEmail($to) ? trim((string) $to) : null;
+        $validCc = $this->isValidNeblogisticEmail($cc) ? trim((string) $cc) : null;
+        $warnings = [];
+
+        if ($to !== null && trim((string) $to) !== '' && $validTo === null) {
+            $warnings[] = 'Notification email was not sent because the recipient email is missing or invalid (e.g. Vacant).';
+            Log::warning('Neblogistic email skipped: invalid to address', $context + [
+                'to' => $to,
+                'cc' => $cc,
+            ]);
+        } elseif ($cc !== null && trim((string) $cc) !== '' && $validCc === null) {
+            $warnings[] = 'ABM notification was skipped because the ABM email is missing or invalid (e.g. Vacant).';
+            Log::warning('Neblogistic email CC skipped: invalid cc address', $context + [
+                'to' => $to,
+                'cc' => $cc,
+            ]);
+        }
+
+        if ($validTo === null) {
+            return $warnings[0] ?? 'Notification email was not sent because no valid recipient email was found.';
+        }
+
+        try {
+            $pending = Mail::to($validTo);
+            if ($validCc !== null) {
+                $pending->cc($validCc);
+            }
+            $pending->send($mailable);
+        } catch (\Swift_RfcComplianceException $e) {
+            Log::error('Neblogistic email RFC error', $context + [
+                'to' => $validTo,
+                'cc' => $validCc,
+                'message' => $e->getMessage(),
+            ]);
+            return 'Notification email could not be sent due to an invalid email address.';
+        } catch (\Throwable $e) {
+            Log::error('Neblogistic email failed', $context + [
+                'to' => $validTo,
+                'cc' => $validCc,
+                'message' => $e->getMessage(),
+            ]);
+            return 'Notification email could not be sent.';
+        }
+
+        return $warnings[0] ?? null;
+    }
+
     protected function normalizeNapPartition(?string $partition): string
     {
         $partition = trim((string) $partition);
diff --git a/database/sql/incept_neb_allocations_update_2026-10-28_aravind_m.sql b/database/sql/incept_neb_allocations_update_2026-10-28_aravind_m.sql
new file mode 100644
index 00000000..8a81bf64
--- /dev/null
+++ b/database/sql/incept_neb_allocations_update_2026-10-28_aravind_m.sql
@@ -0,0 +1,92 @@
+-- Nebulizers Allocation Data - 28102026 ARAVIND M.xlsx
+-- UPDATE incept_neb_allocations for 28 employees (sheet under ARAVIND M).
+-- Existing incept_neb_usage rows are left untouched.
+-- 27 rows differ from current DB (mostly control_d_qty); 144137 ARAVIND M unchanged.
+-- Sheet totals: Robust 332, Mini 395, Control D 319.
+START TRANSACTION;
+
+-- 144137 / ARAVIND M  Robust 11, Mini 5, Control D 0
+UPDATE incept_neb_allocations SET emp_name = 'ARAVIND M', designation = 'Area Business Manager', team = 'Neb - Arise', robust_qty = 11, mini_qty = 5, control_d_qty = 0, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '144137';
+
+-- 179234 / Harish Kumar  Robust 0, Mini 10, Control D 0
+UPDATE incept_neb_allocations SET emp_name = 'Harish Kumar', designation = 'Therapy Manager', team = 'Neb - Arise', robust_qty = 0, mini_qty = 10, control_d_qty = 0, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '179234';
+
+-- 147085 / Paladi Vikas  Robust 11, Mini 15, Control D 0
+UPDATE incept_neb_allocations SET emp_name = 'Paladi Vikas', designation = 'Therapy Manager', team = 'Neb 1', robust_qty = 11, mini_qty = 15, control_d_qty = 0, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '147085';
+
+-- 149522 / Banty .  Robust 11, Mini 15, Control D 0
+UPDATE incept_neb_allocations SET emp_name = 'Banty .', designation = 'Therapy Manager', team = 'Neb 1', robust_qty = 11, mini_qty = 15, control_d_qty = 0, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '149522';
+
+-- 173569 / Raghav Tiwari  Robust 11, Mini 15, Control D 0
+UPDATE incept_neb_allocations SET emp_name = 'Raghav Tiwari', designation = 'Therapy Manager', team = 'Neb 1', robust_qty = 11, mini_qty = 15, control_d_qty = 0, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '173569';
+
+-- 176198 / Enukonda Vishwanth  Robust 11, Mini 15, Control D 0
+UPDATE incept_neb_allocations SET emp_name = 'Enukonda Vishwanth', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 0, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '176198';
+
+-- 165632 / Aashi Gupta  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Aashi Gupta', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '165632';
+
+-- 168436 / Ashish Singh Chauhan  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Ashish Singh Chauhan', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '168436';
+
+-- 169088 / Bharti Rajput  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Bharti Rajput', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '169088';
+
+-- 169431 / Anamika Anni Shukla  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Anamika Anni Shukla', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '169431';
+
+-- 170212 / Upender Yadav  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Upender Yadav', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '170212';
+
+-- 170214 / Priyanshi Sharma  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Priyanshi Sharma', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '170214';
+
+-- 170282 / Parshant Mavi  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Parshant Mavi', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '170282';
+
+-- 171898 / Priyanshu Pandey  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Priyanshu Pandey', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '171898';
+
+-- 172432 / Aditya Joshi  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Aditya Joshi', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '172432';
+
+-- 176201 / Deepali shrivastav  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Deepali shrivastav', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '176201';
+
+-- 177311 / Sakshi Kanojia  Robust 6, Mini 10, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Sakshi Kanojia', designation = 'Management Trainee', team = 'Neb 2', robust_qty = 6, mini_qty = 10, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '177311';
+
+-- 127020 / Pawan Panwar  Robust 16, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Pawan Panwar', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 16, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '127020';
+
+-- 129394 / Rakesh Kumar  Robust 26, Mini 15, Control D 13
+UPDATE incept_neb_allocations SET emp_name = 'Rakesh Kumar', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 26, mini_qty = 15, control_d_qty = 13, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '129394';
+
+-- 139813 / Rohit Dhall  Robust 24, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Rohit Dhall', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 24, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '139813';
+
+-- 156360 / Akash Kumar Bharti  Robust 11, Mini 15, Control D 13
+UPDATE incept_neb_allocations SET emp_name = 'Akash Kumar Bharti', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 13, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '156360';
+
+-- 159248 / Ashok Kumar  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Ashok Kumar', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '159248';
+
+-- 161573 / Amandeep .  Robust 21, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Amandeep .', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 21, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '161573';
+
+-- 165238 / Ankit .  Robust 19, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Ankit .', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 19, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '165238';
+
+-- 172211 / Punit Bhardwaj  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Punit Bhardwaj', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '172211';
+
+-- 172442 / Sanjana Kumari  Robust 11, Mini 15, Control D 10
+UPDATE incept_neb_allocations SET emp_name = 'Sanjana Kumari', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 10, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '172442';
+
+-- 174034 / Nandan .  Robust 11, Mini 15, Control D 15
+UPDATE incept_neb_allocations SET emp_name = 'Nandan .', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 11, mini_qty = 15, control_d_qty = 15, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '174034';
+
+-- 178614 / Digvijay Sagar  Robust 0, Mini 10, Control D 13
+UPDATE incept_neb_allocations SET emp_name = 'Digvijay Sagar', designation = 'Therapy Manager', team = 'Neb 2', robust_qty = 0, mini_qty = 10, control_d_qty = 13, updated_at = '2026-10-28 00:00:00' WHERE emp_id = '178614';
+
+COMMIT;