<div class="container-fluid">
    <div>
        <h3>Add New Language & Key</h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Home</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Languages</a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Add New Language & Key</li>
            </ol>
        </nav>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Add New Language</h6>
					<div class="alert alert-info">Note: This may take up to 5 minutes.</div>
                    <div class="email-settings-alert"></div>
                    <form class="email-settings" method="POST">
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Language Name</label>
                                <input type="text" id="lang" name="lang" class="form-control">
                                <small class="admin-info">Use only english letters, no spaces allowed. E.g: russian</small>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Language ISO <small></small></label>
                                <input type="iso" id="iso" name="iso" class="form-control">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label for="direction" class="main-label">Direction</label>
                                <br><small class="admin-info">The direction of the language 'Left To Right' or 'Right To Left'</small>
                                <select class="form-control show-tick" id="direction" name="direction">
                                    <option value="ltr">LTR</option>
                                    <option value="rtl">RTL</option>
                                </select>
                            </div>
                        </div>
                        
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Add Language</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Add New Language Key</h6>
                    <div class="key-settings-alert"></div>
                    <form class="key-settings" method="POST">
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Key Name </label>
                                <input type="text" id="lang_key" name="lang_key" class="form-control">
                                <small class="admin-info">Use only english letters, no spaces allowed, example: this_is_a_key</small>
                            </div>
                        </div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Add Key</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>

$(function() {
    var form_email_settings = $('form.email-settings');
    form_email_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=add_new_lang',
        beforeSend: function() {
            form_email_settings.find('button').text('Please wait..');
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.email-settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Language successfully added</div>');
                setTimeout(function () {
		            window.location.href = '<?php echo Wo_LoadAdminLinkSettings('manage-languages'); ?>';
		        }, 1000);
            }
            form_email_settings.find('button').text('Add Language');
        }
    });

    var form_key_settings = $('form.key-settings');
    form_key_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=add_new_lang_key',
        beforeSend: function() {
            form_key_settings.find('button').text('Please wait..');
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.key-settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Key successfully added</div>');
                 setTimeout(function () {
                    window.location.href = data.url;
                  }, 1000);
            } else {
                $('.key-settings-alert').html('<div class="alert alert-danger">'+data.message+'</div>');
                setTimeout(function () {
                    $('.key-settings-alert').empty();
                }, 2000);
            }
            form_key_settings.find('button').text('Add Key');
        }
    });
});
</script>