From f67aab1fdcd1e5b68c99593f33d4fe85e450b2fb Mon Sep 17 00:00:00 2001 From: Ravi Gulhane Date: Thu, 8 Oct 2026 09:12:45 +0530 Subject: [PATCH 1/3] Add the Team3 POB form so TMs can record doctor and chemist orders and upload invoices. Co-authored-by: Cursor --- app/Http/Controllers/FormController.php | 104 ++++ ...8862-93e7-43b5-bf4e-7a29b30e3830.blade.php | 499 ++++++++++++++++++ routes/edit/web.php | 1 + routes/web.php | 1 + 4 files changed, 605 insertions(+) create mode 100644 resources/views/form/rapport-team3/1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php index 57c1dda8..22695c04 100644 --- a/app/Http/Controllers/FormController.php +++ b/app/Http/Controllers/FormController.php @@ -63,6 +63,88 @@ class FormController extends Controller return $formId; } + protected function pobFormId() { + return '1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830'; + } + + protected function pobPrices() { + return [ + 'asthalin_inhaler' => 129, + 'asthalin_rotacap' => 55, + 'aerocort_inhaler' => 260, + 'aerocort_rotacap' => 109, + 'aerocort_forte_rotacap' => 99, + ]; + } + + protected function pobWholeNumber($value) { + if ($value === null || $value === '') { + return 0; + } + if (!preg_match('/^\d+$/', trim((string) $value))) { + return null; + } + return (int) $value; + } + + protected function applyPobAmounts(array $post) { + if (($post['form_id'] ?? '') !== $this->pobFormId()) { + return $post; + } + $prices = $this->pobPrices(); + $isUpload = !empty($post['id']); + if (!$isUpload) { + $date = (string) ($post['record_date'] ?? ''); + $today = date('Y-m-d'); + if ($date < '2026-09-01' || $date > $today) { + return ['__error' => 'Date must be from 1 Sep 2026 through today.']; + } + if (empty($post['contact_id']) || !in_array($post['contact_type'] ?? '', ['ebt_doctor', 'ebt_chemist'], true)) { + return ['__error' => 'Select a doctor or chemist.']; + } + if (!in_array($post['supply_status'] ?? '', ['Yes', 'No'], true)) { + return ['__error' => 'Select the supply status.']; + } + $totalUnits = 0; + $totalValue = 0; + foreach ($prices as $code => $price) { + $units = $this->pobWholeNumber($post[$code.'_units'] ?? 0); + if ($units === null) { + return ['__error' => 'POB units must be a whole number.']; + } + $post[$code.'_units'] = (string) $units; + $post[$code.'_value'] = (string) ($units * $price); + $totalUnits += $units; + $totalValue += $units * $price; + } + $post['total_pob_units'] = (string) $totalUnits; + $post['total_pob_value'] = (string) $totalValue; + $post['submission_status'] = 'Order Taken'; + return $post; + } + $invoice = (string) ($post['upload_invoice'] ?? ''); + $extension = strtolower(pathinfo((string) parse_url($invoice, PHP_URL_PATH), PATHINFO_EXTENSION)); + if ($invoice === '' || !in_array($extension, ['jpg', 'jpeg', 'png', 'pdf'], true)) { + return ['__error' => 'Upload an invoice as a JPG, JPEG, PNG, or PDF file.']; + } + $totalUnits = 0; + $totalValue = 0; + foreach ($prices as $code => $price) { + $units = $this->pobWholeNumber($post['actual_'.$code.'_units'] ?? 0); + if ($units === null) { + return ['__error' => 'Actual POB units must be a whole number.']; + } + $post['actual_'.$code.'_units'] = (string) $units; + $post['actual_'.$code.'_value'] = (string) ($units * $price); + $totalUnits += $units; + $totalValue += $units * $price; + } + $post['total_actual_pob_units'] = (string) $totalUnits; + $post['total_actual_pob_value'] = (string) $totalValue; + $post['submission_status'] = 'Invoice Uploaded'; + return $post; + } + protected function deliverform($formdata, $questions, $id = false) { $additional_info = $this->get_additional_info($formdata); // if($formdata->form_id == '1711609582-e93dba24-9c98-43e7-b97a-b22d64d9b9fc') { @@ -7659,6 +7741,10 @@ class FormController extends Controller if(isset($formdata) && !empty($formdata) && $formdata->user_id != '') { + $post = $this->applyPobAmounts($post); + if (isset($post['__error'])) { + return response()->json(['status' => 'error', 'message' => $post['__error']]); + } $post = $this->processformdata($formdata->form_id, $post, $formdata->user_id, $formdata->partition); Log::debug(print_r($post, true)); $finfo = LambdaRequest::postrequest('form', 'formentity/submitmultipleform', ['formdata' => $post, 'entity_id' => $post['form_id'], 'user_id' => $formdata->user_id, 'partition' => $formdata->partition ]); @@ -8256,6 +8342,24 @@ class FormController extends Controller return response()->json(['form' => $history->data->form, 'questions' => $history->data->questions, 'submissions' => $history->data->submissions, 'form_id' => $form_id]); } + public function pobhistory(Request $request) { + $formdata = $request->session()->get('formdata'); + $formId = $request->input('form_id', ''); + $contactId = $request->input('contact_id', ''); + if (!$formdata || $formId !== $this->pobFormId() || $contactId === '') { + return response()->json(['submissions' => []]); + } + $history = LambdaRequest::postrequest('form', 'formentity/getformhistory', [ + 'form_id' => $formId, + 'user_id' => $formdata->user_id, + 'partition' => $formdata->partition, + 'limit' => 100, + 'filters' => ['formdata.contact_id' => $contactId], + ]); + $submissions = (isset($history->data) && isset($history->data->submissions)) ? $history->data->submissions : []; + return response()->json(['submissions' => $submissions]); + } + public function history(Request $request) { $formdata = $request->session()->get('formdata'); Log::debug(print_r($formdata, true)); diff --git a/resources/views/form/rapport-team3/1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php b/resources/views/form/rapport-team3/1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php new file mode 100644 index 00000000..8bd79045 --- /dev/null +++ b/resources/views/form/rapport-team3/1791391025-cf688862-93e7-43b5-bf4e-7a29b30e3830.blade.php @@ -0,0 +1,499 @@ + + + + @include('layouts.shared/title-meta', ['title' => 'POB']) + @include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? '']) + + + + + +
Loading
+ +@include('layouts.shared/footer-script') + + + + + diff --git a/routes/edit/web.php b/routes/edit/web.php index 9727a891..da7fe716 100644 --- a/routes/edit/web.php +++ b/routes/edit/web.php @@ -236,6 +236,7 @@ foreach ($modules as $mod => $class) { Route::any('/getidrivedoctowisedownload', [FormController::class, 'getidrivedoctowisedownload']); Route::get('/form/nebmitrahistory', [FormController::class, 'nebmitrahistory']); +Route::get('/form/pobhistory', [FormController::class, 'pobhistory']); Route::post('/form/ajaxdoctortagging', [FormController::class, 'ajaxdoctortagging']); Route::get('/form/pulmocarecoachingtool', [FormController::class, 'pulmocarecoachingtool']); diff --git a/routes/web.php b/routes/web.php index 2dbf5e0f..951fae50 100755 --- a/routes/web.php +++ b/routes/web.php @@ -303,6 +303,7 @@ Route::get('/milestones/exportTeamReport', [MilestoneController::class, 'exportT Route::any('/getidrivedoctowisedownload', [FormController::class, 'getidrivedoctowisedownload']); Route::get('/form/nebmitrahistory', [FormController::class, 'nebmitrahistory']); +Route::get('/form/pobhistory', [FormController::class, 'pobhistory']); Route::post('/form/ajaxdoctortagging', [FormController::class, 'ajaxdoctortagging']); Route::get('/form/pulmocarecoachingtool', [FormController::class, 'pulmocarecoachingtool']); From bc4d3d056ba6cafe79ce4a33dce00f0db9418d49 Mon Sep 17 00:00:00 2001 From: Ravi Gulhane Date: Thu, 8 Oct 2026 09:12:45 +0530 Subject: [PATCH 2/3] Sort each zone on the custom dashboard by the combined active FSO count. Co-authored-by: Cursor --- .../Controllers/ZenovaReportController.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/ZenovaReportController.php b/app/Http/Controllers/ZenovaReportController.php index 67d1ea50..bcce1f2f 100644 --- a/app/Http/Controllers/ZenovaReportController.php +++ b/app/Http/Controllers/ZenovaReportController.php @@ -199,9 +199,9 @@ class ZenovaReportController extends Controller if ($zone !== 0) { return $zone; } - $users = $this->fsoCount($right) <=> $this->fsoCount($left); - if ($users !== 0) { - return $users; + $active = $this->activeFsoTotal($right) <=> $this->activeFsoTotal($left); + if ($active !== 0) { + return $active; } return strcasecmp($this->rowName($left), $this->rowName($right)); @@ -229,11 +229,19 @@ class ZenovaReportController extends Controller return ''; } - private function fsoCount($row): float + private function activeFsoTotal($row): float { - $value = $row->{'Demography & Details'}->{'No. of FSOs'} ?? 0; + $demo = $row->{'Demography & Details'} ?? null; + if (!is_object($demo)) { + return 0; + } - return is_numeric($value) ? (float) $value : 0; + $glipiq = $demo->{'Glipiq Active FSOs'} ?? 0; + $sitazit = $demo->{'Sitazit Active FSOs'} ?? 0; + $glipiq = is_numeric($glipiq) ? (float) $glipiq : 0; + $sitazit = is_numeric($sitazit) ? (float) $sitazit : 0; + + return $glipiq + $sitazit; } private function rowName($row): string From addc215f366e5d7c8fc2ed29d2857df3f15f1fc6 Mon Sep 17 00:00:00 2001 From: Tanuja Pansare Date: Thu, 8 Oct 2026 10:28:43 +0530 Subject: [PATCH 3/3] COPD Form Changes - Damdaar Duolin Chalo 105 % ! --- .../1789539434-fd05787a-184d-4089-872b-8ff009e95320.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/form/rapport-copd/1789539434-fd05787a-184d-4089-872b-8ff009e95320.blade.php b/resources/views/form/rapport-copd/1789539434-fd05787a-184d-4089-872b-8ff009e95320.blade.php index 4aac62da..457550c7 100644 --- a/resources/views/form/rapport-copd/1789539434-fd05787a-184d-4089-872b-8ff009e95320.blade.php +++ b/resources/views/form/rapport-copd/1789539434-fd05787a-184d-4089-872b-8ff009e95320.blade.php @@ -297,7 +297,7 @@ var yyyy = today.getFullYear(); var todayDate = yyyy + '-' + mm + '-' + dd; - var firstDayOfMonth = yyyy + '-' + mm + '-01'; + var firstDayOfMonth = '2026-09-15'; var plandateField = document.getElementById('field-record_date');