@extends('layouts.app')

@section('title', 'Warehouse Bins')

@section('content')
<div class="page-content">
    <div class="row">
        <div class="col-md-12">
            <div class="page-title-box">
                <div class="page-title-right">
                    <ol class="breadcrumb m-0">
                        <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Dashboard</a></li>
                        <li class="breadcrumb-item active">Warehouse Bins</li>
                    </ol>
                </div>
                <h4 class="page-title">Warehouse Bins</h4>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h4 class="header-title">Warehouse Bins</h4>
                    <a href="{{ route('warehouse-bins.create') }}" class="btn btn-primary">
                        <i class="fas fa-plus"></i> Add New Bin
                    </a>
                </div>
                <div class="card-body">
                    @if(session('success'))
                        <div class="alert alert-success">{{ session('success') }}</div>
                    @endif
                    @if(session('error'))
                        <div class="alert alert-danger">{{ session('error') }}</div>
                    @endif

                    <div class="table-responsive">
                        <table id="warehouse-bins-table" class="table table-striped table-centered mb-0">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Code</th>
                                    <th>Full Code</th>
                                    <th>Warehouse</th>
                                    <th>Type</th>
                                    <th>Status</th>
                                    <th>Stock Count</th>
                                    <th>Created</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@push('plugin-scripts')
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap5.min.js"></script>
@endpush

@push('plugin-styles')
<link href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap5.min.css" rel="stylesheet">
@endpush

@push('scripts')
<script>
$(document).ready(function() {
    $('#warehouse-bins-table').DataTable({
        processing: true,
        serverSide: false,
        ajax: '{{ route("warehouse-bins.data") }}',
        columns: [
            {data: 'id', name: 'id'},
            {data: 'code', name: 'code'},
            {data: 'full_code', name: 'full_code'},
            {data: 'warehouse_name', name: 'warehouse_name'},
            {data: 'type_badge', name: 'type'},
            {data: 'status_badge', name: 'status'},
            {data: 'stock_count', name: 'stock_count'},
            {data: 'created_at', name: 'created_at'},
            {data: 'actions', name: 'actions', orderable: false, searchable: false}
        ],
        order: [[0, 'desc']],
        pageLength: 25,
        language: {
            search: "Search:",
            lengthMenu: "Show _MENU_ entries per page",
            info: "Showing _START_ to _END_ of _TOTAL_ entries",
            infoEmpty: "Showing 0 to 0 of 0 entries",
            infoFiltered: "(filtered from _MAX_ total entries)",
            processing: "Processing...",
            emptyTable: "No warehouse bins found"
        }
    });
});
</script>
@endpush
