<div class="modal fade" id="allergy-intolerance-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="add-label text-left semi-bold"></h5>
            </div>
            <div class="modal-body">
                <form id="allergy_intolerance_form" method="POST" onsubmit="return false">
                    <input type='hidden' name='type_id'/>
                    <div class="row">
                        <?php echo Forms::AlertDiv('allergy_intolerance_alert'); ?>
                        <div class="col-md-12 form-group m-t-10">
                            <label><?php print CommonLanguage::getMessage('title'); ?></label><span class="red-star">*</span>
                            <input type="text"  placeholder="<?php print CommonLanguage::getMessage('title'); ?>" name="title" class="form-control " 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 btn-cons" id="submit_allergy_tolerance"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('allergyIntoleranceLoader'); ?>
        </div>
    </div>
</div>
<script>
    $(function(){
        $("#submit_allergy_tolerance").on("click", function () {
            if (!$("#allergy_intolerance_form").valid())
                return;
            var Data = new FormData(document.getElementById("allergy_intolerance_form"));
            $("#allergyIntoleranceLoader").removeClass('hidden');
            $.ajax({
                url: "InventoryAjax/submitAllergyIntolerance",
                method: "POST",
                data: Data,
                processData: false,
                contentType: false,
                dataType: "JSON",
                complete: function (jqXHR, status) {
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            hideModalAlert('allergy-intolerance-modal', 'allergy_intolerance_alert');
                        }
                        AddAlert("#allergy_intolerance_alert", jqXHR.responseJSON[0], jqXHR.responseJSON[1]);
                    }
                    $("#allergyIntoleranceLoader").addClass('hidden');
                }
            });
        });
    });
</script>