<?php
global $gdb;

$grid = new \grid( 'pp_langs' );
$grid -> gdb_opt      = $gdb;
$grid -> order        = [ 'column' => 'o', 'type' => 'ASC' ];
$grid -> search       = [
                            [ 'name' => 'Język', 'db' => 'name', 'type' => 'text' ],
                            [ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ],
                            [ 'name' => 'Domyślny', 'db' => 'start', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
                        ];
$grid -> columns_view = [
                          [ 
                            'name' => 'Lp.',
                            'th' => [ 'class' => 'g-lp' ],
                            'td' => [ 'class' => 'g-center' ],
                            'autoincrement' => true 
                          ],
                          [
                            'name'  => 'Domyślny',
                            'db'    => 'start',
                            'th'    => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
                            'td'    => [ 'class' => 'g-center' ],
                            'php'   => 'if ( [start] ) echo "<span class=\'text-system\'>tak</span>"; else echo "nie";'
                          ],
                          [
                            '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' => 'Język',
                            'db' => 'name'
                          ],
                          [ 
                            'name' => 'Edytuj', 
                            'action' => [ 'type' => 'edit', 'url' => '/admin/languages/language_edit/id=[id]' ], 
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
                            'td' => [ 'class' => 'g-center' ]
                          ],
                          [ 
                            'name' => 'Usuń', 
                            'action' => [ 'type' => 'delete', 'url' => '/admin/languages/language_delete/id=[id]' ], 
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
                            'td' => [ 'class' => 'g-center' ]
                          ]
                        ];
$grid -> buttons      = [
                          [ 
                            'label' => 'Dodaj język', 
                            'url'   => '/admin/languages/language_edit/', 
                            'icon'  => 'fa-plus-circle',
                            'class' => 'btn-success'
                          ]
                        ];
echo $grid -> draw();