<?php
global $gdb;

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