<div class="container-fluid">
    <div class="block-header">
        <h2>Pages > Create New Custom Page</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-8 col-md-8">
            <div class="card">
                <div class="header">
                    <h2>Create New Custom Page</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">
                                <input type="text" id="page_name" name="page_name" class="form-control">
                                <label class="form-label">Page Name <small><?php echo $music->config->site_url . '/site-pages/PAGE_NAME'?></small></label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="page_title" name="page_title" class="form-control">
                                <label class="form-label">Page Name <small>The page title that will show in the footer</small></label>
                            </div>
                        </div>
                         <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="page_content" id="page_content" class="form-control" cols="30" rows="5"></textarea>
                                <label class="form-label">Page Content <small>The page content (HTML allowed)</small></label>
                            </div>
                        </div>
                        <label for="page_type">Page Type</label>
                        <select class="form-control show-tick " id="page_type" name="page_type">
                            <option value="1">Include background and header</option>
                            <option value="0">Empty page</option>
                        </select>
                        <div class="clearfix"></div>
                        <br>
                        <input type="hidden" name="hash_id" value="<?php echo createMainSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Create</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: '{{CONFIG ajax_url}}/ap/add_new_page',
        beforeSend: function() {
            form_add_settings.find('.waves-effect').text('Please wait..');
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.add-settings-alert').html('<i class="fa fa-check"></i> Page added successfully');
                setTimeout(function () {
		            window.location.href = '<?php echo LoadAdminLinkSettings('manage-custom-pages'); ?>';
		        }, 1000);
            } else if (data.status == 400) {
	          alert(data.message);
	        }
	        form_add_settings.find('.waves-effect').text('Create');
        }
    });
});
</script>