<script src="<?php echo THEME_PATH; ?>plugins/jquery-validation/js/jquery.validate.min.js"></script>
<div class="modal fade" id="edit-lebanon-vate-modal" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('lebanon_vat_amount'); ?></h4>
            </div>
            <div class="modal-body">
                <form id="service_form5" method="POST" onsubmit="return false">
                    <div class="row">
                        <?php echo Forms::AlertDiv('rate_alert'); ?>
                        <div class="col-xs-12">
                            <input type="text" id="setting_current_value5" value="<?php echo smc_session()['default_setting']['lebanon_vat_amount']; ?>" name="setting_value5" class="form-control"   required />
                        </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-primary" id = "submitLebanonVat"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('serviceDisabler'); ?>
        </div>
    </div>
</div>
<script>
    var setting_current_value5;
    var lebanon_vat_amount = <?php echo json_encode(smc_session()['default_setting']['lebanon_vat_amount']); ?>;
    $(function(){

        $('#edit-lebanon-vate-modal').on('shown.bs.modal',function(){
            // $('#edit-lebanon-vate-modal').modal('show')
            console.log('lebanon_vat_amount');
            console.log(lebanon_vat_amount);
            console.log('setting_current_value5');
            console.log(setting_current_value5);
            $('#setting_current_value5').val(lebanon_vat_amount);
         });
        $("#submitLebanonVat").on('click',function(){
            if (!$("#service_form5").valid())
                return;
                
            $("#serviceDisabler").removeClass('hidden');
            var Data = new FormData(document.getElementById("service_form5"));
            console.log(Data);
            $.ajax({
                url: "RestaurantAjax/submitLebanonVat",
                method: "POST",
                data: Data,
                processData: false,
                contentType: false,
                dataType: "JSON",
                complete: function (jqXHR, status) {
                    console.log('jqXHR.responseJSON')
                    console.log(jqXHR.responseJSON)
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            hideModalAlert('edit-lebanon-vate-modal', 'rate_alert');
                            setting_current_value5 = $('#setting_current_value5').val();
                            lebanon_vat_amount = $('#setting_current_value5').val();
                            $('#setting_current_value5').val(setting_current_value5);
                        }
                        AddAlert("#rate_alert", jqXHR.responseJSON[0], jqXHR.responseJSON[1]);
                    }
                    $("#serviceDisabler").addClass('hidden');
                }
            });
        });
    });
</script>