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(); ?>
'form-control', 'rows' => 3, 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
getCustomFieldSelectOptions($fieldKey), ['class' => 'form-control', 'prompt' => Yii::t('AnimalManagementModule.base', 'Select...'), 'id' => "animalmedicalvisitform-customfields-$fieldKey"] ) ?>
'form-control', 'step' => 'any', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
'form-control', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
'form-control', 'id' => "animalmedicalvisitform-customfields-$fieldKey"]) ?>
'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 = 'edit-medical-media-gallery-modal'; $medicalFormId = 'edit-medical-visit-form'; $this->registerCss(<< .panel-heading { color: #eef5fb; background: rgba(10, 18, 28, 0.42); border-color: rgba(255, 255, 255, 0.2); } .inline-editor-shell > .panel-body { background: rgba(10, 18, 28, 0.2); } .inline-editor-shell .panel.panel-default { border-color: rgba(255, 255, 255, 0.2); background: rgba(10, 18, 28, 0.34); } .inline-editor-shell .panel.panel-default > .panel-heading { color: #eef5fb; background: rgba(10, 18, 28, 0.42); border-color: rgba(255, 255, 255, 0.2); } .inline-editor-shell .panel.panel-default > .panel-heading a { color: inherit; display: block; text-decoration: none; } .inline-editor-shell .panel.panel-default > .panel-heading a:hover, .inline-editor-shell .panel.panel-default > .panel-heading a:focus { color: #ffffff; text-decoration: none; } .inline-editor-shell, .inline-editor-shell .panel-body, .inline-editor-shell .control-label, .inline-editor-shell .checkbox label, .inline-editor-shell .radio label, .inline-editor-shell .help-block { color: #eef5fb; } .inline-editor-shell .text-muted { color: rgba(233, 242, 250, 0.78) !important; } .inline-editor-shell .form-control { background: rgba(10, 18, 28, 0.56); border-color: rgba(255, 255, 255, 0.44); color: #f3f8ff; } .inline-editor-shell .form-control::placeholder { color: rgba(243, 248, 255, 0.72); } .inline-editor-shell .form-control[readonly], .inline-editor-shell .form-control[disabled] { background: rgba(10, 18, 28, 0.42); color: rgba(243, 248, 255, 0.72); } .inline-editor-shell select.form-control option { color: #0f1b2a; } .inline-editor-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-editor-shell .animal-inline-top-save-action:hover, .inline-editor-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 ); } ?>
Edit Medical Visit') ?> ', [ 'class' => 'animal-inline-top-save-action', 'title' => Yii::t('AnimalManagementModule.base', 'Save Medical Visit'), 'form' => $medicalFormId, ]) ?> ', [ 'id' => 'medical-inline-cancel-icon', 'class' => 'animal-inline-top-save-action', 'title' => Yii::t('AnimalManagementModule.base', 'Cancel'), 'type' => 'button', ]) ?>
$medicalFormId, 'enctype' => 'multipart/form-data']; if (!$isInline) { $formOptions['target'] = '_top'; } $form = ActiveForm::begin(['options' => $formOptions]); ?> 'medical-media-gallery-path']) ?> errorSummary($model, ['showAllErrors' => true]) ?>
field($model, 'visit_at')->input('datetime-local') ?>
field($model, 'provider_name') ?>
field($model, 'notes')->textarea(['rows' => 3]) ?> field($model, 'recommendations')->textarea(['rows' => 3]) ?>
field($model, 'post_to_space_feed')->checkbox() ?> field($model, 'post_to_animal_feed')->checkbox() ?>
$definition): ?>
submit() ?> link(($returnTo ?? 'view') === 'medical-visits' ? $space->createUrl('/animal_management/animals/medical-visits', ['id' => $animal->id]) : $space->createUrl('/animal_management/animals/view', ['id' => $animal->id])) ?>
registerJs(<<'); } else { preview.html(''); } } 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-edit-inline-' . (int)$medicalVisit->id, ]); $this->registerJs(<<