Files
de.vidok.com/admin/templates/scontainers/containers-list.php
2024-11-17 19:39:31 +01:00

79 lines
4.0 KiB
PHP

<?php
global $gdb;
$grid = new \grid( 'pp_scontainers' );
$grid -> gdb_opt = $gdb;
$grid -> sql = 'SELECT *'
. 'FROM ( '
. 'SELECT '
. 'id, status, '
. '( SELECT title FROM pp_scontainers_langs AS psl, pp_langs AS pl WHERE lang_id = pl.id AND container_id = ps.id AND title != \'\' ORDER BY o ASC LIMIT 1 ) AS title '
. 'FROM '
. 'pp_scontainers AS ps '
. ') AS q1 '
. 'WHERE '
. '1=1 [where] '
. 'ORDER BY '
. '[order_p1] [order_p2]';
$grid -> sql_count = 'SELECT '
. 'COUNT(0) FROM ( '
. 'SELECT '
. 'id, status, '
. '( SELECT title FROM pp_scontainers_langs AS psl, pp_langs AS pl WHERE lang_id = pl.id AND container_id = ps.id AND title != \'\' ORDER BY o ASC LIMIT 1 ) AS title '
. 'FROM '
. 'pp_scontainers AS ps '
. ') AS q1 '
. 'WHERE '
. '1=1 [where] ';
$grid -> debug = true;
$grid -> order = [ 'column' => 'title', 'type' => 'ASC' ];
$grid -> search = [
[ 'name' => 'Tytuł', 'db' => 'title', 'type' => 'text' ],
[ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
];
$grid -> columns_view = [
[
'name' => 'Lp.',
'th' => [ 'class' => 'g-lp' ],
'td' => [ 'class' => 'g-center' ],
'autoincrement' => true
],
[
'name' => 'Tytuł',
'db' => 'title',
'php' => 'echo "<a href=\'/admin/scontainers/container_edit/id=[id]\'>[title]</a>";',
'sort' => true
],
[
'name' => 'Kod',
'php' => 'echo "[KONTENER:[id]]";'
],
[
'name' => 'Aktywny',
'db' => 'status',
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
'td' => [ 'class' => 'g-center' ]
],
[
'name' => 'Edytuj',
'action' => [ 'type' => 'edit', 'url' => '/admin/scontainers/container_edit/id=[id]' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
'td' => [ 'class' => 'g-center' ]
],
[
'name' => 'Usuń',
'action' => [ 'type' => 'delete', 'url' => '/admin/scontainers/container_delete/id=[id]' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
'td' => [ 'class' => 'g-center' ]
]
];
$grid -> buttons = [
[
'label' => 'Dodaj kontener',
'url' => '/admin/scontainers/container_edit/',
'icon' => 'fa-plus-circle',
'class' => 'btn-success'
]
];
echo $grid -> draw();