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;
diff --git a/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d-history.blade.php b/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d-history.blade.php
new file mode 100644
index 00000000..ef9237c2
--- /dev/null
+++ b/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d-history.blade.php
@@ -0,0 +1,148 @@
+
+
+
+ @include('layouts.shared/title-meta', ['title' => "History"])
+ @include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
+
+
+
+
+
+
+
+
+
+ {{$formname}}
+
+
+ New Submission
+
+
+
+ @if(session()->has('message'))
+
+ {{ session()->get('message') }}
+
+ @endif
+ @if(session()->has('error'))
+
+ {{ session()->get('error') }}
+
+ @endif
+
+
+
+
+
+
+
+
+
+
+ Submission Date
+ @foreach(($userAttrs ?? []) as $attr)
+ {{ $userAttrLabels[$attr] ?? ucwords(str_replace('_', ' ', $attr)) }}
+ @endforeach
+ @foreach($questions as $code => $question)
+ @if($question->type == 'hidden')
+ @continue;
+ @endif
+ @if($question->type == 'multitextbox')
+ @foreach($question->options as $k => $v)
+ {{ is_object($v) ? ($v->display ?? $v->label ?? $k) : $v }} ({{$question->label}})
+ @endforeach
+ @else
+ {{$question->label}}
+ @endif
+ @endforeach
+ Action
+
+
+
+ @foreach($submissions as $submission)
+
+ {{date("d M Y", strtotime($submission->updatedAt))}}
+ @foreach(($userAttrs ?? []) as $attr)
+ @php
+ $uaUser = $submission->user_info ?? null;
+ $uaVal = '-';
+ if ($uaUser) {
+ if (isset($uaUser->{$attr}) && $uaUser->{$attr} !== '') {
+ $uaVal = $uaUser->{$attr};
+ } elseif (isset($uaUser->{'attribute_'.$attr}) && $uaUser->{'attribute_'.$attr} !== '') {
+ $uaVal = $uaUser->{'attribute_'.$attr};
+ }
+ }
+ @endphp
+ {{ $uaVal }}
+ @endforeach
+ @foreach($questions as $code => $question)
+ @if($question->type == 'hidden')
+ @continue;
+ @endif
+ @if($question->type == 'file')
+ Download
+
+ @elseif($question->type == 'radiometrix' && isset($submission->formdata->{$code}) && is_object($submission->formdata->{$code}))
+
+ {{ collect((array)$submission->formdata->{$code})->map(function($val, $key){ return "$key: $val"; })->implode(', ') }}
+
+
+ @elseif($question->type == 'multitextbox')
+ @foreach($question->options as $k => $v)
+ @php
+ $optKey = is_object($v) ? ($v->value ?? $k) : $k;
+ $optVal = '';
+ if (isset($submission->formdata->{$optKey})) {
+ $raw = $submission->formdata->{$optKey};
+ $optVal = is_array($raw) ? implode(', ', $raw) : (is_object($raw) ? json_encode($raw) : $raw);
+ } elseif (isset($submission->formdata->{$code}) && (is_object($submission->formdata->{$code}) || is_array($submission->formdata->{$code}))) {
+ $box = (array) $submission->formdata->{$code};
+ if (array_key_exists($optKey, $box)) {
+ $raw = $box[$optKey];
+ $optVal = is_array($raw) ? implode(', ', $raw) : (is_object($raw) ? json_encode($raw) : $raw);
+ }
+ }
+ @endphp
+ {{ $optVal }}
+ @endforeach
+
+ @elseif(count((array)$question->options) > 0 && 1==2 )
+ {{ $question->options->{ $submission->formdata->{$code} } }}
+ @else
+ {{ isset($submission->formdata->{$code}) ? is_array($submission->formdata->{$code})? implode(', ', $submission->formdata->{$code}) : (is_object($submission->formdata->{$code}) ? collect((array)$submission->formdata->{$code})->map(function($val, $key){ return "$key: $val"; })->implode(', ') : $submission->formdata->{$code}) : '' }}
+ @endif
+ @endforeach
+
+ @php
+ $isApproved = ($submission->workflow ?? '') == 'yes' && ($submission->workflow_status ?? '') == 'approved';
+ $showFieldDelete = isset($form->allow_delete_by_user) && $form->allow_delete_by_user == 'yes' && !$isApproved;
+ @endphp
+ @if($isApproved)
+ Approved
+ @endif
+ @if($showFieldDelete || !empty($can_delete_submission))
+ Delete
+ @endif
+
+
+ @endforeach
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @include('layouts.shared/footer-script')
+
+
\ No newline at end of file
diff --git a/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d.blade.php b/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d.blade.php
index 25cc6f01..be503ff7 100644
--- a/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d.blade.php
+++ b/resources/views/form/rapport-horizon/1793272971-f2e4a8b3-d211-46ba-b867-69d4b85da68d.blade.php
@@ -44,7 +44,12 @@
@if($id)
@endif
- @if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
+
+ @if(
+ isset($form->manager_can_submit) &&
+ $form->manager_can_submit == true &&
+ $form->title != 'Upload Daily Field Work Photo'
+ )