<?
//print_r($page_card);
?>

<!-- BEGIN: Content-->
<div class="app-content content">
    <div class="content-overlay"></div>
    <div class="header-navbar-shadow"></div>
    <div class="content-wrapper">
        <div class="content-header row">
        </div>
        <div class="content-body">
            <!-- Dashboard Analytics Start -->
            <section id="dashboard-analytics">

                <div class="row">

                    <div class="col-xl-4 col-md-12 col-sm-12">
                        <div class="card">
                            <div class="card-content">
                                <div class="card-body">
                                    <h4 class="card-title">Add New Page</h4>
                                </div>
                                <div class="card-body">
                                    <form class="form" method="POST" action="/member/addcard">
                                        <div class="form-body">
                                            <div class="form-group">
                                                <label for="feedback1" class="sr-only">Card Name</label>
                                                <input type="text" id="feedback1" class="form-control" placeholder="Title" name="title" value="<?= isset($title) ? $title : '' ?>" maxlength="49">
                                            </div>



                                            <div class="form-group">
                                                <label for="feedback3" class="sr-only">Description</label>
                                                <textarea id="feedback3" rows="3" class="form-control" name="description" placeholder="Description"><?= isset($description) ? $description : '' ?></textarea>

                                              

                                            </div>
                                            
                                              <div class="form-group">
                                                    <label for="feedback3" class="sr-only">Page Template</label>
                                                    <?= $page_template ?>
                                                </div>
                                            
                                        </div>



                                        <div class="form-actions" style="text-align: right;">
                                            <button type="submit" class="btn btn-primary mr-1">Add Page</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>


                    <div class="col-xl-4 col-md-6 col-sm-12">



                        <div class="card collapse-icon accordion-icon-rotate">
                            <div class="card-body">
                                <div class="card-body">
                                    <h4 class="card-title">My Pages</h4>
                                </div>

                                <div class="accordion" id="accordionExample" data-toggle-hover="true">

                                    <?php
                                    foreach ($page_card AS $drow) {
                                        // print_r($drow);
                                        ?>
                                        <div class="collapse-margin" id="line_detail<?= $drow->id ?>">
                                            <div class="card-header" id="headingOne" data-toggle="collapse" role="button" data-target="#collapseOne<?= $drow->id ?>" aria-expanded="false" aria-controls="collapseOne">
                                                <span class="lead collapse-title collapsed">
                                                    <?= $drow->title ?>
                                                </span>
                                            </div>

                                            <div id="collapseOne<?= $drow->id ?>" class="collapse" aria-labelledby="headingOne" data-parent="#accordionExample">
                                                <div class="card-body">
                                                    <?= $drow->description ?>
                                                </div>
                                                <div class="card-body" style="background-color:aliceblue;">
                                                    <a href="/member/page?pgname=<?= $drow->page_key ?>" class="card-link">Go to Page</a> 
                                                    <a href="#" onclick="viewShareAction(<?= $_SESSION['member_id'] ?>,<?= $drow->id ?>, );" class="card-link">Share Page</a> 
                                                    <a href="#" class="card-link"  onclick="deletePageAction(<?= $_SESSION['member_id'] ?>,<?= $drow->id ?>, );" style="color: red;">Delete</a>
                                                </div>
                                            </div>
                                        </div>



                                    <?php }
                                    ?>


                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xl-4 col-md-6 col-sm-12">
                        <div class="card">
                            <div class="card-content">

                                <div id="share_detail">

                                </div>
                                <!-- div class="embed-responsive embed-responsive-item embed-responsive-16by9">
                                    <iframe class="img-thumbnail" src="https://www.youtube.com/embed/vTlSEMdC5qw" allowfullscreen></iframe>
                                </div-->

                            </div>
                        </div>
                    </div>


                </div>





            </section>
            <!-- Dashboard Analytics end -->

        </div>
    </div>
</div>
<!-- END: Content-->


<script type="text/javascript">
<!--

    function viewShareAction(member_id, page_id) {

        $('#share_detail').html('Processing...');
        $('#acc' + page_id).prop('disabled', true);
        $.ajax({
            url: "/member/viewSharePage?proc=PROCESS&page_id=" + page_id + "&member_id=" + member_id
        }).done(function (data) {
            $('#share_detail').html(data);
            $('#acc' + page_id).prop('disabled', false);
        });
        return false;
    }

    function deletePageAction(member_id, page_id) {

        var x = confirm("Are you sure you want to delete?");
        if (!x)
            return true;


        $('#acc' + page_id).prop('disabled', true);
        $.ajax({
            url: "/member/deletePageAction?proc=PROCESS&page_id=" + page_id + "&member_id=" + member_id
        }).done(function (data) {
            $('#line_detail' + page_id).html(data);
            $('#acc' + page_id).prop('disabled', false);
        });
        return false;
    }

//initMap();
// -->
</script>