<style>
    .checkbox label::after {
        left:1.2px !important;
    }
</style>
<link href="Views/Inventory/CustomerListStyle.css" rel="stylesheet"/>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div id="usercustomerAlert"></div>
            <div class="panel-title"><?php print CommonLanguage::getMessage('user_customer_list'); ?></div>

            <div class="clearfix"></div>
        </div>

        <div class="panel-body">
            <div class="row m-b-10 form-group">
                <div class="col-md-3">
                    <label class="labelText"><?php print CommonLanguage::getMessage('user'); ?></label>

                    <select  id="users"  class="full-width Account_Code " data-init-plugin="select2">
                        <?php foreach ($users as $user): ?>
                            <option value="<?php echo $user['User_ID']; ?>"><?php echo $user['User_Name']; ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
            <table class="table table-bordered inventory table-hover demo-table-search " id="tableWithSearch">
                <thead>
                    <tr>
                        <th class="text-center" ><?php print CommonLanguage::getMessage('Action'); ?></th>
                        <th class="text-center"  ><?php print CommonLanguage::getMessage('Code'); ?></th>
                        <th class="text-center" style="width:25%" ><?php print CommonLanguage::getMessage('Name'); ?></th>
                        <th class="text-center" ><?php print CommonLanguage::getMessage('Phone'); ?></th> 
                        <th class="text-center" ><?php print CommonLanguage::getMessage('address'); ?></th>
                        <!--<th class="text-center no-print" ><?php print CommonLanguage::getMessage('Action'); ?></th>-->
                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>

    </div>
</div>


<script>
    var CurentCustomer_ToDelete;
    var Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
     Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>,
            title = <?php echo json_encode(CommonLanguage::getMessage('user_customer_list')); ?>;
    $(function () {

        RebuildDataTable(title, [ 1, 2, 3,4], 'InventoryAjax/UserCustomersList', {uid: $("#users").val()});
        $("#users").on("change",function(){
        RebuildDataTable(title, [ 1, 2, 3,4], 'InventoryAjax/UserCustomersList', {uid: $("#users").val()});

        })
        $("#tableWithSearch").on("change", ".chooseCust", function () {
            var is_checked = $(this).is(":checked") ? 1 : 0,
                    cid = $(this).attr("data-id");
            $.ajax({
                type: 'POST',
                url: 'InventoryAjax/assignUserCustomer',
                data: {is_checked: is_checked, cid: cid, uid: $("#users").val()},
                complete: function (data, vv) {
                    if (vv == "success") {
                        if (data.responseText == 'OK') {
                           toastr.clear();
                             toastr.success(Submitted_Successfully)
//                            RebuildDataTable(title, [1, 2, 3], 'InventoryAjax/UserCustomersList',  {uid: $("#users").val()});
                        } else {
                            toastr.success(Failed_Submit)
                        }
                    }
                }
            })
        })


    });



</script>
