<?php global $gdb;?>
<div class="block-header">
  <h2>Lista <strong>tematów</strong></h2>
</div>
<?php
$grid = new \grid( 'zaplecze_tematy' );
$grid -> debug = true;
$grid -> gdb_opt = $gdb;
$grid -> order = [ 'column' => 'data_publikacji', 'type' => 'DESC' ];
$grid -> search = [
    [ 'name' => 'zaakceptowany', 'db' => 'zaakceptowany', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ],
];
$grid -> columns_view = [
    [
      'name' => 'Lp.',
      'th' => [ 'class' => 'g-lp', 'style' => 'width: 75px' ],
      'td' => [ 'class' => 'g-center' ],
      'autoincrement' => true
    ], [
      'name' => 'Strona',
      'db'   => 'strona'
    ], [
      'name' => 'Kategoria',
      'db' => 'kategoria',
    ], [
      'name' => 'Kategoria ID',
      'db' => 'kategoria_id',
    ], [
      'name' => 'Link',
      'db' => 'link',
    ], [
      'name' => 'Temat',
      'db' => 'temat',
    ], [
      'name' => 'Data publikacji',
      'db' => 'data_publikacji',
    ], [
      'name' => 'Opublikowany',
      'db' => 'opublikowany',
      'td' => [ 'class' => 'g-center' ],
      'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
      'php' => 'echo ( (int)[opublikowany] == 1 ) ? "tak" : "<span class=\"text-danger\">nie</span>";',
    ], [
      'name' => 'Zaakceptowany',
      'db' => 'zaakceptowany',
      'td' => [ 'class' => 'g-center' ],
      'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
      'php' => 'echo ( (int)[zaakceptowany] == 1 ) ? "<a href=\"/backend_sites/topic_unaccept/id=[id]\">tak</a>" : "<a href=\"/backend_sites/topic_accept/id=[id]\" class=\"text-danger\">nie</a>";',
    ], [
        'name'   => 'Edytuj',
        'action' => [ 'type' => 'edit', 'url' => '/backend_sites/topic_edit/id=[id]' ],
        'th'     => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
        'td'     => [ 'class' => 'g-center' ]
    ], [
        'name'   => 'Usuń',
        'action' => [ 'type' => 'delete', 'url' => '/backend_sites/topic_delete/id=[id]' ],
        'th'     => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
        'td'     => [ 'class' => 'g-center' ]
    ]
];
$grid -> buttons = [
  [
    'label' => 'Dodaj temat ogólny',
    'url'   => '/backend_sites/topic_edit/',
    'icon'  => 'fa-plus-circle',
    'class' => 'btn-success'
  ]
];
$grid -> hide_columns = false;
$grid -> limit = 10;
echo $grid -> draw();
?>
