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

This commit is contained in:
zeeshan 2026-10-07 17:06:52 +05:30
commit 9e732ec091
10 changed files with 773 additions and 94 deletions

View File

@ -123,7 +123,7 @@ class ZenovaReportExport implements FromArray, WithEvents
if ($column['type'] === 'text') {
$sheet->getStyle($dataRange)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
} elseif ($column['type'] === 'percent') {
$sheet->getStyle($dataRange)->getNumberFormat()->setFormatCode('0.00"%"');
$sheet->getStyle($dataRange)->getNumberFormat()->setFormatCode('0.0"%"');
$sheet->getStyle($dataRange)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
} else {
$sheet->getStyle($dataRange)->getNumberFormat()->setFormatCode('#,##0');
@ -134,9 +134,9 @@ class ZenovaReportExport implements FromArray, WithEvents
$col += $span;
}
$sheet->getRowDimension(1)->setRowHeight(22);
$sheet->getRowDimension(1)->setRowHeight(36);
$sheet->getRowDimension(2)->setRowHeight(36);
$sheet->freezePane('A3');
$sheet->freezePane('C3');
if (!empty($this->totals)) {
$sheet->getStyle('A' . $rowCount . ':' . $lastCol . $rowCount)->applyFromArray([

View File

@ -56,6 +56,13 @@ class FormController extends Controller
return $value === true || $value === 1 || $value === '1' || $value === 'true';
}
protected function doctorChemistBladeId($formId) {
if ($formId === '1790230856-704c97b6-61f7-4eda-901a-2cb4ff6f293d') {
return '1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e';
}
return $formId;
}
protected function deliverform($formdata, $questions, $id = false) {
$additional_info = $this->get_additional_info($formdata);
// if($formdata->form_id == '1711609582-e93dba24-9c98-43e7-b97a-b22d64d9b9fc') {
@ -91,10 +98,11 @@ class FormController extends Controller
// return view('form.common', $data);
// }
if (\View::exists('form.'.$formdata->partition.'.'.$formdata->form_id)) {
return view('form.'.$formdata->partition.'.'.$formdata->form_id)->with($data);
} elseif (\View::exists('form.'.$formdata->form_id)) {
return view('form.'.$formdata->form_id)->with($data);
$viewId = $this->doctorChemistBladeId($formdata->form_id);
if (\View::exists('form.'.$formdata->partition.'.'.$viewId)) {
return view('form.'.$formdata->partition.'.'.$viewId)->with($data);
} elseif (\View::exists('form.'.$viewId)) {
return view('form.'.$viewId)->with($data);
} elseif(isset($formdata->form_type) && $formdata->form_type == 'enrollment_form'){
return view('form.common-enrollmentform', $data);
} elseif(isset($formdata->form_type) && $formdata->form_type == 'plan_vs_execution'){
@ -563,6 +571,11 @@ class FormController extends Controller
public function show(Request $request) {
$formdata = $request->session()->get('formdata');
//Log::debug(print_r($formdata, true));
$requestedFormId = $request->input('form_id', '');
if (is_string($requestedFormId) && $requestedFormId !== '') {
$formdata->form_id = $requestedFormId;
$request->session()->put('formdata', $formdata);
}
$id = $request->input('id', false);
$action = $request->input('action', false);
Log::debug(print_r(['form_id' => $formdata->form_id, 'user_id' => $formdata->user_id, 'partition' => $formdata->partition, 'id' => $id ], true));
@ -8345,6 +8358,34 @@ class FormController extends Controller
$data['incept_neb'] = $inceptService->withOrgTotals([], $formdata);
}
$doctorSurveyId = '1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e';
$chemistSurveyId = '1790230856-704c97b6-61f7-4eda-901a-2cb4ff6f293d';
if (in_array($form_id, [$doctorSurveyId, $chemistSurveyId], true)) {
$loadHistory = function ($id) use ($formdata, $form_id, $history) {
if ($id === $form_id) {
return $history;
}
return LambdaRequest::postrequest('form', 'formentity/getformhistory', ['form_id' => $id, 'user_id' => $formdata->user_id, 'partition' => $formdata->partition]);
};
$doctorHistory = $loadHistory($doctorSurveyId);
$chemistHistory = $loadHistory($chemistSurveyId);
$historyRows = function ($response) {
return [
'questions' => isset($response->data->questions) ? $response->data->questions : [],
'submissions' => isset($response->data->submissions) ? $response->data->submissions : [],
];
};
$doctorRows = $historyRows($doctorHistory);
$chemistRows = $historyRows($chemistHistory);
$data['doctor_form_id'] = $doctorSurveyId;
$data['chemist_form_id'] = $chemistSurveyId;
$data['doctor_questions'] = $doctorRows['questions'];
$data['doctor_submissions'] = $doctorRows['submissions'];
$data['chemist_questions'] = $chemistRows['questions'];
$data['chemist_submissions'] = $chemistRows['submissions'];
return view('form.'.$formdata->partition.'.'.$doctorSurveyId.'-history')->with($data);
}
if (\View::exists('form.'.$formdata->partition.'.'.$formdata->form_id.'-history')) {
return view('form.'.$formdata->partition.'.'.$formdata->form_id.'-history')->with($data);
} elseif (\View::exists('form.'.$formdata->form_id.'-history')) {
@ -8359,15 +8400,22 @@ class FormController extends Controller
public function edit(Request $request) {
$formdata = $request->session()->get('formdata');
//Log::debug(print_r($formdata, true));
$requestedFormId = $request->input('form_id', '');
if (is_string($requestedFormId) && $requestedFormId !== '') {
$formdata->form_id = $requestedFormId;
$request->session()->put('formdata', $formdata);
}
$id = $request->input('id', false);
//'user_id' => $formdata->user_id,
$finfo = LambdaRequest::postrequest('form', 'formentity/getformdefination', ['form_id' => $formdata->form_id, 'partition' => $formdata->partition, 'id' => $id ]);
$formdata->title = $finfo->data->formdata->title;
$formdata->formdata = $finfo->data->formdata;
//Log::debug(print_r($finfo->data->formdata, true));
if (\View::exists('form.'.$formdata->partition.'.'.$formdata->form_id)) {
return view('form.'.$formdata->partition.'.'.$formdata->form_id)->with(['questions' => $finfo->data->questions,'form_id' => $formdata->form_id, 'form' => $formdata, 'id' => $id, 'formdata' => $finfo->data->formdata ]);
} elseif (\View::exists('form.'.$formdata->form_id)) {
return view('form.'.$formdata->form_id)->with(['questions' => $finfo->data->questions,'form_id' => $formdata->form_id, 'form' => $formdata, 'id' => $id, 'formdata' => $finfo->data->formdata ]);
$viewId = $this->doctorChemistBladeId($formdata->form_id);
if (\View::exists('form.'.$formdata->partition.'.'.$viewId)) {
return view('form.'.$formdata->partition.'.'.$viewId)->with(['questions' => $finfo->data->questions,'form_id' => $formdata->form_id, 'form' => $formdata, 'id' => $id, 'formdata' => $finfo->data->formdata ]);
} elseif (\View::exists('form.'.$viewId)) {
return view('form.'.$viewId)->with(['questions' => $finfo->data->questions,'form_id' => $formdata->form_id, 'form' => $formdata, 'id' => $id, 'formdata' => $finfo->data->formdata ]);
} else {
return view('form.common')->with(['questions' => $finfo->data->questions, 'form_id' => $formdata->form_id, 'form' => $formdata, 'id' => $id, 'formdata' => $finfo->data->formdata ]);
}

View File

@ -23,7 +23,7 @@ class ZenovaReportController extends Controller
$this->_service = 'reports';
$this->_module = 'zenova_reports';
$this->_viewname = 'zenovareport';
$this->_title = 'Glipiq & Sitazit Dashboard';
$this->_title = 'Custom Dashboard';
$this->_base_url = '/zenovareport';
}
@ -35,11 +35,14 @@ class ZenovaReportController extends Controller
public function dashboard(Request $request)
{
$level = $this->level($request);
$built = $this->build($level);
$month = $this->month($request);
$built = $this->build($level, $month);
return view('zenovareport.dashboard', [
'title' => $this->_title,
'level' => $level,
'month' => $month,
'months' => $this->months(),
'groups' => $built['groups'],
'body' => $built['body'],
'totals' => $built['totals'],
@ -50,10 +53,11 @@ class ZenovaReportController extends Controller
public function export(Request $request)
{
$level = $this->level($request);
$built = $this->build($level);
$month = $this->month($request);
$built = $this->build($level, $month);
if ($built['error']) {
return redirect('/zenovareport/dashboard?level=' . $level)->with('error', $built['error']);
return redirect('/zenovareport/dashboard?level=' . $level . '&month=' . urlencode($month))->with('error', $built['error']);
}
return Excel::download(
@ -69,24 +73,51 @@ class ZenovaReportController extends Controller
return ($level >= 1 && $level <= 5) ? $level : 3;
}
private function build(int $level): array
private function months(): array
{
$now = now()->startOfMonth();
$startYear = $now->month >= 4 ? $now->year : $now->year - 1;
$cursor = now()->setDate($startYear, 4, 1)->startOfMonth();
$months = [];
while ($cursor->lte($now)) {
$months[$cursor->format('Y-m')] = $cursor->format('F Y');
$cursor->addMonth();
}
return $months;
}
private function month(Request $request): string
{
$months = $this->months();
$selected = (string) $request->input('month', '');
if (isset($months[$selected])) {
return $selected;
}
return (string) array_key_last($months);
}
private function build(int $level, string $month): array
{
$response = LambdaRequest::signedrequest(
'get',
'reports',
'zenova_reports/glipiqsitazit_report',
['level' => (string) $level],
['level' => (string) $level, 'month' => $month],
120
);
$rows = [];
$error = null;
if (!$response || ($response->status ?? '') !== 'success') {
$error = $response->message ?? 'Unable to load the Glipiq & Sitazit report.';
$error = $response->message ?? 'Unable to load the Custom Dashboard.';
} else {
$rows = is_array($response->data ?? null) ? $response->data : [];
}
$rows = $this->sortRows($rows);
$groups = $this->groups($rows);
$columns = [];
foreach ($groups as $group) {
@ -153,6 +184,70 @@ class ZenovaReportController extends Controller
];
}
private function sortRows(array $rows): array
{
usort($rows, function ($left, $right) {
$zoneLeft = $this->zoneName($left);
$zoneRight = $this->zoneName($right);
if ($zoneLeft === '' && $zoneRight !== '') {
return 1;
}
if ($zoneRight === '' && $zoneLeft !== '') {
return -1;
}
$zone = strcasecmp($zoneLeft, $zoneRight);
if ($zone !== 0) {
return $zone;
}
$users = $this->fsoCount($right) <=> $this->fsoCount($left);
if ($users !== 0) {
return $users;
}
return strcasecmp($this->rowName($left), $this->rowName($right));
});
return $rows;
}
private function zoneName($row): string
{
$parents = (array) ($row->parent_positions ?? []);
foreach ($parents as $key => $value) {
if (strcasecmp((string) $key, 'Zone') === 0 && $value !== null && $value !== '') {
return (string) $value;
}
}
$demo = (array) ($row->{'Demography & Details'} ?? []);
foreach ($demo as $key => $value) {
if (strcasecmp((string) $key, 'Name of Zone') === 0 && $value !== null && $value !== '') {
return (string) $value;
}
}
return '';
}
private function fsoCount($row): float
{
$value = $row->{'Demography & Details'}->{'No. of FSOs'} ?? 0;
return is_numeric($value) ? (float) $value : 0;
}
private function rowName($row): string
{
$demo = (array) ($row->{'Demography & Details'} ?? []);
foreach ($demo as $key => $value) {
if (strpos((string) $key, 'Name of ') === 0) {
return (string) $value;
}
}
return (string) ($row->position_name ?? '');
}
private function groups(array $rows): array
{
$nameKey = 'Name of Region';
@ -197,7 +292,7 @@ class ZenovaReportController extends Controller
];
$groups = [
['label' => 'Demography & Details', 'tone' => 'demo', 'columns' => $demoColumns],
['label' => 'Demography & Details (Data as per Yesterday)', 'tone' => 'demo', 'columns' => $demoColumns],
];
$first = isset($rows[0]) ? $rows[0] : null;
@ -247,10 +342,13 @@ class ZenovaReportController extends Controller
if (strcasecmp($currentType, $type) === 0) {
$column = $this->column($type, 'Demography & Details', $nameKey, 'text');
$column['is_total'] = true;
$columns[] = $column;
continue;
} else {
$column = $this->column($type, 'parent_positions', $type, 'text');
}
$columns[] = $this->column($type, 'parent_positions', $type, 'text');
if (in_array($type, ['Zone', 'Region'], true)) {
$column['sticky'] = strtolower($type);
}
$columns[] = $column;
}
return $columns;
@ -337,7 +435,7 @@ class ZenovaReportController extends Controller
}
$number = (float) $value;
if ($type === 'percent') {
return number_format($number, 2) . '%';
return number_format($number, 1) . '%';
}
if (floor($number) == $number) {
return number_format($number, 0);

View File

@ -101,14 +101,17 @@
@endif
</div>
<div class="mt-0">
<form method="POST" action="">
@if (session('message'))
<div class="alert alert-danger" role="alert">{{ session('message') }}</div>
@endif
<form method="POST" action="" id="otp-form">
@csrf
<div class="mb-2">
<label for="otp" class="form-label">OTP</label>
<input class="form-control" type="text" id="otp" name="otp" required="" placeholder="Enter OTP">
</div>
<div class="mb-3">
<button class="btn btn-primary btn-block waves-effect waves-light" type="submit"> Verify OTP </button>
<button class="btn btn-primary btn-block waves-effect waves-light" type="submit" id="verify-otp"> Verify OTP </button>
</div>
</form>
@ -136,7 +139,26 @@
</footer>
@include('layouts.shared/footer-script')
<script>
(function () {
var form = document.getElementById('otp-form');
var button = document.getElementById('verify-otp');
if (!form || !button) {
return;
}
var submitting = false;
form.addEventListener('submit', function (event) {
if (submitting) {
event.preventDefault();
return;
}
submitting = true;
setTimeout(function () {
button.disabled = true;
}, 0);
});
})();
</script>
</body>

View File

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
@include('layouts.shared/title-meta', ['title' => 'History'])
@include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
</head>
<body class="loading">
<div class="account-pages">
<div class="container">
<div class="row">
<div class="col-8 p-2">
<h4 class="page-title">Doctor & Chemist Survey</h4>
</div>
<div class="col-4 p-2">
<a href="/form/show?form_id={{ $doctor_form_id }}" class="float-end pt-1">New Submission</a>
</div>
</div>
@if(session()->has('message'))
<div class="alert alert-success">{{ session()->get('message') }}</div>
@endif
@if(session()->has('error'))
<div class="alert alert-danger">{{ session()->get('error') }}</div>
@endif
@foreach([
['title' => 'Doctor Survey', 'form_id' => $doctor_form_id, 'questions' => $doctor_questions, 'submissions' => $doctor_submissions],
['title' => 'Chemist Survey', 'form_id' => $chemist_form_id, 'questions' => $chemist_questions, 'submissions' => $chemist_submissions],
] as $section)
<div class="row">
<div class="col-12 p-0">
<div class="card">
<div class="card-body">
<h5 class="mb-3">{{ $section['title'] }}</h5>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Submission Date</th>
<th>Submitted By</th>
<th>Workflow Status</th>
@foreach($section['questions'] as $code => $question)
@if(($question->type ?? '') === 'hidden')
@continue
@endif
<th>{{ $question->label ?? $code }}</th>
@endforeach
<th>Action</th>
</tr>
</thead>
<tbody>
@forelse($section['submissions'] as $submission)
<tr>
<td>{{ date('d M Y', strtotime($submission->updatedAt ?? $submission->createdAt)) }}</td>
<td>{{ $submission->user_info->name ?? '' }}</td>
<td>{{ $submission->workflow_status ?? '' }}</td>
@foreach($section['questions'] as $code => $question)
@if(($question->type ?? '') === 'hidden')
@continue
@endif
@php
$cell = $submission->formdata->{$code} ?? '';
if (is_array($cell)) {
$cell = implode(', ', $cell);
} elseif (is_object($cell)) {
$cell = collect((array) $cell)->map(function ($val, $key) {
return $key.': '.$val;
})->implode(', ');
}
@endphp
<td>
@if(($question->type ?? '') === 'file' && $cell)
<a href="{{ $cell }}" target="_blank" rel="noopener">View</a>
@else
{{ $cell }}
@endif
</td>
@endforeach
<td>
<a href="/form/show?form_id={{ $section['form_id'] }}&id={{ $submission->id }}" class="btn btn-primary btn-xs">Edit</a>
</td>
</tr>
@empty
<tr>
<td colspan="4">No submissions</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
@include('layouts.shared/footer-script')
</body>
</html>

View File

@ -4,6 +4,7 @@
@include('layouts.shared/title-meta', ['title' => "Doctor & Chemist Survey"])
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
<link href="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
<style>
.quick-action-form-card .form-control { font-size: 16px; }
.survey-section { border: 1px solid #d9d9d9; border-radius: 0.25rem; margin-bottom: 0.75rem; }
@ -42,7 +43,8 @@
</div>
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
@csrf
<input type="hidden" name="form_id" id="field-form_id" value="1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e">
<input type="hidden" name="form_id" id="field-form_id" value="{{ $form_id ?? $form->form_id }}">
<input type="hidden" name="id" id="field-submission_id" value="{{ $id ?: '' }}">
<div class="mb-2">
<label class="form-label" for="field-record_date">Date <span class="text-danger">*</span></label>
@ -73,6 +75,34 @@
</div>
@include('layouts.shared/footer-script')
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
@php
$savedAnswers = [];
$savedSource = null;
if (!empty($id)) {
if (isset($formdata) && (is_object($formdata) || is_array($formdata))) {
$savedSource = $formdata;
} elseif (isset($form->formdata)) {
$savedSource = $form->formdata;
}
}
if (is_object($savedSource) || is_array($savedSource)) {
foreach ((array) $savedSource as $savedKey => $savedValue) {
if ($savedKey === 'title' || is_array($savedValue) || is_object($savedValue) || $savedValue === null || $savedValue === '') {
continue;
}
$savedAnswers[$savedKey] = $savedValue;
}
}
foreach (($questions ?? []) as $savedQuestion) {
if (!is_object($savedQuestion) || empty($savedQuestion->code)) {
continue;
}
if (!isset($savedAnswers[$savedQuestion->code]) && isset($savedQuestion->value) && $savedQuestion->value !== '' && !is_array($savedQuestion->value) && !is_object($savedQuestion->value)) {
$savedAnswers[$savedQuestion->code] = $savedQuestion->value;
}
}
@endphp
<script>
$(function () {
var doctorFormId = '1790230856-a5ff58a6-d509-4ac0-9b18-6d366a74965e';
@ -85,6 +115,10 @@ $(function () {
dateInput.max = today.getFullYear() + '-' + month + '-' + day;
var surveyContacts = [];
var contactsReady = false;
// Dev only: open every section. Set to false to lock later sections until the previous step is complete.
var unlockAllSections = true;
var savedAnswers = @json($savedAnswers);
var photoFields = ['visiting_card', 'rx_pad', 'doctor_board', 'chemist_board'];
function activeRoot() {
return $('#field-visit_type').val() === 'chemist' ? '#chemist-fields' : '#doctor-fields';
@ -102,7 +136,7 @@ $(function () {
var section = $(this);
section.toggleClass('locked', !open);
section.find(':input').prop('disabled', !open);
if (!open) {
if (!open || unlockAllSections) {
return;
}
var gates = section.find('[data-gate]');
@ -112,6 +146,7 @@ $(function () {
});
syncOtherFields();
syncServiceFields();
syncProductUnits();
}
function syncOtherFields() {
@ -146,6 +181,20 @@ $(function () {
});
}
function syncProductUnits() {
$('#doctor-fields .product-row').each(function () {
var row = $(this);
var show = row.find('.product-choice').val() === 'Yes' && !$('#doctor-fields').prop('disabled');
var units = row.find('.product-units');
units.toggle(show);
var input = units.find('input');
input.prop('required', show).prop('disabled', !show);
if (!show) {
input.val('');
}
});
}
function fillSelect(select, contacts) {
var current = select.value;
select.innerHTML = '<option value="">-- Select --</option>';
@ -161,6 +210,12 @@ $(function () {
option.setAttribute('data-stockist-id', contact.stockist_id || '');
select.appendChild(option);
});
if (select.classList.contains('stockist-pick')) {
var other = document.createElement('option');
other.value = 'others';
other.textContent = 'Others';
select.appendChild(other);
}
if (current) {
select.value = current;
}
@ -180,11 +235,16 @@ $(function () {
return item.contact && String(item.contact.type || '').toLowerCase() === 'ebt_stockist';
});
document.querySelectorAll('#chemist-fields .rcpa-doctor').forEach(function (select) {
if ($(select).data('select2')) {
$(select).select2('destroy');
}
fillSelect(select, doctors);
});
document.querySelectorAll('#chemist-fields .stockist-pick').forEach(function (select) {
fillSelect(select, stockists);
});
matchSavedContacts();
initDoctorSearch();
},
error: function () {
contactsReady = true;
@ -192,7 +252,11 @@ $(function () {
});
}
var doctorLock = false;
function applyDoctor(select) {
if (doctorLock) {
return;
}
var row = $(select).closest('tr');
var option = select.options[select.selectedIndex];
var chosen = select.value;
@ -204,22 +268,30 @@ $(function () {
}
});
if (duplicate) {
select.value = '';
option = select.options[0];
doctorLock = true;
$(select).val('').trigger('change');
doctorLock = false;
row.find('.rcpa-name, .rcpa-mobile, .rcpa-speciality, .rcpa-code').val('');
fail('This doctor is already selected for this product.');
return;
}
}
row.find('.rcpa-name').val(select.value ? option.textContent : '');
row.find('.rcpa-mobile').val(select.value ? (option.getAttribute('data-phone') || '') : '');
row.find('.rcpa-speciality').val(select.value ? (option.getAttribute('data-speciality') || '') : '');
row.find('.rcpa-code').val(select.value ? (option.getAttribute('data-code') || '') : '');
if (!chosen || !option) {
row.find('.rcpa-name, .rcpa-mobile, .rcpa-speciality, .rcpa-code').val('');
return;
}
row.find('.rcpa-name').val(option.textContent || '');
row.find('.rcpa-mobile').val(option.getAttribute('data-phone') || '');
row.find('.rcpa-speciality').val(option.getAttribute('data-speciality') || '');
row.find('.rcpa-code').val(option.getAttribute('data-code') || '');
}
function applyStockist(select) {
function applyStockist(select, keepAddress) {
var block = $(select).closest('.stockist-block');
var option = select.options[select.selectedIndex];
var chosen = select.value;
if (chosen) {
var isOther = chosen === 'others';
if (chosen && !isOther) {
var duplicate = false;
$('#chemist-fields .stockist-pick').each(function () {
if (this !== select && this.value === chosen) {
@ -228,13 +300,33 @@ $(function () {
});
if (duplicate) {
select.value = '';
chosen = '';
isOther = false;
option = select.options[0];
fail('This stockist is already selected.');
}
}
block.find('.stockist-name').val(select.value ? option.textContent : '');
block.find('.stockist-location').val(select.value ? (option.getAttribute('data-location') || '') : '');
block.find('.stockist-id').val(select.value ? (option.getAttribute('data-stockist-id') || '') : '');
var location = block.find('.stockist-location');
var otherName = block.find('.stockist-other-name');
block.find('.stockist-other').toggle(isOther);
block.find('.stockist-id-wrap').toggle(!isOther);
location.prop('readonly', !isOther).prop('required', isOther).attr('tabindex', isOther ? null : '-1');
otherName.prop('required', isOther);
block.find('.stockist-address-label').html(isOther
? 'Other Stockist Address <span class="text-danger">*</span>'
: 'Stockist ' + (select.getAttribute('data-slot') || '') + ' Location');
if (isOther) {
block.find('.stockist-name').val(otherName.val());
block.find('.stockist-id').val('');
if (!keepAddress) {
location.val('');
}
return;
}
otherName.val('').prop('required', false);
block.find('.stockist-name').val(chosen ? option.textContent : '');
location.val(chosen ? (option.getAttribute('data-location') || '') : '');
block.find('.stockist-id').val(chosen ? (option.getAttribute('data-stockist-id') || '') : '');
}
function setVisit(type) {
@ -242,10 +334,174 @@ $(function () {
$('#doctor-fields').prop('disabled', !doctor).toggle(doctor);
$('#chemist-fields').prop('disabled', doctor).toggle(!doctor);
$('#field-form_id').val(doctor ? doctorFormId : chemistFormId);
$('#field-doctor_name').val(doctor ? ($('#field-doctor_name').val() || 'Dr. ') : $('#field-doctor_name').val());
if (doctor && !$('#field-doctor_name').val()) {
$('#field-doctor_name').val('Dr. ');
}
if (doctor) {
lockDoctorPrefix();
}
refreshSections();
if (doctor) {
$('#chemist-fields .rcpa-doctor').each(function () {
if ($(this).data('select2')) {
$(this).select2('destroy');
}
});
} else {
initDoctorSearch();
}
}
function initDoctorSearch() {
if ($('#field-visit_type').val() !== 'chemist') {
return;
}
$('#chemist-fields .rcpa-doctor').each(function () {
var field = $(this);
if (field.data('select2')) {
field.select2('destroy');
}
field.select2({
width: '100%',
dropdownParent: $('.quick-action-form-card'),
placeholder: '-- Select --',
allowClear: true
});
});
}
function lockDoctorPrefix() {
var input = document.getElementById('field-doctor_name');
if (!input || input.value.indexOf('Dr. ') === 0) {
return;
}
var rest = input.value.replace(/^Dr\.\s*/i, '');
var caret = input.selectionStart || 0;
input.value = 'Dr. ' + rest;
var next = Math.max(4, caret);
if (document.activeElement === input) {
input.setSelectionRange(next, next);
}
}
function showSavedPhoto(field, url) {
var link = document.createElement('a');
link.href = url;
link.target = '_blank';
link.rel = 'noopener';
link.className = 'd-block mt-1';
link.textContent = 'View current photo';
field.parentNode.appendChild(link);
field.removeAttribute('required');
if (!field.parentNode.querySelector('input.saved-file[name="' + field.name + '"]')) {
var hidden = document.createElement('input');
hidden.type = 'hidden';
hidden.name = field.name;
hidden.value = url;
hidden.className = 'saved-file';
field.parentNode.appendChild(hidden);
}
}
function applySaved() {
if (!$('#field-submission_id').val()) {
return;
}
var root = $(activeRoot());
Object.keys(savedAnswers).forEach(function (code) {
if (photoFields.indexOf(code) !== -1 || /_charge$/.test(code)) {
return;
}
var fields = root.find('[name="' + code + '"]');
if (!fields.length && code === 'record_date') {
fields = $('#field-record_date');
}
fields.each(function () {
if (this.type === 'file') {
return;
}
if (this.type === 'radio' || this.type === 'checkbox') {
this.checked = this.value === String(savedAnswers[code]);
} else {
this.value = savedAnswers[code];
}
});
});
if ($('#field-visit_type').val() !== 'chemist') {
lockDoctorPrefix();
}
refreshSections();
Object.keys(savedAnswers).forEach(function (code) {
if (!/_charge$/.test(code)) {
return;
}
root.find('[name="' + code + '"]').val(savedAnswers[code]);
});
photoFields.forEach(function (code) {
if (!savedAnswers[code]) {
return;
}
var field = document.getElementById('field-' + code);
if (!field || !root.find(field).length) {
return;
}
showSavedPhoto(field, savedAnswers[code]);
});
}
function selectSavedOption(select, label) {
if (!label) {
return;
}
for (var i = 0; i < select.options.length; i++) {
if (select.options[i].textContent === label) {
select.value = select.options[i].value;
return;
}
}
var option = document.createElement('option');
option.value = label;
option.textContent = label;
select.appendChild(option);
select.value = label;
}
function matchSavedContacts() {
if (!$('#field-submission_id').val() || $('#field-visit_type').val() !== 'chemist') {
return;
}
document.querySelectorAll('#chemist-fields .rcpa-doctor').forEach(function (select) {
selectSavedOption(select, $(select).closest('tr').find('.rcpa-name').val());
});
document.querySelectorAll('#chemist-fields .stockist-pick').forEach(function (select) {
var block = $(select).closest('.stockist-block');
var name = block.find('.stockist-name').val();
if (!name) {
return;
}
var matched = false;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i].value !== 'others' && select.options[i].textContent === name) {
select.value = select.options[i].value;
matched = true;
break;
}
}
if (!matched) {
select.value = 'others';
block.find('.stockist-other-name').val(name);
applyStockist(select, true);
return;
}
applyStockist(select, true);
});
}
$('#field-doctor_name').on('input', lockDoctorPrefix);
$('#doctor-fields').on('change', '.product-choice', syncProductUnits);
$('#chemist-fields').on('input', '.stockist-other-name', function () {
$(this).closest('.stockist-block').find('.stockist-name').val(this.value);
});
$('#field-visit_type').on('change', function () { setVisit(this.value); });
$('#report-form').on('input change', '.survey-section :input', refreshSections);
$('#chemist-fields').on('change', '.rcpa-doctor', function () { applyDoctor(this); refreshSections(); });
@ -266,6 +522,20 @@ $(function () {
return /^[A-Za-z0-9]+$/.test(value);
}
function addressOk(value) {
return /^[A-Za-z0-9]+(?:[ ]+[A-Za-z0-9]+)*$/.test(value);
}
function therapiesFilled(root) {
var filled = false;
$(root).find('.therapy-units').each(function () {
if (this.value !== '') {
filled = true;
}
});
return filled;
}
function mobileTaken(type, mobile) {
return surveyContacts.some(function (item) {
var contact = item.contact || {};
@ -305,12 +575,12 @@ $(function () {
fail('Contact list is still loading. Please try again.');
return;
}
if (mobileTaken('ebt_doctor', $('#field-mobile_number').val())) {
if (!$('#field-submission_id').val() && mobileTaken('ebt_doctor', $('#field-mobile_number').val())) {
fail('A doctor with this mobile number already exists.');
return;
}
if (!alphaOk($('#field-doctor_location').val().trim())) {
fail('Doctor location can contain letters, spaces and periods only.');
if (!addressOk($('#field-doctor_location').val().trim())) {
fail('Doctor address can contain letters, numbers and spaces only.');
return;
}
if (!/^[1-9][0-9]{5}$/.test($('#field-doctor_pincode').val())) {
@ -325,6 +595,24 @@ $(function () {
fail('Enter the other specialty in letters only.');
return;
}
var missingUnits = false;
$('#doctor-fields .product-choice').each(function () {
if ($(this).val() !== 'Yes') {
return;
}
var units = $(this).closest('.product-row').find('.product-units input').val();
if (units === '' || !/^\d+$/.test(units)) {
missingUnits = true;
}
});
if (missingUnits) {
fail('Enter the number of units in a month for each product marked Yes. 0 is allowed.');
return;
}
if (!therapiesFilled('#doctor-fields')) {
fail('Enter at least one other therapy. 0 is allowed.');
return;
}
var photos = ['visiting_card', 'rx_pad', 'doctor_board'];
var hasPhoto = false;
for (var i = 0; i < photos.length; i++) {
@ -336,13 +624,18 @@ $(function () {
return;
}
}
if (!hasPhoto) {
var savedDoctorPhoto = $('#field-submission_id').val() && photoFields.slice(0, 3).some(function (code) { return savedAnswers[code]; });
if (!hasPhoto && !savedDoctorPhoto) {
fail('Upload at least one of visiting card, Rx pad or doctor board.');
return;
}
} else {
if (!alphaOk($('#field-chemist_name').val().trim()) || !alphaOk($('#field-chemist_location').val().trim())) {
fail('Chemist name and location can contain letters, spaces and periods only.');
if (!alphaOk($('#field-chemist_name').val().trim())) {
fail('Chemist name can contain letters, spaces and periods only.');
return;
}
if (!addressOk($('#field-chemist_location').val().trim())) {
fail('Chemist address can contain letters, numbers and spaces only.');
return;
}
if (!/^[6-9][0-9]{9}$/.test($('#field-chemist_mobile').val())) {
@ -353,18 +646,29 @@ $(function () {
fail('Contact list is still loading. Please try again.');
return;
}
if (mobileTaken('ebt_chemist', $('#field-chemist_mobile').val())) {
if (!$('#field-submission_id').val() && mobileTaken('ebt_chemist', $('#field-chemist_mobile').val())) {
fail('A chemist with this mobile number already exists.');
return;
}
var missingDoctor = false;
$('#chemist-fields .rcpa-doctor[data-slot="1"]').each(function () {
if (!this.value) {
missingDoctor = true;
var badStockist = false;
$('#chemist-fields .stockist-pick').each(function () {
if (this.value !== 'others') {
return;
}
var block = $(this).closest('.stockist-block');
var otherName = block.find('.stockist-other-name').val().trim();
var otherAddress = block.find('.stockist-location').val().trim();
block.find('.stockist-name').val(otherName);
if (!addressOk(otherName) || !addressOk(otherAddress)) {
badStockist = true;
}
});
if (missingDoctor) {
fail('Select doctor 1 for each product.');
if (badStockist) {
fail('Other stockist name and address can contain letters, numbers and spaces only.');
return;
}
if (!therapiesFilled('#chemist-fields')) {
fail('Enter at least one other therapy. 0 is allowed.');
return;
}
var missingCharge = false;
@ -382,12 +686,20 @@ $(function () {
return;
}
var board = document.getElementById('field-chemist_board').files[0];
if (!board || !/\.(jpe?g|png)$/i.test(board.name) || board.size > 10 * 1024 * 1024) {
if (board && (!/\.(jpe?g|png)$/i.test(board.name) || board.size > 10 * 1024 * 1024)) {
fail('Chemist board must be a JPG, JPEG or PNG no larger than 10 MB.');
return;
}
if (!board && !($('#field-submission_id').val() && savedAnswers.chemist_board)) {
fail('Chemist board must be a JPG, JPEG or PNG no larger than 10 MB.');
return;
}
}
var emptyFiles = $('#report-form input[type="file"]').filter(function () {
return !this.files || !this.files.length;
});
emptyFiles.prop('disabled', true);
$('#pageloader').css('display', 'flex').hide().fadeIn();
$.ajax({
type: 'POST',
@ -396,24 +708,32 @@ $(function () {
processData: false,
contentType: false,
success: function (data) {
emptyFiles.prop('disabled', false);
$('#pageloader').fadeOut();
if (data.status == 'success') {
Swal.fire({ title: 'Great!', text: 'Your data is successfully submitted!', icon: 'success' });
$('#report-form .saved-file').remove();
$('#report-form a').filter(function () { return $(this).text() === 'View current photo'; }).remove();
$('#report-form')[0].reset();
setVisit('doctor');
$('#field-submission_id').val('').attr('value', '');
$('#field-visit_type').val('doctor');
setVisit('doctor');
} else {
Swal.fire({ icon: 'error', title: 'Data not submitted', text: 'Please try again.' });
}
},
error: function () {
emptyFiles.prop('disabled', false);
$('#pageloader').fadeOut();
Swal.fire({ icon: 'error', title: 'Data not submitted', text: 'Please try again.' });
}
});
});
setVisit('doctor');
var openingType = ($('#field-form_id').val() === chemistFormId || @json($form->form_id ?? '') === chemistFormId) ? 'chemist' : 'doctor';
$('#field-visit_type').val(openingType);
setVisit(openingType);
applySaved();
loadContacts();
});
</script>

View File

@ -21,21 +21,21 @@ $services = ['BP Monitoring' => 'chemist_bp_monitoring','Weighing Machine' => 'c
<div class="section-body">
<div class="mb-2"><label class="form-label">Chemist Name <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-chemist_name" name="chemist_name" data-gate required></div>
<div class="mb-2"><label class="form-label">Mobile Number <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-chemist_mobile" name="mobile_number" inputmode="numeric" maxlength="10" data-gate required></div>
<div class="mb-2"><label class="form-label">Chemist Location <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-chemist_location" name="chemist_location" data-gate required></div>
<div class="mb-2"><label class="form-label">Chemist Address <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-chemist_location" name="chemist_location" data-gate required></div>
<div class="mb-2"><label class="form-label">Chemist Pincode <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-chemist_pincode" name="chemist_pincode" inputmode="numeric" maxlength="6" data-gate required></div>
<div class="mb-2"><label class="form-label">Chemist Type <span class="text-danger">*</span></label><select class="form-control" name="chemist_type" data-gate required><option value="">-- Select --</option>@foreach($chemistTypes as $item)<option value="{{$item}}">{{$item}}</option>@endforeach</select></div>
<div class="mb-2"><label class="form-label" for="field-chemist_manager_joint_visit">Manager (EBM) Joint Visit Status <span class="text-danger">*</span></label><select class="form-control" id="field-chemist_manager_joint_visit" name="manager_joint_visit" data-gate required><option value="">-- Select --</option><option value="Yes">Yes</option><option value="No">No</option></select></div>
</div>
</div>
<div class="survey-section locked">
<div class="survey-section">
<button type="button" class="section-head">Upload photo</button>
<div class="section-body">
<div class="mb-2"><label class="form-label">Chemist Board <span class="text-danger">*</span></label><input type="file" class="form-control" id="field-chemist_board" name="chemist_board" accept=".jpg,.jpeg,.png,image/jpeg,image/png" data-gate required></div>
<div class="mb-2"><label class="form-label">Chemist Board <span class="text-danger">*</span></label><input type="file" class="form-control" id="field-chemist_board" name="chemist_board" accept=".jpg,.jpeg,.png,image/jpeg,image/png" capture="environment" data-gate required></div>
</div>
</div>
<div class="survey-section locked">
<div class="survey-section">
<button type="button" class="section-head">RCPA details</button>
<div class="section-body">
@foreach($products as $label => $code)
@ -45,7 +45,7 @@ $services = ['BP Monitoring' => 'chemist_bp_monitoring','Weighing Machine' => 'c
<table class="table table-sm align-middle mb-0 rcpa-doctors">
<thead>
<tr>
<th>Name</th>
<th>Prescribing Dr</th>
<th>Mobile</th>
<th>Speciality</th>
<th>Code</th>
@ -55,7 +55,7 @@ $services = ['BP Monitoring' => 'chemist_bp_monitoring','Weighing Machine' => 'c
@foreach([1, 2, 3] as $doctor)
<tr data-product="{{$code}}">
<td>
<select class="form-control rcpa-doctor" data-product="{{$code}}" data-slot="{{$doctor}}" aria-label="Doctor {{$doctor}} name" @if($doctor === 1) data-gate required @endif>
<select class="form-control rcpa-doctor" data-product="{{$code}}" data-slot="{{$doctor}}" aria-label="Prescribing Dr {{$doctor}}">
<option value="">-- Select --</option>
</select>
<input type="hidden" name="{{$code}}_doctor_{{$doctor}}_name" class="rcpa-name">
@ -72,30 +72,32 @@ $services = ['BP Monitoring' => 'chemist_bp_monitoring','Weighing Machine' => 'c
</div>
</div>
<div class="survey-section locked">
<div class="survey-section">
<button type="button" class="section-head">Stockist</button>
<div class="section-body">
@foreach([1,2] as $n)
<div class="stockist-block mb-3" data-slot="{{$n}}">
<div class="mb-2"><label class="form-label">Stockist {{$n}} Name</label><select class="form-control stockist-pick" data-slot="{{$n}}"><option value="">-- Select --</option></select><input type="hidden" name="stockist_{{$n}}_name" class="stockist-name"></div>
<div class="mb-2"><label class="form-label">Stockist {{$n}} Location</label><input type="text" class="form-control stockist-location" name="stockist_{{$n}}_location" readonly tabindex="-1"></div>
<div class="mb-2"><label class="form-label">Stockist {{$n}} ID</label><input type="text" class="form-control stockist-id" name="stockist_{{$n}}_id" readonly tabindex="-1"></div>
<div class="mb-2"><label class="form-label">Frequency of Supply</label><input type="number" min="0" step="1" class="form-control" name="stockist_{{$n}}_frequency"></div>
<div class="mb-2 stockist-other" style="display:none"><label class="form-label">Other Stockist Name <span class="text-danger">*</span></label><input type="text" class="form-control stockist-other-name"></div>
<div class="mb-2"><label class="form-label stockist-address-label">Stockist {{$n}} Location</label><input type="text" class="form-control stockist-location" name="stockist_{{$n}}_location" readonly tabindex="-1"></div>
<div class="mb-2 stockist-id-wrap"><label class="form-label">Stockist {{$n}} ID</label><input type="text" class="form-control stockist-id" name="stockist_{{$n}}_id" readonly tabindex="-1"></div>
<div class="mb-2"><label class="form-label">Frequency of Supply (No. of times in a Month)</label><input type="number" min="0" step="1" class="form-control" name="stockist_{{$n}}_frequency"></div>
</div>
@endforeach
</div>
</div>
<div class="survey-section locked">
<div class="survey-section">
<button type="button" class="section-head">Other therapies</button>
<div class="section-body">
<p class="text-muted">Enter at least one. 0 is allowed. <span class="text-danger">*</span></p>
@foreach($therapies as $label => $code)
<div class="mb-2"><label class="form-label">{{$label}}</label><input type="number" min="0" step="1" class="form-control" name="{{$code}}"></div>
<div class="mb-2"><label class="form-label">{{$label}}</label><input type="number" min="0" step="1" class="form-control therapy-units" name="{{$code}}"></div>
@endforeach
</div>
</div>
<div class="survey-section locked">
<div class="survey-section">
<button type="button" class="section-head">Services</button>
<div class="section-body">
@foreach($services as $label => $code)

View File

@ -17,7 +17,7 @@ $products = ['Asthalin Inhaler' => 'asthalin_inhaler','Asthalin Rotacap' => 'ast
<div class="mb-2" id="wrap-other_degree" style="display:none"><label class="form-label">Other Degree <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-other_degree" name="other_degree" disabled></div>
<div class="mb-2"><label class="form-label">Specialty <span class="text-danger">*</span></label><select class="form-control" id="field-specialty" name="specialty" data-gate required><option value="">-- Select --</option>@foreach($specialties as $item)<option value="{{$item}}">{{$item}}</option>@endforeach</select></div>
<div class="mb-2" id="wrap-other_specialty" style="display:none"><label class="form-label">Other Specialty <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-other_specialty" name="other_specialty" disabled></div>
<div class="mb-2"><label class="form-label">Doctor Location <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-doctor_location" name="doctor_location" data-gate required></div>
<div class="mb-2"><label class="form-label">Doctor Address <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-doctor_location" name="doctor_location" data-gate required></div>
<div class="mb-2"><label class="form-label">Doctor Pincode <span class="text-danger">*</span></label><input type="text" class="form-control" id="field-doctor_pincode" name="doctor_pincode" inputmode="numeric" maxlength="6" data-gate required></div>
<div class="mb-2"><label class="form-label">Doctor Type <span class="text-danger">*</span></label><select class="form-control" id="field-doctor_type" name="doctor_type" data-gate required><option value="">-- Select --</option>@foreach($doctorTypes as $item)<option value="{{$item}}">{{$item}}</option>@endforeach</select></div>
<div class="mb-2"><label class="form-label">No. of Total Patients Seen in a Day <span class="text-danger">*</span></label><select class="form-control" name="total_patients" data-gate required><option value="">-- Select --</option>@foreach($bands as $item)<option value="{{$item}}">{{$item}}</option>@endforeach</select></div>
@ -26,7 +26,7 @@ $products = ['Asthalin Inhaler' => 'asthalin_inhaler','Asthalin Rotacap' => 'ast
</div>
</div>
<div class="survey-section locked">
<div class="survey-section">
<button type="button" class="section-head">Chemist details</button>
<div class="section-body">
<div class="mb-2"><label class="form-label">Attached Chemist Name (If any)</label><input type="text" class="form-control" name="attached_chemist_name"></div>
@ -34,21 +34,49 @@ $products = ['Asthalin Inhaler' => 'asthalin_inhaler','Asthalin Rotacap' => 'ast
</div>
</div>
<div class="survey-section locked">
<button type="button" class="section-head">Is the Doctor Prescriber of our Products?</button>
<div class="survey-section">
<button type="button" class="section-head">Doctor Prescription (No. of Units in a Month)</button>
<div class="section-body">
@foreach($products as $label => $code)
<div class="mb-2"><label class="form-label">{{$label}} <span class="text-danger">*</span></label><select class="form-control" name="{{$code}}" data-gate required><option value="">-- Select --</option><option value="Yes">Yes</option><option value="No">No</option></select></div>
<div class="mb-2 product-row">
<label class="form-label">{{$label}} <span class="text-danger">*</span></label>
<select class="form-control product-choice" name="{{$code}}" data-gate required><option value="">-- Select --</option><option value="Yes">Yes</option><option value="No">No</option></select>
<div class="mt-2 product-units" style="display:none">
<label class="form-label">No. of Units in a Month <span class="text-danger">*</span></label>
<input type="number" min="0" step="1" class="form-control" name="{{$code}}_units" disabled>
</div>
</div>
@endforeach
</div>
</div>
<div class="survey-section locked">
<button type="button" class="section-head">Upload photos</button>
<div class="survey-section">
<button type="button" class="section-head">Other therapies</button>
<div class="section-body">
<p class="text-muted">Upload one of visiting card, Rx pad or doctor board. JPG, JPEG or PNG, max 10 MB.</p>
<div class="mb-2"><label class="form-label">Visiting Card</label><input type="file" class="form-control" id="field-visiting_card" name="visiting_card" accept=".jpg,.jpeg,.png,image/jpeg,image/png"></div>
<div class="mb-2"><label class="form-label">Rx Pad</label><input type="file" class="form-control" id="field-rx_pad" name="rx_pad" accept=".jpg,.jpeg,.png,image/jpeg,image/png"></div>
<div class="mb-2"><label class="form-label">Doctor Board</label><input type="file" class="form-control" id="field-doctor_board" name="doctor_board" accept=".jpg,.jpeg,.png,image/jpeg,image/png"></div>
<p class="text-muted">Enter at least one. 0 is allowed. <span class="text-danger">*</span></p>
@foreach([
'Nebulization No. of Respules per Month (all included)' => 'neb_respules',
'Foracort Inhaler No. of Units per Month' => 'foracort_inhaler_units',
'Foracort Rotacaps No. of Units per Month' => 'foracort_rotacaps_units',
'Asthalin Syrup No. of Units per Month' => 'asthalin_syrup_units',
'Levolin Syrup No. of Units per Month' => 'levolin_syrup_units',
'Deriphyllin No. of Units per Month' => 'deriphyllin_units',
'Beclomethasone Tablet No. of Units per Month' => 'beclomethasone_units',
'Methylprednisolone Tablet No. of Units per Month' => 'methylprednisolone_units',
'Prednisolone Tablet No. of Units per Month' => 'prednisolone_units',
'Cough Syrups No. of Units per Month' => 'cough_syrups_units',
] as $label => $code)
<div class="mb-2"><label class="form-label">{{$label}}</label><input type="number" min="0" step="1" class="form-control therapy-units" name="{{$code}}"></div>
@endforeach
</div>
</div>
<div class="survey-section">
<button type="button" class="section-head">Upload photos</button>
<div class="section-body">
<p class="text-muted">Upload one of visiting card, Rx pad or doctor board. JPG, JPEG or PNG, max 10 MB. <span class="text-danger">*</span></p>
<div class="mb-2"><label class="form-label">Visiting Card</label><input type="file" class="form-control" id="field-visiting_card" name="visiting_card" accept=".jpg,.jpeg,.png,image/jpeg,image/png" capture="environment"></div>
<div class="mb-2"><label class="form-label">Rx Pad</label><input type="file" class="form-control" id="field-rx_pad" name="rx_pad" accept=".jpg,.jpeg,.png,image/jpeg,image/png" capture="environment"></div>
<div class="mb-2"><label class="form-label">Doctor Board</label><input type="file" class="form-control" id="field-doctor_board" name="doctor_board" accept=".jpg,.jpeg,.png,image/jpeg,image/png" capture="environment"></div>
</div>
</div>

View File

@ -194,7 +194,7 @@
<a href="/zenovareport/dashboard">
<i data-feather="file-text"></i>
<span>
Glipiq &amp; Sitazit </span>
Custom Dashboard </span>
</a>
</li>
@endif

View File

@ -27,9 +27,47 @@
}
.zenova-table thead tr:first-child th {
top: 0;
height: 56px;
}
.zenova-table thead tr:nth-child(2) th {
top: 34px;
top: 56px;
}
.zenova-table thead tr:nth-child(2) th.sticky-zone,
.zenova-table tbody td.sticky-zone {
position: sticky;
left: 0;
min-width: 160px;
width: 160px;
background: #fff;
}
.zenova-table thead tr:nth-child(2) th.sticky-region,
.zenova-table tbody td.sticky-region {
position: sticky;
left: 160px;
min-width: 160px;
width: 160px;
background: #fff;
box-shadow: 2px 0 0 #e5e7eb;
}
.zenova-table tbody td.sticky-zone,
.zenova-table tbody td.sticky-region {
z-index: 1;
}
.zenova-table tr.totals td.sticky-zone,
.zenova-table tr.totals td.sticky-region {
background: #f8f9fa;
}
.zenova-table thead tr:first-child th.sticky-group {
position: sticky;
left: 0;
z-index: 6;
min-width: 320px;
white-space: normal;
box-shadow: 2px 0 0 #e5e7eb;
}
.zenova-table thead th.sticky-zone,
.zenova-table thead th.sticky-region {
z-index: 5;
}
.zenova-table td {
text-align: right;
@ -54,11 +92,15 @@
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-6 p-2">
<h4 class="page-title">{{ $title }}</h4>
</div>
<div class="col-md-6 p-2 d-flex justify-content-end align-items-center">
<form method="get" action="/zenovareport/dashboard" class="d-flex align-items-center gap-2">
<div class="col-12 p-2 d-flex flex-wrap justify-content-between align-items-center gap-2">
<h4 class="page-title mb-0">{{ $title }}</h4>
<form method="get" action="/zenovareport/dashboard" class="d-flex flex-wrap align-items-center gap-2">
<label for="month" class="mb-0">Month</label>
<select class="form-select" name="month" id="month" style="width: 160px;" onchange="this.form.submit()">
@foreach ($months as $value => $label)
<option value="{{ $value }}" {{ $month === $value ? 'selected' : '' }}>{{ $label }}</option>
@endforeach
</select>
<label for="level" class="mb-0">Level</label>
<select class="form-select" name="level" id="level" style="width: 110px;" onchange="this.form.submit()">
@for ($option = 1; $option <= 5; $option++)
@ -67,9 +109,13 @@
</option>
@endfor
</select>
<a href="/zenovareport/export?level={{ $level }}" class="btn btn-primary">Export</a>
<a href="/zenovareport/dashboard?level={{ $level }}&month={{ $month }}" class="btn btn-outline-secondary">Refresh</a>
<a href="/zenovareport/export?level={{ $level }}&month={{ $month }}" class="btn btn-primary">Export</a>
</form>
</div>
<div class="col-12 px-2">
<p class="text-muted mb-2">Please refresh before downloading the latest report.</p>
</div>
</div>
@if (session()->has('error'))
@ -86,15 +132,31 @@
<thead>
<tr>
@foreach ($groups as $group)
<th class="tone-{{ $group['tone'] }}" colspan="{{ count($group['columns']) }}">
{{ $group['label'] }}
</th>
@php
$stickyCount = 0;
foreach ($group['columns'] as $column) {
if (!empty($column['sticky'])) {
$stickyCount++;
}
}
$scrollCount = count($group['columns']) - $stickyCount;
@endphp
@if ($stickyCount > 0)
<th class="tone-{{ $group['tone'] }} sticky-group" colspan="{{ $stickyCount }}">
{{ $group['label'] }}
</th>
@endif
@if ($scrollCount > 0)
<th class="tone-{{ $group['tone'] }}" colspan="{{ $scrollCount }}">
{{ $stickyCount > 0 ? '' : $group['label'] }}
</th>
@endif
@endforeach
</tr>
<tr>
@foreach ($groups as $group)
@foreach ($group['columns'] as $column)
<th class="tone-{{ $group['tone'] }} {{ $column['type'] === 'text' ? 'text-cell' : '' }}">
<th class="tone-{{ $group['tone'] }} {{ $column['type'] === 'text' ? 'text-cell' : '' }} {{ !empty($column['sticky']) ? 'sticky-'.$column['sticky'] : '' }}">
{{ $column['label'] }}
</th>
@endforeach
@ -107,7 +169,7 @@
@php $cellIndex = 0; @endphp
@foreach ($groups as $group)
@foreach ($group['columns'] as $column)
<td class="{{ $column['type'] === 'text' ? 'text-cell' : '' }}">
<td class="{{ $column['type'] === 'text' ? 'text-cell' : '' }} {{ !empty($column['sticky']) ? 'sticky-'.$column['sticky'] : '' }}">
{{ $line[$cellIndex] ?? '' }}
</td>
@php $cellIndex++; @endphp
@ -126,7 +188,7 @@
@php $cellIndex = 0; @endphp
@foreach ($groups as $group)
@foreach ($group['columns'] as $column)
<td class="{{ $column['type'] === 'text' ? 'text-cell' : '' }}">
<td class="{{ $column['type'] === 'text' ? 'text-cell' : '' }} {{ !empty($column['sticky']) ? 'sticky-'.$column['sticky'] : '' }}">
{{ $totals[$cellIndex] ?? '' }}
</td>
@php $cellIndex++; @endphp