<?php
global $gdb;

$grid = new \grid( 'pp_seo_additional' );
$grid -> gdb_opt      = $gdb;
$grid -> order        = [ 'column' => 'url', 'type' => 'ASC' ];
$grid -> search       = [
                            [ 'name' => 'Url', 'db' => 'url', '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'  => 'Url',
                            'db'    => 'url',
                            'php'   => 'echo "<a href=\'/admin/seo_additional/element_edit/id=[id]\'>[url]</a>";',
                            'sort'  => true
                          ],
                          [
                            'name'  => 'Title',
                            'db'    => 'title',
                            'sort'  => true
                          ],
                          [
                            'name' => 'Aktywny',
                            'db' => 'status',
                            'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
                            'td' => [ 'class' => 'g-center' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
                            'sort' => true
                          ],
                          [ 
                            'name' => 'Edytuj', 
                            'action' => [ 'type' => 'edit', 'url' => '/admin/seo_additional/element_edit/id=[id]' ], 
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
                            'td' => [ 'class' => 'g-center' ]
                          ],
                          [ 
                            'name' => 'Usuń', 
                            'action' => [ 'type' => 'delete', 'url' => '/admin/seo_additional/element_delete/id=[id]' ], 
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
                            'td' => [ 'class' => 'g-center' ]
                          ]
                        ];
$grid -> buttons      = [
                          [ 
                            'label' => 'Dodaj element', 
                            'url'   => '/admin/seo_additional/element_edit/', 
                            'icon'  => 'fa-plus-circle',
                            'class' => 'btn-success'
                          ]
                        ];
echo $grid -> draw();