<?php $wo['terms'] = Wo_GetTerms(); ?>
<div class="container-fluid">
    <div class="block-header">
        <h2>Pages > Edit Terms Pages</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-8 col-md-8">
            <div class="card">
                <div class="header">
                    <h2>Edit Term Pages</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success add-settings-alert"></div>
                    <form class="add-settings" method="POST">
                         <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="terms_of_use" id="terms_of_use" class="form-control" cols="30" rows="10"><?php echo $wo['terms']['terms_of_use'];?></textarea>
                                <label class="form-label">Terms of Use (HTML Allowed)</label>
                            </div>
                        </div>
                        <br>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="privacy_policy" id="privacy_policy" class="form-control" cols="30" rows="10"><?php echo $wo['terms']['privacy_policy'];?></textarea>
                                <label class="form-label">Privacy Policy (HTML Allowed)</label>
                            </div>
                        </div>
                        <br>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="about" id="about" class="form-control" cols="30" rows="10"><?php echo $wo['terms']['about'];?></textarea>
                                <label class="form-label">About (HTML Allowed)</label>
                            </div>
                        </div>
                        <br>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="refund" id="refund" class="form-control" cols="30" rows="10"><?php echo $wo['terms']['refund'];?></textarea>
                                <label class="form-label">Refund (HTML Allowed)</label>
                            </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">Save</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>

$(function() {
    var form_add_settings = $('form.add-settings');
    form_add_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_terms_setting',
        beforeSend: function() {
            form_add_settings.find('.waves-effect').text('Please wait..');
        },
        beforeSubmit : function(arr, $form, options){
          delete arr[0];
          delete arr[1];
          delete arr[2];
          arr.push({name:'terms_of_use', value:btoa(unescape(encodeURIComponent($('#terms_of_use').val())))}); 
          arr.push({name:'privacy_policy', value:btoa(unescape(encodeURIComponent($('#privacy_policy').val())))});
          arr.push({name:'about', value:btoa(unescape(encodeURIComponent($('#about').val())))});
          arr.push({name:'refund', value:btoa(unescape(encodeURIComponent($('#refund').val())))});
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.add-settings-alert').html('<i class="fa fa-check"></i> Pages saved successfully');
            } else if (data.status == 400) {
	          alert(data.message);
	        }
	        form_add_settings.find('.waves-effect').text('Save');
        }
    });
});
</script>