<?php
global $config, $gdb, $mdb;

$grid = new \grid( 'domain_tester' );
$grid -> gdb_opt = $gdb;

$grid -> sql = 'SELECT * FROM domain_tester AS dt WHERE hidden = 0 [where] ORDER BY [order_p1] [order_p2]';
$grid -> sql_count = 'SELECT COUNT(0) FROM domain_tester AS dt WHERE hidden = 0 [where]';
$grid -> search = [
  [ 'name' => 'Url', 'db' => 'url', 'type' => 'text' ],
];
$grid -> order = [ 'column' => 'date_add', 'type' => 'DESC' ];
if ( \S::get( 'url' ) )
  $grid -> filters    = [ 'url' => [ 'value' => \S::get( 'url' ), 'type' => 'like' ] ];

$grid -> columns_view = [
                          [
                            'name' => 'Lp.',
                            'th' => [ 'class' => 'g-lp' ],
                            'td' => [ 'class' => 'g-center' ],
                            'autoincrement' => true
                          ],
                          [
                            'name' => 'Data dodania',
                            'th' => [ 'style' => 'width: 150px; text-align: center;' ],
                            'td' => [ 'style' => 'text-align: center;' ],
                            'db' => 'date_add',
                            'date_mod' => 'Y-m-d H:i',
                            'sort' => true
                          ], [
                            'name'   => 'Rank',
                            'th' => [ 'style' => 'width: 75px; text-align: center;' ],
                            'td' => [ 'style' => 'text-align: center;' ],
                            'db'     => 'opr',
                            'sort'   => true,
                          ], [
                            'name'  => 'Url',
                            'db'    => 'url',
                            'sort'  => true,
                            'php'   => 'echo "<a href=\'http://[url]\' target=\'blank\'>[url]</a>";'
                          ], [
                            'name'   => 'Archive',
                            'th'     => [ 'style' => 'text-align: center;' ],
                            'td'     => [ 'style' => 'text-align: center;' ],
                            'php'    => 'echo "<a href=\'https://web.archive.org/web/[url]\' target=\'_blank\'>archive</a>";'
                          ], [
                            'name' => 'Akcja',
                            'th' => [ 'style' => 'width: 125px; text-align: center;' ],
                            'td' => [ 'style' => 'text-align: center;' ],
                            'php' => ' echo "<a href=\'#\'>ukryj domenę</a>";'
                          ], [
                            'name' => 'Akcja',
                            'action' => [ 'type' => 'delete', 'url' => '#' ],
                            'th' => [ 'class' => 'g-center' ],
                            'td' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ]
                          ]
                        ];
echo $grid -> draw();
?>