<?php
global $gdb;

foreach ( $this -> apilo_carrier_account_list as $carrier_account )
{
  $carrier_accounts[ $carrier_account['id'] ] = $carrier_account['name'];
}
// sellasist_shipments_methods
$sellasist_shipments_methods = [];
foreach ( $this -> sellasist_shipments_methods as $sellasist_shipments_method )
{
  $sellasist_shipments_methods[ $sellasist_shipments_method['id'] ] = $sellasist_shipments_method['title'];
}

$grid = new \grid( 'pp_shop_transports' );
$grid -> gdb_opt      = $gdb;
$grid -> debug        = true;
$grid -> order        = [ 'column' => 'name', 'type' => 'ASC' ];
$grid -> search       = [
                            [ 'name' => 'Nazwa', 'db' => 'name', 'type' => 'text' ],
                            [ 'name' => 'Aktywny', 'db' => 'status', '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ślna FT',
                            'db' => 'default',
                            'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
                            'td' => [ 'class' => 'g-center' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
                            'sort' => true
                          ], [
                            'name' => 'Aktywny',
                            'db' => 'status',
                            'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
                            'td' => [ 'class' => 'g-center' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
                            'sort' => true
                          ],
                          [
                            'name'  => 'Koszt',
                            'db'    => 'cost',
                            'td'    => [ 'class' => 'g-center' ],
                            'th'    => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
                            'php'   => 'echo \\S::decimal( [cost] ) . " zł";',
                            'sort'  => true
                          ],
                          [
                            'name'  => 'Maks. WP',
                            'db'    => 'max_wp',
                            'td'    => [ 'class' => 'g-center' ],
                            'th'    => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
                            'sort'  => true
                          ],
                          [
                            'name'  => 'Nazwa',
                            'db'    => 'name',
                            'sort'  => true,
                            'php' => 'echo "<a href=\'/admin/shop_transport/transport_edit/id=[id]\'>[name]</a>";'
                          ], [
                            'name' => 'Typ kuriera Apilo',
                            'db' => 'apilo_carrier_account_id',
                            'th'    => [ 'class' => 'g-center' ],
                            'td'    => [ 'class' => 'g-center' ],
                            'replace' => [ 'array' => $carrier_accounts ],
                          ], [
                            'name' => 'Typ kuriera Sellasist',
                            'db' => 'sellasist_shipment_method_id',
                            'th'    => [ 'class' => 'g-center' ],
                            'td'    => [ 'class' => 'g-center' ],
                            'replace' => [ 'array' => $sellasist_shipments_methods ],
                          ], [
                            'name' => 'Edytuj',
                            'action' => [ 'type' => 'edit', 'url' => '/admin/shop_transport/transport_edit/id=[id]' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
                            'td' => [ 'class' => 'g-center' ]
                          ]
                        ];
echo $grid -> draw();