Merge branch 'main' of http://192.168.1.200:3000/Stratawiz/Rapport-Laravel
Specific Folder FTP Upload / ftp-deploy (push) Successful in 28s Details

This commit is contained in:
zeeshan 2026-10-29 17:18:21 +05:30
commit 9bc537b7b7
10 changed files with 3180 additions and 208 deletions

View File

@ -126,64 +126,28 @@ class AdherencePobDriveExport
'Days Daily Target Met',
'Target Status',
];
$summaryHelp = [
'No. of Total W',
'Count of Active TMs',
'No. of Total W x Count of Active TMs',
'Sum of count of all Days',
'Total TMs Qualified / Month Target (POBs)',
'No. of Unique Chemists with ≥₹15k POB Value',
'No. of Days on which Daily Target is achieved',
'If Month Target achieved = Achieved, If Month Target not achieved = In Progress',
];
$dayStart = count($identity) + 1;
$summaryStart = $dayStart + count($this->dayTemplate);
$lastCol = $summaryStart + count($summary) - 1;
$sheet->setCellValue('A1', 'Adherence Pack POB Drive – ABM – ' . $this->month);
$sheet->mergeCells('A1:' . $this->col($lastCol) . '1');
$sheet->setCellValue('A3', 'Legend: pink = vacant HQ; green day = working day; grey day = holiday.');
$sheet->mergeCells('A3:' . $this->col($lastCol) . '3');
$sheet->setCellValue('A5', 'Data of no. of chemists with Adherence Pack POB ≥ ₹15,000');
$sheet->setCellValue('J5', 'Day type (W / H) →');
$sheet->setCellValue('A1', 'Adherence Pack POB Drive – ABM');
$sheet->setCellValue('A3', 'Data of no. of chemists with Adherence Pack POB ≥ ₹15,000 will be added by Smartian App');
foreach ($this->dayTemplate as $index => $day) {
$sheet->setCellValue($this->col($dayStart + $index) . '5', $day['type'] === 'H' ? 'H' : 'W');
$sheet->setCellValue($this->col($dayStart + $index) . '4', $day['type'] === 'H' ? 'H' : 'W');
}
$help = [
'Zone',
'Region',
'Area',
'as it is',
'ABM Emp Name',
'ABM Emp Code',
'RBM Name',
'ABM Email ID',
'Count of Active TMs',
'Blank Remarks Column',
];
$this->writeValues($sheet, 6, $help);
if (count($this->dayTemplate) > 0) {
$sheet->setCellValue($this->col($dayStart) . '6', 'No. of TMs with at least 1 Chemist with ≥₹15k POB Value');
if (count($this->dayTemplate) > 1) {
$sheet->mergeCells($this->col($dayStart) . '6:' . $this->col($summaryStart - 1) . '6');
}
}
$this->writeValues($sheet, 6, $summaryHelp, $summaryStart);
$headers = $identity;
foreach ($this->dayTemplate as $day) {
$headers[] = $this->dayHeader($day['label']);
}
$headers = array_merge($headers, $summary);
$this->writeValues($sheet, 7, $headers);
$this->styleHeaderRow($sheet, 7, $lastCol, count($identity), $summaryStart);
$sheet->getStyle('A5')->getFont()->setName('Century Gothic')->setBold(true)->setSize(9)->getColor()->setARGB(self::BLUE);
$this->paintDayTypes($sheet, 5, $dayStart, false);
$this->paintDayHeaders($sheet, 7, $dayStart, false);
$this->writeValues($sheet, 5, $headers);
$this->styleHeaderRow($sheet, 5, $lastCol, count($identity), $summaryStart);
$sheet->getStyle('A3')->getFont()->setName('Century Gothic')->setBold(true)->setSize(9)->getColor()->setARGB(self::BLUE);
$this->paintDayTypes($sheet, 4, $dayStart, false);
$this->paintDayHeaders($sheet, 5, $dayStart, false);
$rowNumber = 8;
$rowNumber = 6;
foreach ($this->abmRows as $row) {
$values = [];
foreach ($identity as $key) {
@ -204,49 +168,31 @@ class AdherencePobDriveExport
$rowNumber++;
}
$this->finishSheet($sheet, 7, max(7, $rowNumber - 1), $lastCol, $dayStart, 14);
$sheet->freezePane('A8');
$this->finishSheet($sheet, 5, max(5, $rowNumber - 1), $lastCol, $dayStart, 14);
$sheet->getStyle('A3')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
$sheet->freezePane('A6');
}
private function writeRegionSheet($sheet): void
{
$columns = $this->regionColumns();
$lastCol = 3 + count($columns);
$sheet->setCellValue('A1', 'Region-wise Daily Winner – Highest no. of chemists with Adherence Pack POB ≥ ₹15,000 – ' . $this->month);
$sheet->mergeCells('A1:' . $this->col($lastCol) . '1');
$sheet->setCellValue('A1', 'Region-wise Daily Winner – Highest no. of chemists with Adherence Pack POB ≥ ₹15,000');
$typeRow = ['', '', ''];
$helpRow = ['', '', ''];
$headerRow = ['Region (RBM)', 'RBM Name', 'RBM Employee Code'];
$pairHelp = 0;
foreach ($columns as $column) {
if ($column['kind'] === 'total-tm' || $column['kind'] === 'total-chemist') {
$typeRow[] = 'Sum of count of all Days';
$helpRow[] = $column['kind'] === 'total-tm'
? 'No. of TMs with at least 1 Chemist with ≥₹15k POB Value'
: 'No. of Unique Chemists with ≥₹15k POB Value';
$typeRow[] = '';
$headerRow[] = $column['header'];
continue;
}
$typeRow[] = $column['type'] === 'H' ? 'H' : 'W';
if ($pairHelp === 0 && $column['kind'] === 'tm') {
$helpRow[] = 'No. of TMs with at least 1 Chemist with ≥₹15k POB Value';
$pairHelp = 1;
} elseif ($pairHelp === 1 && $column['kind'] === 'chemist') {
$helpRow[] = 'No. of Unique Chemists with ≥₹15k POB Value';
$pairHelp = 2;
} else {
$helpRow[] = '';
}
$headerRow[] = $column['header'];
}
$this->writeValues($sheet, 2, $typeRow);
$this->writeValues($sheet, 3, $helpRow);
$this->writeValues($sheet, 3, $typeRow);
$this->writeValues($sheet, 4, $headerRow);
if (count($columns) >= 2 && $columns[count($columns) - 1]['kind'] === 'total-chemist') {
$sheet->mergeCells($this->col($lastCol - 1) . '2:' . $this->col($lastCol) . '2');
}
$this->styleHeaderRow($sheet, 4, $lastCol, 3, $lastCol - 1);
$this->paintRegionDayMarks($sheet, $columns);
@ -288,30 +234,25 @@ class AdherencePobDriveExport
{
$dayStart = 4;
$totalCol = $dayStart + count($this->dayTemplate);
$sheet->setCellValue('A1', 'Territory-wise Daily Winner – Highest no. of chemists with Adherence Pack POB ≥ ₹15,000 – ' . $this->month);
$sheet->mergeCells('A1:' . $this->col($totalCol) . '1');
$sheet->setCellValue('A1', 'Territory-wise Daily Winner – Highest no. of chemists with Adherence Pack POB ≥ ₹15,000');
$typeRow = ['', '', ''];
foreach ($this->dayTemplate as $day) {
$typeRow[] = $day['type'] === 'H' ? 'H' : 'W';
}
$this->writeValues($sheet, 3, $typeRow);
if (count($this->dayTemplate) > 0) {
$sheet->setCellValue('D4', 'No. of Unique Chemists with ≥₹15k POB Value');
}
$sheet->setCellValue($this->col($totalCol) . '4', 'Sum of all Days of No. of Unique Chemists with ≥₹15k POB Value');
$headers = ['Territory', 'TM Name', 'TM Employee Code'];
foreach ($this->dayTemplate as $day) {
$headers[] = $this->dayHeader($day['label']);
}
$headers[] = 'Total Chemists Qualified (≥₹15k POB)';
$this->writeValues($sheet, 5, $headers);
$this->styleHeaderRow($sheet, 5, $totalCol, 3, $totalCol);
$this->writeValues($sheet, 4, $headers);
$this->styleHeaderRow($sheet, 4, $totalCol, 3, $totalCol);
$this->paintDayTypes($sheet, 3, $dayStart, true);
$this->paintDayHeaders($sheet, 5, $dayStart, true);
$this->paintDayHeaders($sheet, 4, $dayStart, true);
$rowNumber = 6;
$rowNumber = 5;
foreach ($this->tmRows as $row) {
$dayMap = $this->dayMap($this->field($row, 'days'));
$values = [
@ -331,8 +272,8 @@ class AdherencePobDriveExport
$rowNumber++;
}
$this->finishSheet($sheet, 5, max(5, $rowNumber - 1), $totalCol, $dayStart, 13);
$sheet->freezePane('A6');
$this->finishSheet($sheet, 4, max(4, $rowNumber - 1), $totalCol, $dayStart, 13);
$sheet->freezePane('A5');
}
/**
@ -713,7 +654,7 @@ class AdherencePobDriveExport
}
$cell = $this->col(4 + $index);
$color = $column['type'] === 'H' ? self::GREY : self::GREEN;
$this->paintCell($sheet, $cell . '2', $color);
$this->paintCell($sheet, $cell . '3', $color);
$this->paintCell($sheet, $cell . '4', $color);
$sheet->getStyle($cell . '4')->getFont()->setBold(true)->setSize(11)->getColor()->setARGB('000000');
}

View File

@ -258,10 +258,11 @@ class FormController extends Controller
return $this->deliverform($formdata, $finfo->data->questions);
} elseif ($formdata->link_type == 'list') {
$form = $finfo->data->form ?? $formdata;
$showPositions = $form->show_positions ?? $form->show_position ?? 'no';
$positionColumns = $this->getAvailablePositionColumns($finfo->data->submissions ?? [], $showPositions);
$userAttrs = $this->userAttributeCodes($form);
$userAttrLabels = $this->resolveUserAttributeLabels($userAttrs);
$dataDesignerView = $this->hasDataDesignerView($form);
$showPositions = $dataDesignerView ? 'no' : ($form->show_positions ?? $form->show_position ?? 'no');
$positionColumns = $dataDesignerView ? [] : $this->getAvailablePositionColumns($finfo->data->submissions ?? [], $showPositions);
$userAttrs = $dataDesignerView ? [] : $this->userAttributeCodes($form);
$userAttrLabels = $dataDesignerView ? [] : $this->resolveUserAttributeLabels($userAttrs);
$listViewData = [
'questions' => $finfo->data->questions,
'submissions' => $finfo->data->submissions,
@ -273,6 +274,7 @@ class FormController extends Controller
'positionColumns' => $positionColumns,
'userAttrs' => $userAttrs,
'userAttrLabels' => $userAttrLabels,
'dataDesignerView' => $dataDesignerView,
];
if (\View::exists('form.'.$formdata->partition.'.list-'.$formdata->form_id)) {
return view('form.'.$formdata->partition.'.list-'.$formdata->form_id)->with($listViewData);
@ -401,83 +403,106 @@ class FormController extends Controller
$sessionForm = $request->session()->get('formdata');
$canDeleteByPermission = $request->input('delete_submission') == 1
|| $this->sessionFlag($sessionForm, 'delete_submission');
$userAttrs = $this->userAttributeCodes($formdata);
$dataDesignerView = $this->hasDataDesignerView($formdata);
$userAttrs = $dataDesignerView ? [] : $this->userAttributeCodes($formdata);
foreach($submissions as $submission) {
if (!isset($submission->user_info->name)) continue;
$row = [
"date" => date("d M Y", strtotime($submission->updatedAt)),
"name" => $submission->user_info->name,
"designation" => $submission->user_info->designation ?? "",
"employee_code" => $submission->user_info->employee_code ?? "",
"submission_id" => $submission->id,
"actions" => []
];
foreach ($userAttrs as $attr) {
$row[$attr] = $this->userAttributeValue($submission->user_info ?? null, $attr);
}
// workflow status
if (isset($formdata->workflow) && $formdata->workflow == 'yes') {
$row["workflow_status"] = ucfirst($submission->workflow_status ?? "");
$row["workflow_next_approver"] = $submission->workflow_next_approver ?? "";
}
if ($dataDesignerView) {
foreach ($questions as $code => $question) {
if (isset($question->type) && $question->type == 'hidden') {
continue;
}
$value = null;
if (isset($submission->formdata) && is_object($submission->formdata) && property_exists($submission->formdata, $code)) {
$value = $submission->formdata->{$code};
} elseif (isset($submission->{$code})) {
$value = $submission->{$code};
}
if (is_array($value)) {
$value = implode(', ', $value);
}
$row[$code] = $value ?? '';
}
if (isset($formdata->workflow) && $formdata->workflow == 'yes') {
$row['workflow_next_approver'] = $submission->workflow_next_approver ?? '';
}
} else {
$row['date'] = date("d M Y", strtotime($submission->updatedAt));
$row['name'] = $submission->user_info->name;
$row['designation'] = $submission->user_info->designation ?? "";
$row['employee_code'] = $submission->user_info->employee_code ?? "";
foreach ($userAttrs as $attr) {
$row[$attr] = $this->userAttributeValue($submission->user_info ?? null, $attr);
}
// answers for all questions (put on top level!)
foreach($questions as $code => $question) {
if ($question->type == 'hidden') continue;
if ($question->type == 'multitextbox') {
foreach ($question->options as $k => $v) {
$row[$k] = isset($submission->formdata->{$k})
? (is_array($submission->formdata->{$k})
? implode(', ', $submission->formdata->{$k})
: $submission->formdata->{$k})
// workflow status
if (isset($formdata->workflow) && $formdata->workflow == 'yes') {
$row["workflow_status"] = ucfirst($submission->workflow_status ?? "");
$row["workflow_next_approver"] = $submission->workflow_next_approver ?? "";
}
// answers for all questions (put on top level!)
foreach($questions as $code => $question) {
if ($question->type == 'hidden') continue;
if ($question->type == 'multitextbox') {
foreach ($question->options as $k => $v) {
$row[$k] = isset($submission->formdata->{$k})
? (is_array($submission->formdata->{$k})
? implode(', ', $submission->formdata->{$k})
: $submission->formdata->{$k})
: '';
}
} else if ($question->type == 'file') {
$row[$code . '_file'] = isset($submission->formdata->{$code})
? (is_array($submission->formdata->{$code})
? implode(', ', $submission->formdata->{$code})
: $submission->formdata->{$code})
: '';
} else {
$row[$code] = isset($submission->formdata->{$code})
? (is_array($submission->formdata->{$code})
? implode(', ', $submission->formdata->{$code})
: $submission->formdata->{$code})
: '';
}
} else if ($question->type == 'file') {
$row[$code . '_file'] = isset($submission->formdata->{$code})
? (is_array($submission->formdata->{$code})
? implode(', ', $submission->formdata->{$code})
: $submission->formdata->{$code})
: '';
} else {
$row[$code] = isset($submission->formdata->{$code})
? (is_array($submission->formdata->{$code})
? implode(', ', $submission->formdata->{$code})
: $submission->formdata->{$code})
: '';
}
}
$generatedFiles = $submission->formdata->genareted_image ?? null;
if (is_object($generatedFiles)) {
$generatedFiles = array_values((array) $generatedFiles);
}
if (is_array($generatedFiles) && count($generatedFiles)) {
$imageFormId = $submission->formdata->form_id ?? $form_id;
$row['generated_image_url'] = collect($generatedFiles)->filter()->map(function ($file) use ($imageFormId) {
return asset('storage/personalized/'.$imageFormId.'/'.$file);
})->implode(', ');
}
if (isset($formdata->workflow) && $formdata->workflow == 'yes') {
$row['workflow_action_date'] = $this->formatWorkflowActionDate($submission);
$row['approval_history'] = $this->formatApprovalHistory($submission);
}
// show positions (legacy: show_position) — null-safe; blades only render available columns
$showPositions = $formdata->show_positions ?? $formdata->show_position ?? 'no';
if ($showPositions == 'yes') {
foreach (['territory', 'area', 'region', 'zone'] as $positionField) {
$row[$positionField] = $submission->{$positionField} ?? '';
$generatedFiles = $submission->formdata->genareted_image ?? null;
if (is_object($generatedFiles)) {
$generatedFiles = array_values((array) $generatedFiles);
}
if (is_array($generatedFiles) && count($generatedFiles)) {
$imageFormId = $submission->formdata->form_id ?? $form_id;
$row['generated_image_url'] = collect($generatedFiles)->filter()->map(function ($file) use ($imageFormId) {
return asset('storage/personalized/'.$imageFormId.'/'.$file);
})->implode(', ');
}
}
// show L1/L2 manager details
if (isset($formdata->show_manager_details) && $formdata->show_manager_details == 'yes') {
$row['manager1_name'] = $submission->manager1_name ?? '';
$row['manager1_code'] = $submission->manager1_code ?? '';
$row['manager2_name'] = $submission->manager2_name ?? '';
$row['manager2_code'] = $submission->manager2_code ?? '';
if (isset($formdata->workflow) && $formdata->workflow == 'yes') {
$row['workflow_action_date'] = $this->formatWorkflowActionDate($submission);
$row['approval_history'] = $this->formatApprovalHistory($submission);
}
// show positions (legacy: show_position) — null-safe; blades only render available columns
$showPositions = $formdata->show_positions ?? $formdata->show_position ?? 'no';
if ($showPositions == 'yes') {
foreach (['territory', 'area', 'region', 'zone'] as $positionField) {
$row[$positionField] = $submission->{$positionField} ?? '';
}
}
// show L1/L2 manager details
if (isset($formdata->show_manager_details) && $formdata->show_manager_details == 'yes') {
$row['manager1_name'] = $submission->manager1_name ?? '';
$row['manager1_code'] = $submission->manager1_code ?? '';
$row['manager2_name'] = $submission->manager2_name ?? '';
$row['manager2_code'] = $submission->manager2_code ?? '';
}
}
// actions
@ -490,8 +515,8 @@ class FormController extends Controller
}
if (isset($submission->actions) && in_array('edit', $submission->actions)) $row['actions'][] = 'edit';
if (
isset($formdata->workflow) &&
$formdata->workflow == 'yes' &&
isset($formdata->workflow) &&
$formdata->workflow == 'yes' &&
$submission->workflow_status == 'unapproved'
) {
$row['actions'][] = 'approve';
@ -508,23 +533,25 @@ class FormController extends Controller
}
// Target forms: always expose approval status for list UI (downloadpersonalization list)
$targetFormIds = [
'1781004538-88671587-3b81-403b-af63-fdbfae8a965e', // rapport-team2
'1782118020-9c6160bf-f07c-465e-9ea1-e8ff0c0b89dd', // rapport-titans
];
$resolvedFormIds = array_filter([
(string) $form_id,
(string) ($originalFormId ?? ''),
(string) (is_object($formdata) ? ($formdata->id ?? '') : ''),
(string) (is_object($formdata) ? ($formdata->form_id ?? '') : ''),
]);
$isTargetForm = count(array_intersect($targetFormIds, $resolvedFormIds)) > 0;
if (!$dataDesignerView) {
$targetFormIds = [
'1781004538-88671587-3b81-403b-af63-fdbfae8a965e', // rapport-team2
'1782118020-9c6160bf-f07c-465e-9ea1-e8ff0c0b89dd', // rapport-titans
];
$resolvedFormIds = array_filter([
(string) $form_id,
(string) ($originalFormId ?? ''),
(string) (is_object($formdata) ? ($formdata->id ?? '') : ''),
(string) (is_object($formdata) ? ($formdata->form_id ?? '') : ''),
]);
$isTargetForm = count(array_intersect($targetFormIds, $resolvedFormIds)) > 0;
if ($isTargetForm) {
$workflowStatus = $submission->workflow_status
?? (is_object($submission->formdata) ? ($submission->formdata->workflow_status ?? '') : '');
$row['workflow_status'] = ucfirst(trim((string) $workflowStatus));
$row['workflow_next_approver'] = $submission->workflow_next_approver ?? ($row['workflow_next_approver'] ?? '');
if ($isTargetForm) {
$workflowStatus = $submission->workflow_status
?? (is_object($submission->formdata) ? ($submission->formdata->workflow_status ?? '') : '');
$row['workflow_status'] = ucfirst(trim((string) $workflowStatus));
$row['workflow_next_approver'] = $submission->workflow_next_approver ?? ($row['workflow_next_approver'] ?? '');
}
}
$jsonRows[] = $row;
}
@ -901,6 +928,72 @@ class FormController extends Controller
]);
}
$whatsapp = preg_replace('/\D+/', '', (string) ($post['whatsapp_mobile_number'] ?? ''));
if (strlen($whatsapp) > 10) {
$whatsapp = substr($whatsapp, -10);
}
$post['whatsapp_mobile_number'] = $whatsapp;
if (!preg_match('/^[6-9]\d{9}$/', $whatsapp)) {
return response()->json([
'status' => 'error',
'message' => 'WhatsApp number is invalid.',
'description' => 'Please enter a valid 10-digit WhatsApp mobile number starting with 6, 7, 8, or 9.',
]);
}
$whatsappExists = false;
$phoneContacts = LambdaRequest::getrequest('contact', 'contact/get_all', [
'keyword' => $whatsapp,
'start' => 0,
'length' => 10000,
], $accessToken);
if (isset($phoneContacts->data->items) && is_array($phoneContacts->data->items)) {
foreach ($phoneContacts->data->items as $item) {
$itemPhone = isset($item->phone) ? preg_replace('/\D+/', '', (string) $item->phone) : '';
if (strlen($itemPhone) > 10) {
$itemPhone = substr($itemPhone, -10);
}
if ($itemPhone === '' || $itemPhone !== $whatsapp) {
continue;
}
$itemId = isset($item->id) ? (string) $item->id : '';
if ($currentSubmissionId !== '' && $linkedContactId !== '' && $itemId === $linkedContactId) {
continue;
}
$whatsappExists = true;
break;
}
}
if (!$whatsappExists && isset($previousEntries->data->submissions) && is_array($previousEntries->data->submissions)) {
foreach ($previousEntries->data->submissions as $submission) {
$submissionId = isset($submission->id) ? (string) $submission->id : '';
if ($currentSubmissionId !== '' && $submissionId === $currentSubmissionId) {
continue;
}
$entryPhone = isset($submission->formdata->whatsapp_mobile_number)
? preg_replace('/\D+/', '', (string) $submission->formdata->whatsapp_mobile_number)
: '';
if (strlen($entryPhone) > 10) {
$entryPhone = substr($entryPhone, -10);
}
if ($entryPhone !== '' && $entryPhone === $whatsapp) {
$whatsappExists = true;
break;
}
}
}
if ($whatsappExists) {
return response()->json([
'status' => 'error',
'message' => 'Doctor with this WhatsApp number already exists.',
'description' => 'Please check the enrolled doctor list or use a different WhatsApp number.',
]);
}
// Create contact only on new enrolments (not edits)
if ($currentSubmissionId === '') {
$doctorName = trim((string) ($post['contact_id'] ?? ($post['doctor_name'] ?? '')));
@ -1543,6 +1636,33 @@ class FormController extends Controller
]);
}
if ($formdata->form_id == '1741155802-25a7600f-1613-4a82-af1d-f460a8f79ffa') {
$contactIds = [];
foreach (['contact_id', 'contact_id_2'] as $contactKey) {
$contactId = trim((string) ($post[$contactKey] ?? ''));
if ($contactId !== '' && strcasecmp($contactId, 'others') !== 0) {
$contactIds[] = $contactId;
}
}
$contactIds = array_values(array_unique($contactIds));
if ($contactIds !== [] && !empty($formdata->partition)) {
list($application, $domain) = explode('-', $formdata->partition);
$token = DB::table('users')->select('access_token')->where('domain', $domain)->where('permissions', 'like', '%contact_create%')->orderBy('updated_at', 'desc')->skip(0)->take(1)->get();
$userId = trim((string) ($post['user_id'] ?? ($formdata->user_id ?? '')));
if ($token->isNotEmpty() && $userId !== '') {
foreach ($contactIds as $contactId) {
LambdaRequest::postrequest('contact', 'contact/update', [
'domain' => $domain,
'application' => $application,
'user_id' => $userId,
'id' => $contactId,
'ardc_camps_ardc_poster_execution_dr_tagging' => 'Yes',
], $token[0]->access_token);
}
}
}
}
if($formdata->form_id == '1757055046-ba0eff4e-0d4a-4e90-b190-c59f12ef6edd') {
// if(isset($post['cresar_bs_launched']) && $post['cresar_bs_launched'] == 'Yes' ) {
list($application, $domain) = explode("-", $formdata->partition);
@ -13244,6 +13364,47 @@ class FormController extends Controller
Log::debug($cmd);
}
/**
* True when the form Data Designer has at least one show_in_view field.
* Opt-in only: empty designer or export-only fields keep the legacy list.
*/
protected function hasDataDesignerView($form): bool
{
if (!$form) {
return false;
}
$designer = $form->data_designer ?? null;
if (is_string($designer) && trim($designer) !== '') {
$decoded = json_decode($designer, true);
$designer = is_array($decoded) ? $decoded : null;
} elseif (is_object($designer)) {
$designer = (array) $designer;
}
if (!is_array($designer)) {
return false;
}
$fields = $designer['fields'] ?? [];
if (is_object($fields)) {
$fields = (array) $fields;
}
if (!is_array($fields)) {
return false;
}
foreach ($fields as $field) {
if (is_object($field)) {
$show = $field->show_in_view ?? false;
} elseif (is_array($field)) {
$show = $field['show_in_view'] ?? false;
} else {
continue;
}
if ($show === true || $show === 1 || $show === '1' || $show === 'true') {
return true;
}
}
return false;
}
/**
* Selected user attribute codes when Show User Attributes is Yes.
* A saved attribute list is ignored while that setting is No.

File diff suppressed because it is too large Load Diff

View File

@ -64,6 +64,15 @@
<thead>
<tr>
<th data-priority="1">Action</th>
@if(!empty($dataDesignerView))
@foreach($questions as $code => $question)
@if(isset($question->type) && $question->type == 'hidden')
@continue
@endif
<th data-priority="1">{{ $question->label }}</th>
@endforeach
@php $showGeneratedImage = false; @endphp
@else
<th data-priority="1">Submission Date</th>
<th data-priority="1">Submitted By</th>
<th data-priority="1">Employee Code</th>
@ -107,6 +116,7 @@
@if($showGeneratedImage)
<th data-priority="1">Generated Image</th>
@endif
@endif
</tr>
</thead>
<tbody>
@ -240,6 +250,14 @@
return buttons;
}
},
@if(!empty($dataDesignerView))
@foreach($questions as $code => $question)
@if(isset($question->type) && $question->type == 'hidden')
@continue
@endif
{ "data": "{{$code}}", "defaultContent": "" },
@endforeach
@else
{ "data": "date" },
{ "data": "name" },
{ "data": "employee_code" },
@ -310,6 +328,7 @@
}
},
@endif
@endif
],
"initComplete": function(settings, json) {
var textBox = $('.dataTables_filter label input');

View File

@ -0,0 +1,443 @@
<!DOCTYPE html>
<html lang="en">
<head>
@include('layouts.shared/title-meta', ['title' => "Form"])
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
</head>
<div id="pageloader">
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
</div>
<body class="loading">
<div class="account-pages">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
<div class="card bg-pattern">
<div class="card-body p-3 row">
@if(Session::has('error'))<div class="alert alert-danger">{{Session::get('error')}}</div>
<br>@endif
@if(session('success'))<div class=" alert alert-success">{{ session('success') }}
</div>
<br>@endif
<div class="col-8">
<h4 class="page-title">{{$form->title}}</h4>
</div>
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
<div class="col-4">
@if($form->link_type == 'form')
<a href="/form/history" class="float-end pt-1">View History</a>
@else
<a href="{{url()->previous()}}" class="float-end pt-1">Back</a>
@endif
</div>
@endif
@if(isset($form->user_info))
<div class="col-12">
<h6>Submitted By: {{$form->user_info->name}}</h6>
</div>
@endif
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
<input type="hidden" name="form_id" value="{{$form_id}}">
@csrf
@if($id)
<input type="hidden" name="id" value="{{$id}}">
@endif
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
<div class="col-md-12 mb-2">
<label for="field-user_id" class="form-label"> Select User / Territory <span class="text-danger">*</span> </label>
<select class="form-control" id="field-user_id" name="user_id" required>
<option value=""> -- Select -- </option>
@foreach($form->users as $option)
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
@endforeach
</select>
<input type="hidden" id="field-hierarchy_id" name="hierarchy_id" value="">
</div>
@endif
@foreach($questions as $question)
<div class="col-md-12 mb-2">
<label for="field-{{$question->code}}" class="form-label">{{$question->question}} {!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!} </label>
@switch($question->type)
@case('hidden')
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
@break
@case('text')
@case('email')
@case('tel')
@case('date')
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}">
@break
@case('number')
<input type="{{$question->type}}" min="0" max="9999999999" step="1" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
@break
@case('textarea')
<textarea id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
@break
@case('dropdown')
<select class="form-control" id="field-{{$question->code}}" name="{{$question->code}}" {{$question->required == 'yes'?'required':'' }}>
<option value=""> -- Select -- </option>
@foreach($question->options as $option)
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
@endforeach
</select>
@break
@case('radio')
@foreach($question->options as $option)
<div class="form-check mb-2 form-check-success">
<input class="form-check-input" type="radio" name="{{$question->code}}" id="field-{{$question->code}}_{{$option->value}}" value="{{$option->value}}">
<label class="form-check-label" for="field-{{$question->code}}_{{$option->value}}">{{$option->display}}</label>
</div>
@endforeach
@break
@case('radiometrix')
@php
// Decode the first option's value to use as heading labels
$headings =
count($question->options) > 0
? json_decode($question->options[0]->value)
: [];
@endphp
{{-- Matrix Wrapper with Horizontal Scroll on Small Screens --}}
<div class="table-responsive">
<div class="d-table w-100">
{{-- Table Headers --}}
<div class="d-table-row font-weight-bold">
<div class="d-table-cell p-2" style="width: 150px;"></div>
{{-- Placeholder for row labels --}}
@foreach ($headings as $head)
<div class="d-table-cell text-center p-2">{{ $head }}
</div>
@endforeach
</div>
{{-- Table Rows --}}
@foreach ($question->options as $option)
@php $nn = json_decode($option->value); @endphp
<div class="d-table-row align-middle">
<div class="d-table-cell font-weight-bold p-2"
style="width: 150px;">
{{ $option->display }}
</div>
@foreach ($nn as $value)
<div class="d-table-cell text-center p-2">
<input type="radio"
id="field-{{ $option->display }}-{{ $value }}"
name="{{ $question->code }}[{{$option->display}}]" value="{{$value}}" class="form-check-input"
{{ isset($question->display) && $option->display != $option->display ? 'checked' : '' }}>
</div>
@endforeach
</div>
@endforeach
</div>
</div>
@break
@case('checkbox')
@foreach($question->options as $option)
<div class="form-check mb-2 form-check-primary ms-2">
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
</div>
@endforeach
@break
@case('file')
@if(!isset($form->is_approval) || $form->is_approval != 'yes')
@if($question->code == 'upload_photo')
<div id="photo-camera-container">
<video id="photo-camera-preview"
autoplay
playsinline
style="display:none; width:100%; max-height:350px; border-radius:8px;">
</video>
<img id="photo-captured-preview"
alt="Captured photo"
style="display:none; width:100%; max-height:350px; object-fit:contain;">
<input type="file"
id="field-upload_photo"
name="upload_photo"
accept="image/*"
data-required="{{$question->required == 'yes' ? '1' : '0'}}"
style="display:none;">
<div class="d-flex flex-wrap gap-2 mt-2">
<button type="button" id="start-photo-camera"
class="btn btn-primary">
Open Camera
</button>
<button type="button" id="capture-photo"
class="btn btn-success" style="display:none;">
Capture Photo
</button>
<button type="button" id="retake-photo"
class="btn btn-secondary" style="display:none;">
Retake Photo
</button>
</div>
</div>
@else
<input type="file"
id="field-{{$question->code}}"
name="{{$question->code}}"
class="form-control"
{{$question->required == 'yes' ? 'required' : ''}}>
@endif
@elseif(isset($question->value))
<img src="{{$question->value}}" class="img-fluid">
@endif
@break
@case('multitextbox')
<div class="row">
@foreach($question->options as $option)
<div class="col-6">{{$option->display}}</div>
<div class="col-6 mb-1">
<input type="number" id="field-{{$option->value}}" name="{{$option->value}}" class="form-control" required value="{{isset($option->val)?$option->val:0}}">
</div>
@endforeach
</div>
@break
@endswitch
</div>
@endforeach
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
<div class="text-center d-grid mt-3">
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
</div>
@endif
</form>
</div> <!-- end card-body -->
</div>
<!-- end card -->
<!-- end row -->
</div> <!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end container -->
</div>
<!-- end page -->
<style type="text/css">
#pageloader {
background: rgba( 255, 255, 255, 0.8 );
display: none;
height: 100%;
position: fixed;
width: 100%;
z-index: 9999;
}
#pageloader img {
left: 50%;
margin-left: -32px;
margin-top: -32px;
position: absolute;
top: 50%;
}
.form-label {
font-weight:bold;
font-size:16px;
}
</style>
@include('layouts.shared/footer-script')
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
$('#field-user_id').change(function(){
let hierarchy = $('option:selected', this).attr('hierarchy');
$('#field-hierarchy_id').val(hierarchy)
event.preventDefault();
$.ajax({
type: "GET",
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
processData: false,
contentType: false,
success: function( data ) {
$("#pageloader").fadeOut();
$('#field-contact_id').html('')
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
for(let itm of data) {
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display));
}
},
});
console.log(hierarchy)
})
$('#report-form').on('submit', function(event){
event.preventDefault();
const photoField = document.getElementById('field-upload_photo');
if (
photoField &&
photoField.dataset.required === '1' &&
photoField.files.length === 0
) {
Swal.fire({
icon: 'warning',
title: 'Photo Required',
text: 'Please open the camera and capture a photo before submitting.'
});
return;
}
$("#pageloader").fadeIn();
$.ajax({
type: "POST",
url: '/form/ajaxsubmit',
data: new FormData($('#report-form')[0]),
processData: false,
contentType: false,
success: function( data ) {
$("#pageloader").fadeOut();
if(data.status == 'success') {
Swal.fire({
title: 'Great!',
text: 'Your data is successfully submitted!',
icon: 'success'
})
$('#report-form').trigger("reset");
} else {
Swal.fire({
icon: 'error',
title: data.hasOwnProperty('message') ? 'You are not mapped to any position code' : 'Data not submitted',
text: data.hasOwnProperty('message') ? 'for resolution please email Position code, L1 Manager and L2 Manager details to support1@stratawiz.com':'Something went wrong, please try again after some time!'
})
}
},
});
});
var today = new Date();
var yyyy = today.getFullYear();
var mm = String(today.getMonth() + 1).padStart(2, '0');
var dd = String(today.getDate()).padStart(2, '0');
var currentDate = yyyy + '-' + mm + '-' + dd;
var dateField = document.getElementById('field-record_date');
if (dateField) {
dateField.value = currentDate;
dateField.setAttribute('readonly', 'readonly');
dateField.setAttribute('max', currentDate);
dateField.style.pointerEvents = 'none';
}
let photoStream = null;
const video = document.getElementById('photo-camera-preview');
const preview = document.getElementById('photo-captured-preview');
const photoInput = document.getElementById('field-upload_photo');
$('#start-photo-camera').on('click', async function () {
try {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
throw new Error('Camera access is not supported by this browser.');
}
photoStream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: { ideal: 'environment' } },
audio: false
});
video.srcObject = photoStream;
video.style.display = 'block';
preview.style.display = 'none';
$('#start-photo-camera').hide();
$('#capture-photo').show();
$('#retake-photo').hide();
} catch (error) {
Swal.fire({
icon: 'error',
title: 'Camera Unavailable',
text: 'Please allow camera access and try again.'
});
}
});
$('#capture-photo').on('click', function () {
if (!photoStream || !video.videoWidth) {
return;
}
const canvas = document.createElement('canvas');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(
video, 0, 0, canvas.width, canvas.height
);
canvas.toBlob(function (blob) {
if (!blob) {
Swal.fire('Error', 'Could not capture the photo.', 'error');
return;
}
const file = new File(
[blob],
'captured-photo.jpg',
{ type: 'image/jpeg' }
);
const transfer = new DataTransfer();
transfer.items.add(file);
photoInput.files = transfer.files;
preview.src = URL.createObjectURL(blob);
preview.style.display = 'block';
video.style.display = 'none';
stopPhotoCamera();
$('#capture-photo').hide();
$('#start-photo-camera').hide();
$('#retake-photo').show();
}, 'image/jpeg', 0.9);
});
$('#retake-photo').on('click', function () {
photoInput.value = '';
preview.src = '';
preview.style.display = 'none';
$('#retake-photo').hide();
$('#start-photo-camera').trigger('click');
});
function stopPhotoCamera() {
if (photoStream) {
photoStream.getTracks().forEach(track => track.stop());
photoStream = null;
}
video.srcObject = null;
}
window.addEventListener('beforeunload', stopPhotoCamera);
});
</script>
</body>
</html>

View File

@ -28,7 +28,7 @@
<br>
@endif
<div class="col-8">
<h4 class="page-title">Report Camp</h4>
<h4 class="page-title">TGICS (The Great Indian Cough Study - Dr Enrolment)</h4>
</div>
@if (!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'))
<div class="col-4">
@ -425,30 +425,36 @@
$('#execution-form-wrapper').hide()
function copyTgicsLink(text) {
if (navigator.clipboard && window.isSecureContext) {
return navigator.clipboard.writeText(text);
function fallbackCopy() {
return new Promise(function(resolve, reject) {
var textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-9999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var ok = document.execCommand('copy');
document.body.removeChild(textArea);
ok ? resolve() : reject();
} catch (err) {
document.body.removeChild(textArea);
reject(err);
}
});
}
return new Promise(function(resolve, reject) {
var textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-9999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var ok = document.execCommand('copy');
document.body.removeChild(textArea);
ok ? resolve() : reject();
} catch (err) {
document.body.removeChild(textArea);
reject(err);
}
});
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
return navigator.clipboard.writeText(text).catch(function() {
return fallbackCopy();
});
}
return fallbackCopy();
}
$(document).on('click', '.btn-copy-tgics-link', function() {
var link = $(this).data('link') || '';
var link = $(this).attr('data-link') || '';
var $btn = $(this);
if (!link) {
return;
@ -460,6 +466,11 @@
$btn.html(original);
}, 1500);
}).catch(function() {
var $input = $btn.closest('.input-group').find('.tgics-doctor-link');
if ($input.length) {
$input.trigger('focus');
$input[0].select();
}
Swal.fire({
icon: 'error',
title: 'Unable to copy',
@ -527,11 +538,7 @@
$('#execution-contact_id').val(docid) */
$('#execution-id').val(selected['id'])
toggleOtherQualification('execution');
})
$('#report-form').on('submit', function(event) {
@ -579,21 +586,29 @@
$('#field-other_qualification').prop({"required":false});
$('#field-other_qualification').parent().hide();
function toggleOtherQualification(prefix) {
var $qualification = $('#' + prefix + '-qualification');
var $other = $('#' + prefix + '-other_qualification');
if (!$qualification.length || !$other.length) {
return;
}
if ($qualification.val() === 'Others') {
$other.parent().show();
$other.prop('required', true);
} else {
$other.val('');
$other.prop('required', false);
$other.parent().hide();
}
}
$('#field-qualification').on('change',function(){
let dropDown=$('#field-qualification').val();
if(dropDown==='Others'){
$('#field-other_qualification').parent().show();
$('#field-other_qualification').prop({"required":true});
}
else{
$('#field-other_qualification').parent().hide();
$('#field-other_qualification').prop({"required":false});
}
})
toggleOtherQualification('field');
toggleOtherQualification('execution');
$('#field-qualification, #execution-qualification').on('change', function() {
var prefix = this.id.indexOf('execution-') === 0 ? 'execution' : 'field';
toggleOtherQualification(prefix);
});
$('#field-contact_id,#field-city_town,#field-state,#field-other_qualification').on('input', function () {

View File

@ -464,7 +464,7 @@
var workflowStatus = String(submission.workflow_status || '').toLowerCase();
if (info.supply_status === 'No' && info.submission_status === 'Order Taken') {
button = '<button type="button" class="btn btn-warning btn-xs edit-order" data-submission="' + payload + '">Edit</button>';
} else if (workflowStatus === 'rejected') {
} else if (workflowStatus === 'rejected' && info.submission_status === 'Rejected') {
button = '<button type="button" class="btn btn-warning btn-xs upload-invoice" data-submission="' + payload + '">Upload Invoice</button>';
}
return '<tr><td>' + button + '</td><td>' + esc(info.record_date || '') + '</td><td>' + esc(info.submission_status || '') + '</td><td>' + esc(info.total_pob_value || '') + '</td><td>' + esc(info.total_actual_pob_value || '') + '</td></tr>';

View File

@ -0,0 +1,65 @@
<div id="imageModal" class="image-modal" onclick="closeImageModal()">
<div class="image-modal-content" onclick="event.stopPropagation()">
<span class="image-modal-close" onclick="closeImageModal()">&times;</span>
<img id="modalImage" src="" alt="Uploaded photo" class="modal-image" />
</div>
</div>
<script>
function openImageModal(imageSrc) {
document.getElementById('modalImage').src = imageSrc;
document.getElementById('imageModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeImageModal() {
document.getElementById('imageModal').style.display = 'none';
document.body.style.overflow = 'auto';
}
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape') closeImageModal();
});
</script>
<style>
html, body.preview-approval-body { background: #fff; margin: 0; padding: 0; }
.approval-container { max-width: 900px; margin: 0 auto; padding: 16px 16px 24px; background: #fff; }
.approval-header { text-align: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 2px solid #f8f9fa; }
.approval-title { font-size: 1.6rem; font-weight: 600; margin-bottom: 8px; }
.approval-subtitle { color: #6c757d; font-size: 1rem; margin-bottom: 0; }
.preview-panel { background: #fff; border: 1px solid #dee2e6; border-radius: 8px; margin: 16px 0; overflow: hidden; }
.preview-panel > summary { list-style: none; cursor: pointer; }
.preview-panel > summary::-webkit-details-marker { display: none; }
.section-title {
background: #007bff; color: #fff; margin: 0; padding: 12px 40px 12px 16px;
font-size: 1.05rem; font-weight: 600; position: relative;
}
.section-title::after {
content: '+'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
font-size: 1.25rem; line-height: 1;
}
.preview-panel[open] > .section-title::after { content: '−'; }
.section-content { padding: 16px; }
.detail-row {
display: flex; justify-content: space-between; gap: 12px; padding: 8px 0;
border-bottom: 1px solid #f1f3f4;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { font-weight: 600; color: #495057; min-width: 140px; }
.detail-value { color: #212529; flex: 1; text-align: right; word-break: break-word; }
.request-letter-container { text-align: center; }
.request-letter-image {
max-width: 100%; max-height: 420px; border: 1px solid #dee2e6;
border-radius: 8px; cursor: pointer;
}
.image-modal {
display: none; position: fixed; z-index: 9999; left: 0; top: 0;
width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.9);
}
.image-modal-content {
position: relative; margin: auto; padding: 20px; width: 90%; height: 90%;
display: flex; align-items: center; justify-content: center;
}
.modal-image { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.image-modal-close {
position: absolute; top: 10px; right: 20px; color: #fff;
font-size: 36px; font-weight: bold; cursor: pointer;
}
</style>

View File

@ -0,0 +1,189 @@
<!DOCTYPE html>
<html lang="en">
<head>
@include('layouts.shared/title-meta', ['title' => $form->title ?? 'Chemist Survey'])
@include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
</head>
<body class="preview-approval-body">
@php
$byCode = [];
foreach ($questions ?? [] as $question) {
if (isset($question->code)) {
$byCode[$question->code] = $question;
}
}
$submitted = $submitted_formdata ?? null;
$val = function ($code) use ($byCode, $submitted) {
if (is_object($submitted) && isset($submitted->{$code}) && $submitted->{$code} !== '' && $submitted->{$code} !== null) {
return $submitted->{$code};
}
if (is_array($submitted) && isset($submitted[$code]) && $submitted[$code] !== '' && $submitted[$code] !== null) {
return $submitted[$code];
}
if (isset($byCode[$code]->value) && $byCode[$code]->value !== '' && $byCode[$code]->value !== null) {
return $byCode[$code]->value;
}
return '';
};
$show = function ($code) use ($val) {
$value = $val($code);
return $value !== '' && $value !== null ? $value : '—';
};
$fileUrl = function ($url) {
$url = trim((string) $url);
if ($url === '') {
return '';
}
if (!preg_match('#^https?://#i', $url)) {
return rtrim((string) env('AWS_URL'), '/') . '/' . ltrim($url, '/');
}
return $url;
};
$isImageUrl = function ($url) {
$ext = strtolower(pathinfo((string) parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION));
return in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'webp'], true);
};
$products = [
'Asthalin Inhaler' => 'asthalin_inhaler',
'Asthalin Rotacap' => 'asthalin_rotacap',
'Aerocort Inhaler' => 'aerocort_inhaler',
'Aerocort Rotacap' => 'aerocort_rotacap',
'Aerocort Forte Rotacap' => 'aerocort_forte_rotacap',
];
$therapies = [
'Nebulization Respules / Month' => 'neb_respules',
'Foracort Inhaler Units / Month' => 'foracort_inhaler_units',
'Foracort Rotacaps Units / Month' => 'foracort_rotacaps_units',
'Asthalin Syrup Units / Month' => 'asthalin_syrup_units',
'Levolin Syrup Units / Month' => 'levolin_syrup_units',
'Deriphyllin Units / Month' => 'deriphyllin_units',
'Betnesol Tablet Units / Month' => 'beclomethasone_units',
'Methylprednisolone Units / Month' => 'methylprednisolone_units',
'Prednisolone Units / Month' => 'prednisolone_units',
'Cough Syrups Units / Month' => 'cough_syrups_units',
];
$services = [
'BP Monitoring' => 'chemist_bp_monitoring',
'Weighing Machine' => 'chemist_weighing_machine',
'Nebulization' => 'chemist_nebulization',
];
$boardUrl = $fileUrl($val('chemist_board'));
@endphp
<div class="approval-container">
<div class="approval-header">
<h1 class="approval-title">Chemist Survey Review</h1>
<p class="approval-subtitle">Review the submitted chemist survey before you approve or reject</p>
@if(isset($form->user_info->name) && $form->user_info->name !== '')
<p class="text-muted mb-0">Submitted by: {{ $form->user_info->name }}</p>
@endif
</div>
<div class="preview-accordion">
<details class="preview-panel" open>
<summary class="section-title">Chemist details</summary>
<div class="section-content">
<div class="detail-row"><span class="detail-label">Date</span><span class="detail-value">{{ $show('record_date') }}</span></div>
<div class="detail-row"><span class="detail-label">Chemist Name</span><span class="detail-value">{{ $show('chemist_name') }}</span></div>
<div class="detail-row"><span class="detail-label">MSL Code</span><span class="detail-value">{{ $show('msl_code') }}</span></div>
<div class="detail-row"><span class="detail-label">Mobile Number</span><span class="detail-value">{{ $show('mobile_number') }}</span></div>
<div class="detail-row"><span class="detail-label">Chemist Address</span><span class="detail-value">{{ $show('chemist_location') }}</span></div>
<div class="detail-row"><span class="detail-label">Chemist Pincode</span><span class="detail-value">{{ $show('chemist_pincode') }}</span></div>
<div class="detail-row"><span class="detail-label">Chemist Type</span><span class="detail-value">{{ $show('chemist_type') }}</span></div>
<div class="detail-row"><span class="detail-label">Manager Joint Visit</span><span class="detail-value">{{ $show('manager_joint_visit') }}</span></div>
</div>
</details>
<details class="preview-panel" open>
<summary class="section-title">Chemist Board</summary>
<div class="section-content">
@if($boardUrl === '')
<p class="text-muted mb-0">No chemist board uploaded.</p>
@else
@if($isImageUrl($boardUrl))
<div class="request-letter-container">
<img src="{{ $boardUrl }}" alt="Chemist board" class="request-letter-image" onclick="openImageModal(@json($boardUrl))" />
</div>
@endif
<p class="text-center mt-2 mb-0"><a href="{{ $boardUrl }}" target="_blank" rel="noopener">Open chemist board</a></p>
@endif
</div>
</details>
<details class="preview-panel" open>
<summary class="section-title">RCPA details</summary>
<div class="section-content">
@foreach($products as $label => $code)
<div class="mb-3">
<div class="fw-semibold mb-1">{{ $label }}</div>
<div class="detail-row">
<span class="detail-label">Units / Month</span>
<span class="detail-value">{{ $show($code.'_units') }}</span>
</div>
@for($doctor = 1; $doctor <= 3; $doctor++)
@php
$docName = $val($code.'_doctor_'.$doctor.'_name');
$docCode = $val($code.'_doctor_'.$doctor.'_code');
@endphp
@if($docName !== '' || $docCode !== '')
<div class="detail-row">
<span class="detail-label">Doctor {{ $doctor }}</span>
<span class="detail-value">{{ trim(($docName !== '' ? $docName : '—').' / '.($docCode !== '' ? $docCode : '—')) }}</span>
</div>
@endif
@endfor
</div>
@endforeach
</div>
</details>
<details class="preview-panel">
<summary class="section-title">Stockist</summary>
<div class="section-content">
@foreach([1, 2] as $n)
<div class="mb-3">
<div class="fw-semibold mb-1">Stockist {{ $n }}</div>
<div class="detail-row"><span class="detail-label">Name</span><span class="detail-value">{{ $show('stockist_'.$n.'_name') }}</span></div>
<div class="detail-row"><span class="detail-label">Location</span><span class="detail-value">{{ $show('stockist_'.$n.'_location') }}</span></div>
<div class="detail-row"><span class="detail-label">ID</span><span class="detail-value">{{ $show('stockist_'.$n.'_id') }}</span></div>
<div class="detail-row"><span class="detail-label">Supply Frequency</span><span class="detail-value">{{ $show('stockist_'.$n.'_frequency') }}</span></div>
</div>
@endforeach
</div>
</details>
<details class="preview-panel">
<summary class="section-title">Other therapies</summary>
<div class="section-content">
@foreach($therapies as $label => $code)
<div class="detail-row">
<span class="detail-label">{{ $label }}</span>
<span class="detail-value">{{ $show($code) }}</span>
</div>
@endforeach
</div>
</details>
<details class="preview-panel">
<summary class="section-title">Services</summary>
<div class="section-content">
@foreach($services as $label => $code)
<div class="detail-row">
<span class="detail-label">{{ $label }}</span>
<span class="detail-value">
{{ $show($code) }}
@if($val($code) === 'Yes' && $val($code.'_charge') !== '')
({{ $val($code.'_charge') }})
@endif
</span>
</div>
@endforeach
</div>
</details>
</div>
</div>
@include('form.rapport-team3.partials.survey-preview-styles')
</body>
</html>

View File

@ -0,0 +1,178 @@
<!DOCTYPE html>
<html lang="en">
<head>
@include('layouts.shared/title-meta', ['title' => $form->title ?? 'Doctor Survey'])
@include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
</head>
<body class="preview-approval-body">
@php
$byCode = [];
foreach ($questions ?? [] as $question) {
if (isset($question->code)) {
$byCode[$question->code] = $question;
}
}
$submitted = $submitted_formdata ?? null;
$val = function ($code) use ($byCode, $submitted) {
if (is_object($submitted) && isset($submitted->{$code}) && $submitted->{$code} !== '' && $submitted->{$code} !== null) {
return $submitted->{$code};
}
if (is_array($submitted) && isset($submitted[$code]) && $submitted[$code] !== '' && $submitted[$code] !== null) {
return $submitted[$code];
}
if (isset($byCode[$code]->value) && $byCode[$code]->value !== '' && $byCode[$code]->value !== null) {
return $byCode[$code]->value;
}
return '';
};
$show = function ($code) use ($val) {
$value = $val($code);
return $value !== '' && $value !== null ? $value : '—';
};
$fileUrl = function ($url) {
$url = trim((string) $url);
if ($url === '') {
return '';
}
if (!preg_match('#^https?://#i', $url)) {
return rtrim((string) env('AWS_URL'), '/') . '/' . ltrim($url, '/');
}
return $url;
};
$isImageUrl = function ($url) {
$ext = strtolower(pathinfo((string) parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION));
return in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'webp'], true);
};
$products = [
'Asthalin Inhaler' => 'asthalin_inhaler',
'Asthalin Rotacap' => 'asthalin_rotacap',
'Aerocort Inhaler' => 'aerocort_inhaler',
'Aerocort Rotacap' => 'aerocort_rotacap',
'Aerocort Forte Rotacap' => 'aerocort_forte_rotacap',
];
$therapies = [
'Nebulization Respules / Month' => 'neb_respules',
'Foracort Inhaler Units / Month' => 'foracort_inhaler_units',
'Foracort Rotacaps Units / Month' => 'foracort_rotacaps_units',
'Asthalin Syrup Units / Month' => 'asthalin_syrup_units',
'Levolin Syrup Units / Month' => 'levolin_syrup_units',
'Deriphyllin Units / Month' => 'deriphyllin_units',
'Betnesol Tablet Units / Month' => 'beclomethasone_units',
'Methylprednisolone Units / Month' => 'methylprednisolone_units',
'Prednisolone Units / Month' => 'prednisolone_units',
'Cough Syrups Units / Month' => 'cough_syrups_units',
];
$photos = [
'Visiting Card' => 'visiting_card',
'Rx Pad' => 'rx_pad',
'Doctor Board' => 'doctor_board',
];
$degree = (string) $val('degree');
if (strcasecmp($degree, 'Other') === 0 && $val('doctor_other_degree') !== '') {
$degree = $val('doctor_other_degree');
}
$specialty = (string) $val('specialty');
if (strcasecmp($specialty, 'Other') === 0 && $val('doctor_other_speciality') !== '') {
$specialty = $val('doctor_other_speciality');
}
@endphp
<div class="approval-container">
<div class="approval-header">
<h1 class="approval-title">Doctor Survey Review</h1>
<p class="approval-subtitle">Review the submitted doctor survey before you approve or reject</p>
@if(isset($form->user_info->name) && $form->user_info->name !== '')
<p class="text-muted mb-0">Submitted by: {{ $form->user_info->name }}</p>
@endif
</div>
<div class="preview-accordion">
<details class="preview-panel" open>
<summary class="section-title">Doctor details</summary>
<div class="section-content">
<div class="detail-row"><span class="detail-label">Date</span><span class="detail-value">{{ $show('record_date') }}</span></div>
<div class="detail-row"><span class="detail-label">Doctor Name</span><span class="detail-value">{{ $show('doctor_name') }}</span></div>
<div class="detail-row"><span class="detail-label">MSL Code</span><span class="detail-value">{{ $show('msl_code') }}</span></div>
<div class="detail-row"><span class="detail-label">Registration Number</span><span class="detail-value">{{ $show('doctor_registration_number') }}</span></div>
<div class="detail-row"><span class="detail-label">Mobile Number</span><span class="detail-value">{{ $show('mobile_number') }}</span></div>
<div class="detail-row"><span class="detail-label">Legacy Code</span><span class="detail-value">{{ $show('legacy_code') }}</span></div>
<div class="detail-row"><span class="detail-label">Degree</span><span class="detail-value">{{ $degree !== '' ? $degree : '—' }}</span></div>
<div class="detail-row"><span class="detail-label">Specialty</span><span class="detail-value">{{ $specialty !== '' ? $specialty : '—' }}</span></div>
<div class="detail-row"><span class="detail-label">Doctor Address</span><span class="detail-value">{{ $show('doctor_location') }}</span></div>
<div class="detail-row"><span class="detail-label">Doctor Pincode</span><span class="detail-value">{{ $show('doctor_pincode') }}</span></div>
<div class="detail-row"><span class="detail-label">Doctor Type</span><span class="detail-value">{{ $show('doctor_type') }}</span></div>
<div class="detail-row"><span class="detail-label">Total Patients / Day</span><span class="detail-value">{{ $show('total_patients') }}</span></div>
<div class="detail-row"><span class="detail-label">Respiratory Patients / Day</span><span class="detail-value">{{ $show('respiratory_patients') }}</span></div>
<div class="detail-row"><span class="detail-label">Manager Joint Visit</span><span class="detail-value">{{ $show('manager_joint_visit') }}</span></div>
<div class="detail-row"><span class="detail-label">Attached Chemist</span><span class="detail-value">{{ $show('attached_chemist_name') }}</span></div>
<div class="detail-row"><span class="detail-label">No. of Staff</span><span class="detail-value">{{ $show('no_of_staff') }}</span></div>
</div>
</details>
<details class="preview-panel" open>
<summary class="section-title">Doctor Prescription</summary>
<div class="section-content p-0">
<table class="table table-sm mb-0">
<thead class="table-light">
<tr>
<th>Product</th>
<th>Prescribed</th>
<th class="text-end">Units / Month</th>
</tr>
</thead>
<tbody>
@foreach($products as $label => $code)
<tr>
<td>{{ $label }}</td>
<td>{{ $show($code) }}</td>
<td class="text-end">{{ $val($code.'_units') !== '' ? $val($code.'_units') : '—' }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</details>
<details class="preview-panel">
<summary class="section-title">Other therapies</summary>
<div class="section-content">
@foreach($therapies as $label => $code)
<div class="detail-row">
<span class="detail-label">{{ $label }}</span>
<span class="detail-value">{{ $show($code) }}</span>
</div>
@endforeach
</div>
</details>
<details class="preview-panel" open>
<summary class="section-title">Photos</summary>
<div class="section-content">
@php $anyPhoto = false; @endphp
@foreach($photos as $label => $code)
@php $url = $fileUrl($val($code)); @endphp
@if($url !== '')
@php $anyPhoto = true; @endphp
<div class="mb-3">
<div class="detail-label mb-2">{{ $label }}</div>
@if($isImageUrl($url))
<div class="request-letter-container">
<img src="{{ $url }}" alt="{{ $label }}" class="request-letter-image" onclick="openImageModal(@json($url))" />
</div>
@endif
<p class="text-center mt-2 mb-0"><a href="{{ $url }}" target="_blank" rel="noopener">Open {{ strtolower($label) }}</a></p>
</div>
@endif
@endforeach
@if(!$anyPhoto)
<p class="text-muted mb-0">No photos uploaded.</p>
@endif
</div>
</details>
</div>
</div>
@include('form.rapport-team3.partials.survey-preview-styles')
</body>
</html>