<?php global $gdb;?>
<div class="row block-header">
  <div class="col-12">
    <h2>Lista <strong>klientów </strong></h2>
  </div>
</div>
<?php
$grid = new \grid( 'crm_client' );
$grid -> debug = true;
$grid -> gdb_opt = $gdb;
$grid -> search = [
    [ 'name' => 'Nazwa', 'db' => 'firm', 'type' => 'text' ],
    [ 'name' => 'Status', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => \factory\Crm::$status ] ],
];
$grid -> order = [ 'column' => 'firm', 'type' => 'ASC' ];
$grid -> columns_view = [
    [
        'name'          => 'Lp.',
        'th'            => [ 'class' => 'g-lp' ],
        'td'            => [ 'class' => 'g-center' ],
        'autoincrement' => true
    ], [
        'name' => 'Zaktualizowano',
        'db'   => 'date_update',
        'td'   => [ 'class' => 'g-center' ],
        'th'   => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
        'php'  => 'echo date( "Y-m-d H:i", strtotime( "[date_update]" ) );',
        'sort' => true
    ], [
        'name' => 'Nazwa',
        'db'   => 'firm',
    ], [
        'name' => 'Nazwa firmy',
        'db'   => 'firm_name',
    ], [
        'name' => 'Telefony',
        'db'   => 'phones',
    ], [
        'name' => 'Emaile',
        'db'   => 'emails'
    ], [
        'name'   => 'Edytuj',
        'action' => [ 'type' => 'edit', 'url' => '/crm/client_edit/id=[id]' ],
        'th'     => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
        'td'     => [ 'class' => 'g-center' ]
    ], [
        'name'   => 'Usuń',
        'action' => [ 'type' => 'delete', 'url' => '/crm/client_delete/client_id=[id]' ],
        'th'     => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
        'td'     => [ 'class' => 'g-center' ]
    ]
];
$grid -> buttons = [
    [
        'label' => 'Dodaj klienta',
        'url'   => '/crm/client_edit/',
        'icon'  => 'fa-plus-circle',
        'class' => 'btn-success'
    ]
];
$grid -> hide_columns = false;
$grid -> default_buttons = false;
$grid -> limit = 25;
echo $grid -> draw();
?>
