<div class="modal fade" id="end_of_shift_modal" data-backdrop="static" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class=" text-left semi-bold"><?php echo CommonLanguage::getMessage('end_of_shift');?></h5>
            </div>
            <div class="modal-body">
                <form id="end_of_shift_form" method="POST" onsubmit="return false">
                    <div class="row">
                        <?php echo Forms::AlertDiv('end_of_shift_alert'); ?>
                        <div class="col-md-12 m-t-10">
                            <input type="hidden" id="shift_user_id" name="user_id" class="full-width" required>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button class="btn btn-primary" id="submit_end_of_shift"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('endOfShiftDisabler'); ?>
        </div>
    </div>
</div>
<script>
    $(function () {
        build_select2($("#shift_user_id"), "xhr/getUsersWithCashAccounts",1);
        $("#submit_end_of_shift").on("click", function () {
            if (!$("#end_of_shift_form").valid())
                return;
            $("#endOfShiftDisabler").removeClass('hidden');
            var Data = new FormData(document.getElementById("end_of_shift_form"));
            $.ajax({
                url: "InventoryAjax/submitEndOfShift",
                method: "POST",
                data: Data,
                processData: false,
                contentType: false,
                dataType: "JSON",
                complete: function (jqXHR, status) {
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            hideModalAlert('end_of_shift_modal', 'end_of_shift_alert');
                        }
                        AddAlert("#end_of_shift_alert", jqXHR.responseJSON[0], jqXHR.responseJSON[1]);
                    }
                    $("#endOfShiftDisabler").addClass('hidden');
                }
            });
        });
    });
</script>