<?php
global $gdb;

$grid = new \grid( 'pp_layouts' );
$grid -> gdb_opt      = $gdb;
$grid -> order        = [ 'column' => 'name', 'type' => 'ASC' ];
$grid -> search       = [
                            [ 'name' => 'Nazwa', 'db' => 'name', 'type' => 'text' ],
                            [ 'name' => 'Szablon domyślny', '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'  => 'Nazwa',
                            'db'    => 'name',
                            'php'   => 'echo "<a href=\'/admin/layouts/layout_edit/id=[id]\'>[name]</a>";',
                            'sort'  => true
                          ],
                          [
                            'name' => 'Szablon domyślny',
                            'db' => 'status',
                            'replace' => [ 'array' => [ 0 => 'nie', 1 => '<span class="text-system">tak</span>' ] ],
                            'td' => [ 'class' => 'g-center' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
                          ],
                          [ 
                            'name' => 'Akcja', 
                            'action' => [ 'type' => 'edit', 'url' => '/admin/layouts/layout_edit/id=[id]' ], 
                            'th' => [ 'class' => 'g-center' ],
                            'td' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ]
                          ],
                          [ 
                            'name' => 'Akcja', 
                            'action' => [ 'type' => 'delete', 'url' => '/admin/layouts/layout_delete/id=[id]' ], 
                            'th' => [ 'class' => 'g-center' ],
                            'td' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ]
                          ]
                        ];
$grid -> buttons      = [
                          [ 'label' => 'Dodaj szablon', 'url' => '/admin/layouts/layout_edit/', 'icon' => 'fa-plus-circle', 'class' => 'btn-success' ]
                        ];
echo $grid -> draw();