@push('style')
@endpush
@php
// TABLE HEADERS
# SEPARATED TO HANDLE CONFIG CONSTRUCTION IN THIS FILE
$headers = [
    // EXTRA DATA HIDDEN
    [
        'label' => '',
        'target' => 'label',
        'hclass' => 'hidden',
        'dclass' => 'hidden'
    ],
    [
        'label' => '',
        'target' => 'store_label',
        'hclass' => 'hidden',
        'dclass' => 'hidden'
    ],
    [
        'label' => '',
        'target' => 'store_id',
        'hclass' => 'hidden',
        'dclass' => 'hidden'
    ],
    [
        'label' => '',
        'target' => 'detail_label',
        'hclass' => 'hidden',
        'dclass' => 'hidden'
    ],
    [
        'label' => '',
        'target' => 'detail_id',
        'hclass' => 'hidden',
        'dclass' => 'hidden'
    ],
    [
        'label' => '',
        'target' => 'delivery_label',
        'hclass' => 'hidden',
        'dclass' => 'hidden'
    ],
    [
        'label' => '',
        'target' => 'delivery_id',
        'hclass' => 'hidden',
        'dclass' => 'hidden'
    ],
    [
        'label' => '',
        'target' => 'delivery_code',
        'hclass' => 'hidden',
        'dclass' => 'hidden'
    ],
    // VISIBLE DATA 
    [
        'label' => __('table.header.id'),
        'target' => 'id',
    ],
    [
        'label' => __('table.header.code'),
        'target' => 'code',
    ],
    [
        'label' => __('table.header.status'),
        'target' => 'status_label',
    ],
    /*
    [
        'label' => __('table.header.user'),
        'target' => 'user_code',
        'dclass' => 'lefted',
        'hclass' => 'labelx'
    ],
    */
    [
        'label' => __('table.header.store'),
        'target' => 'store_code',
        'dclass' => 'lefted',
        'hclass' => 'labelx',
    ],
    [
        'label' => __('table.header.details'),
        'target' => 'detail_code',
        'dclass' => 'lefted',
        'hclass' => 'labelx'
    ],
    [
        'label' => __('table.header.documents'),
        'target' => 'documents_count',
    ],
    [
        'label' => __('table.header.payments'),
        'target' => 'payments_count',
    ],
    [
        'label' => __('table.header.products'),
        'target' => 'products_count',
    ],
    [
        'label' => __('table.header.total'),
        'target' => 'total',
        'dclass' => 'bold',
    ],
    [
        'label' => __('table.header.payed'),
        'target' => 'payed',
        'dclass' => 'bold text-success',
    ],
    [
        'label' => __('table.header.difference'),
        'target' => 'to_pay',
        'dclass' => 'text-danger',
    ],
    [
        'label' => __('table.header.delivery'),
        'target' => 'deliver_at',
    ],
    [
        'label' => __('table.header.registered'),
        'target' => 'created_at',
    ],
    [
        'label' => __('table.header.notes'),
        'target' => 'notes',
        'hclass' => 'notes',
        'wclass' => 'notes'
    ],
    [
        'label' => __('table.header.documents'),
        'hclass' => 'handle',
        'target' => '_button',
        'class' => 'btn btn-info documents',
        'icon' => 'fa fa-file-text-o'
    ],
    [
        'label' => __('table.header.delivery'),
        'hclass' => 'handle',
        'target' => '_button1',
        'class' => 'btn btn-default delivery',
        'icon' => 'fa fa-truck'
    ],
    [
        'label' => __('table.header.edit'),
        'target' => '_edit',
    ],
    [
        'label' => __('table.header.archive'),
        'target' => '_archive',
    ],
    [
        'label' => __('table.header.delete'),
        'target' => '_delete'
    ],
];
// GET HEADERS TARGETS
$col = array_flip( array_column($headers, 'target') );
@endphp
@include('components.table', [
    'id' => $id,
    'edit' => @$edit,                       // EDIT TARGET ID
    'class' => 'table cell-border hover',
    'data' => $data,
    'headers' => $headers,
    'fields' => $col,                       // TRACK COLUMNS BY NAME
])
@push('ready')
@endpush