Changes
This commit is contained in:
parent
cc2b8cfba2
commit
c50a203bca
|
|
@ -18,6 +18,14 @@ class AdherencePobDriveExport
|
||||||
|
|
||||||
private const PINK = 'F8CBAD';
|
private const PINK = 'F8CBAD';
|
||||||
|
|
||||||
|
private const RED = 'C00000';
|
||||||
|
|
||||||
|
private const MAROON = '8A1538';
|
||||||
|
|
||||||
|
private const WHITE = 'FFFFFF';
|
||||||
|
|
||||||
|
private const BLUE = '0000FF';
|
||||||
|
|
||||||
/** @var array<int, mixed> */
|
/** @var array<int, mixed> */
|
||||||
private $abmRows;
|
private $abmRows;
|
||||||
|
|
||||||
|
|
@ -170,7 +178,8 @@ class AdherencePobDriveExport
|
||||||
}
|
}
|
||||||
$headers = array_merge($headers, $summary);
|
$headers = array_merge($headers, $summary);
|
||||||
$this->writeValues($sheet, 7, $headers);
|
$this->writeValues($sheet, 7, $headers);
|
||||||
$this->styleHeaderRow($sheet, 7, $lastCol);
|
$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->paintDayTypes($sheet, 5, $dayStart, false);
|
||||||
$this->paintDayHeaders($sheet, 7, $dayStart, false);
|
$this->paintDayHeaders($sheet, 7, $dayStart, false);
|
||||||
|
|
||||||
|
|
@ -195,7 +204,7 @@ class AdherencePobDriveExport
|
||||||
$rowNumber++;
|
$rowNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->finishSheet($sheet, 7, max(7, $rowNumber - 1), $lastCol, $dayStart);
|
$this->finishSheet($sheet, 7, max(7, $rowNumber - 1), $lastCol, $dayStart, 14);
|
||||||
$sheet->freezePane('A8');
|
$sheet->freezePane('A8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,7 +247,7 @@ class AdherencePobDriveExport
|
||||||
if (count($columns) >= 2 && $columns[count($columns) - 1]['kind'] === 'total-chemist') {
|
if (count($columns) >= 2 && $columns[count($columns) - 1]['kind'] === 'total-chemist') {
|
||||||
$sheet->mergeCells($this->col($lastCol - 1) . '2:' . $this->col($lastCol) . '2');
|
$sheet->mergeCells($this->col($lastCol - 1) . '2:' . $this->col($lastCol) . '2');
|
||||||
}
|
}
|
||||||
$this->styleHeaderRow($sheet, 4, $lastCol);
|
$this->styleHeaderRow($sheet, 4, $lastCol, 3, $lastCol - 1);
|
||||||
$this->paintRegionDayMarks($sheet, $columns);
|
$this->paintRegionDayMarks($sheet, $columns);
|
||||||
|
|
||||||
$rowNumber = 5;
|
$rowNumber = 5;
|
||||||
|
|
@ -271,7 +280,7 @@ class AdherencePobDriveExport
|
||||||
$rowNumber++;
|
$rowNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->finishSheet($sheet, 4, max(4, $rowNumber - 1), $lastCol, 4);
|
$this->finishSheet($sheet, 4, max(4, $rowNumber - 1), $lastCol, 4, 13);
|
||||||
$sheet->freezePane('A5');
|
$sheet->freezePane('A5');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,7 +307,7 @@ class AdherencePobDriveExport
|
||||||
}
|
}
|
||||||
$headers[] = 'Total Chemists Qualified (≥₹15k POB)';
|
$headers[] = 'Total Chemists Qualified (≥₹15k POB)';
|
||||||
$this->writeValues($sheet, 5, $headers);
|
$this->writeValues($sheet, 5, $headers);
|
||||||
$this->styleHeaderRow($sheet, 5, $totalCol);
|
$this->styleHeaderRow($sheet, 5, $totalCol, 3, $totalCol);
|
||||||
$this->paintDayTypes($sheet, 3, $dayStart, true);
|
$this->paintDayTypes($sheet, 3, $dayStart, true);
|
||||||
$this->paintDayHeaders($sheet, 5, $dayStart, true);
|
$this->paintDayHeaders($sheet, 5, $dayStart, true);
|
||||||
|
|
||||||
|
|
@ -322,7 +331,7 @@ class AdherencePobDriveExport
|
||||||
$rowNumber++;
|
$rowNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->finishSheet($sheet, 5, max(5, $rowNumber - 1), $totalCol, $dayStart);
|
$this->finishSheet($sheet, 5, max(5, $rowNumber - 1), $totalCol, $dayStart, 13);
|
||||||
$sheet->freezePane('A6');
|
$sheet->freezePane('A6');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -672,7 +681,9 @@ class AdherencePobDriveExport
|
||||||
private function paintDayHeaders($sheet, int $row, int $startColumn, bool $singleColumn): void
|
private function paintDayHeaders($sheet, int $row, int $startColumn, bool $singleColumn): void
|
||||||
{
|
{
|
||||||
foreach ($this->dayTemplate as $index => $day) {
|
foreach ($this->dayTemplate as $index => $day) {
|
||||||
$this->paintCell($sheet, $this->col($startColumn + $index) . $row, $day['type'] === 'H' ? self::GREY : self::GREEN);
|
$cell = $this->col($startColumn + $index) . $row;
|
||||||
|
$this->paintCell($sheet, $cell, $day['type'] === 'H' ? self::GREY : self::GREEN);
|
||||||
|
$sheet->getStyle($cell)->getFont()->setBold(true)->setSize(11)->getColor()->setARGB('000000');
|
||||||
}
|
}
|
||||||
if ($singleColumn) {
|
if ($singleColumn) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -704,6 +715,7 @@ class AdherencePobDriveExport
|
||||||
$color = $column['type'] === 'H' ? self::GREY : self::GREEN;
|
$color = $column['type'] === 'H' ? self::GREY : self::GREEN;
|
||||||
$this->paintCell($sheet, $cell . '2', $color);
|
$this->paintCell($sheet, $cell . '2', $color);
|
||||||
$this->paintCell($sheet, $cell . '4', $color);
|
$this->paintCell($sheet, $cell . '4', $color);
|
||||||
|
$sheet->getStyle($cell . '4')->getFont()->setBold(true)->setSize(11)->getColor()->setARGB('000000');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -726,23 +738,40 @@ class AdherencePobDriveExport
|
||||||
|
|
||||||
private function paintCell($sheet, string $cell, string $color): void
|
private function paintCell($sheet, string $cell, string $color): void
|
||||||
{
|
{
|
||||||
$sheet->getStyle($cell)->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB($color);
|
$style = $sheet->getStyle($cell);
|
||||||
|
$style->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB($color);
|
||||||
|
$style->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function styleHeaderRow($sheet, int $row, int $lastColumn): void
|
private function styleHeaderRow($sheet, int $row, int $lastColumn, int $identityCount, int $summaryStart): void
|
||||||
{
|
{
|
||||||
$range = 'A' . $row . ':' . $this->col($lastColumn) . $row;
|
$range = 'A' . $row . ':' . $this->col($lastColumn) . $row;
|
||||||
$sheet->getStyle($range)->getFont()->setBold(true);
|
|
||||||
$sheet->getStyle($range)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_CENTER)->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
$sheet->getStyle($range)->getAlignment()->setWrapText(true)->setVertical(Alignment::VERTICAL_CENTER)->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||||
$sheet->getRowDimension($row)->setRowHeight(32);
|
$sheet->getRowDimension($row)->setRowHeight(36);
|
||||||
|
if ($identityCount > 0) {
|
||||||
|
$this->paintHeaderGroup($sheet, $row, 1, $identityCount, self::RED, 10);
|
||||||
|
}
|
||||||
|
if ($summaryStart > $identityCount && $summaryStart <= $lastColumn) {
|
||||||
|
$this->paintHeaderGroup($sheet, $row, $summaryStart, $lastColumn, self::MAROON, 9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function finishSheet($sheet, int $headerRow, int $lastRow, int $lastColumn, int $dayStart): void
|
private function paintHeaderGroup($sheet, int $row, int $start, int $end, string $color, int $size): void
|
||||||
{
|
{
|
||||||
$range = 'A1:' . $this->col($lastColumn) . $lastRow;
|
$range = $this->col($start) . $row . ':' . $this->col($end) . $row;
|
||||||
$sheet->getStyle($range)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
$style = $sheet->getStyle($range);
|
||||||
|
$style->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB($color);
|
||||||
|
$style->getFont()->setName('Century Gothic')->setBold(true)->setSize($size)->getColor()->setARGB(self::WHITE);
|
||||||
|
$style->getAlignment()->setWrapText(true)->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function finishSheet($sheet, int $headerRow, int $lastRow, int $lastColumn, int $dayStart, int $titleSize = 14): void
|
||||||
|
{
|
||||||
|
$sheet->getStyle('A1')->getFont()->setName('Century Gothic')->setBold(true)->setSize($titleSize)->getColor()->setARGB(self::MAROON);
|
||||||
|
if ($lastRow > 1) {
|
||||||
|
$sheet->getStyle('A2:' . $this->col($lastColumn) . $lastRow)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
}
|
||||||
$sheet->getStyle('A' . $headerRow . ':' . $this->col($lastColumn) . $lastRow)->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
|
$sheet->getStyle('A' . $headerRow . ':' . $this->col($lastColumn) . $lastRow)->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
|
||||||
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
|
|
||||||
for ($column = 1; $column <= $lastColumn; $column++) {
|
for ($column = 1; $column <= $lastColumn; $column++) {
|
||||||
$width = $column < $dayStart ? 22 : 14;
|
$width = $column < $dayStart ? 22 : 14;
|
||||||
$sheet->getColumnDimension($this->col($column))->setWidth($width);
|
$sheet->getColumnDimension($this->col($column))->setWidth($width);
|
||||||
|
|
|
||||||
|
|
@ -5883,7 +5883,8 @@ class FormController extends Controller
|
||||||
$replaceSubmissionId = $post['__replace_submission_id'] ?? '';
|
$replaceSubmissionId = $post['__replace_submission_id'] ?? '';
|
||||||
$deleteReason = $post['__delete_reason'] ?? '';
|
$deleteReason = $post['__delete_reason'] ?? '';
|
||||||
$reasonCode = $post['__reason_code'] ?? '';
|
$reasonCode = $post['__reason_code'] ?? '';
|
||||||
unset($post['__replace_submission_id'], $post['__delete_reason'], $post['__reason_code'], $post['reason_field_code']);
|
$deleteReasons = is_array($post['__delete_reasons'] ?? null) ? $post['__delete_reasons'] : [];
|
||||||
|
unset($post['__replace_submission_id'], $post['__delete_reason'], $post['__reason_code'], $post['__delete_reasons'], $post['reason_field_code'], $post['replace_submission_id']);
|
||||||
Log::debug(print_r($post, true));
|
Log::debug(print_r($post, true));
|
||||||
$finfo = LambdaRequest::postrequest('form', 'formentity/submitform', ['formdata' => $post, 'entity_id' => $formdata->form_id, 'user_id' => $formdata->user_id, 'partition' => $formdata->partition ]);
|
$finfo = LambdaRequest::postrequest('form', 'formentity/submitform', ['formdata' => $post, 'entity_id' => $formdata->form_id, 'user_id' => $formdata->user_id, 'partition' => $formdata->partition ]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|
@ -5904,7 +5905,8 @@ class FormController extends Controller
|
||||||
$formdata->form_id,
|
$formdata->form_id,
|
||||||
$replaceSubmissionId,
|
$replaceSubmissionId,
|
||||||
$reasonCode,
|
$reasonCode,
|
||||||
$deleteReason
|
$deleteReason,
|
||||||
|
$deleteReasons
|
||||||
);
|
);
|
||||||
if (!$marked) {
|
if (!$marked) {
|
||||||
return response()->json(['status' => 'failure', 'message' => 'The new entry was saved, but the previous entry could not be marked Deleted.']);
|
return response()->json(['status' => 'failure', 'message' => 'The new entry was saved, but the previous entry could not be marked Deleted.']);
|
||||||
|
|
@ -8027,7 +8029,7 @@ class FormController extends Controller
|
||||||
return response()->json($allapprovers->data->approvals);
|
return response()->json($allapprovers->data->approvals);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function markMotherForumSubmissionDeleted($partition, $userId, $formId, $submissionId, $reasonCode, $reason): bool
|
protected function markMotherForumSubmissionDeleted($partition, $userId, $formId, $submissionId, $reasonCode, $reason, array $reasons = []): bool
|
||||||
{
|
{
|
||||||
$loaded = LambdaRequest::postrequest('form', 'formentity/getformdefination', [
|
$loaded = LambdaRequest::postrequest('form', 'formentity/getformdefination', [
|
||||||
'form_id' => $formId,
|
'form_id' => $formId,
|
||||||
|
|
@ -8044,7 +8046,11 @@ class FormController extends Controller
|
||||||
$previous['id'] = $submissionId;
|
$previous['id'] = $submissionId;
|
||||||
$previous['form_id'] = $formId;
|
$previous['form_id'] = $formId;
|
||||||
$previous['record_status'] = 'Deleted';
|
$previous['record_status'] = 'Deleted';
|
||||||
if ($reasonCode !== '') {
|
if ($reasons !== []) {
|
||||||
|
foreach ($reasons as $code => $value) {
|
||||||
|
$previous[$code] = $value;
|
||||||
|
}
|
||||||
|
} elseif ($reasonCode !== '') {
|
||||||
$previous[$reasonCode] = $reason;
|
$previous[$reasonCode] = $reason;
|
||||||
}
|
}
|
||||||
$saved = LambdaRequest::postrequest('form', 'formentity/submitform', [
|
$saved = LambdaRequest::postrequest('form', 'formentity/submitform', [
|
||||||
|
|
@ -8061,8 +8067,53 @@ class FormController extends Controller
|
||||||
switch($form) {
|
switch($form) {
|
||||||
case '1791539482-b06c2f9a-fe45-4b16-843a-224f07ed0d7b':
|
case '1791539482-b06c2f9a-fe45-4b16-843a-224f07ed0d7b':
|
||||||
$reasonCode = trim((string) ($post['reason_field_code'] ?? ''));
|
$reasonCode = trim((string) ($post['reason_field_code'] ?? ''));
|
||||||
unset($post['reason_field_code']);
|
$replaceFromMonth = trim((string) ($post['replace_submission_id'] ?? ''));
|
||||||
|
unset($post['reason_field_code'], $post['replace_submission_id']);
|
||||||
$post['record_status'] = 'Active';
|
$post['record_status'] = 'Active';
|
||||||
|
if ($replaceFromMonth !== '' && empty($post['id'])) {
|
||||||
|
$loaded = LambdaRequest::postrequest('form', 'formentity/getformdefination', [
|
||||||
|
'form_id' => $form,
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'partition' => $partition,
|
||||||
|
'id' => $replaceFromMonth,
|
||||||
|
]);
|
||||||
|
$previous = json_decode(json_encode($loaded->data->formdata ?? new \stdClass()), true);
|
||||||
|
if (!is_array($previous) || $previous === []) {
|
||||||
|
$post['__error'] = 'Unable to load the entry being changed.';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$previousStatus = trim((string) ($previous['record_status'] ?? 'Active'));
|
||||||
|
if (strcasecmp($previousStatus, 'Deleted') === 0) {
|
||||||
|
$post['__error'] = 'This entry has been replaced and can no longer be changed.';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$reasons = [];
|
||||||
|
for ($slot = 1; $slot <= 5; $slot++) {
|
||||||
|
$previousContact = trim((string) ($previous['contact_id_'.$slot] ?? ''));
|
||||||
|
$nextContact = trim((string) ($post['contact_id_'.$slot] ?? ''));
|
||||||
|
if ($previousContact === '' || $previousContact === $nextContact) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$reason = trim((string) ($post['reason_'.$slot] ?? ''));
|
||||||
|
if ($reason === '') {
|
||||||
|
$post['__error'] = 'Enter the reason for deletion for doctor '.$slot.'.';
|
||||||
|
break 2;
|
||||||
|
}
|
||||||
|
$reasons['reason_'.$slot] = $reason;
|
||||||
|
}
|
||||||
|
$baseId = trim((string) ($previous['base_submission_id'] ?? ''));
|
||||||
|
if ($baseId === '') {
|
||||||
|
$baseId = $replaceFromMonth;
|
||||||
|
}
|
||||||
|
for ($slot = 1; $slot <= 5; $slot++) {
|
||||||
|
$post['reason_'.$slot] = '';
|
||||||
|
}
|
||||||
|
$post['record_status'] = 'Active';
|
||||||
|
$post['base_submission_id'] = $baseId;
|
||||||
|
$post['__replace_submission_id'] = $replaceFromMonth;
|
||||||
|
$post['__delete_reasons'] = $reasons;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (empty($post['id'])) {
|
if (empty($post['id'])) {
|
||||||
$post['base_submission_id'] = '';
|
$post['base_submission_id'] = '';
|
||||||
break;
|
break;
|
||||||
|
|
@ -8084,24 +8135,32 @@ class FormController extends Controller
|
||||||
$post['__error'] = 'This entry has been replaced and can no longer be edited.';
|
$post['__error'] = 'This entry has been replaced and can no longer be edited.';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$reason = trim((string) ($reasonCode !== '' ? ($post[$reasonCode] ?? '') : ''));
|
$reasons = [];
|
||||||
if ($reason === '') {
|
for ($slot = 1; $slot <= 5; $slot++) {
|
||||||
$post['__error'] = 'Enter the reason for deletion.';
|
$previousContact = trim((string) ($previous['contact_id_'.$slot] ?? ''));
|
||||||
break;
|
$nextContact = trim((string) ($post['contact_id_'.$slot] ?? ''));
|
||||||
|
if ($previousContact === '' || $previousContact === $nextContact) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$reason = trim((string) ($post['reason_'.$slot] ?? ''));
|
||||||
|
if ($reason === '') {
|
||||||
|
$post['__error'] = 'Enter the reason for deletion for doctor '.$slot.'.';
|
||||||
|
break 2;
|
||||||
|
}
|
||||||
|
$reasons['reason_'.$slot] = $reason;
|
||||||
}
|
}
|
||||||
$baseId = trim((string) ($previous['base_submission_id'] ?? ''));
|
$baseId = trim((string) ($previous['base_submission_id'] ?? ''));
|
||||||
if ($baseId === '') {
|
if ($baseId === '') {
|
||||||
$baseId = $previousId;
|
$baseId = $previousId;
|
||||||
}
|
}
|
||||||
unset($post['id']);
|
unset($post['id']);
|
||||||
|
for ($slot = 1; $slot <= 5; $slot++) {
|
||||||
|
$post['reason_'.$slot] = '';
|
||||||
|
}
|
||||||
$post['record_status'] = 'Active';
|
$post['record_status'] = 'Active';
|
||||||
$post['base_submission_id'] = $baseId;
|
$post['base_submission_id'] = $baseId;
|
||||||
if ($reasonCode !== '') {
|
|
||||||
$post[$reasonCode] = '';
|
|
||||||
}
|
|
||||||
$post['__replace_submission_id'] = $previousId;
|
$post['__replace_submission_id'] = $previousId;
|
||||||
$post['__delete_reason'] = $reason;
|
$post['__delete_reasons'] = $reasons;
|
||||||
$post['__reason_code'] = $reasonCode;
|
|
||||||
break;
|
break;
|
||||||
case '1756965702-68add159-7312-476d-8c92-0c7683015351':
|
case '1756965702-68add159-7312-476d-8c92-0c7683015351':
|
||||||
if (($post['chemist_list'] ?? '') !== 'Others') {
|
if (($post['chemist_list'] ?? '') !== 'Others') {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
.pob-table th,
|
.pob-table th,
|
||||||
.pob-table td {
|
.pob-table td {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pob-table thead tr:nth-child(1) th {
|
.pob-table thead tr:nth-child(1) th {
|
||||||
|
|
@ -31,16 +32,15 @@
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pob-table td.pob-day-w,
|
|
||||||
.pob-table thead tr th.pob-day-w {
|
.pob-table thead tr th.pob-day-w {
|
||||||
background: #e2efda;
|
background: #c6efce;
|
||||||
color: inherit;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pob-table td.pob-day-h,
|
.pob-table td.pob-day-h,
|
||||||
.pob-table thead tr th.pob-day-h {
|
.pob-table thead tr th.pob-day-h {
|
||||||
background: #d9d9d9;
|
background: #d9d9d9;
|
||||||
color: #808080;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pob-table thead tr th.pob-identity {
|
.pob-table thead tr th.pob-identity {
|
||||||
|
|
@ -53,15 +53,9 @@
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pob-table td.pob-vacant {
|
.pob-table tr.pob-vacant td {
|
||||||
background: #fce4e4;
|
background: #f8cbad;
|
||||||
color: #c00000;
|
color: #000;
|
||||||
}
|
|
||||||
|
|
||||||
.pob-table td.pob-achieved {
|
|
||||||
background: #c6efce;
|
|
||||||
color: #006100;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
@ -153,19 +147,13 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@forelse ($section['rows'] as $row)
|
@forelse ($section['rows'] as $row)
|
||||||
<tr>
|
<tr class="{{ !empty($row['vacant']) ? 'pob-vacant' : '' }}">
|
||||||
@foreach ($row['cells'] as $cellIndex => $cell)
|
@foreach ($row['cells'] as $cellIndex => $cell)
|
||||||
@php
|
@php
|
||||||
$dayType = $section['dayTypes'][$cellIndex] ?? '';
|
$dayType = $section['dayTypes'][$cellIndex] ?? '';
|
||||||
$cellClass = '';
|
$cellClass = '';
|
||||||
if ($dayType === 'H' || $cell === 'Holiday') {
|
if (empty($row['vacant']) && ($dayType === 'H' || $cell === 'Holiday')) {
|
||||||
$cellClass = 'pob-day-h';
|
$cellClass = 'pob-day-h';
|
||||||
} elseif ($dayType === 'W') {
|
|
||||||
$cellClass = 'pob-day-w';
|
|
||||||
} elseif (!empty($row['vacant']) && $firstDay !== null && $cellIndex < $firstDay) {
|
|
||||||
$cellClass = 'pob-vacant';
|
|
||||||
} elseif ($cell === 'Achieved') {
|
|
||||||
$cellClass = 'pob-achieved';
|
|
||||||
}
|
}
|
||||||
@endphp
|
@endphp
|
||||||
<td class="{{ $cellClass }}">{{ $cell }}</td>
|
<td class="{{ $cellClass }}">{{ $cell }}</td>
|
||||||
|
|
|
||||||
|
|
@ -41,22 +41,75 @@
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@php
|
@php
|
||||||
$submissions = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
$history = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id);
|
||||||
$submissions = $submissions->data->submissions;
|
$submissions = $history->data->submissions ?? [];
|
||||||
|
|
||||||
/* echo "<pre>";
|
/* echo "<pre>";
|
||||||
print_r($submissions);
|
print_r($submissions);
|
||||||
echo "</pre>"; */
|
echo "</pre>"; */
|
||||||
|
|
||||||
|
|
||||||
$submittedMonths = [];
|
$monthEntries = [];
|
||||||
|
$monthEntryTimes = [];
|
||||||
if (!empty($submissions)) {
|
if (!empty($submissions)) {
|
||||||
foreach ($submissions as $sub) {
|
foreach ($submissions as $sub) {
|
||||||
if (isset($sub->formdata->month) && !empty($sub->formdata->month)) {
|
$saved = $sub->formdata ?? null;
|
||||||
$submittedMonths[] = trim($sub->formdata->month);
|
if (!$saved || empty($saved->month)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
$status = (string) ($saved->record_status ?? 'Active');
|
||||||
|
if (strcasecmp($status, 'Deleted') === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$monthName = trim((string) $saved->month);
|
||||||
|
$updated = strtotime((string) ($sub->updatedAt ?? '')) ?: 0;
|
||||||
|
if (isset($monthEntryTimes[$monthName]) && $updated < $monthEntryTimes[$monthName]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$payload = json_decode(json_encode($saved), true);
|
||||||
|
if (!is_array($payload)) {
|
||||||
|
$payload = [];
|
||||||
|
}
|
||||||
|
unset($payload['id']);
|
||||||
|
$contactsById = [];
|
||||||
|
$contactsByName = [];
|
||||||
|
$savedContacts = isset($sub->contacts) ? $sub->contacts : [];
|
||||||
|
foreach ($savedContacts as $contact) {
|
||||||
|
$contactId = trim((string) ($contact->id ?? $contact->contact_id ?? ''));
|
||||||
|
$contactName = trim((string) ($contact->name ?? ''));
|
||||||
|
if ($contactId === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$contactsById[$contactId] = $contactName;
|
||||||
|
if ($contactName !== '' && !isset($contactsByName[$contactName])) {
|
||||||
|
$contactsByName[$contactName] = $contactId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$doctorLabels = [];
|
||||||
|
for ($slot = 1; $slot <= 5; $slot++) {
|
||||||
|
$contactKey = 'contact_id_'.$slot;
|
||||||
|
$current = trim((string) ($payload[$contactKey] ?? ''));
|
||||||
|
if ($current === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isset($contactsById[$current])) {
|
||||||
|
$doctorLabels[$contactKey] = $contactsById[$current];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isset($contactsByName[$current])) {
|
||||||
|
$payload[$contactKey] = $contactsByName[$current];
|
||||||
|
$doctorLabels[$contactKey] = $current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$monthEntries[$monthName] = [
|
||||||
|
'id' => (string) ($sub->id ?? ''),
|
||||||
|
'formdata' => $payload,
|
||||||
|
'labels' => $doctorLabels,
|
||||||
|
];
|
||||||
|
$monthEntryTimes[$monthName] = $updated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$submittedMonths = array_keys($monthEntries);
|
||||||
|
|
||||||
|
|
||||||
$isEditMode = !empty($id);
|
$isEditMode = !empty($id);
|
||||||
|
|
@ -87,9 +140,12 @@
|
||||||
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
<input type="hidden" name="user_id" value="{{$form->user_id}}">
|
||||||
<input type="hidden" name="record_status" value="Active">
|
<input type="hidden" name="record_status" value="Active">
|
||||||
<input type="hidden" name="base_submission_id" value="{{ $baseSubmissionId }}">
|
<input type="hidden" name="base_submission_id" value="{{ $baseSubmissionId }}">
|
||||||
@if($reasonQuestionCode !== '')
|
@if($id && $reasonQuestionCode !== '')
|
||||||
<input type="hidden" name="reason_field_code" value="{{ $reasonQuestionCode }}">
|
<input type="hidden" name="reason_field_code" value="{{ $reasonQuestionCode }}">
|
||||||
@endif
|
@endif
|
||||||
|
@if(!$id)
|
||||||
|
<input type="hidden" name="replace_submission_id" id="field-replace_submission_id" value="">
|
||||||
|
@endif
|
||||||
|
|
||||||
@csrf
|
@csrf
|
||||||
@if($id)
|
@if($id)
|
||||||
|
|
@ -101,12 +157,17 @@
|
||||||
@continue
|
@continue
|
||||||
@endif
|
@endif
|
||||||
@php
|
@php
|
||||||
$isReasonField = $reasonQuestionCode !== '' && $question->code === $reasonQuestionCode;
|
$reasonSlot = null;
|
||||||
$fieldRequired = $isReasonField ? $isEditMode : ($question->required == 'yes');
|
if (preg_match('/^reason_(\d+)$/', (string) $question->code, $reasonMatch)) {
|
||||||
$fieldDisabled = $isReasonField && !$isEditMode;
|
$reasonSlot = $reasonMatch[1];
|
||||||
|
}
|
||||||
|
$isReasonField = $reasonSlot !== null;
|
||||||
|
$hideReason = $isReasonField;
|
||||||
|
$fieldRequired = $hideReason ? false : ($isReasonField ? true : ($question->required == 'yes'));
|
||||||
|
$fieldDisabled = $hideReason;
|
||||||
@endphp
|
@endphp
|
||||||
<div class="col-md-12 mb-2">
|
<div class="col-md-12 mb-2{{ $hideReason ? ' d-none doctor-reason' : '' }}" @if($reasonSlot) id="doctor-reason-{{ $reasonSlot }}" @endif>
|
||||||
<label for="field-{{$question->code}}" class="form-label">{{$question->question}} {!!$fieldRequired ? '<span class="text-danger">*</span>':''!!} </label>
|
<label for="field-{{$question->code}}" class="form-label">{{$question->question}} {!!$fieldRequired ? '<span class="text-danger">*</span>':''!!} @if($hideReason)<span class="text-danger reason-required d-none">*</span>@endif </label>
|
||||||
@switch($question->type)
|
@switch($question->type)
|
||||||
@case('hidden')
|
@case('hidden')
|
||||||
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
|
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
|
||||||
|
|
@ -160,10 +221,9 @@
|
||||||
<option value=""> -- Select -- </option>
|
<option value=""> -- Select -- </option>
|
||||||
@foreach ($question->options as $option)
|
@foreach ($question->options as $option)
|
||||||
@php
|
@php
|
||||||
$isSubmitted = ($question->code == 'month' && in_array(trim($option->value), $submittedMonths));
|
$isSubmitted = ($question->code == 'month' && in_array(trim($option->value), $submittedMonths, true));
|
||||||
$isSelected = (isset($question->value) && $question->value == $option->value);
|
$isSelected = (isset($question->value) && $question->value == $option->value);
|
||||||
|
$isDisabled = ($isEditMode && $isSubmitted && !$isSelected);
|
||||||
$isDisabled = ($isSubmitted && (!$isEditMode || !$isSelected));
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor')
|
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor')
|
||||||
|
|
@ -177,7 +237,7 @@
|
||||||
<option value="{{ $option->value }}"
|
<option value="{{ $option->value }}"
|
||||||
{{ $isSelected ? 'selected' : '' }}
|
{{ $isSelected ? 'selected' : '' }}
|
||||||
{{ $isDisabled ? 'disabled' : '' }}>
|
{{ $isDisabled ? 'disabled' : '' }}>
|
||||||
{{ $option->display }} {{ $isDisabled ? '(Already Submitted)' : '' }}
|
{{ $option->display }}@if($isDisabled) (Already Submitted)@elseif($isSubmitted && !$isEditMode) (I want to change)@endif
|
||||||
</option>
|
</option>
|
||||||
@else
|
@else
|
||||||
<option value="{{ $option->value }}"
|
<option value="{{ $option->value }}"
|
||||||
|
|
@ -275,6 +335,151 @@
|
||||||
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(document).ready(function($){
|
jQuery(document).ready(function($){
|
||||||
|
var monthEntries = @json($monthEntries);
|
||||||
|
var loadedDoctors = {};
|
||||||
|
var applyingMonth = false;
|
||||||
|
|
||||||
|
function doctorSlot(selectId) {
|
||||||
|
var match = String(selectId || '').match(/^field-contact_id_(\d+)$/);
|
||||||
|
return match ? match[1] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setReasonVisible(slot, show) {
|
||||||
|
var wrap = $('#doctor-reason-' + slot);
|
||||||
|
var field = $('#field-reason_' + slot);
|
||||||
|
if (!wrap.length) return;
|
||||||
|
var wasHidden = wrap.hasClass('d-none');
|
||||||
|
wrap.toggleClass('d-none', !show);
|
||||||
|
wrap.find('.reason-required').toggleClass('d-none', !show);
|
||||||
|
field.prop('disabled', !show).prop('required', !!show);
|
||||||
|
if (!show || wasHidden) field.val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearDoctorSlot(slot) {
|
||||||
|
$('#field-contact_id_' + slot).val('');
|
||||||
|
$('#field-msl_code_' + slot).val('');
|
||||||
|
$('#field-speciality_' + slot).val('');
|
||||||
|
$('#field-city_' + slot).val('');
|
||||||
|
$('#field-pin_code_' + slot).val('');
|
||||||
|
setReasonVisible(slot, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillLoadedDoctor(slot) {
|
||||||
|
var saved = loadedDoctors[slot];
|
||||||
|
if (!saved) return;
|
||||||
|
$('#field-msl_code_' + slot).val(saved.msl);
|
||||||
|
$('#field-speciality_' + slot).val(saved.speciality);
|
||||||
|
$('#field-city_' + slot).val(saved.city);
|
||||||
|
$('#field-pin_code_' + slot).val(saved.pincode);
|
||||||
|
setReasonVisible(slot, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberLoadedDoctors() {
|
||||||
|
for (var n = 1; n <= 5; n++) {
|
||||||
|
var doctor = $('#field-contact_id_' + n);
|
||||||
|
if (!doctor.length) continue;
|
||||||
|
var contact = doctor.attr('data-initial-value');
|
||||||
|
if (contact == null || contact === '') contact = doctor.val() || '';
|
||||||
|
loadedDoctors[n] = {
|
||||||
|
contact: String(contact || '').trim(),
|
||||||
|
msl: $('#field-msl_code_' + n).val() || '',
|
||||||
|
speciality: $('#field-speciality_' + n).val() || '',
|
||||||
|
city: $('#field-city_' + n).val() || '',
|
||||||
|
pincode: $('#field-pin_code_' + n).val() || ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDoctorChange(select) {
|
||||||
|
if (applyingMonth) return;
|
||||||
|
var slot = doctorSlot(select.attr('id'));
|
||||||
|
if (!slot) return;
|
||||||
|
var selected = select.find(':selected');
|
||||||
|
var current = String(select.val() || '').trim();
|
||||||
|
var saved = loadedDoctors[slot];
|
||||||
|
if (!saved || !saved.contact) {
|
||||||
|
$('#field-msl_code_' + slot).val(selected.attr('msl_code') || '');
|
||||||
|
$('#field-speciality_' + slot).val(selected.attr('speciality') || '');
|
||||||
|
setReasonVisible(slot, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (current === saved.contact) {
|
||||||
|
fillLoadedDoctor(slot);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#field-city_' + slot).val('');
|
||||||
|
$('#field-pin_code_' + slot).val('');
|
||||||
|
$('#field-msl_code_' + slot).val(selected.attr('msl_code') || '');
|
||||||
|
$('#field-speciality_' + slot).val(selected.attr('speciality') || '');
|
||||||
|
setReasonVisible(slot, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setDoctorSelect(select, contactId, label) {
|
||||||
|
contactId = String(contactId || '').trim();
|
||||||
|
if (!select || !select.length) return;
|
||||||
|
if (!contactId) {
|
||||||
|
select.val('').trigger('change.select2');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var exists = false;
|
||||||
|
select.find('option').each(function () {
|
||||||
|
if (String(this.value) === contactId) {
|
||||||
|
this.disabled = false;
|
||||||
|
exists = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!exists) {
|
||||||
|
select.append($('<option></option>').attr('value', contactId).text(label || contactId));
|
||||||
|
}
|
||||||
|
select.val(contactId).trigger('change.select2');
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyMonth(month) {
|
||||||
|
var replaceField = $('#field-replace_submission_id');
|
||||||
|
if (!replaceField.length) return;
|
||||||
|
applyingMonth = true;
|
||||||
|
var entry = monthEntries[month];
|
||||||
|
loadedDoctors = {};
|
||||||
|
if (!entry || !entry.formdata) {
|
||||||
|
replaceField.val('');
|
||||||
|
for (var slot = 1; slot <= 5; slot++) clearDoctorSlot(slot);
|
||||||
|
$("[id^='field-contact_id_']").each(function () {
|
||||||
|
$(this).trigger('change.select2');
|
||||||
|
});
|
||||||
|
applyingMonth = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
replaceField.val(entry.id || '');
|
||||||
|
var data = entry.formdata;
|
||||||
|
var labels = entry.labels || {};
|
||||||
|
Object.keys(data).forEach(function (key) {
|
||||||
|
if (key === 'id' || key === 'record_status' || key === 'base_submission_id' || /^reason_\d+$/.test(key) || /^contact_id_\d+$/.test(key)) return;
|
||||||
|
var field = $('#field-' + key);
|
||||||
|
if (!field.length || field.attr('id') === 'field-month') return;
|
||||||
|
field.val(data[key] == null ? '' : data[key]);
|
||||||
|
});
|
||||||
|
for (var n = 1; n <= 5; n++) {
|
||||||
|
loadedDoctors[n] = {
|
||||||
|
contact: String(data['contact_id_' + n] || '').trim(),
|
||||||
|
msl: data['msl_code_' + n] || '',
|
||||||
|
speciality: data['speciality_' + n] || '',
|
||||||
|
city: data['city_' + n] || '',
|
||||||
|
pincode: data['pin_code_' + n] || ''
|
||||||
|
};
|
||||||
|
setDoctorSelect($('#field-contact_id_' + n), loadedDoctors[n].contact, labels['contact_id_' + n] || '');
|
||||||
|
fillLoadedDoctor(n);
|
||||||
|
}
|
||||||
|
applyingMonth = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#field-month').on('change', function () {
|
||||||
|
applyMonth(String($(this).val() || ''));
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($('#report-form input[name="id"]').length) {
|
||||||
|
rememberLoadedDoctors();
|
||||||
|
}
|
||||||
|
|
||||||
$('[data-toggle="select2"]').select2();
|
$('[data-toggle="select2"]').select2();
|
||||||
var hierarcies = [];
|
var hierarcies = [];
|
||||||
var contacts = [];
|
var contacts = [];
|
||||||
|
|
@ -382,22 +587,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
select.off('change').on('change', function () {
|
select.off('change').on('change select2:select select2:clear', function () {
|
||||||
var selected = $(this).find(':selected');
|
handleDoctorChange($(this));
|
||||||
var selectId = $(this).attr('id');
|
|
||||||
var match = selectId.match(/^field-contact_id(_\d+)?$/);
|
|
||||||
var suffix = match && match[1] ? match[1] : '';
|
|
||||||
|
|
||||||
var mslCodeField = $('#field-msl_code' + suffix);
|
|
||||||
var specialityField = $('#field-speciality' + suffix);
|
|
||||||
|
|
||||||
if (mslCodeField.length) {
|
|
||||||
mslCodeField.val(selected.attr('msl_code') || '');
|
|
||||||
}
|
|
||||||
if (specialityField.length) {
|
|
||||||
specialityField.val(selected.attr('speciality') || '');
|
|
||||||
}
|
|
||||||
|
|
||||||
enforceUniqueDoctorSelections();
|
enforceUniqueDoctorSelections();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -415,6 +606,9 @@
|
||||||
select.val(String(existingVal)).trigger('change');
|
select.val(String(existingVal)).trigger('change');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if ($('#field-replace_submission_id').length && $('#field-month').val()) {
|
||||||
|
applyMonth(String($('#field-month').val()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$("[id^='field-city_']").on('input keyup paste', function() {
|
$("[id^='field-city_']").on('input keyup paste', function() {
|
||||||
|
|
@ -477,13 +671,9 @@
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
$("[id^='field-contact_id_']").on('change', function () {
|
||||||
|
handleDoctorChange($(this));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#report-form').on('submit', function(event){
|
$('#report-form').on('submit', function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue