detail.table_find.php
Исходный код
<?php
$Table = $Page;
$canFind = false;
$cols = $Table->getCols();
foreach ($cols as $name => $Col) {
if ($Col->canFind()) {
$canFind = true;
$find = $Table->getFind($name);
print "\n" . '<td' . $Col->displayClass() . $Col->displayStyle() . $Col->displayAttrs() . '>';
if ($Col->find === 'checkbox') {
print '<div class="uk-inline uk-width-1-1">';
print '<select name="find[' . htmlspecialchars($name) . ']" class="uk-select uk-form-small' . (($align = $Col->getAlign()) ? ' uk-text-' . $align : '') . '">';
print '<option value=""></option>';
print '<option value="Y"' . ($find === 'Y' ? ' selected' : '') . '>Да</option>';
print '<option value="N"' . ($find === 'N' ? ' selected' : '') . '>Нет</option>';
print '</select>';
print '<span class="uk-form-icon uk-form-icon-flip"><i class="las la-caret-down"></i></span>';
print '</div>';
} elseif ($Col->find === 'select') {
if ($Col->options) {
print '<div class="uk-inline uk-width-1-1">';
print '<select name="find[' . htmlspecialchars($name) . ']" class="uk-select uk-form-small' . (($align = $Col->getAlign()) ? ' uk-text-' . $align : '') . '">';
print $Col->displayOptions($find);
print '</select>';
print '<span class="uk-form-icon uk-form-icon-flip"><i class="las la-caret-down"></i></span>';
print '</div>';
}
} elseif ($Col->find === 'date' || $Col->find === 'datetime') {
print '<div class="uk-flex uk-width-1-1" data-name="find-' . htmlspecialchars($name) . '">';
print '<div class="uk-inline uk-width-1-2">';
print '<input type="date" name="find[' . htmlspecialchars($name) . '][0]" class="uk-input uk-form-small" value="' . htmlspecialchars(strval(is_array($find) ? $find[0] : $find)) . '" onclick="try { this.showPicker() } catch (e) { }">';
print '</div>';
print '<div class="uk-inline uk-width-1-2">';
print '<input type="date" name="find[' . htmlspecialchars($name) . '][1]" class="uk-input uk-form-small" value="' . htmlspecialchars(strval(is_array($find) ? $find[1] : $find)) . '" onclick="try { this.showPicker() } catch (e) { }">';
print '</div>';
print '</div>';
} else {
print '<div class="uk-inline uk-width-1-1">';
print '<input type="text" name="find[' . htmlspecialchars($name) . ']" class="uk-input uk-form-small" value="' . htmlspecialchars(strval($Table->getFind($name))) . '">';
print '<span class="uk-form-icon uk-form-icon-flip"><i class="las la-search"></i></span>';
print '</div>';
}
print '</td>';
} else {
print "\n" . '<td></td>';
}
}
if ($canFind) {
$html = ob_get_clean();
ob_start();
print "\n" . '<thead data-name="find"><tr class="uk-background-muted">';
print $html;
print "\n" . '</tr></thead>';
print "\n" . '<thead hidden><tr><th>';
if (strlen($sort = $Table->getSort())) print '<input type="hidden" name="sort" value="' . htmlspecialchars(strval($sort)) . '">';
if (strlen($desc = $Table->getDesc())) print '<input type="hidden" name="desc" value="' . htmlspecialchars(strval($desc)) . '">';
print '<button type="submit" hidden></button>';
print <<<X
<script>
cmsRequire(['jquery'], function($) {
$('table[data-name="{$Table->name}"] [data-name="find"]').off('change.table.find').on('change.table.find', function() {
$(this).closest('form').submit();
});
});
</script>
X;
print "\n" . '</tr></thead>';
} else {
ob_end_clean();
ob_start();
}
?>