return function () {
$self = url('/@object/@action/' . urlencode('table/filter'));
// the row buttons link back here: the demo only reports the click, nothing is edited
$act = preg_replace('~[^a-z]~', '', (string) ($_GET['act'] ?? ''));
$notice = $act ? '<div class="alert alert-info">Button <b>' . $act . '</b>' . (isset($_GET['row']) ? ' of row <b>' . (int) $_GET['row'] . '</b>' : '') . ' was clicked (the demo only shows it).</div>' : '';
$data = json_decode(file_get_contents(__DIR__ . '/products.json'), true);
return $notice . table($data, [
'filter' => true,
'filter_params' => [
'name' => 'like',
'price' => 'between',
],
])
->image('id', 'uploads/shop/products/{subdir2}/{subdir3}/product_%d_1_thumb.jpg', ['width' => '50px'])
->text('name')
->link('cat_id', url('/@object/@action/' . urlencode('table/products')), _class('cats')->_get_items_names('shop_cats'))
->text('price')
->text('quantity')
->date('add_date')
->btn_edit(['icon' => 'icon-star', 'link' => $self . '?act=edit&row=%d', 'no_ajax' => 1])
->btn_delete(['link' => $self . '?act=delete&row=%d', 'no_ajax' => 1])
->btn_clone(['link' => $self . '?act=clone&row=%d', 'no_ajax' => 1])
->btn_active(['link' => $self . '?act=active&row=%d'])
->footer_add(['link' => $self . '?act=add', 'no_ajax' => 1]);
};