<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.js"></script>


<?php $__env->startSection('main'); ?>

    <div id="wrapper">

        <?php echo $__env->make('admin.sidebar_menu', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>

        <div id="page-wrapper">
            

            <?php if(session('error')): ?>
                <div class="row">
                    <div class="col-lg-12">
                        <br />
                        <div class="alert alert-danger">
                            <?php echo e(session('error')); ?>

                        </div>
                    </div>
                </div>
            <?php endif; ?>

            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"><?php echo app('translator')->getFromJson('app.dashboard'); ?></h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <?php if(Auth::user()->user_type == "agent" && Auth::user()->zeia_badge == 0): ?>
            <div class="row" style="margin-bottom:20px;">
                <div class="col-lg-12">
                    <h4 >To approve your ZEIA Membership upload your certificate and id <a href="<?php echo e(route('profit_edit')); ?>">here</a></h4>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <?php endif; ?>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-3 col-md-3">
                    <div class="panel panel-primary" style="box-shadow: -2px 0px 10px 0px rgba(0,0,0,0.2);overflow:hidden;">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-12">
                                    <div><?php echo app('translator')->getFromJson('app.approved_ads'); ?></div><hr class="new1">
                                    <div class="huge"><?php echo e($approved_ads); ?></div>
                                </div>
                            </div>
                        </div>
                        </div>
                        
                        <div class="panel panel-success" style="box-shadow: -2px 0px 10px 0px rgba(0,0,0,0.2);overflow:hidden;">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-12">
                                    <div><?php echo app('translator')->getFromJson('app.reports'); ?></div><hr class="new1">
                                    <div class="huge"><?php echo e($total_reports); ?></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="col-lg-3 col-md-3">
                    <div class="panel panel-info" style="box-shadow: -2px 0px 10px 0px rgba(0,0,0,0.2);overflow:hidden;">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-12">
                                    <div><?php echo app('translator')->getFromJson('app.pending_ads'); ?></div><hr class="new1">
                                    <div class="huge"><?php echo e($pending_ads); ?></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="panel panel-warning" style="box-shadow: -2px 0px 10px 0px rgba(0,0,0,0.2);overflow:hidden;">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-12">
                                    <div><?php echo app('translator')->getFromJson('app.success_payments'); ?></div><hr class="new1">
                                    <div class="huge"><?php echo e($total_payments); ?></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3 col-md-3">
                    <div class="panel panel-danger" style="box-shadow: -2px 0px 10px 0px rgba(0,0,0,0.2);overflow:hidden;">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-12">
                                    <div><?php echo app('translator')->getFromJson('app.blocked_ads'); ?></div><hr class="new1">
                                    <div class="huge"><?php echo e($blocked_ads); ?></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="panel panel-white" style="box-shadow: -2px 0px 10px 0px rgba(0,0,0,0.2);overflow:hidden;">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-12">
                                    <div><?php echo app('translator')->getFromJson('app.total_payment'); ?></div><hr class="new1">
                                    <div class="huge">  <?php echo e($total_payments_amount); ?> <small><?php echo e(get_option('currency_sign')); ?></small></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <?php if($ten_contact_messages): ?>
                <div class="col-lg-3 col-md-3">
                    <div class="panel panel-white" style="box-shadow: -2px 0px 10px 0px rgba(0,0,0,0.2);overflow:hidden;">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-12">
                                    <div><?php echo app('translator')->getFromJson('app.users'); ?></div><hr class="new1">
                                    <div class="huge"><?php echo e($total_users); ?></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <?php endif; ?>

            </div>
            <!-- /.row -->

                <?php if($lUser->is_admin()): ?>
            <div class="row">
                <div class="row">
                <div class="col-lg-12">
                <?php if($ten_contact_messages): ?>
                <div class="col-xs-12">
                    <div class="panel panel-default" id="msg_panel">
                        <div class="panel-heading">
                            <?php echo app('translator')->getFromJson('app.latest_ten_contact_messages'); ?>
                        </div>
                        <div class="panel-body">
                            <table class="table table-striped table-responsive" id="msg_table">
                                <thead>
                                <tr>
                                    <th style="width: 30%;"><?php echo app('translator')->getFromJson('app.sender'); ?></th>
                                    <th>Senders Email</th>
                                    <th style="width: 100%;"><?php echo app('translator')->getFromJson('app.message'); ?></th>
                                </tr>
                                </thead>
                                <?php $__currentLoopData = $ten_contact_messages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $message): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td>
                                            <span class="icon_bg"><i class="fa fa-user"></i></span> <div class="msg_content"> <?php echo e($message->name); ?></div> <br />
                                            <span class="icon_bg_time"><i class="fa fa-clock-o"></i></span> <div class="msg_content"><?php echo e($message->created_at->diffForHumans()); ?></div>
                                        </td>
                                        <td><?php echo e($message->email); ?> </td>
                                        <td><?php echo e($message->message); ?></td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </table>
                        </div>
                    </div>
                </div>
                </div>
                
                <?php endif; ?>
                </div>

                <?php if($reports): ?>
                <div class="col-xs-12">
                    <div class="panel panel-default" id="msg_panel">
                        <div class="panel-heading">
                            <?php echo app('translator')->getFromJson('app.latest_ten_ads_report'); ?>
                        </div>
                        <div class="panel-body">

                            <?php if($reports->count() > 0): ?>
                                <table class="table table-striped table-responsive table-fixed" id="msg_table">
                                    <thead>
                                    <tr>
                                        <th><?php echo app('translator')->getFromJson('app.reason'); ?></th>
                                        <th><?php echo app('translator')->getFromJson('app.email'); ?></th>
                                        <th style="width: 20%;"><?php echo app('translator')->getFromJson('app.message'); ?></th>
                                        <th style="width: 20%;">Time Stamp</th>
                                        <th style="width: 100%;"><?php echo app('translator')->getFromJson('app.ad_info'); ?></th>
                                    </tr>
                                    </thead>
                                    <?php $__currentLoopData = $reports; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $report): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td><?php echo e($report->reason); ?></td>
                                            <td> <?php echo e($report->email); ?>  </td>
                                            <td>
                                                <?php echo e($report->message); ?>

                                            </td>
                                            <td>
                                                <p class="text-muted"> <i><?php echo app('translator')->getFromJson('app.date_time'); ?>: <?php echo e($report->posting_datetime()); ?></i></p>
                                            </td>
                                            <td>
                                                <?php if($report->ad): ?>
                                                    <a href="<?php echo e(route('single_ad', $report->ad->slug)); ?>" target="_blank"><?php echo app('translator')->getFromJson('app.view_ad'); ?></a>
                                                    <i class="clearfix"></i>
                                                    <a href="<?php echo e(route('reports_by_ads', $report->ad->slug)); ?>">
                                                        <i class="fa fa-exclamation-triangle"></i> <?php echo app('translator')->getFromJson('app.reports'); ?> : <?php echo e($report->ad->reports->count()); ?>

                                                    </a>
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </table>
                            <?php endif; ?>

                        </div>
                    </div>
                </div>
                <?php endif; ?>
            </div>
            <?php endif; ?>
        <script src = "https://cdn.bootcss.com/randomcolor/0.5.4/randomColor.min.js" > </script>
        <script>
        
                <?php if($chat_agents): ?>
                    var agents = [ <?php $__currentLoopData = $chat_agents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $agent): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <?php echo '"'. $agent->name . '"'; ?>, <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>];
                    var ads = [<?php $__currentLoopData = $chat_agents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $agent): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <?php echo e($agent->ads); ?>, <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>];
                <?php else: ?>
                    var agents = ["none"];
                    var ads = [0];
                <?php endif; ?>
                
                var borders = randomColor({
                                   count : ads.length,
                                   luminosity: 'dark',
                                   format: 'rgba',
                                   alpha: 0.5 // e.g. 'rgba(9, 1, 107, 0.5)',
                                });
                var backg = randomColor({
                                   count : ads.length,
                                   luminosity: 'bright',
                                   format: 'rgba',
                                   alpha: 0.7 // e.g. 'rgba(9, 1, 107, 0.5)',
                                });
                
                $(document).ready(function () {
                $('#msg_table').DataTable({
                "scrollY": "200px",
                "scrollCollapse": true,
                });
                $('.dataTables_length').addClass('bs-select');
                });
                //doughnut PIE
                var ctxD = document.getElementById("doughnutChart").getContext('2d');
                var myLineChart = new Chart(ctxD, {
                  type: 'doughnut',
                  data: {
                    labels: agents,
                    datasets: [{
                      
                      data: ads,
                      backgroundColor: backg,
                      hoverBackgroundColor: ["#9033de", "#c9c9c9"]
                    }]
                  },
                  options: {
                    responsive: true
                  }
                });
        </script>
        <script>
                new Chart(document.getElementById("horizontalBar"), {
                    "type": "horizontalBar",
                    "data": {
                    "labels": agents,
                    "datasets": [{
                    "label": "Sales by Agent",
                    "data": ads,
                    "fill": false,
                    "backgroundColor": backg,
                    "borderColor": borders,
                    "borderWidth": 1
                    }]
                    },
                    "options": {
                    "scales": {
                    "xAxes": [{
                    "ticks": {
                    "beginAtZero": true
                    }
                    }]
                    }
                    }
                });
        </script>

        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layout.main', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>