Initial import of animal_management module
This commit is contained in:
901
views/animals/medical-visits.php
Normal file
901
views/animals/medical-visits.php
Normal file
@@ -0,0 +1,901 @@
|
||||
<?php
|
||||
|
||||
use humhub\modules\animal_management\models\Animal;
|
||||
use humhub\modules\animal_management\helpers\DateDisplayHelper;
|
||||
use humhub\modules\animal_management\models\AnimalGalleryItem;
|
||||
use humhub\modules\animal_management\models\AnimalMedicalVisit;
|
||||
use humhub\modules\animal_management\models\forms\AnimalMedicalVisitForm;
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\widgets\Button;
|
||||
use yii\bootstrap\ActiveForm;
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var Space $space */
|
||||
/* @var Animal $animal */
|
||||
/* @var bool $canManage */
|
||||
/* @var AnimalMedicalVisitForm $medicalVisitForm */
|
||||
/* @var AnimalMedicalVisit[] $medicalVisits */
|
||||
/* @var AnimalGalleryItem[] $galleryItems */
|
||||
|
||||
$hiddenMedicalKeys = [
|
||||
'second_physician_name',
|
||||
'second_physician_business_name',
|
||||
'second_physician_street_address',
|
||||
'second_physician_city',
|
||||
'second_physician_state',
|
||||
'second_physician_zip',
|
||||
'second_physician_cell_phone',
|
||||
'second_physician_business_phone',
|
||||
'second_physician_license_number',
|
||||
'previous_physicians',
|
||||
];
|
||||
|
||||
$renderCustomField = static function (string $fieldKey, AnimalMedicalVisitForm $model, array $definitions): string {
|
||||
if (!isset($definitions[$fieldKey])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$definition = $definitions[$fieldKey];
|
||||
$inputType = (string)$definition['input_type'];
|
||||
$vitalLabelOverrides = [
|
||||
'blood_pressure' => 'BP',
|
||||
'oxygen' => 'O₂',
|
||||
];
|
||||
$label = (string)($vitalLabelOverrides[$fieldKey] ?? $definition['label']);
|
||||
if ((int)$definition['required'] === 1) {
|
||||
$label .= ' *';
|
||||
}
|
||||
|
||||
$fieldName = "AnimalMedicalVisitForm[customFields][$fieldKey]";
|
||||
$fieldValue = $model->customFields[$fieldKey] ?? '';
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<?php if ($inputType === 'textarea'): ?>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="animalmedicalvisitform-customfields-<?= Html::encode($fieldKey) ?>"><?= Html::encode($label) ?></label>
|
||||
<?= Html::textarea($fieldName, (string)$fieldValue, ['class' => 'form-control', 'rows' => 3, 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
|
||||
</div>
|
||||
<?php elseif ($inputType === 'boolean'): ?>
|
||||
<div class="checkbox" style="margin-bottom:10px;">
|
||||
<label>
|
||||
<?= Html::hiddenInput($fieldName, '0') ?>
|
||||
<?= Html::checkbox($fieldName, !empty($fieldValue), ['value' => '1']) ?>
|
||||
<?= Html::encode($label) ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php elseif ($inputType === 'select'): ?>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="animalmedicalvisitform-customfields-<?= Html::encode($fieldKey) ?>"><?= Html::encode($label) ?></label>
|
||||
<?= Html::dropDownList(
|
||||
$fieldName,
|
||||
(string)$fieldValue,
|
||||
$model->getCustomFieldSelectOptions($fieldKey),
|
||||
['class' => 'form-control', 'prompt' => Yii::t('AnimalManagementModule.base', 'Select...'), 'id' => "animalmedicalvisitform-customfields-$fieldKey"]
|
||||
) ?>
|
||||
</div>
|
||||
<?php elseif ($inputType === 'number'): ?>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="animalmedicalvisitform-customfields-<?= Html::encode($fieldKey) ?>"><?= Html::encode($label) ?></label>
|
||||
<?= Html::input('number', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'step' => 'any', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
|
||||
</div>
|
||||
<?php elseif ($inputType === 'date'): ?>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="animalmedicalvisitform-customfields-<?= Html::encode($fieldKey) ?>"><?= Html::encode($label) ?></label>
|
||||
<?= Html::input('date', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
|
||||
</div>
|
||||
<?php elseif ($inputType === 'datetime'): ?>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="animalmedicalvisitform-customfields-<?= Html::encode($fieldKey) ?>"><?= Html::encode($label) ?></label>
|
||||
<?= Html::input('datetime-local', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="animalmedicalvisitform-customfields-<?= Html::encode($fieldKey) ?>"><?= Html::encode($label) ?></label>
|
||||
<?= Html::textInput($fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
return (string)ob_get_clean();
|
||||
};
|
||||
|
||||
$medicalCustomDefinitions = $medicalVisitForm->getCustomFieldDefinitions();
|
||||
$knownMedicalKeys = [
|
||||
'weight',
|
||||
'pulse',
|
||||
'blood_pressure',
|
||||
'oxygen',
|
||||
'chronic_conditions',
|
||||
'acute_conditions',
|
||||
'special_needs',
|
||||
'date_of_most_recent_medical_visit',
|
||||
'physician_name',
|
||||
'physician_business_name',
|
||||
'physician_street_address',
|
||||
'physician_city',
|
||||
'physician_state',
|
||||
'physician_zip',
|
||||
'physician_cell_phone',
|
||||
'physician_business_phone',
|
||||
'physician_license_number',
|
||||
'medical_media_reference',
|
||||
'media_reference',
|
||||
];
|
||||
|
||||
$remainingMedicalDefinitions = [];
|
||||
foreach ($medicalCustomDefinitions as $fieldKey => $definition) {
|
||||
if (in_array($fieldKey, $knownMedicalKeys, true) || in_array($fieldKey, $hiddenMedicalKeys, true)) {
|
||||
continue;
|
||||
}
|
||||
$remainingMedicalDefinitions[$fieldKey] = $definition;
|
||||
}
|
||||
|
||||
$newMedicalMediaPath = trim((string)($medicalVisitForm->customFields['medical_media_reference'] ?? $medicalVisitForm->customFields['media_reference'] ?? ''));
|
||||
$hasNewMedicalMedia = $newMedicalMediaPath !== '' && (preg_match('/^https?:\/\//i', $newMedicalMediaPath) || substr($newMedicalMediaPath, 0, 1) === '/');
|
||||
$medicalGalleryModalId = 'medical-media-gallery-modal';
|
||||
$medicalAddModalId = 'add-medical-visit-modal';
|
||||
$medicalFormId = 'add-medical-visit-form';
|
||||
$openMedicalEditId = (int)Yii::$app->request->get('inlineMedicalEdit', 0);
|
||||
$openMedicalAdd = (int)Yii::$app->request->get('inlineMedicalAdd', 0) === 1;
|
||||
$medicalVitalLabelOverrides = [
|
||||
'blood_pressure' => 'BP',
|
||||
'oxygen' => 'O₂',
|
||||
];
|
||||
?>
|
||||
|
||||
<style>
|
||||
.medical-feed-card {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border: 1px solid #d5dfe8;
|
||||
border-radius: 12px;
|
||||
background: #223446;
|
||||
margin-bottom: 12px;
|
||||
min-height: 260px;
|
||||
box-shadow: 0 8px 22px rgba(12, 24, 36, 0.16);
|
||||
}
|
||||
|
||||
.medical-feed-cover {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.medical-feed-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(110deg, rgba(10, 18, 28, 0.28) 10%, rgba(10, 18, 28, 0.55) 52%, rgba(10, 18, 28, 0.75) 100%);
|
||||
}
|
||||
|
||||
.medical-feed-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
min-height: 260px;
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.medical-feed-top-row {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin-left: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.medical-feed-text-wrap {
|
||||
width: 55%;
|
||||
max-width: 55%;
|
||||
min-width: 0;
|
||||
margin-left: auto;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.22);
|
||||
background: rgba(10, 18, 28, 0.5);
|
||||
backdrop-filter: blur(2px);
|
||||
padding: 12px;
|
||||
color: #ecf2f8;
|
||||
}
|
||||
|
||||
.medical-feed-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.medical-feed-date {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.medical-feed-text-wrap {
|
||||
width: 55%;
|
||||
max-width: 55%;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 991px) {
|
||||
.medical-feed-text-wrap {
|
||||
width: 55%;
|
||||
max-width: 55%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.medical-chip-row--top {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.medical-chip-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.medical-chip-row--top {
|
||||
margin-bottom: 0;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.medical-chip {
|
||||
display: inline-block;
|
||||
background: rgba(255, 255, 255, 0.16);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 999px;
|
||||
padding: 4px 10px;
|
||||
font-size: 12px;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.medical-media-select-thumb.is-selected {
|
||||
border-color: #1f8dd6;
|
||||
box-shadow: 0 0 0 2px rgba(31, 141, 214, 0.2);
|
||||
}
|
||||
|
||||
.medical-section-label {
|
||||
font-size: 11px;
|
||||
letter-spacing: .04em;
|
||||
text-transform: uppercase;
|
||||
color: rgba(231, 241, 249, 0.78);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.medical-section-body {
|
||||
color: #eff5fb;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.medical-feed-inline-editor {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
width: auto;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
margin: 0 14px 14px 14px;
|
||||
padding-top: 0;
|
||||
align-self: stretch;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.medical-feed-inline-editor iframe {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.medical-feed-inline-editor {
|
||||
width: auto;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 991px) {
|
||||
.medical-feed-inline-editor {
|
||||
width: auto;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="medical-visits-page" class="panel panel-default">
|
||||
<div class="panel-heading" style="display:flex;align-items:center;">
|
||||
<span style="font-size:20px;line-height:1.2;"><?= Yii::t('AnimalManagementModule.base', '<strong>Medical Visits</strong>') ?></span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div style="display:flex;gap:18px;flex-wrap:wrap;align-items:center;margin-bottom:12px;">
|
||||
<?= Html::a(
|
||||
Html::encode($animal->getDisplayName()),
|
||||
$space->createUrl('/animal_management/animals/view', ['id' => $animal->id]),
|
||||
['style' => 'font-size:20px;font-weight:700;line-height:1.2;']
|
||||
) ?>
|
||||
<?= Html::a(
|
||||
Yii::t('AnimalManagementModule.base', 'All Animals'),
|
||||
$space->createUrl('/animal_management/animals/index'),
|
||||
['style' => 'font-size:16px;line-height:1.2;']
|
||||
) ?>
|
||||
<?php if ($canManage): ?>
|
||||
<?= Html::a('<i class="fa fa-plus"></i> ' . Yii::t('AnimalManagementModule.base', 'Add Medical Visit'), '#medical-add-inline', [
|
||||
'class' => 'btn btn-success btn-sm',
|
||||
'title' => Yii::t('AnimalManagementModule.base', 'Add Medical Visit'),
|
||||
'aria-label' => Yii::t('AnimalManagementModule.base', 'Add Medical Visit'),
|
||||
'data-toggle' => 'collapse',
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($canManage): ?>
|
||||
<div id="medical-add-inline" class="collapse medical-feed-inline-editor<?= $openMedicalAdd ? ' in' : '' ?>" style="margin:0 0 14px 0;">
|
||||
<iframe
|
||||
src="<?= Html::encode($space->createUrl('/animal_management/animals/add-medical-visit-inline', ['id' => $animal->id, 'inline' => 1, 'returnTo' => 'medical-visits', '_v' => time()])) ?>"
|
||||
style="width:100%;min-height:860px;border:1px solid rgba(255,255,255,0.22);border-radius:10px;background:transparent;"
|
||||
loading="lazy"
|
||||
></iframe>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (empty($medicalVisits)): ?>
|
||||
<div class="text-muted" style="margin-bottom:10px;"><?= Yii::t('AnimalManagementModule.base', 'No medical visits recorded.') ?></div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($medicalVisits as $visit): ?>
|
||||
<?php
|
||||
$visitCustomValues = $visit->getCustomFieldDisplayValues($canManage);
|
||||
$visitFieldsByKey = [];
|
||||
$additionalVisitFields = [];
|
||||
$medicalMedia = '';
|
||||
foreach ($visitCustomValues as $customField) {
|
||||
$fieldKey = (string)($customField['field_key'] ?? '');
|
||||
if (in_array($fieldKey, $hiddenMedicalKeys, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fieldValue = trim((string)($customField['value'] ?? ''));
|
||||
if ($fieldValue === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($fieldKey === 'medical_media_reference' || $fieldKey === 'media_reference') {
|
||||
$medicalMedia = $fieldValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($fieldKey, $knownMedicalKeys, true)) {
|
||||
$visitFieldsByKey[$fieldKey] = [
|
||||
'label' => (string)($medicalVitalLabelOverrides[$fieldKey] ?? ($customField['label'] ?? $fieldKey)),
|
||||
'value' => $fieldValue,
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
$additionalVisitFields[] = [
|
||||
'label' => (string)($customField['label'] ?? $fieldKey),
|
||||
'value' => $fieldValue,
|
||||
];
|
||||
}
|
||||
|
||||
$hasMedicalMedia = $medicalMedia !== '' && (preg_match('/^https?:\/\//i', $medicalMedia) || substr($medicalMedia, 0, 1) === '/');
|
||||
$visitDateDisplay = DateDisplayHelper::format((string)$visit->visit_at);
|
||||
$vitalKeys = ['weight', 'pulse', 'blood_pressure', 'oxygen'];
|
||||
$hasVitals = false;
|
||||
foreach ($vitalKeys as $vitalKey) {
|
||||
if (!empty($visitFieldsByKey[$vitalKey]['value'])) {
|
||||
$hasVitals = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div id="medical-visit-<?= (int)$visit->id ?>" class="medical-feed-card">
|
||||
<?php if ($hasMedicalMedia): ?>
|
||||
<img class="medical-feed-cover" src="<?= Html::encode($medicalMedia) ?>" alt="<?= Yii::t('AnimalManagementModule.base', 'Medical media') ?>">
|
||||
<?php endif; ?>
|
||||
<div class="medical-feed-overlay"></div>
|
||||
<div class="medical-feed-content">
|
||||
<div class="medical-feed-top-row">
|
||||
<span class="medical-feed-date"><?= Html::encode($visitDateDisplay !== '' ? $visitDateDisplay : (string)$visit->visit_at) ?></span>
|
||||
<?php if ($hasVitals): ?>
|
||||
<div class="medical-chip-row medical-chip-row--top">
|
||||
<?php foreach ($vitalKeys as $vitalKey): ?>
|
||||
<?php if (empty($visitFieldsByKey[$vitalKey]['value'])) { continue; } ?>
|
||||
<span class="medical-chip">
|
||||
<?= Html::encode($visitFieldsByKey[$vitalKey]['label']) ?>: <?= Html::encode($visitFieldsByKey[$vitalKey]['value']) ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="medical-feed-text-wrap">
|
||||
<div class="medical-feed-header">
|
||||
<div>
|
||||
<?php if (!empty($visit->provider_name)): ?>
|
||||
<div style="font-size:12px;color:rgba(239,245,251,0.86);margin-top:2px;"><?= Yii::t('AnimalManagementModule.base', 'Provider') ?>: <?= Html::encode((string)$visit->provider_name) ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($canManage): ?>
|
||||
<?= Html::a(
|
||||
'<i class="fa fa-pencil"></i>',
|
||||
'#medical-edit-inline-' . (int)$visit->id,
|
||||
[
|
||||
'class' => 'btn btn-xs btn-default',
|
||||
'data-toggle' => 'collapse',
|
||||
'title' => Yii::t('AnimalManagementModule.base', 'Edit'),
|
||||
'aria-label' => Yii::t('AnimalManagementModule.base', 'Edit'),
|
||||
]
|
||||
) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($visit->notes)): ?>
|
||||
<div class="medical-section-label"><?= Yii::t('AnimalManagementModule.base', 'Clinical Notes') ?></div>
|
||||
<div class="medical-section-body"><?= nl2br(Html::encode((string)$visit->notes)) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($visit->recommendations)): ?>
|
||||
<div class="medical-section-label"><?= Yii::t('AnimalManagementModule.base', 'Recommendations') ?></div>
|
||||
<div class="medical-section-body"><?= nl2br(Html::encode((string)$visit->recommendations)) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$conditionKeys = ['chronic_conditions', 'acute_conditions', 'special_needs'];
|
||||
foreach ($conditionKeys as $conditionKey):
|
||||
if (empty($visitFieldsByKey[$conditionKey]['value'])) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<div class="medical-section-label"><?= Html::encode($visitFieldsByKey[$conditionKey]['label']) ?></div>
|
||||
<div class="medical-section-body"><?= nl2br(Html::encode($visitFieldsByKey[$conditionKey]['value'])) ?></div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php
|
||||
$contactKeys = [
|
||||
'physician_name',
|
||||
'physician_business_name',
|
||||
'physician_street_address',
|
||||
'physician_city',
|
||||
'physician_state',
|
||||
'physician_zip',
|
||||
'physician_cell_phone',
|
||||
'physician_business_phone',
|
||||
'physician_license_number',
|
||||
];
|
||||
$hasContact = false;
|
||||
foreach ($contactKeys as $contactKey) {
|
||||
if (!empty($visitFieldsByKey[$contactKey]['value'])) {
|
||||
$hasContact = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php if ($hasContact): ?>
|
||||
<?php
|
||||
$contactLines = [];
|
||||
if (!empty($visitFieldsByKey['physician_name']['value'])) {
|
||||
$contactLines[] = (string)$visitFieldsByKey['physician_name']['value'];
|
||||
}
|
||||
if (!empty($visitFieldsByKey['physician_business_name']['value'])) {
|
||||
$contactLines[] = (string)$visitFieldsByKey['physician_business_name']['value'];
|
||||
}
|
||||
if (!empty($visitFieldsByKey['physician_street_address']['value'])) {
|
||||
$contactLines[] = (string)$visitFieldsByKey['physician_street_address']['value'];
|
||||
}
|
||||
|
||||
$cityStateZip = trim(implode(', ', array_filter([
|
||||
trim((string)($visitFieldsByKey['physician_city']['value'] ?? '')),
|
||||
trim((string)($visitFieldsByKey['physician_state']['value'] ?? '')),
|
||||
])));
|
||||
$zipValue = trim((string)($visitFieldsByKey['physician_zip']['value'] ?? ''));
|
||||
if ($zipValue !== '') {
|
||||
$cityStateZip = trim($cityStateZip . ($cityStateZip !== '' ? ' ' : '') . $zipValue);
|
||||
}
|
||||
if ($cityStateZip !== '') {
|
||||
$contactLines[] = $cityStateZip;
|
||||
}
|
||||
|
||||
$phones = array_filter([
|
||||
trim((string)($visitFieldsByKey['physician_cell_phone']['value'] ?? '')),
|
||||
trim((string)($visitFieldsByKey['physician_business_phone']['value'] ?? '')),
|
||||
]);
|
||||
if (!empty($phones)) {
|
||||
$contactLines[] = implode(' · ', $phones);
|
||||
}
|
||||
|
||||
if (!empty($visitFieldsByKey['physician_license_number']['value'])) {
|
||||
$contactLines[] = (string)$visitFieldsByKey['physician_license_number']['value'];
|
||||
}
|
||||
?>
|
||||
<div class="medical-section-label"><?= Yii::t('AnimalManagementModule.base', 'Care Contact') ?></div>
|
||||
<div class="medical-section-body">
|
||||
<?php foreach ($contactLines as $contactLine): ?>
|
||||
<div><?= Html::encode($contactLine) ?></div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($visitFieldsByKey['date_of_most_recent_medical_visit']['value'])): ?>
|
||||
<div class="medical-section-label"><?= Html::encode($visitFieldsByKey['date_of_most_recent_medical_visit']['label']) ?></div>
|
||||
<div class="medical-section-body"><?= Html::encode(DateDisplayHelper::format((string)$visitFieldsByKey['date_of_most_recent_medical_visit']['value'])) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($additionalVisitFields)): ?>
|
||||
<div class="medical-section-label"><?= Yii::t('AnimalManagementModule.base', 'Additional Fields') ?></div>
|
||||
<div class="medical-section-body">
|
||||
<?php foreach ($additionalVisitFields as $additionalField): ?>
|
||||
<div><strong><?= Html::encode((string)$additionalField['label']) ?>:</strong> <?= nl2br(Html::encode((string)$additionalField['value'])) ?></div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($canManage): ?>
|
||||
<div id="medical-edit-inline-<?= (int)$visit->id ?>" class="collapse medical-feed-inline-editor<?= $openMedicalEditId === (int)$visit->id ? ' in' : '' ?>">
|
||||
<iframe
|
||||
src="<?= Html::encode($space->createUrl('/animal_management/animals/edit-medical-visit', ['id' => $animal->id, 'visitId' => $visit->id, 'inline' => 1, 'returnTo' => 'medical-visits', '_v' => time()])) ?>"
|
||||
style="width:100%;min-height:760px;border:1px solid rgba(255,255,255,0.22);border-radius:10px;background:transparent;"
|
||||
loading="lazy"
|
||||
></iframe>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canManage): ?>
|
||||
<div class="modal fade" id="<?= Html::encode($medicalAddModalId) ?>" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="<?= Yii::t('AnimalManagementModule.base', 'Close') ?>"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><?= Yii::t('AnimalManagementModule.base', 'Add Medical Visit') ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<?php $medicalForm = ActiveForm::begin([
|
||||
'action' => $space->createUrl('/animal_management/animals/add-medical-visit', ['id' => $animal->id]),
|
||||
'options' => ['id' => $medicalFormId, 'enctype' => 'multipart/form-data'],
|
||||
]); ?>
|
||||
<?= Html::hiddenInput('returnTo', 'medical-visits') ?>
|
||||
<?= Html::hiddenInput('medicalMediaGalleryPath', $newMedicalMediaPath, ['id' => 'medical-media-gallery-path']) ?>
|
||||
<?= $medicalForm->errorSummary($medicalVisitForm, ['showAllErrors' => true]) ?>
|
||||
|
||||
<div class="panel panel-default" style="margin-bottom:12px;">
|
||||
<div class="panel-heading"><strong><?= Yii::t('AnimalManagementModule.base', 'Visit') ?></strong></div>
|
||||
<div class="panel-body" style="padding-bottom:8px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-6"><?= $medicalForm->field($medicalVisitForm, 'visit_at')->input('datetime-local') ?></div>
|
||||
<div class="col-sm-6"><?= $medicalForm->field($medicalVisitForm, 'provider_name') ?></div>
|
||||
</div>
|
||||
<?= $medicalForm->field($medicalVisitForm, 'notes')->textarea(['rows' => 3]) ?>
|
||||
<?= $medicalForm->field($medicalVisitForm, 'recommendations')->textarea(['rows' => 3]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default" style="margin-bottom:12px;">
|
||||
<div class="panel-heading"><strong><?= Yii::t('AnimalManagementModule.base', 'Vitals') ?></strong></div>
|
||||
<div class="panel-body" style="padding-bottom:8px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><?= $renderCustomField('weight', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-3"><?= $renderCustomField('pulse', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-3"><?= $renderCustomField('blood_pressure', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-3"><?= $renderCustomField('oxygen', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default" style="margin-bottom:12px;">
|
||||
<div class="panel-heading"><strong><?= Yii::t('AnimalManagementModule.base', 'Conditions') ?></strong></div>
|
||||
<div class="panel-body" style="padding-bottom:8px;">
|
||||
<?= $renderCustomField('chronic_conditions', $medicalVisitForm, $medicalCustomDefinitions) ?>
|
||||
<?= $renderCustomField('acute_conditions', $medicalVisitForm, $medicalCustomDefinitions) ?>
|
||||
<?= $renderCustomField('special_needs', $medicalVisitForm, $medicalCustomDefinitions) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default" style="margin-bottom:12px;">
|
||||
<div class="panel-heading"><strong><?= Yii::t('AnimalManagementModule.base', 'Medical Visit Detail') ?></strong></div>
|
||||
<div class="panel-body" style="padding-bottom:8px;">
|
||||
<?= $renderCustomField('date_of_most_recent_medical_visit', $medicalVisitForm, $medicalCustomDefinitions) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default" style="margin-bottom:12px;">
|
||||
<div class="panel-heading"><strong><?= Yii::t('AnimalManagementModule.base', 'Media') ?></strong></div>
|
||||
<div class="panel-body" style="padding-bottom:8px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-4" style="margin-bottom:8px;">
|
||||
<div id="medical-media-preview" style="border-radius:8px;overflow:hidden;background:#f2f4f6;height:150px;display:flex;align-items:center;justify-content:center;">
|
||||
<?php if ($hasNewMedicalMedia): ?>
|
||||
<img src="<?= Html::encode($newMedicalMediaPath) ?>" alt="<?= Yii::t('AnimalManagementModule.base', 'Selected medical media') ?>" style="width:100%;height:100%;object-fit:cover;">
|
||||
<?php else: ?>
|
||||
<i class="fa fa-image fa-2x" style="color:#a7b0b8;"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#<?= Html::encode($medicalGalleryModalId) ?>" style="margin-bottom:8px;">
|
||||
<i class="fa fa-photo"></i> <?= Yii::t('AnimalManagementModule.base', 'Choose from Gallery or Upload') ?>
|
||||
</button>
|
||||
<div class="checkbox" style="margin-top:0;">
|
||||
<label>
|
||||
<input type="checkbox" name="removeMedicalMedia" value="1">
|
||||
<?= Yii::t('AnimalManagementModule.base', 'Remove selected media') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default" style="margin-bottom:12px;">
|
||||
<div class="panel-heading"><strong><?= Yii::t('AnimalManagementModule.base', 'Physician') ?></strong></div>
|
||||
<div class="panel-body" style="padding-bottom:8px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-6"><?= $renderCustomField('physician_name', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-6"><?= $renderCustomField('physician_business_name', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-12"><?= $renderCustomField('physician_street_address', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-4"><?= $renderCustomField('physician_city', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-4"><?= $renderCustomField('physician_state', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-4"><?= $renderCustomField('physician_zip', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-4"><?= $renderCustomField('physician_cell_phone', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-4"><?= $renderCustomField('physician_business_phone', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
<div class="col-sm-4"><?= $renderCustomField('physician_license_number', $medicalVisitForm, $medicalCustomDefinitions) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($remainingMedicalDefinitions)): ?>
|
||||
<div class="panel panel-default" style="margin-bottom:12px;">
|
||||
<div class="panel-heading"><strong><?= Yii::t('AnimalManagementModule.base', 'Additional Details') ?></strong></div>
|
||||
<div class="panel-body" style="padding-bottom:8px;">
|
||||
<?php foreach ($remainingMedicalDefinitions as $fieldKey => $definition): ?>
|
||||
<?= $renderCustomField($fieldKey, $medicalVisitForm, $remainingMedicalDefinitions) ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= Button::save(Yii::t('AnimalManagementModule.base', 'Add Medical Visit'))->submit() ?>
|
||||
<?php ActiveForm::end(); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($canManage): ?>
|
||||
<div class="modal fade" id="<?= Html::encode($medicalGalleryModalId) ?>" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="<?= Yii::t('AnimalManagementModule.base', 'Close') ?>"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><?= Yii::t('AnimalManagementModule.base', 'Select Medical Media from Gallery') ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<?php if (empty($galleryItems)): ?>
|
||||
<div class="text-muted" style="margin-bottom:10px;"><?= Yii::t('AnimalManagementModule.base', 'No gallery images available yet.') ?></div>
|
||||
<?php else: ?>
|
||||
<div class="row" style="max-height:280px;overflow:auto;margin-bottom:10px;">
|
||||
<?php foreach ($galleryItems as $galleryItem): ?>
|
||||
<?php $galleryUrl = trim((string)$galleryItem->getImageUrl()); ?>
|
||||
<?php if ($galleryUrl === '') { continue; } ?>
|
||||
<div class="col-xs-6 col-sm-4" style="margin-bottom:8px;">
|
||||
<button type="button" class="btn btn-default medical-media-select-thumb<?= $newMedicalMediaPath === $galleryUrl ? ' is-selected' : '' ?>" data-media-url="<?= Html::encode($galleryUrl) ?>" style="width:100%;padding:3px;">
|
||||
<img src="<?= Html::encode($galleryUrl) ?>" alt="<?= Yii::t('AnimalManagementModule.base', 'Gallery image') ?>" style="width:100%;height:120px;object-fit:cover;display:block;">
|
||||
</button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="form-group" style="margin-bottom:0;">
|
||||
<label class="control-label" for="medicalMediaUpload"><?= Yii::t('AnimalManagementModule.base', 'Upload New Image') ?></label>
|
||||
<input type="file" class="form-control" id="medicalMediaUpload" name="medicalMediaUpload" form="<?= Html::encode($medicalFormId) ?>" accept="image/*">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$this->registerJs(<<<JS
|
||||
(function(){
|
||||
var pageRootSelector = '#medical-visits-page';
|
||||
var formSelector = '#{$medicalFormId}';
|
||||
|
||||
function scrollInlineEditorIntoView(editor) {
|
||||
var editorNode = $(editor);
|
||||
if (!editorNode.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var sideSpacing = parseFloat(editorNode.css('margin-left'));
|
||||
if (!(sideSpacing > 0)) {
|
||||
sideSpacing = parseFloat(editorNode.closest('.panel-body').css('padding-left'));
|
||||
}
|
||||
if (!(sideSpacing > 0)) {
|
||||
sideSpacing = 14;
|
||||
}
|
||||
|
||||
var fixedHeaderHeight = 0;
|
||||
$('.navbar-fixed-top:visible, #topbar:visible, .topbar:visible, .layout-top-container:visible').each(function() {
|
||||
var h = $(this).outerHeight() || 0;
|
||||
if (h > fixedHeaderHeight) {
|
||||
fixedHeaderHeight = h;
|
||||
}
|
||||
});
|
||||
|
||||
var topReserve = Math.max(sideSpacing, 14) + Math.max(fixedHeaderHeight, 64) + 28;
|
||||
var top = Math.max(0, editorNode.offset().top - topReserve);
|
||||
$('html, body').stop(true).animate({scrollTop: top}, 220);
|
||||
}
|
||||
|
||||
function refreshMedicalVisitsPageRoot() {
|
||||
return $.get(window.location.href).done(function(html) {
|
||||
var doc = $('<div></div>').append($.parseHTML(html, document, true));
|
||||
var nextRoot = doc.find(pageRootSelector).first();
|
||||
if (!nextRoot.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(pageRootSelector).replaceWith(nextRoot);
|
||||
if (typeof window.initMedicalVisitsPage === 'function') {
|
||||
window.initMedicalVisitsPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!window.__animalMedicalVisitsInlineListenerBound) {
|
||||
window.__animalMedicalVisitsInlineListenerBound = true;
|
||||
window.addEventListener('message', function(event) {
|
||||
var data = event.data || {};
|
||||
if (!data || typeof data !== 'object' || data.source !== 'animal-inline-editor') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type === 'cancel') {
|
||||
if (data.collapseId) {
|
||||
$('#' + data.collapseId).collapse('hide');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type === 'saved') {
|
||||
if (data.collapseId) {
|
||||
$('#' + data.collapseId).collapse('hide');
|
||||
}
|
||||
refreshMedicalVisitsPageRoot();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.initMedicalVisitsPage = function() {
|
||||
$(document)
|
||||
.off('shown.bs.collapse.medicalInlineScroll', pageRootSelector + ' .medical-feed-inline-editor')
|
||||
.on('shown.bs.collapse.medicalInlineScroll', pageRootSelector + ' .medical-feed-inline-editor', function() {
|
||||
scrollInlineEditorIntoView(this);
|
||||
});
|
||||
|
||||
$(document)
|
||||
.off('click.medicalInlineScroll', pageRootSelector + ' a[href^="#medical-edit-inline-"], ' + pageRootSelector + ' a[href="#medical-add-inline"]')
|
||||
.on('click.medicalInlineScroll', pageRootSelector + ' a[href^="#medical-edit-inline-"], ' + pageRootSelector + ' a[href="#medical-add-inline"]', function() {
|
||||
var target = $(this).attr('href');
|
||||
if (!target || target.charAt(0) !== '#') {
|
||||
return;
|
||||
}
|
||||
|
||||
window.setTimeout(function() {
|
||||
scrollInlineEditorIntoView($(target));
|
||||
}, 260);
|
||||
});
|
||||
|
||||
var preopenedEditor = $(pageRootSelector + ' .medical-feed-inline-editor.in').first();
|
||||
if (preopenedEditor.length) {
|
||||
window.setTimeout(function() {
|
||||
scrollInlineEditorIntoView(preopenedEditor);
|
||||
}, 260);
|
||||
}
|
||||
|
||||
function renderMedicalPreview(source) {
|
||||
var preview = $('#medical-media-preview');
|
||||
if (!preview.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (source) {
|
||||
preview.html('<img src="' + source + '" alt="Selected medical media" style="width:100%;height:100%;object-fit:cover;">');
|
||||
} else {
|
||||
preview.html('<i class="fa fa-image fa-2x" style="color:#a7b0b8;"></i>');
|
||||
}
|
||||
}
|
||||
|
||||
function markSelectedMedicalThumb(value) {
|
||||
$('.medical-media-select-thumb').removeClass('is-selected');
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.medical-media-select-thumb').each(function() {
|
||||
if (($(this).attr('data-media-url') || '') === value) {
|
||||
$(this).addClass('is-selected');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).off('click.medicalMediaSelect', pageRootSelector + ' .medical-media-select-thumb').on('click.medicalMediaSelect', pageRootSelector + ' .medical-media-select-thumb', function() {
|
||||
var mediaUrl = $(this).attr('data-media-url') || '';
|
||||
$('#medical-media-gallery-path').val(mediaUrl);
|
||||
markSelectedMedicalThumb(mediaUrl);
|
||||
$('#medicalMediaUpload').val('');
|
||||
$('input[name="removeMedicalMedia"]').prop('checked', false);
|
||||
if (mediaUrl) {
|
||||
renderMedicalPreview(mediaUrl);
|
||||
}
|
||||
$('#{$medicalGalleryModalId}').modal('hide');
|
||||
});
|
||||
|
||||
$(document).off('change.medicalMediaUpload', '#medicalMediaUpload').on('change.medicalMediaUpload', '#medicalMediaUpload', function() {
|
||||
var file = this.files && this.files[0] ? this.files[0] : null;
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#medical-media-gallery-path').val('');
|
||||
markSelectedMedicalThumb('');
|
||||
$('input[name="removeMedicalMedia"]').prop('checked', false);
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
renderMedicalPreview(e.target.result);
|
||||
$('#{$medicalGalleryModalId}').modal('hide');
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
|
||||
$(document).off('shown.bs.modal.medicalMediaModal', '#{$medicalGalleryModalId}').on('shown.bs.modal.medicalMediaModal', '#{$medicalGalleryModalId}', function() {
|
||||
markSelectedMedicalThumb($('#medical-media-gallery-path').val());
|
||||
});
|
||||
|
||||
$(document).off('submit.medicalVisitAjax', formSelector).on('submit.medicalVisitAjax', formSelector, function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var form = this;
|
||||
var formData = new FormData(form);
|
||||
var submitButtons = $(form).find('button[type="submit"], input[type="submit"]');
|
||||
submitButtons.prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: form.action,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false
|
||||
}).always(function() {
|
||||
submitButtons.prop('disabled', false);
|
||||
}).done(function() {
|
||||
$('#{$medicalAddModalId}').modal('hide');
|
||||
refreshMedicalVisitsPageRoot();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
window.initMedicalVisitsPage();
|
||||
})();
|
||||
JS
|
||||
, \yii\web\View::POS_END);
|
||||
?>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user