Merge branch 'main' of http://192.168.1.200:3000/Stratawiz/Rapport-Laravel
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m53s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m53s
Details
This commit is contained in:
commit
1f1caf5752
|
|
@ -12963,13 +12963,12 @@ class FormController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Selected user attribute codes when the form is configured to show them.
|
||||
* Uses the saved attribute list as the source of truth so columns still render
|
||||
* if Show User Attributes was left off after attributes were selected.
|
||||
* Selected user attribute codes when Show User Attributes is Yes.
|
||||
* A saved attribute list is ignored while that setting is No.
|
||||
*/
|
||||
protected function userAttributeCodes($form): array
|
||||
{
|
||||
if (!$form) {
|
||||
if (!$form || ($form->show_user_attributes ?? 'no') !== 'yes') {
|
||||
return [];
|
||||
}
|
||||
$raw = $form->user_attributes ?? [];
|
||||
|
|
|
|||
|
|
@ -158,9 +158,6 @@ class FormentityController extends Controller
|
|||
$values->show_manager_details = $values->show_manager_details ?? 'no';
|
||||
$values->show_user_attributes = (($values->show_user_attributes ?? 'no') === 'yes') ? 'yes' : 'no';
|
||||
$values->user_attributes = $this->normalizeAttributeCodes($values->user_attributes ?? []);
|
||||
if (!empty($values->user_attributes)) {
|
||||
$values->show_user_attributes = 'yes';
|
||||
}
|
||||
}
|
||||
//echo '<pre>'; print_r($values); exit;
|
||||
return $values;
|
||||
|
|
@ -254,9 +251,6 @@ class FormentityController extends Controller
|
|||
$data['roles_info'] = ($data['roles_info'] ?? 'no') === 'yes' ? 'yes' : 'no';
|
||||
$data['show_user_attributes'] = ($data['show_user_attributes'] ?? 'no') === 'yes' ? 'yes' : 'no';
|
||||
$data['user_attributes'] = $this->normalizeAttributeCodes($data['user_attributes'] ?? []);
|
||||
if (!empty($data['user_attributes'])) {
|
||||
$data['show_user_attributes'] = 'yes';
|
||||
}
|
||||
if ($data['email_notification'] === 'no') {
|
||||
$data['email_notification_rules'] = [];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,309 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => $form->title ?? 'POB'])
|
||||
@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 '';
|
||||
};
|
||||
$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;
|
||||
};
|
||||
$contactType = strtolower((string) $val('contact_type'));
|
||||
$isChemist = $contactType === 'ebt_chemist';
|
||||
$contactLabel = $isChemist ? 'Chemist' : 'Doctor';
|
||||
$skus = [
|
||||
['Asthalin Inhaler', 'asthalin_inhaler'],
|
||||
['Asthalin Rotacap', 'asthalin_rotacap'],
|
||||
['Aerocort Inhaler', 'aerocort_inhaler'],
|
||||
['Aerocort Rotacap', 'aerocort_rotacap'],
|
||||
['Aerocort Forte Rotacap', 'aerocort_forte_rotacap'],
|
||||
];
|
||||
$supplyStatus = (string) $val('supply_status');
|
||||
$invoiceUrl = $fileUrl($val('upload_invoice'));
|
||||
$invoiceExt = strtolower(pathinfo((string) parse_url($invoiceUrl, PHP_URL_PATH), PATHINFO_EXTENSION));
|
||||
$invoiceIsImage = in_array($invoiceExt, ['jpg', 'jpeg', 'png', 'gif', 'webp'], true);
|
||||
$invoiceIsPdf = $invoiceExt === 'pdf';
|
||||
@endphp
|
||||
|
||||
<div class="approval-container">
|
||||
<div class="approval-header">
|
||||
<h1 class="approval-title">POB Review</h1>
|
||||
<p class="approval-subtitle">Review the actual POB and invoice 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">
|
||||
<summary class="section-title">{{ $contactLabel }} details</summary>
|
||||
<div class="section-content">
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Date</span>
|
||||
<span class="detail-value">{{ $val('record_date') !== '' ? $val('record_date') : '—' }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">{{ $contactLabel }}</span>
|
||||
<span class="detail-value">{{ $val('contact_name') !== '' ? $val('contact_name') : '—' }}</span>
|
||||
</div>
|
||||
@if(!$isChemist)
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Speciality</span>
|
||||
<span class="detail-value">{{ $val('speciality') !== '' ? $val('speciality') : '—' }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Doctor Address</span>
|
||||
<span class="detail-value">{{ $val('doctor_location') !== '' ? $val('doctor_location') : '—' }}</span>
|
||||
</div>
|
||||
@else
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Chemist Address</span>
|
||||
<span class="detail-value">{{ $val('chemist_location') !== '' ? $val('chemist_location') : '—' }}</span>
|
||||
</div>
|
||||
@endif
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">MSL Code</span>
|
||||
<span class="detail-value">{{ $val('msl_code') !== '' ? $val('msl_code') : '—' }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Supply Status</span>
|
||||
<span class="detail-value">{{ $supplyStatus !== '' ? $supplyStatus : '—' }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Submission Status</span>
|
||||
<span class="detail-value">{{ $val('submission_status') !== '' ? $val('submission_status') : '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="preview-panel" open>
|
||||
<summary class="section-title">Actual POB</summary>
|
||||
<div class="section-content p-0">
|
||||
<table class="table table-sm mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>SKU</th>
|
||||
<th class="text-end">Actual Units</th>
|
||||
<th class="text-end">Actual Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($skus as [$label, $code])
|
||||
<tr>
|
||||
<td>{{ $label }}</td>
|
||||
<td class="text-end">{{ $val('actual_'.$code.'_units') !== '' ? $val('actual_'.$code.'_units') : '0' }}</td>
|
||||
<td class="text-end">{{ $val('actual_'.$code.'_value') !== '' ? $val('actual_'.$code.'_value') : '0' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr class="fw-semibold">
|
||||
<td>Total</td>
|
||||
<td class="text-end">{{ $val('total_actual_pob_units') !== '' ? $val('total_actual_pob_units') : '0' }}</td>
|
||||
<td class="text-end">{{ $val('total_actual_pob_value') !== '' ? $val('total_actual_pob_value') : '0' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="preview-panel" open>
|
||||
<summary class="section-title">Invoice</summary>
|
||||
<div class="section-content">
|
||||
@if($invoiceUrl === '')
|
||||
<p class="text-muted mb-0">No invoice uploaded.</p>
|
||||
@elseif($invoiceIsImage)
|
||||
<div class="request-letter-container">
|
||||
<img src="{{ $invoiceUrl }}" alt="Uploaded invoice" class="request-letter-image" onclick="openImageModal(@json($invoiceUrl))" />
|
||||
</div>
|
||||
<p class="text-center mt-2 mb-0"><a href="{{ $invoiceUrl }}" target="_blank" rel="noopener">Open invoice</a></p>
|
||||
@elseif($invoiceIsPdf)
|
||||
<iframe class="invoice-frame" src="{{ $invoiceUrl }}" title="Uploaded invoice"></iframe>
|
||||
<p class="text-center mt-2 mb-0"><a href="{{ $invoiceUrl }}" target="_blank" rel="noopener">Open invoice</a></p>
|
||||
@else
|
||||
<p class="mb-0"><a href="{{ $invoiceUrl }}" target="_blank" rel="noopener">Open invoice</a></p>
|
||||
@endif
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="imageModal" class="image-modal" onclick="closeImageModal()">
|
||||
<div class="image-modal-content" onclick="event.stopPropagation()">
|
||||
<span class="image-modal-close" onclick="closeImageModal()">×</span>
|
||||
<img id="modalImage" src="" alt="Uploaded invoice" 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;
|
||||
}
|
||||
.request-letter-container { text-align: center; }
|
||||
.request-letter-image {
|
||||
max-width: 100%;
|
||||
max-height: 500px;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.invoice-frame {
|
||||
width: 100%;
|
||||
height: 480px;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.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>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue