<?php
global $gdb;

$grid = new \grid( 'pp_authors' );
$grid -> gdb_opt = $gdb;
$grid -> order = [ 'column' => 'author', 'type' => 'ASC' ];
$grid -> search = [
                    [ 'author' => 'Autor', 'db' => 'name', 'type' => 'text' ]
                  ];
$grid -> columns_view = [
                          [
                            'name' => 'Lp.',
                            'th' => [ 'class' => 'g-lp' ],
                            'td' => [ 'class' => 'g-center' ],
                            'autoincrement' => true
                          ], [
                            'name' => 'Autor',
                            'db' => 'author',
                            'sort' => true,
                            'php' => 'echo "<a href=\"/admin/authors/edit/id=[id]\">[author]</a>";'
                          ], [
                            'name' => 'Edytuj',
                            'action' => [ 'type' => 'edit', 'url' => '/admin/authors/edit/id=[id]' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
                            'td' => [ 'class' => 'g-center' ]
                          ], [
                            'name' => 'Usuń',
                            'action' => [ 'type' => 'delete', 'url' => '/admin/authors/delete/id=[id]' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
                            'td' => [ 'class' => 'g-center' ]
                          ]
                        ];
$grid -> buttons = [
                    [
                      'label' => 'Dodaj autora',
                      'url'   => '/admin/authors/edit/',
                      'icon'  => 'fa-plus-circle',
                      'class' => 'btn-success'
                    ]
                  ];
echo $grid -> draw();