request->get('showTopCancel', '0') === '1'; $renderCustomField = static function (string $fieldKey, AnimalProgressUpdateForm $formModel, array $definitions): string { if (!isset($definitions[$fieldKey])) { return ''; } $definition = $definitions[$fieldKey]; $inputType = (string)$definition['input_type']; $label = (string)$definition['label']; if ((int)$definition['required'] === 1) { $label .= ' *'; } $fieldName = "AnimalProgressUpdateForm[customFields][$fieldKey]"; $fieldValue = $formModel->customFields[$fieldKey] ?? ''; ob_start(); ?>
'form-control', 'rows' => 3, 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
getCustomFieldSelectOptions($fieldKey), ['class' => 'form-control', 'prompt' => Yii::t('AnimalManagementModule.base', 'Select...'), 'id' => "animalprogressupdateform-customfields-$fieldKey"] ) ?>
'form-control', 'step' => 'any', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
getCustomFieldDefinitions(); $knownProgressKeys = ['progress_notes', 'routine_updates', 'media_reference']; $otherCustomDefinitions = []; foreach ($customDefinitions as $fieldKey => $definition) { if (in_array($fieldKey, $knownProgressKeys, true)) { continue; } $otherCustomDefinitions[$fieldKey] = $definition; } $currentMediaReference = trim((string)($model->customFields['media_reference'] ?? '')); $progressFormId = 'add-progress-update-inline-form'; $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 ); } ?>
>
$progressFormId, 'enctype' => 'multipart/form-data']; if (!$isInline) { $formOptions['target'] = '_top'; } $form = ActiveForm::begin(['options' => $formOptions]); ?>
', [ 'class' => 'animal-inline-top-save-action', 'title' => Yii::t('AnimalManagementModule.base', 'Save Progress Update'), 'form' => $progressFormId, ]) ?> ', [ 'id' => 'progress-inline-add-cancel-icon', 'class' => 'animal-inline-top-save-action', 'title' => Yii::t('AnimalManagementModule.base', 'Cancel'), 'type' => 'button', ]) ?>
errorSummary($model, ['showAllErrors' => true]) ?>
field($model, 'weight') ?>
field($model, 'vitals')->textInput(['maxlength' => 255]) ?>
field($model, 'behavior_notes')->textarea(['rows' => 2]) ?>
field($model, 'medical_concerns')->textarea(['rows' => 2]) ?>
field($model, 'meal_plan_changes')->textarea(['rows' => 2]) ?>
field($model, 'housing_changes')->textarea(['rows' => 2]) ?>
$definition): ?>
field($model, 'post_to_space_feed')->checkbox() ?> field($model, 'post_to_animal_feed')->checkbox() ?>
submit() ?> link(($returnTo ?? 'progress-updates') === 'progress-updates' ? $space->createUrl('/animal_management/animals/progress-updates', ['id' => $animal->id]) : $space->createUrl('/animal_management/animals/view', ['id' => $animal->id])) ?>
registerCss(<<registerJs(<<'); } else { preview.html(''); } setProgressShellBackground(source); } function markSelectedMediaThumb(value) { $('.progress-media-select-thumb').removeClass('is-selected'); if (!value) { return; } $('.progress-media-select-thumb').each(function() { if (($(this).attr('data-media-url') || '') === value) { $(this).addClass('is-selected'); } }); } $(document).off('click.addProgressMediaSelect', '.progress-media-select-thumb').on('click.addProgressMediaSelect', '.progress-media-select-thumb', function() { var mediaUrl = $(this).attr('data-media-url') || ''; $('#progress-media-gallery-path').val(mediaUrl); markSelectedMediaThumb(mediaUrl); $('#progressMediaUpload').val(''); $('input[name="removeProgressMedia"]').prop('checked', false); if (mediaUrl) { renderProgressPreview(mediaUrl); } $('#progress-media-modal').modal('hide'); }); $(document).off('change.addProgressMediaUpload', '#progressMediaUpload').on('change.addProgressMediaUpload', '#progressMediaUpload', function() { var file = this.files && this.files[0] ? this.files[0] : null; if (!file) { return; } $('#progress-media-gallery-path').val(''); markSelectedMediaThumb(''); $('input[name="removeProgressMedia"]').prop('checked', false); var reader = new FileReader(); reader.onload = function(e) { renderProgressPreview(e.target.result); $('#progress-media-modal').modal('hide'); }; reader.readAsDataURL(file); }); $(document).off('shown.bs.modal.addProgressMediaModal', '#progress-media-modal').on('shown.bs.modal.addProgressMediaModal', '#progress-media-modal', function() { markSelectedMediaThumb($('#progress-media-gallery-path').val()); }); })(); JS , \yii\web\View::POS_END); if ($isInline) { $cancelPayload = Json::htmlEncode([ 'source' => 'animal-inline-editor', 'type' => 'cancel', 'collapseId' => 'progress-add-inline', ]); $this->registerJs(<<