<?php $music->terms = GetTerms(); ?>
<div class="container-fluid">
    <div class="block-header">
        <h2>Pages > Manage 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" id="terms" class="form-control" cols="30" rows="10"><?php echo $music->terms['terms'];?></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" id="privacy" class="form-control" cols="30" rows="10"><?php echo $music->terms['privacy'];?></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 $music->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="dmca" id="dmca" class="form-control" cols="30" rows="10"><?php echo $music->terms['dmca'];?></textarea>
                                <label class="form-label">DMCA (HTML Allowed)</label>
                            </div>
                        </div>
                        <input type="hidden" name="hash_id" value="<?php echo createMainSession();?>">
                        <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 -->
</div>
<script>

$(function() {
    var form_add_settings = $('form.add-settings');
    form_add_settings.ajaxForm({
        url: '{{CONFIG ajax_url}}/ap/save-terms',
        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];
          delete arr[3];
          arr.push({name:'terms', value:btoa(unescape(encodeURIComponent($('#terms').val())))});
          arr.push({name:'privacy', value:btoa(unescape(encodeURIComponent($('#privacy').val())))});
          arr.push({name:'about', value:btoa(unescape(encodeURIComponent($('#about').val())))});
          arr.push({name:'dmca', value:btoa(unescape(encodeURIComponent($('#dmca').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>