
<?php $__env->startSection('content'); ?>
    <main class="main-content">
        <div class="container">
            <?php if (isset($component)) { $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74 = $component; } ?>
<?php $component = $__env->getContainer()->make(App\View\Components\FlashMessage::class, []); ?>
<?php $component->withName('flashMessage'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74)): ?>
<?php $component = $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74; ?>
<?php unset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74); ?>
<?php endif; ?>
            <!-- begin::page header -->
            <div class="page-header d-md-flex align-items-center justify-content-between">
                <div>
                    <h3>Dashboard</h3>
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="#">Dashboard</a></li>
                            <li class="breadcrumb-item active" aria-current="page">HRMS</li>
                        </ol>
                    </nav>
                </div>
                <div class="form-group mt-3 d-flex">
                    

                    <form class="dashboard-date-form" action="<?php echo e(asset('hrms/dashboard')); ?>" method="get">
                        <div class="d-flex">
                            <div id="reportrange" class="reportrange btn btn-outline-light m-r-5">
                                <input type="hidden" name="start_date" class="start-date-input">
                                <input type="hidden" name="end_date" class="end-date-input">
                                <i class="ti-calendar m-r-10"></i>
                                <span class="selected-date"></span>
                                <i class="ti-angle-down m-l-10"></i>
                            </div>
                            <div class="dropdown m-r-5">
                                <button class="btn btn-success"><i class="fa fa-filter"></i> </button>
                                <a href="<?php echo e(asset('hrms/dashboard')); ?>" class="btn btn-outline-secondary"><i class="ti ti-reload"></i></a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div>
               
                <div class="row">
                    <div class="col-md-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="p-0 m-0 text-center"> Employees</h5>
                            </div>
                            <div class="card-body text-center"><?php echo e($employees??''); ?></div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="p-0 m-0 text-center"> Promotions</h5>
                            </div>
                            <div class="card-body text-center"><?php echo e($emp_promotion??''); ?></div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="p-0 m-0 text-center"> Transfer</h5>
                            </div>
                            <div class="card-body text-center"><?php echo e($emp_transfer??''); ?></div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="p-0 m-0 text-center"> Awards</h5>
                            </div>
                            <div class="card-body text-center"><?php echo e($emp_award??''); ?></div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="p-0 m-0 text-center"> Resignations</h5>
                            </div>
                            <div class="card-body text-center"><?php echo e($emp_resignation??''); ?></div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="p-0 m-0 text-center"> Terminations</h5>
                            </div>
                            <div class="card-body text-center"><?php echo e($emp_terminate??''); ?></div>
                        </div>
                    </div>
                </div>

                <div class="row mb-3">
                    <div class="col-md-12">
                        <div class="chart_div" id="chart_div"></div>
                    </div>
                </div>
                

                <!-- <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <h4>Recent Task</h4>
                            </div>
                            <div class="card-body">
                                <table class="table table-striped">
                                    <thead>
                                        <tr class="text-bold">
                                            <th>Date</th>
                                            
                                            <th>Type</th>
                                            <th>Task Name</th>
                                            <th>Allotted To</th>
                                            <th>Status</th>
                                            <th>Priority</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                       
                                    </tbody>
                                </table>
                                <div class="d-flex justify-content-end">
                                    <a class="btn btn-outline-primary btn-sm" href="#">View
                                        More...</a>
                                </div>
                            </div>
                        </div>

                    </div>
                </div> -->



                <div class="row">
                    <div class="col-md-7">



                        <div class="card">
                            <div class="card-header">
                                <h4>Latest Activity</h4>
                            </div>
                            <div class="card-body">
                                <?php
                                    $alertClasses = ['alert-success', 'alert-danger', 'alert-warning', 'alert-info']; // Add as many classes as you want
                                ?>

                                <?php $__currentLoopData = $activity; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$act): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php
                                        $alertClass = $alertClasses[$key % count($alertClasses)];
                                    ?>
                                    <div class="alert <?php echo e($alertClass); ?>">
                                        <strong><?php echo e($act->user_name); ?> !</strong>
                                       <?php echo e($act->subject); ?>

                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                
                            </div>
                        </div>


                    </div>

                    <div class="col-md-5">
                        <div class="card">
                            <div class="card-header">
                                <h4>How To Use Software</h4>
                            </div>
                            <div class="card-body">
                                <video width="100%" controls>
                                    <source src="<?php echo e(asset('public/demo.mp4')); ?>" type="video/mp4">
                                    Your browser does not support the video tag.
                                </video>
                            </div>
                        </div>
                    </div>

                </div>


            </div>
        </div>
    </main>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <script src="https://cdn.jsdelivr.net/npm/html2canvas@1.0.0-rc.7/dist/html2canvas.min.js"></script>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
    <script>
        
        //date picker
        $(function() {
            var start = moment().subtract(29, 'days');
            var end = moment();

            function cb(start, end) {
                $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
                filterByDate(start, end);
            }
            $('#reportrange').daterangepicker({
                startDate: start,
                endDate: end,
                ranges: {
                    'Today': [moment(), moment()],
                    'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                    'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                    'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                    'This Month': [moment().startOf('month'), moment().endOf('month')],
                    'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1,
                        'month').endOf('month')]
                }
            }, cb);
            cb(start, end);
        });

        function filterByDate(start_date, end_date) {
            //$(".dashboard-date-form").submit();
            var s_date = new Date(start_date);
            var n_date = new Date(end_date);
            $(".start-date-input").val(s_date.toISOString());
            $(".end-date-input").val(n_date.toISOString());
        }
        var role = $(".has-role").attr("roledata");
        
        var title_date = new Date();
        var year = title_date.getFullYear();
        var month = ('0' + (title_date.getMonth() + 1)).slice(-2); // Adding leading zero if needed
        var day = ('0' + title_date.getDate()).slice(-2); // Adding leading zero if needed
        // Concatenate the year, month, and day with hyphens
        var c_date = year + '-' + month + '-' + day;
        var date = new Date();
        var options = {
            year: 'numeric',
            month: 'long'
        };

        google.charts.load('current', { packages: ['corechart', 'bar'] });
        google.charts.setOnLoadCallback(drawChart);

        function drawChart() {
            var salaryData = <?php echo json_encode($salary_data, 15, 512) ?>; // Laravel data passed to JS

            // Get last 6 months dynamically in the correct order
            let lastSixMonths = [];
            let monthNames = [];
            let currentDate = new Date();

            for (let i = 5; i >= 0; i--) {
                let month = new Date(currentDate.getFullYear(), currentDate.getMonth() - i, 1);
                let monthFormatted = month.toLocaleString('default', { month: 'long' }); // Full month name (e.g., "January")
                lastSixMonths.push(monthFormatted);
                monthNames.push(monthFormatted);
            }

            let departments = [...new Set(salaryData.map(item => item.department))]; // Get unique departments

            var dataArray = [['Month', ...departments]]; // Headers for the chart

            lastSixMonths.forEach(month => {
                let row = [month]; // First column is the month

                departments.forEach(department => {
                    let salary = salaryData.find(item => item.month_name === month && item.department === department);
                    row.push(salary ? Number(salary.total_salary) : 0); // Default to 0 if no data
                });

                dataArray.push(row);
            });

            var chartData = google.visualization.arrayToDataTable(dataArray);

            var options = {
                title: 'Monthly Salary Distribution (Last 6 Months)',
                hAxis: { 
                    title: 'Month', 
                    slantedText: true, 
                    slantedTextAngle: 45 // Tilt month labels for better visibility
                },
                vAxis: { title: 'Total Salary' },
                bars: 'grouped',
                colors: ['#f97316', '#38bdf8', '#22c55e', '#dc2626', '#a855f7', '#14b8a6', '#ef4444', '#84cc16'],
                legend: { position: 'top', maxLines: 3 },
            };

            var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
            chart.draw(chartData, options);
        }
    </script>
   
 
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\blurb_erp\resources\views/hrms/dashboard/dashboard.blade.php ENDPATH**/ ?>