<div class="container-fluid">
    <div class="block-header">
        <h2>Settings > E-mail Security</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-5 col-md-5">
            <div class="card">
                <div class="header">
                    <h2>Add E-mail Provider</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success add-provider-settings-alert"></div>
                    <form class="add-provider-settings" method="POST">

                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="provider" name="provider" class="form-control">
                                <label class="form-label">Provider (example: gmail)</label>
                            </div>
                        </div>
                        <br>
                        <div class="clearfix"></div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Save</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="col-lg-5 col-md-5">
            <div class="card">
                <div class="header">
                    <h2>Remove E-mail Provider</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success remove-provider-settings-alert"></div>
                    <form class="remove-provider-settings" method="POST">
                        <label for="provider">Provider</label>
                        <select class="form-control show-tick" id="provider" name="provider">
                            <?php foreach ($wo['config']['providers_array'] as $key => $provider) { ?>
                                <option value="<?php echo($provider) ?>"><?php echo($provider) ?></option>
                            <?php } ?>
                        </select>
                        <div class="clearfix"></div>
                        <br><br>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Delete</button>
                    </form>
                </div>
            </div>
        </div>
        
    </div>
    <!-- #END# Vertical Layout -->
<script>
    $(function () {

        var form_add_site_settings = $('form.add-provider-settings');
        form_add_site_settings.ajaxForm({
            url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=add_new_provider',
            beforeSend: function() {
                form_add_site_settings.find('.waves-effect').text('Please wait..');
            },
            success: function(data) {
                if (data.status == 200) {
                    form_add_site_settings.find('.waves-effect').text('Save');
                    $("html, body").animate({ scrollTop: 0 }, "slow");
                    $('.add-provider-settings-alert').html('<i class="fa fa-check"></i> Provider successfully added');
                    setTimeout(function () {
                        $('.add-provider-settings-alert').empty();
                        location.reload();
                    }, 2000);
                }
            }
        });


        var form_remove_site_settings = $('form.remove-provider-settings');
        form_remove_site_settings.ajaxForm({
            url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=remove_provider',
            beforeSend: function() {
                if (confirm("Are you sure you want to delete this provider?") == false) {
                    return false;
                  }
                form_remove_site_settings.find('.waves-effect').text('Please wait..');
            },
            success: function(data) {
                if (data.status == 200) {
                    form_remove_site_settings.find('.waves-effect').text('Save');
                    $("html, body").animate({ scrollTop: 0 }, "slow");
                    $('.remove-provider-settings-alert').html('<i class="fa fa-check"></i> Provider successfully deleted');
                    setTimeout(function () {
                        $('.remove-provider-settings-alert').empty();
                        location.reload();
                    }, 2000);
                }
            }
        });

        
    });
</script>