customFields[$fieldKey] ?? '';
ob_start();
?>
= Html::textarea($fieldName, (string)$fieldValue, ['class' => 'form-control', 'rows' => 3, 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
= Html::dropDownList(
$fieldName,
(string)$fieldValue,
$model->getCustomFieldSelectOptions($fieldKey),
['class' => 'form-control', 'prompt' => Yii::t('AnimalManagementModule.base', 'Select...'), 'id' => "animalprogressupdateform-customfields-$fieldKey"]
) ?>
= Html::input('number', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'step' => 'any', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
= Html::input('date', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
= Html::input('datetime-local', $fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
= Html::textInput($fieldName, (string)$fieldValue, ['class' => 'form-control', 'id' => "animalprogressupdateform-customfields-$fieldKey"]) ?>
getCustomFieldDefinitions();
$knownProgressKeys = ['progress_notes', 'routine_updates', 'media_reference'];
$otherProgressCustomDefinitions = [];
foreach ($progressCustomDefinitions as $fieldKey => $definition) {
if (in_array($fieldKey, $knownProgressKeys, true)) {
continue;
}
$otherProgressCustomDefinitions[$fieldKey] = $definition;
}
$currentMediaReference = trim((string)($progressUpdateForm->customFields['media_reference'] ?? ''));
$progressAddModalId = 'add-progress-update-modal';
$progressFormId = 'add-progress-update-main-form';
$openProgressEditId = (int)Yii::$app->request->get('inlineProgressEdit', 0);
$openProgressAdd = (int)Yii::$app->request->get('inlineProgressAdd', 0) === 1;
?>
= Yii::t('AnimalManagementModule.base', 'Progress Feed') ?>
= 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;']
) ?>
= Html::a(' ' . Yii::t('AnimalManagementModule.base', 'Add Progress Update'), '#progress-add-inline', [
'class' => 'btn btn-success btn-sm',
'title' => Yii::t('AnimalManagementModule.base', 'Add Progress Update'),
'aria-label' => Yii::t('AnimalManagementModule.base', 'Add Progress Update'),
'data-toggle' => 'collapse',
]) ?>
= Yii::t('AnimalManagementModule.base', 'No progress updates recorded.') ?>
getCustomFieldDisplayValues($canManage);
$mediaReference = '';
$progressCustomDisplayValues = [];
foreach ($progressCustomValues as $customField) {
if ((string)($customField['field_key'] ?? '') === 'media_reference') {
$mediaReference = trim((string)$customField['value']);
continue;
}
$progressCustomDisplayValues[] = $customField;
}
$hasMediaImage = $mediaReference !== '' && (preg_match('/^https?:\/\//i', $mediaReference) || substr($mediaReference, 0, 1) === '/');
?>
= Html::encode(DateDisplayHelper::format((string)$update->update_at)) ?>
weight) || !empty($update->vitals)): ?>
weight)): ?>= Yii::t('AnimalManagementModule.base', 'Weight') ?>: = Html::encode((string)$update->weight) ?>
vitals)): ?>= Yii::t('AnimalManagementModule.base', 'Vitals') ?>
vitals)): ?>
= Yii::t('AnimalManagementModule.base', 'Vitals') ?>
= nl2br(Html::encode($update->vitals)) ?>
behavior_notes)): ?>
= Yii::t('AnimalManagementModule.base', 'Behavior') ?>
= nl2br(Html::encode($update->behavior_notes)) ?>
meal_plan_changes)): ?>
= Yii::t('AnimalManagementModule.base', 'Meal Plan') ?>
= nl2br(Html::encode($update->meal_plan_changes)) ?>
housing_changes)): ?>
= Yii::t('AnimalManagementModule.base', 'Housing') ?>
= nl2br(Html::encode($update->housing_changes)) ?>
medical_concerns)): ?>
= Yii::t('AnimalManagementModule.base', 'Medical Concerns') ?>
= nl2br(Html::encode($update->medical_concerns)) ?>
= Yii::t('AnimalManagementModule.base', 'Additional Fields') ?>
= Html::encode((string)$customField['label']) ?>: = nl2br(Html::encode((string)$customField['value'])) ?>
$space->createUrl('/animal_management/animals/add-progress-update', ['id' => $animal->id]),
'options' => ['id' => $progressFormId, 'enctype' => 'multipart/form-data'],
]); ?>
= Html::hiddenInput('returnTo', 'progress-updates') ?>
= $progressForm->errorSummary($progressUpdateForm, ['showAllErrors' => true]) ?>
= Yii::t('AnimalManagementModule.base', 'Progress Update') ?>
= $progressForm->field($progressUpdateForm, 'weight') ?>
= $progressForm->field($progressUpdateForm, 'vitals')->textInput(['maxlength' => 255]) ?>
= $progressForm->field($progressUpdateForm, 'behavior_notes')->textarea(['rows' => 2]) ?>
= $progressForm->field($progressUpdateForm, 'medical_concerns')->textarea(['rows' => 2]) ?>
= $progressForm->field($progressUpdateForm, 'meal_plan_changes')->textarea(['rows' => 2]) ?>
= $progressForm->field($progressUpdateForm, 'housing_changes')->textarea(['rows' => 2]) ?>
= Yii::t('AnimalManagementModule.base', 'Notes') ?>
= $renderCustomField('progress_notes', $progressUpdateForm, $progressCustomDefinitions) ?>
= $renderCustomField('routine_updates', $progressUpdateForm, $progressCustomDefinitions) ?>
= Yii::t('AnimalManagementModule.base', 'Additional Details') ?>
$definition): ?>
= $renderCustomField($fieldKey, $progressUpdateForm, $otherProgressCustomDefinitions) ?>
= Yii::t('AnimalManagementModule.base', 'Media') ?>
= Yii::t('AnimalManagementModule.base', 'Social Post') ?>
= $progressForm->field($progressUpdateForm, 'post_to_space_feed')->checkbox() ?>
= $progressForm->field($progressUpdateForm, 'post_to_animal_feed')->checkbox() ?>
= Button::save(Yii::t('AnimalManagementModule.base', 'Add Progress Update'))->submit() ?>
registerCss(<<registerJs(<< 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 refreshProgressUpdatesPageRoot() {
return $.get(window.location.href).done(function(html) {
var doc = $('').append($.parseHTML(html, document, true));
var nextRoot = doc.find(pageRootSelector).first();
if (!nextRoot.length) {
return;
}
$(pageRootSelector).replaceWith(nextRoot);
if (typeof window.initProgressUpdatesPage === 'function') {
window.initProgressUpdatesPage();
}
});
}
if (!window.__animalProgressUpdatesInlineListenerBound) {
window.__animalProgressUpdatesInlineListenerBound = 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');
}
refreshProgressUpdatesPageRoot();
}
});
}
window.initProgressUpdatesPage = function() {
$(document)
.off('shown.bs.collapse.progressInlineScroll', pageRootSelector + ' .progress-feed-inline-editor')
.on('shown.bs.collapse.progressInlineScroll', pageRootSelector + ' .progress-feed-inline-editor', function() {
scrollInlineEditorIntoView(this);
});
$(document)
.off('click.progressInlineScroll', pageRootSelector + ' a[href^="#progress-edit-inline-"], ' + pageRootSelector + ' a[href="#progress-add-inline"]')
.on('click.progressInlineScroll', pageRootSelector + ' a[href^="#progress-edit-inline-"], ' + pageRootSelector + ' a[href="#progress-add-inline"]', function() {
var target = $(this).attr('href');
if (!target || target.charAt(0) !== '#') {
return;
}
window.setTimeout(function() {
scrollInlineEditorIntoView($(target));
}, 260);
});
var preopenedEditor = $(pageRootSelector + ' .progress-feed-inline-editor.in').first();
if (preopenedEditor.length) {
window.setTimeout(function() {
scrollInlineEditorIntoView(preopenedEditor);
}, 260);
}
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.progressMediaSelect', '.progress-media-select-thumb').on('click.progressMediaSelect', '.progress-media-select-thumb', function(event) {
event.preventDefault();
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) {
$('#progress-media-preview').html('
');
}
$('#progress-media-modal').modal('hide');
});
$(document).off('change.progressMediaUpload', '#progressMediaUpload').on('change.progressMediaUpload', '#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) {
$('#progress-media-preview').html('
');
$('#progress-media-modal').modal('hide');
};
reader.readAsDataURL(file);
});
$(document).off('shown.bs.modal.progressMediaModal', '#progress-media-modal').on('shown.bs.modal.progressMediaModal', '#progress-media-modal', function() {
markSelectedMediaThumb($('#progress-media-gallery-path').val());
});
$(document).off('show.bs.modal.progressMediaStack', '#progress-media-modal').on('show.bs.modal.progressMediaStack', '#progress-media-modal', function() {
var zIndex = 1060 + (10 * $('.modal.in:visible').length);
$(this).css('z-index', zIndex);
window.setTimeout(function() {
$('.modal-backdrop').not('.progress-media-stack').last().css('z-index', zIndex - 1).addClass('progress-media-stack');
}, 0);
});
$(document).off('hidden.bs.modal.progressMediaStack', '#progress-media-modal').on('hidden.bs.modal.progressMediaStack', '#progress-media-modal', function() {
$(this).css('z-index', '');
if ($('#{$progressAddModalId}').is(':visible')) {
$('body').addClass('modal-open');
}
});
$(document).off('submit.progressAjax', formSelector).on('submit.progressAjax', 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() {
$('#{$progressAddModalId}').modal('hide');
refreshProgressUpdatesPageRoot();
});
});
};
window.initProgressUpdatesPage();
})();
JS
);
?>