diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php index 3f47447e..5aa5f196 100644 --- a/app/Http/Controllers/DomainController.php +++ b/app/Http/Controllers/DomainController.php @@ -24,7 +24,7 @@ class DomainController extends Controller //echo '
'; print_r($response); exit;
             $values = $response->data->item;
         }
-        $data = $this->_beforeform($type, $values);
+        $values = $this->_beforeform($type, $values);
         $fields = $this->get_form_fields($type, $values);
         //echo '
'; print_r($data); exit;
         return $this->view('form')->with([
@@ -125,12 +125,22 @@ class DomainController extends Controller
             'badges_recipient_list' => ['title' => 'Badges Recipient List', 'type' => 'select', 'required' => true, 'values' => ['show_all_users' => 'Show all users', 'show_users_under_hierarchy' => 'Show users under hierarchy', 'show_users_under_hierarchy_and_peers' => 'Show users under hierarchy & peers', 'show_users_under_hierarchy_same_level' => 'Show users under hierarchy & at same level'] ],
 
             'users_extra_profile_fields' => ['title' => 'Extra Profile Fields(comma seperated)', 'type' => 'textarea', 'fullwidth' => true],
+            'doctor_tags_roles' => ['title' => 'Doctor Tags Roles', 'type' => 'multiselect', 'values' => $roles_dd, 'fullwidth' => true],
             'terms_text' => ['title' => 'Login Terms & Conditions Text', 'type' => 'textarea', 'required' => true, 'fullwidth' => true],
             'android_server_key' => ['title' => 'Android Server Key', 'type' => 'textarea', 'fullwidth' => true],
             'ios_server_key' => ['title' => 'IOS Server Key', 'type' => 'textarea', 'fullwidth' => true],
         ];
     }
 
+    protected function _beforeform($type, $values) {
+        if ($type == 'edit' && is_object($values)) {
+            if (!isset($values->doctor_tags_roles) || !is_array($values->doctor_tags_roles)) {
+                $values->doctor_tags_roles = [];
+            }
+        }
+        return $values;
+    }
+
     protected function _beforesave($type, $request) {
         $data = $request->except('_token');
         $static_otp_for_roles = [];
@@ -140,6 +150,9 @@ class DomainController extends Controller
             }
         }
         $data['static_otp_for_roles'] = json_encode($static_otp_for_roles);
+        if (!isset($data['doctor_tags_roles']) || !is_array($data['doctor_tags_roles'])) {
+            $data['doctor_tags_roles'] = [];
+        }
         if( $request->file('logo') ) {
             $data['logo'] = $this->_uploadMedia($request, 'logo', 'domain');
         }
diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php
index 8972c4e9..1f7ac950 100644
--- a/app/Http/Controllers/FormController.php
+++ b/app/Http/Controllers/FormController.php
@@ -1081,6 +1081,36 @@ class FormController extends Controller
             $cont = LambdaRequest::postrequest('contact', 'contact/update', $contactdata, $token[0]->access_token);
         }
 
+        // Zenova - Glipiq & Sitazit Tracker Copy
+        if($formdata->form_id == '1788239728-6f7f3c27-c5dc-4e6e-a042-aefd5681af3a' && isset($post['contact_id']) && !empty($post['contact_id'])) {
+            list($application, $domain) = explode("-", $formdata->partition);
+            $token = DB::table('users')->select("access_token","user_id")->where("domain", $domain)->where("permissions", 'like', '%contact_create%')->orderBy('updated_at', 'desc')->skip(0)->take(1)->get();
+            $contactdata = [
+                'domain' => $domain,
+                'application' => $application,
+                'user_id' => $post['user_id'],
+                'id' => $post['contact_id'],
+            ];
+            $contactAttributes = [
+                'sankalp_lead_received_penvial',
+                'sankalp_lead_enrolled_penvial',
+                'pmos_dr',
+                'qbs_dr',
+                'adboard_dr',
+                'fb_live_dr',
+                'ecme_dr',
+                'rtm_dr',
+            ];
+            foreach ($contactAttributes as $attr) {
+                if (isset($post[$attr]) && $post[$attr] !== '') {
+                    $contactdata[$attr] = $post[$attr];
+                }
+            }
+            if (count($contactdata) > 4) {
+                LambdaRequest::postrequest('contact', 'contact/update', $contactdata, $token[0]->access_token);
+            }
+        }
+
         // if($formdata->form_id == '1758800833-00e44f7c-1857-4109-8ad4-2789d49a78fa') {
 
         //     list($application, $domain) = explode("-", $formdata->partition);
