<?php
//include 'Views/Stock/assignProductLocation.php';
?>
<!--
<script src="< ?php echo THEME_PATH; ?>plugins/jquery-validation/js/jquery.validate.min.js"></script>
-->
<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('Product_Location_list') ?></div>
            <?php // echo Forms::FloatingAddButton('4c0870', '#assignProductLocation', CommonLanguage::getMessage('Assign')); ?> 
            <div class="row">
                <div class="col-md-4">
                    <div><label><?php print CommonLanguage::getMessage('Category'); ?></label></div>
                    <input class=" full-width " id="category_main_filter"  type="hidden" />
                </div>
                <div class="col-md-4">
                    <div><label><?php print CommonLanguage::getMessage('Depot'); ?></label></div>
                    <input class=" full-width " id="depot_main_filter"  type="hidden" />
                </div>
            </div>
            <div class="clearfix"></div>
        </div>
        <div class="panel-body" >
            <table class="table table-bordered stock" id="tableWithSearch" >
                <thead>
                    <tr>
                        <th class="text-center"><?php print CommonLanguage::getMessage('Code'); ?></th>
                        <?php if (smc_session()['default_setting']['activate_search_product_second_code'] == 1) { ?>
                            <th><?php print CommonLanguage::getMessage('product_second_code') ?></th>
                        <?php } ?>
                        <th class="text-center"  ><?php print CommonLanguage::getMessage('Name'); ?></th>
                        <th class="text-center"  ><?php print CommonLanguage::getMessage('Depot'); ?></th>
                        <th class="text-center"  ><?php print CommonLanguage::getMessage('quantity'); ?></th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
</div>
<div class="modal fade bs-example-modal-md" data-backdrop="static" id="DeleteLcationFromList" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:50%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('Confirm_Delete') ?></h4>
                <div class="col-md-12">
                    <div id="Delete_modalAlert"></div>
                </div>
            </div>
            <div class="modal-body">
                <form>
                    <div class="row">
                        <div class="col-md-12 ">
                            <div class="col-md-12" style="margin-top: 20px;">
                                <p><?php print CommonLanguage::getMessage('About_To_Delete'); ?> : <strong class="Name"></strong></p>
                                <p><?php print CommonLanguage::getMessage('Proceed_Delete'); ?></p>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button type="button" class="btn btn-danger" id="ProductLocation_Delete" style="width:auto"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
        </div>
    </div>
</div>
<script>
    var Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>,
            Deleted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Deleted_Successfully')); ?>,
            DepotAr = <?php echo json_encode(CommonLanguage::getMessage('Depot')); ?>,
            title = <?php echo json_encode(CommonLanguage::getMessage('Product_Location_list')); ?>,
            QuantityAr = <?php echo json_encode(CommonLanguage::getMessage('quantity')); ?>;
    var CurrentLocation_ToDelete;
    $(function () {
        build_select2($("#category_main_filter"), "xhr/catSearch")
        build_select2($("#depot_main_filter"), "xhr/depotSearch")
        update_table()
        $("#category_main_filter,#depot_main_filter").on("change", function () {
            update_table()
        })
    })
    function update_table(){
        RebuildDataTable(title, [0, 1, 2], 'StockAjax/ProductLocationListRequest', 
        {cat: $("#category_main_filter").val(),depot_id:$("#depot_main_filter").val()});
    }
</script>