<div class="container-fluid">
    <div>
        <h3>Create New Custom Page</h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Admin Panel</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Pages</a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Create New Custom Page</li>
            </ol>
        </nav>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-8 col-md-8">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Create New Custom Page</h6>
                    <div class="add-settings-alert"></div>
                    <form class="add-settings" method="POST">
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Page Name <small><?php echo $pt->config->site_url . '/site-pages/PAGE_NAME'?></small></label>
                                <input type="text" id="page_name" name="page_name" class="form-control">
                                
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Page Name <small>The page title that will show in the footer</small></label>
                                <input type="text" id="page_title" name="page_title" class="form-control">
                                
                            </div>
                        </div>
                         <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Page Content <small>The page content (HTML allowed)</small></label>
                                <textarea name="page_content" id="page_content" class="form-control" cols="30" rows="5"></textarea>
                                
                            </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>
                        <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: '{{LINK aj/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('<div class="alert alert-success"><i class="fa fa-check"></i> Page added successfully</div>');
                setTimeout(function () {
                    window.location.href = '<?php echo PT_LoadAdminLinkSettings('manage-custom-pages'); ?>';
                }, 1000);
            } else if (data.status == 400) {
                $('.add-settings-alert').html('<div class="alert alert-danger">'+data.message+'</div>');
                setTimeout(function () {
                    $('.add-settings-alert').html('');
                }, 1000);
            }
            form_add_settings.find('.waves-effect').text('Create');
        }
    });
});
</script>