diff --git a/app/Http/Controllers/LeaderboardController.php b/app/Http/Controllers/LeaderboardController.php
index 00c63b96..38b88bbb 100644
--- a/app/Http/Controllers/LeaderboardController.php
+++ b/app/Http/Controllers/LeaderboardController.php
@@ -335,6 +335,8 @@ class LeaderboardController extends Controller
             'title' => 'Leaderboard',
             'subtitle' => '',
             'period_label' => '',
+            'periods' => [],
+            'selected_period' => (string) $request->query('period', ''),
             'users' => [],
             'metrics' => [],
             'pills' => [],
@@ -377,6 +379,11 @@ class LeaderboardController extends Controller
         }
 
         $pills = $this->roleLeaderboardPills($id, $roleId, $groups, $request->query('period'));
+        $periods = $this->uniquePeriodOptions($view->periods ?? []);
+        $selectedPeriod = (string) ($request->query('period') ?: ($view->interval ?? ''));
+        if ($selectedPeriod === '') {
+            $selectedPeriod = 'all';
+        }
 
         if (!$selected) {
             return [
@@ -384,6 +391,8 @@ class LeaderboardController extends Controller
                 'title' => $view->name ?? 'Leaderboard',
                 'subtitle' => '',
                 'period_label' => '',
+                'periods' => $periods,
+                'selected_period' => $selectedPeriod,
                 'users' => [],
                 'metrics' => [],
                 'pills' => $pills,
@@ -449,6 +458,8 @@ class LeaderboardController extends Controller
             'title' => $view->name ?? 'Leaderboard',
             'subtitle' => $subtitle,
             'period_label' => $periodLabel,
+            'periods' => $periods,
+            'selected_period' => $selectedPeriod,
             'users' => $users,
             'metrics' => $metrics,
             'pills' => $pills,
@@ -456,6 +467,30 @@ class LeaderboardController extends Controller
         ];
     }
 
