<?php
global $gdb;
foreach ( $this -> apilo_payment_types_list as $payment_type )
{
  if ( isset( $payment_type['name'] ) && isset( $payment_type['id'] ) )
    $payment_types[ $payment_type['id'] ] = $payment_type['name'];
}
// sellasist payment methods
$sellasist_payment_types_list = [];
foreach ( $this -> sellasist_payment_types_list as $sellasist_payment_type )
  $sellasist_payment_types_list[ $sellasist_payment_type['id'] ] = $sellasist_payment_type['title'];

$grid = new \grid( 'pp_shop_payment_methods' );
$grid -> gdb_opt      = $gdb;
$grid -> debug        = true;
$grid -> order        = [ 'column' => 'id', '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'  => 'Nazwa',
                            'db'    => 'name'
                          ], [
                            '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;' ]
                          ], [
                            'name' => 'Typ płatności Apilo',
                            'db' => 'apilo_payment_type_id',
                            'replace' => [ 'array' => $payment_types ],
                            'td' => [ 'class' => 'g-center' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
                          ], [
                            'name' => 'Typ płatności Sellasist',
                            'db' => 'sellasist_payment_type_id',
                            'replace' => [ 'array' => $sellasist_payment_types_list ],
                            'td' => [ 'class' => 'g-center' ],
                            'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
                          ]
                        ];

$grid -> columns_edit = [
                          [
                            'name' => 'Nazwa',
                            'db' => 'name',
                            'type' => 'text',
                            'readonly-edit'  => true
                          ], [
                            'name' => 'Opis',
                            'db' => 'description',
                            'type' => 'textarea'
                          ], [
                            'db' => 'apilo_payment_type_id',
                            'type' => 'select',
                            'name' => 'Typ płatności Apilo',
                            'replace' => [ 'array' => $payment_types ],
                          ], [
                            'db' => 'sellasist_payment_type_id',
                            'type' => 'select',
                            'name' => 'Typ płatności Sellasist',
                            'replace' => [ 'array' => $sellasist_payment_types_list ],
                          ], [
                            'name'            => 'Aktywny',
                            'db'              => 'status',
                            'type'            => 'select',
                            'default_value'   => 1,
                            'replace'         => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ]
                          ]
                        ];
$grid -> actions = [ 'edit' => true ];
echo $grid -> draw();