<link rel="stylesheet" href="<?php echo base_url();?>assets/css/cust_paginition.css" type="text/css" />
<div class="layout-app">
    <div class="container"><div class="row row-app">
            <div class="col-md-12">
                <div class="col-separator col-separator-first col-unscrollable bg-none">
                    <div class="col-table">
                        <div class="row">
                            <div class="col-md-8">
                                <div class="widget">
                                    <div class="widget-head">
                                        <h4 class="heading">Latest Subscriptions</h4>
                                    </div>
                                    <div class="widget-body innerAll inner-2x">
                                        <table class="table table-white table-vertical-center margin-none table-striped footable">
                                            <thead>
                                            <tr>
                                                <th  data-class="highlight" class="text-center">Subscriber Name</th>
                                                <th data-hide="phone" class="text-center">Email</th>
                                                <th data-hide="phone" class="text-center">Phone</th>
                                                <th class="text-center">Magazine Code</th>
                                                <th class="text-center">Period</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if (count($magazine_subscriptions) > 0) {
                                                foreach($magazine_subscriptions as $subscriptions) {?>

                                                    <tr>
                                                        <td class="text-center" ><?php echo ucwords($subscriptions['first_name']." ".$user['last_name']);?></td>
                                                        <td class="text-center" ><?php echo $subscriptions['email']; ?></td>
                                                        <td class="text-center"><?php echo $subscriptions['phone']; ?></td>
                                                        <td class="text-center"><?php echo $subscriptions['magazine_code']; ?></td>
                                                        <td class="text-center"><?php echo $subscriptions['period']; ?> year(s)</td>
                                                    </tr>
                                                <?php }} else { ?>
                                                <tr>
                                                    <td colspan="5" align="center">Sorry, no Subscriptions found!!</td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                        <?php
                                        if (count($magazine_subscriptions) > 0) {?>
                                            <div style="margin-top: 10px" align="right"> <a href="<?php echo base_url();?>index.php/users/subscriptions" class="btn btn-primary view-all">View all</a></div>
                                        <?php } ?>
                                        <div class="col-separator-h clearfix"></div>
                                    </div>
                                    <!-- // END TRENDS -->
                                </div>
                                <div class="col-separator-h"></div>
                            </div>

                            <div class="col-md-4" >
                                <div class="widget">
                                    <div class="widget-head">
                                        <h4 class="heading">Subscription Details</h4>
                                    </div>
                                    <div class="widget-body innerAll inner-2x" style="height: 245px">
                                        <table class="table table-white table-vertical-center margin-none table-striped footable">
                                            <thead>
                                            <tr>
                                                <th  data-class="highlight" class="text-center">Magazine Code</th>
                                                <th  class="text-center">Magazine Name</th>
                                                <th class="text-center">Number of copies</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if (count($magazine_subscribers) > 0) {
                                                foreach($magazine_subscribers as $magazineSubscribers) {?>
                                                    <tr>
                                                        <td class="text-center" ><?php echo $magazineSubscribers['magazine_code']; ?></td>
                                                        <td class="text-center" ><?php echo $magazineSubscribers['name']; ?></td>
                                                        <td class="text-center" ><?php echo $magazineSubscribers['total']; ?></td>
                                                    </tr>
                                                <?php }} else { ?>
                                                <tr>
                                                    <td colspan="3">Sorry, No subscribers found</td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                        <?php
                                        if (count($magazine_subscribers) > 0) {?>
                                            <div style="" align="right"> <a href="<?php echo base_url();?>index.php/users/subscriberlist" class="btn btn-primary view-all">View all</a></div>
                                        <?php } ?>
                                        <div class="col-separator-h clearfix"></div>
                                    </div>
                                    <!-- // END TRENDS -->
                                </div>

                                <div class="col-separator-h"></div>

                            </div>
                            <div class="col-md-8">
                                <!-- REVENUE START -->
                                <div class="widget  padding-none overflow-hidden">
                                    <div class="widget-head">
                                        <h4 class="heading">Revenue</h4>
                                        <form name="revenue" action="<?php echo base_url();?>index.php/users/dashboard" method="post">
                                            &nbsp;
                                            <select name="year" id="year" class="pull-right cust_select" style="margin-top: 5px" onchange="this.form.submit()">
                                                <?php foreach($year as $name => $vale) {?>
                                                    <option value="<?php echo $name;?>"
                                                            <?php if ($current_year == $name){?>selected="selected" <?php } ?>><?php echo $vale;?></option>
                                                <?php }  ?>
                                            </select> &nbsp;
                                            <label class="pull-right"> For Year: &nbsp;</label>

                                            <select name="month" id="month" class="pull-right cust_select" style="margin-top: 5px" onchange="this.form.submit()">
                                                <?php foreach($months as $name => $vale) {?>
                                                    <option value="<?php echo $name;?>"
                                                            <?php if ($current_month == $name){?>selected="selected" <?php } ?>><?php echo $vale;?></option>
                                                <?php }  ?>
                                            </select>
                                            <label class="pull-right"> For Month: </label>

                                        </form>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="innerAll inner-2x text-center">
                                            <h5>Total Revenue</h5>
                                            <h4 class="text-medium text-primary text-condensed"><?php echo "$ ". round($sum_revenue[0]['amount'], 3); ?></h4>
                                        </div>
                                    </div>
                                    <div class="row row-merge border-bottom">
                                        <div class="col-md-6">
                                            <div class="innerAll inner-2x text-center">
                                                <h5>Total Revenue for <b><?php echo $months[$current_month]; ?></b></h5>
                                                <h4 class="text-medium text-primary text-condensed"><?php echo "$ ".(float)$monthly_revenue[0]['amount']; ?></h4>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="innerAll inner-2x bg-grays">
                                        <!-- Chart with lines and fill with no points -->
                                        <div id="chart_lines_fill_nopoints_2" class="flotchart-holder " style="height: 300px !important"></div>
                                    </div>
                                    <div class="innerAll inner-2x bg-grays">
                                        <!-- Chart with lines and fill with no points -->
                                        <div id="chart_lines_nol"></div>
                                    </div>
                                </div>
                                <!-- // END REVENUE -->
                            </div>

                            <div class="col-md-4">
                                <div class="widget">
                                    <div class="widget-head">
                                        <h4 class="heading">Upcoming Renewals</h4>
                                    </div>
                                    <div class="widget-body innerAll inner-2x">
                                        <table class="table table-white table-vertical-center margin-none table-striped footable">
                                            <thead>
                                            <tr>
                                                <th  data-class="highlight" class="text-center">Subscriber Name</th>
                                                <!-- <th data-hide="phone" class="text-center">Email</th> -->
                                                <!-- <th data-hide="phone" class="text-center">Phone</th> -->
                                                <th class="text-center">Magazine Code</th>
                                                <th class="text-center">Date of expiry</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if (count($magazine_renewals)) {
                                                foreach($magazine_renewals as $magazineRenewals) {?>
                                                    <tr>
                                                        <td class="text-center" ><?php echo ucwords($magazineRenewals['first_name']." ".$subscriptions['last_name']);?></td>
                                                        <!-- <td class="text-center" ><?php echo $magazineRenewals['email']; ?></td>
                                                                                                                <td class="text-center"><?php echo $magazineRenewals['phone']; ?></td> -->
                                                        <td class="text-center"><?php echo $magazineRenewals['magazine_code']; ?></td>
                                                        <td class="text-center"><?php echo date("d M Y", strtotime($magazineRenewals['subscription_end_on'])); ?></td>
                                                    </tr>
                                                <?php } } else { ?>
                                                <tr>
                                                    <td colspan="5" align="center">Sorry, No renewals for now !!</td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                        <?php
                                        if (count($magazine_renewals)) {?>
                                            <div style="margin-top: 10px" align="right"> <a href="<?php echo base_url();?>index.php/users/renewals" class="btn btn-primary view-all">View all</a></div>
                                        <?php } ?>
                                        <div class="col-separator-h clearfix"></div>
                                    </div>
                                    <!-- // END TRENDS -->
                                </div>
                                <div class="col-separator-h"></div>
                            </div>

                        </div>
                        <div class="col-separator-h"></div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php #echo "<pre>";print_r($daily_revenue);?>
<script src="<?php echo base_url(); ?>assets/library/jquery/jquery.min.js"></script>
<?php //$intVal = (count($monthly_revenue)) ? count($monthly_revenue):null; ?>
<?php $intVal = count($monthly_revenue); ?>
<input type="hidden" value="<?php echo $intVal; ?>" id="monthly_revenue">
<script>
    $(window).on('load', function(){
        console.log($("#monthly_revenue").val());
        var pauseContent = <?php echo  json_encode($daily_revenue, JSON_NUMERIC_CHECK); ?>;
        var totalRevenue = <?php echo  isset($monthly_revenue[0]) ? $monthly_revenue[0]['amount'] : 0; ?>;
        var countArr = $("#monthly_revenue").val();
        if (countArr > 0) {
            setTimeout(function(){
                charts.chart_lines_fill_nopoints_2.init(pauseContent, totalRevenue);
            }, 100);
        } else {
            $("#chart_lines_fill_nopoints_2").html("<h4 align='center'>Sorry, no revenue for this month !!</h4>");
        }



    });
</script>

<script src="<?php echo base_url(); ?>assets/library/jquery/jquery-migrate.min.js?v=v2.0.0-rc1&amp;sv=v0.0.1.2"></script>
<script>var App = {};</script>
<script>if (/*@cc_on!@*/false && document.documentMode === 10) { document.documentElement.className+=' ie ie10'; }</script>

<!-- Global -->
<script data-id="App.Config">
    var basePath = '',
        commonPath = '<?php echo base_url(); ?>assets/',
        rootPath = '<?php echo base_url(); ?>',
        DEV = false,
        componentsPath = '<?php echo base_url(); ?>/assets/components/';

    var primaryColor = '#eb6a5a', //'#75b9a6'
        dangerColor = '#b55151',
        successColor = '#609450',
        infoColor = '#4a8bc2',
        warningColor = '#ab7a4b',
        inverseColor = '#45484d';

    var themerPrimaryColor = primaryColor;

    App.Config = {
        ajaxify_menu_selectors: ['#menu','#menu_kis'],
        ajaxify_layout_app: false        };
</script>
<script src="<?php echo base_url(); ?>assets/plugins/charts_flot/jquery.flot.js?v=v2.0.0-rc8&amp;sv=v0.0.1.2"></script>
<script src="<?php echo base_url(); ?>assets/plugins/charts_flot/jquery.flot.resize.js?v=v2.0.0-rc8&amp;sv=v0.0.1.2"></script>
<script src="<?php echo base_url(); ?>assets/plugins/charts_flot/plugins/jquery.flot.tooltip.min.js?v=v2.0.0-rc8&amp;sv=v0.0.1.2"></script>
<script src="<?php echo base_url(); ?>assets/components/charts_flot/flotcharts.common.js?v=v2.0.0-rc8&amp;sv=v0.0.1.2"></script>
<script src="<?php echo base_url(); ?>assets/components/charts_flot/flotchart-line-2.init.js?v=v2.0.0-rc8"></script>
<script src="<?php echo base_url(); ?>assets/plugins/charts_flot/jquery.flot.time.min.js"></script>