+    protected function uniquePeriodOptions($periods): array
+    {
+        if (is_object($periods)) {
+            $periods = array_values((array) $periods);
+        }
+        if (!is_array($periods)) {
+            return [];
+        }
+
+        $out = [];
+        $seen = [];
+        foreach ($periods as $period) {
+            $period = is_object($period) ? $period : (object) $period;
+            $value = (string) ($period->value ?? '');
+            if ($value === '' || isset($seen[$value])) {
+                continue;
+            }
+            $seen[$value] = true;
+            $out[] = $period;
+        }
+
+        return $out;
+    }
+
     protected function roleLeaderboardPills($leaderboardId, $selectedRoleId, array $groups, $period = null): array
     {
         $rankRoles = [];
diff --git a/resources/views/form/rapport-arise/1777097685-b3bf0da9-b147-435f-a0be-e2b9087d3c49.blade.php b/resources/views/form/rapport-arise/1777097685-b3bf0da9-b147-435f-a0be-e2b9087d3c49.blade.php
new file mode 100644
index 00000000..c42d35de
--- /dev/null
+++ b/resources/views/form/rapport-arise/1777097685-b3bf0da9-b147-435f-a0be-e2b9087d3c49.blade.php
@@ -0,0 +1,309 @@
+
+
+
+    @include('layouts.shared/title-meta', ['title' => "Form"])
+    @include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
+    
+
+
+ processing... +
+ + + + +@include('layouts.shared/footer-script') + + + + + \ No newline at end of file diff --git a/resources/views/form/rapport-arise/1777271277-05698b95-d240-452c-bd5f-00dab08a14dd.blade.php b/resources/views/form/rapport-arise/1777271277-05698b95-d240-452c-bd5f-00dab08a14dd.blade.php new file mode 100644 index 00000000..c32532c9 --- /dev/null +++ b/resources/views/form/rapport-arise/1777271277-05698b95-d240-452c-bd5f-00dab08a14dd.blade.php @@ -0,0 +1,315 @@ + + + + @include('layouts.shared/title-meta', ['title' => "Form"]) + @include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? '']) + + +
+ processing... +
+ + + + +@include('layouts.shared/footer-script') + + + + + \ No newline at end of file diff --git a/resources/views/form/rapport-arise/1777276825-8b57a724-fffb-4ab9-8fcb-a635b6c71091.blade.php b/resources/views/form/rapport-arise/1777276825-8b57a724-fffb-4ab9-8fcb-a635b6c71091.blade.php new file mode 100644 index 00000000..c32532c9 --- /dev/null +++ b/resources/views/form/rapport-arise/1777276825-8b57a724-fffb-4ab9-8fcb-a635b6c71091.blade.php @@ -0,0 +1,315 @@ + + + + @include('layouts.shared/title-meta', ['title' => "Form"]) + @include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? '']) + + +
+ processing... +
+ + + + +@include('layouts.shared/footer-script') + + + + + \ No newline at end of file diff --git a/resources/views/form/rapport-pulmocare/1781619111-800b2b5e-6d80-4bef-97dd-e2ff0beb8276.blade.php b/resources/views/form/rapport-pulmocare/1781619111-800b2b5e-6d80-4bef-97dd-e2ff0beb8276.blade.php new file mode 100644 index 00000000..f6baab00 --- /dev/null +++ b/resources/views/form/rapport-pulmocare/1781619111-800b2b5e-6d80-4bef-97dd-e2ff0beb8276.blade.php @@ -0,0 +1,906 @@ + + + + @include('layouts.shared/title-meta', ['title' => "Form"]) + @include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? '']) + + +
+ processing... +
+ +@php + $history = Formhelper::getMultiformData($form->partition, $form_id, $form->user_id); + $doctorNameById = []; + $doctorIdByName = []; + + foreach ($questions as $question) { + if ($question->code == 'contact_id' && is_iterable($question->options ?? null)) { + foreach ($question->options as $opt) { + $doctorNameById[$opt->value] = $opt->display; + $doctorIdByName[$opt->display] = $opt->value; + } + } + } + + $resolveContactId = function ($raw) use ($doctorNameById, $doctorIdByName) { + if (is_array($raw) || $raw instanceof \Traversable) { + $raw = trim((string) (array_values((array) $raw)[0] ?? '')); + } else { + $raw = trim((string) ($raw ?? '')); + } + + if ($raw === '') { + return ''; + } + + if (isset($doctorNameById[$raw])) { + return $raw; + } + + if (isset($doctorIdByName[$raw])) { + return $doctorIdByName[$raw]; + } + + return $raw; + }; + + $latestByContact = []; + if (isset($history->data->submissions) && is_iterable($history->data->submissions)) { + foreach ($history->data->submissions as $sub) { + $formdata = $sub->formdata ?? null; + if (!$formdata) { + continue; + } + + $contactId = $resolveContactId($formdata->contact_id ?? ''); + + if ($contactId === '') { + continue; + } + + $ts = 0; + if (!empty($sub->createdAt)) { + $ts = strtotime($sub->createdAt) ?: 0; + } elseif (!empty($sub->updatedAt)) { + $ts = strtotime($sub->updatedAt) ?: 0; + } elseif (!empty($formdata->record_date)) { + $ts = strtotime($formdata->record_date) ?: 0; + } + + if (!isset($latestByContact[$contactId]) || $ts >= $latestByContact[$contactId]['ts']) { + $latestByContact[$contactId] = ['sub' => $sub, 'ts' => $ts]; + } + } + } + + $latestDoctorRows = collect(array_values($latestByContact)) + ->map(function ($item) { + return $item['sub']; + }) + ->sortByDesc(function ($sub) { + $fd = $sub->formdata ?? null; + if (!$fd) { + return 0; + } + return strtotime($sub->createdAt ?? $sub->updatedAt ?? ($fd->record_date ?? '')) ?: 0; + }) + ->values(); + + $reportFormId = '1781620356-76fde7ab-e939-44ff-b0be-c33e7f2a05a7'; + $report_form = Formhelper::getformdefination($form->partition, $reportFormId, $form->user_id); + $reportQuestions = $report_form->data->questions ?? []; + $reportHistory = Formhelper::getMultiformData($form->partition, $reportFormId, $form->user_id); + + $reportMonths = [ + 'January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December', + ]; + $reportMonthNumToName = array_combine(range(1, 12), $reportMonths); + $reportMonthShortNames = [ + 'January' => 'Jan', 'February' => 'Feb', 'March' => 'Mar', + 'April' => 'Apr', 'May' => 'May', 'June' => 'Jun', + 'July' => 'Jul', 'August' => 'Aug', 'September' => 'Sep', + 'October' => 'Oct', 'November' => 'Nov', 'December' => 'Dec', + ]; + $fiscalMonthColumns = [ + 'Apr-26', 'May-26', 'Jun-26', 'Jul-26', 'Aug-26', 'Sep-26', + 'Oct-26', 'Nov-26', 'Dec-26', 'Jan-27', 'Feb-27', 'Mar-27', + ]; + + $normalizeReportMonth = function ($month) use ($reportMonths, $reportMonthNumToName) { + if (is_array($month) || $month instanceof \Traversable) { + $month = array_values((array) $month)[0] ?? ''; + } + + $month = trim((string) $month); + if ($month === '') { + return ''; + } + + if (is_numeric($month)) { + return $reportMonthNumToName[(int) $month] ?? ''; + } + + foreach ($reportMonths as $monthName) { + if (strcasecmp($month, $monthName) === 0) { + return $monthName; + } + } + + return $month; + }; + + $reportMonthColumnKey = function ($month, $year) use ($normalizeReportMonth, $reportMonthShortNames, $fiscalMonthColumns) { + $monthName = $normalizeReportMonth($month); + $year = trim((string) $year); + + if ($monthName === '' || $year === '' || !isset($reportMonthShortNames[$monthName])) { + return null; + } + + $columnKey = $reportMonthShortNames[$monthName] . '-' . substr($year, -2); + return in_array($columnKey, $fiscalMonthColumns, true) ? $columnKey : null; + }; + + $reportTotalsByContact = []; + if (isset($reportHistory->data->submissions) && is_iterable($reportHistory->data->submissions)) { + foreach ($reportHistory->data->submissions as $reportSub) { + $reportFd = $reportSub->formdata ?? null; + if (!$reportFd) { + continue; + } + + $reportContactId = $resolveContactId($reportFd->contact_id ?? ''); + if ($reportContactId === '') { + continue; + } + + $columnKey = $reportMonthColumnKey($reportFd->month ?? '', $reportFd->year ?? ''); + if ($columnKey === null) { + continue; + } + + $totalValue = $reportFd->total_actual_value ?? $reportFd->total ?? 0; + if (is_array($totalValue) || $totalValue instanceof \Traversable) { + $totalValue = array_values((array) $totalValue)[0] ?? 0; + } + $totalValue = (float) $totalValue; + + if (!isset($reportTotalsByContact[$reportContactId][$columnKey])) { + $reportTotalsByContact[$reportContactId][$columnKey] = 0; + } + $reportTotalsByContact[$reportContactId][$columnKey] += $totalValue; + } + } + + $formatReportTotal = function ($value) { + if ($value === null || (float) $value === 0.0) { + return ''; + } + + $formatted = number_format((float) $value, 2, '.', ''); + return rtrim(rtrim($formatted, '0'), '.'); + }; + + $reportCurrentMonth = $reportMonths[(int) date('n') - 1]; + $reportCurrentYear = (int) date('Y'); + if ($reportCurrentYear < 2026) { + $reportCurrentYear = 2026; + } elseif ($reportCurrentYear > 2028) { + $reportCurrentYear = 2028; + } + + $reportReadonlyCalcFields = [ + 'pulmosmart_group_actual_value', + 'pulmosamrt_group_actual_value', + 'total_actual_value', + 'ps_share', + ]; + + foreach ($reportQuestions as $question) { + if ($question->code == 'contact_id' && is_iterable($question->options ?? null)) { + foreach ($question->options as $opt) { + $doctorNameById[$opt->value] = $opt->display; + $doctorIdByName[$opt->display] = $opt->value; + } + } + } +@endphp + + + + + +@include('layouts.shared/footer-script') + + + + + diff --git a/resources/views/form/rapport-team3/1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php b/resources/views/form/rapport-team3/1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php index dd543459..5d6cfb48 100644 --- a/resources/views/form/rapport-team3/1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php +++ b/resources/views/form/rapport-team3/1655458541-00d0e7c9-c60e-410e-ada7-8e0fef8e6ac1.blade.php @@ -44,7 +44,18 @@ @endif @php - $history = Formhelper::getMultiformData($form->partition, $form->form_id, $form->user_id); + $submissions = []; + if (isset($form->manager_can_submit) && $form->manager_can_submit == true && isset($form->users) && count($form->users) > 0) { + foreach ($form->users as $option) { + $history = Formhelper::getMultiformData($form->partition, $form->form_id, $option->value); + if (isset($history->data->submissions) && is_array($history->data->submissions)) { + $submissions = array_merge($submissions, $history->data->submissions); + } + } + } else { + $history = Formhelper::getMultiformData($form->partition, $form->form_id, $form->user_id); + $submissions = $history->data->submissions ?? []; + } @endphp
@@ -56,6 +67,9 @@ Action + @if(isset($form->manager_can_submit) && $form->manager_can_submit == true) + User + @endif Execution Done Plan Date {{-- Team Name --}} @@ -68,18 +82,52 @@ - @foreach ($history->data->submissions as $sub) + @foreach ($submissions as $sub) @php $sub->formdata->id = $sub->id; + if (isset($sub->user_info->id)) { + $sub->formdata->user_id = $sub->user_info->id; + } + if (isset($sub->hierarchy_id) && $sub->hierarchy_id != '') { + $sub->formdata->hierarchy_id = $sub->hierarchy_id; + } elseif (isset($form->users) && isset($sub->formdata->user_id)) { + foreach ($form->users as $option) { + if ($option->value == $sub->formdata->user_id && isset($option->hierarchy_id)) { + $sub->formdata->hierarchy_id = $option->hierarchy_id; + break; + } + } + } @endphp - + + + + + @elseif($sub->workflow_status=='rejected') + + @else + + + + @endif + + @if(isset($form->manager_can_submit) && $form->manager_can_submit == true) + {{ $sub->user_info->name ?? '' }} + @endif {{ isset($sub->formdata->record_date) && $sub->formdata->record_date > 0 ? 'Yes' : 'No' }} {{ $sub->formdata->plan_date }} @@ -116,7 +164,7 @@
@endif @foreach ($questions as $question) - @if (in_array($question->code, ['record_date', 'name_of_the_speaker', 'msl_code', 'attendence','speciality','honorarium_amount','other_expenses','total_eas','no_of_patients_on_duolin','no_of_units_duolin_respules','other_msl_code','other_speciality'])) + @if (in_array($question->code, ['record_date', 'attendence','honorarium_amount','other_expenses','total_eas','no_of_patients_on_duolin','no_of_units_duolin_respules'])) @continue @endif
@@ -155,14 +203,40 @@ @break @case('dropdown') - required == 'yes' ? 'required' : '' }}> - @foreach ($question->options as $option) - - @endforeach + @if ($question->code == 'name_of_the_speaker') + @foreach ($question->options as $option) + @if( isset($option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors) && $option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors == 'Yes' ) + + @endif + @endforeach + + + @elseif ($question->code == 'other_speaker_name') + @foreach ($question->options as $option) + @if(!isset($option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors) || + $option->contact->doctor_activities_for_neb_2_top_30_next_30_doctors === null + ) + + @endif + @endforeach + + @else + @foreach ($question->options as $option) + + @endforeach + @endif @break @@ -197,6 +271,10 @@ @csrf + @if(isset($form->manager_can_submit) && $form->manager_can_submit == true) + + + @endif @foreach ($questions as $question)