<?php
if ($permissions->hasPermission('add_brand') || $permissions->hasPermission('edit_brand') ) {
    include("Views/Inventory/addBrand.php");
}
?>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"> <?php print CommonLanguage::getMessage('brand_list'); ?></div>
            <?php
            if ($permissions->hasPermission('add_brand') || $permissions->hasPermission('edit_brand')) {
                echo Forms::FloatingAddButton('4c0870', '#addBrand', CommonLanguage::getMessage('add_brand'), 'add_brand_btn');
            }
            ?>
        </div>
        <div class="panel-body">
            <div class=" row   ">
                <div class="col-md-12 table-responsive">
                    <table class="table table-bordered  inventory" id="tableWithSearch" >
                        <thead>
                            <tr>
                                <th class="text-center" style="width:15%" ><?php print CommonLanguage::getMessage('brand_name'); ?></th>
                                <th class="text-center" style="width:15%" ><?php print CommonLanguage::getMessage('sort_order'); ?></th>
                                <th class="text-center no-print" style="width:15%"><?php print CommonLanguage::getMessage('Action'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var title = <?php echo json_encode(CommonLanguage::getMessage('brand_list')) ?>;
    var  delete_modal = <?php
    echo json_encode([CommonLanguage::getMessage('Confirm_Delete'),
                      CommonLanguage::getMessage('About_To_Delete'),
                      CommonLanguage::getMessage('Proceed_Delete'),
                      CommonLanguage::getMessage('Close'),
                      CommonLanguage::getMessage('delete'),
                      CommonLanguage::getMessage('Deleted_Successfully')
                     ]);
        ?>;
    $(function () {
        RebuildDataTable(title, [0,1], "InventoryAjax/listBrandRequest");
        $('#tableWithSearch').on('click', '.delete_brand', function () {
            var brand_id = $(this).parents('div.Action').attr('data-id');
            IncludeDeleteModal(delete_modal, {entry_value: brand_id}, function () {
                RebuildDataTable($('.panel-heading .panel-title').html(), [0,1], 'InventoryAjax/listBrandRequest');
            }, "InventoryAjax/deleteBrand");
        });
    });
</script>