request->get('showTopCancel', '0') === '1';
$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 $formModel, 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 = $formModel->customFields[$fieldKey] ?? '';
ob_start();
?>
= Html::textarea($fieldName, (string)$fieldValue, ['class' => 'form-control', 'rows' => 3, 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
= Html::dropDownList(
$fieldName,
(string)$fieldValue,
$formModel->getCustomFieldSelectOptions($fieldKey),
['class' => 'form-control', 'prompt' => Yii::t('AnimalManagementModule.base', 'Select...'), 'id' => "animalmedicalvisitform-customfields-$fieldKey"]
) ?>
= Html::input('number', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'step' => 'any', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
= Html::input('date', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
= Html::input('datetime-local', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
= Html::textInput($fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
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',
];
$remainingDefinitions = [];
foreach ($customDefinitions as $fieldKey => $definition) {
if (in_array($fieldKey, $knownMedicalKeys, true) || in_array($fieldKey, $hiddenMedicalKeys, true)) {
continue;
}
$remainingDefinitions[$fieldKey] = $definition;
}
$medicalMediaPath = trim((string)($model->customFields['medical_media_reference'] ?? $model->customFields['media_reference'] ?? ''));
$hasMedicalMedia = $medicalMediaPath !== '' && (preg_match('/^https?:\/\//i', $medicalMediaPath) || substr($medicalMediaPath, 0, 1) === '/');
$medicalGalleryModalId = 'add-medical-media-gallery-modal';
$medicalFormId = 'add-medical-visit-inline-form';
$visitAtInputValue = trim((string)$model->visit_at);
if ($visitAtInputValue === '') {
$visitAtInputValue = date('Y-m-d\TH:i');
} else {
$visitAtTimestamp = strtotime($visitAtInputValue);
if ($visitAtTimestamp !== false) {
$visitAtInputValue = date('Y-m-d\TH:i', $visitAtTimestamp);
}
}
$this->registerCss(<< .panel-body {
position: relative;
z-index: 1;
background: rgba(10, 18, 28, 0.2);
}
.inline-add-shell .panel.panel-default {
border-color: rgba(255, 255, 255, 0.2);
background: rgba(10, 18, 28, 0.34);
}
.inline-add-shell .panel.panel-default > .panel-heading {
color: #eef5fb;
background: rgba(10, 18, 28, 0.42);
border-color: rgba(255, 255, 255, 0.2);
}
.inline-add-shell .panel.panel-default > .panel-heading a {
color: inherit;
display: block;
text-decoration: none;
}
.inline-add-shell .panel.panel-default > .panel-heading a:hover,
.inline-add-shell .panel.panel-default > .panel-heading a:focus {
color: #ffffff;
text-decoration: none;
}
.inline-add-shell,
.inline-add-shell .panel-body,
.inline-add-shell .control-label,
.inline-add-shell .checkbox label,
.inline-add-shell .radio label,
.inline-add-shell .help-block {
color: #eef5fb;
}
.inline-add-shell .text-muted {
color: rgba(233, 242, 250, 0.78) !important;
}
.inline-add-shell .form-control {
background: rgba(10, 18, 28, 0.56);
border-color: rgba(255, 255, 255, 0.44);
color: #f3f8ff;
}
.inline-add-shell .form-control::placeholder {
color: rgba(243, 248, 255, 0.72);
}
.inline-add-shell .form-control[readonly],
.inline-add-shell .form-control[disabled] {
background: rgba(10, 18, 28, 0.42);
color: rgba(243, 248, 255, 0.72);
}
.inline-add-shell select.form-control option {
color: #0f1b2a;
}
.inline-add-shell .animal-inline-top-save-action {
display: inline-flex;
align-items: center;
justify-content: center;
width: 26px;
height: 26px;
padding: 0;
border-radius: 999px;
border: 1px solid rgba(255, 255, 255, 0.36);
background: rgba(15, 23, 42, 0.72);
color: #f8fafc;
cursor: pointer;
line-height: 1;
font-size: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}
.inline-add-shell .animal-inline-top-save-action:hover,
.inline-add-shell .animal-inline-top-save-action:focus {
background: rgba(30, 41, 59, 0.86);
border-color: rgba(255, 255, 255, 0.5);
color: #f8fafc;
outline: none;
}
CSS
);
if ($isInline) {
$this->registerCss(<< .panel:first-child {
margin-top: 0 !important;
}
CSS
);
}
?>
registerJs(<<');
} else {
preview.html('');
}
setMedicalShellBackground(source);
}
function markSelectedMedicalThumb(value) {
$('.medical-media-select-thumb').removeClass('is-selected');
if (!value) {
return;
}
$('.medical-media-select-thumb').each(function() {
if ($(this).data('media-url') === value) {
$(this).addClass('is-selected');
}
});
}
$(document).on('click', '.medical-media-select-thumb', function() {
var mediaUrl = $(this).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');
});
$('#medicalMediaUpload').on('change', 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);
});
$('#{$medicalGalleryModalId}').on('shown.bs.modal', function() {
markSelectedMedicalThumb($('#medical-media-gallery-path').val());
});
})();
JS
, \yii\web\View::POS_END);
if ($isInline) {
$cancelPayload = Json::htmlEncode([
'source' => 'animal-inline-editor',
'type' => 'cancel',
'collapseId' => 'medical-add-inline',
]);
$this->registerJs(<<