<script src="<?php echo THEME_PATH; ?>plugins/jquery-validation/js/jquery.validate.min.js"></script>
<div class="modal fade" id="edit-product-rate-type-two-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('rate_type_two'); ?></h4>
            </div>
            <div class="modal-body">
                <form id="service_form4" 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_value4" value="<?php echo smc_session()['default_setting']['rate_type_two']; ?>" name="setting_value4" 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 = "submitRateTwo"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
            <?php echo Forms::ModalLoader('serviceDisabler'); ?>
        </div>
    </div>
</div>
<script>
    var setting_current_value4;
    var rate_type_two = <?php echo json_encode(smc_session()['default_setting']['rate_type_two']); ?>;
    $(function(){

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