<div class="modal fade" id="add_edit_kitchen_note_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 text-left">
                 <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                </button>
                <h5 class="modal-title bold"> <?php echo CommonLanguage::getMessage('kitchen_note'); ?></h5>
            </div>
            <div class="modal-body">
                <form id="kitchen_note_form" method="POST" onsubmit="return false">
                    <div class="row">
                        <?php echo Forms::AlertDiv('kitchen_note_alert'); ?>
                        <input type='hidden' name='note_id' id='note_id'/>
                    </div>
                    <div class="row form-group m-t-10">
                        <div class="col-md-12">
                            <label><?php print CommonLanguage::getMessage('note'); ?></label>
                            <input type="text"  placeholder="<?php print CommonLanguage::getMessage('note'); ?>" id="note_title" name="note_title" class="form-control " autocomplete="off" required>
                        </div>
                    </div>
                    <div class="row form-group m-t-10">
                        <div class="col-md-12">
                            <label><?php print CommonLanguage::getMessage('type'); ?></label>
                            <select id="type" name="type" class="full-width" data-init-plugin="select2">
                                <option value="0"><?php echo CommonLanguage::getMessage('order')?></option>
                                <option value="1"><?php echo CommonLanguage::getMessage('invoice')?></option>
                                <option value="2"><?php echo CommonLanguage::getMessage('posponted')?></option>
                            </select>
                        </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_kitchen_note"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('kitchenNoteLoader'); ?>
        </div>
    </div>
</div>
<script>
    $(function () {
        $(".add_kitchen_note").on("click", function () {
            $("#note_id").val(0);
        });
        $("#tableWithSearch").on("click", ".edit", function () {
            var note_id = $(this).parents('div.Action').attr('data-id');
            $("#note_id").val(note_id);
            $("#type").val($(this).attr('data-type')).select2()
            $("#note_title").val($(this).parents('tr').find('td:eq(0)').html());
        });
        $("#submit_kitchen_note").on("click", function () {
            if (!$("#kitchen_note_form").valid())
                return;
            $("#kitchenNoteLoader").removeClass('hidden');
            var Data = new FormData(document.getElementById("kitchen_note_form"));
            $.ajax({
                url: "RestaurantAjax/submitKitchenNote",
                method: "POST",
                data: Data,
                processData: false,
                contentType: false,
                dataType: "JSON",
                complete: function (jqXHR, status) {
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            RebuildDataTable(title, [0], 'RestaurantAjax/kitchen_note_list',1);
                            hideModalAlert('add_edit_kitchen_note_modal', 'kitchen_note_alert');
                        }
                        AddAlert("#kitchen_note_alert", jqXHR.responseJSON[0], jqXHR.responseJSON[1]);
                    }
                    $("#kitchenNoteLoader").addClass('hidden');
                }
            });
        });
    });
</script>