<!-- <?php
    // foreach($hitung_ses as $hitung_ses){
        
    // echo((double)$hitung_ses['y_aksen_ses']);
    // echo(',');
    // }
    //   die;                                      
    ?> -->
<div class="main-content">

    <div class="page-content">

        <!-- Page-Title -->
         <div class="page-title-box" style="background-color:#3c2f27 !important">
            <div class="container-fluid">
                <div class="row align-items-center">
                    <div class="col-md-8">
                        <h4 class="page-title mb-1">Hasil Forecasting Single Exponential Smoothing</h4>
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item active">Produksi Kopi di indonesia</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
        <!-- end page title end breadcrumb -->

        <div class="page-content-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">

                               
                                <h4 class="header-title">Chart Hasil Perhitungan</h4>
                                <p class="card-title-desc">Chart Hasil Forecasting
                                </p>
                                <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
                                <div id="chart">
                                </div>
                                <script>
                                var options = {
                                    chart: {
                                        type: 'line'
                                    },
                                    series: [{
                                        name: 'Data Real (At)',
                                        type: 'line',
                                        data: [
                                            <?php
                                                foreach($at as $at):
                                            
                                            ?>
                                            <?= $at['at'].','?>
                                            <?php
                                            endforeach;?>
                                        ]
                                    }, {
                                        name: 'Data Hasil Forecast (Ft)',
                                        type: 'line',
                                        data: [<?php
                                                foreach($ft as $ft):
                                            
                                            ?>
                                            <?= $ft['ft'].','?>
                                            <?php
                                            endforeach;?>
                                        ]
                                    }],
                                    dataLabels: {
                                        enabled: true,
                                        enabledOnSeries: [0, 1],


                                    },

                                    xaxis: {
                                            categories: [<?php
                                                foreach($bulan as $bulan):
                                                    $nama_bulan = date('F', mktime(0, 0, 0, $bulan['bulan'], 1));
                                            ?>
                                            '<?= $nama_bulan ?>',
                                            <?php
                                                endforeach;
                                            ?>
                                            ]
                                        },
                                    responsive: [{
                                        breakpoint: undefined,
                                        options: {},
                                    }]

                                }


                                var chart = new ApexCharts(document.querySelector("#chart"), options);

                                chart.render();
                                </script>

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

                </div>
             
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="header-title">Perhitungan</h4>

                                <div class="flash-data-news" data-flashdata="<?= $this->session->flashdata('flash') ?>">

                                </div>
                                <div class="flash-data-data" data-flashdata="<?= $this->session->flashdata('data') ?>">
                                </div>

                                <br>
                                <a href ="<?=base_url()?>excel/exportresult/<?= $jeniskopi ?>" type="button p-1 mb-4 " class="btn btn-warning mdi mdi-plus mx-auto">Export Result <?= $jeniskopi ?></a>
                                <br>
                                <br>
                                <div class="table-responsive mb-4">
                                <table id="datatable" class="table table-bordered dt-responsive"
                                    style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                                    <thead>
                                        <tr>
                                            <th>No.</th>
                                            <th>Data Aktual</th>
                                            <th>Hasil Prediksi</th>
                                            <th>MAPE</th>
                                            <th>MAD</th>
                                            <th>MSE</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $n0 = 1; ?>
                                        <?php foreach ($hitung_ses1 as $hitung_ses1) : ?>
                                        <tr>
                                            <td><?=$n0?></td>
                                            <td><?=$hitung_ses1['at']?> Kg</td>
                                            <td><?=$hitung_ses1['ft']?> Kg</td>
                                            <td><?php echo number_format($hitung_ses1['ape'] / 35, 2) ?></td>
                                            <td><?php echo number_format($hitung_ses1['ad'] / 35, 2) ?></td>
                                            <td><?php echo number_format($hitung_ses1['se'] / $countall, 2) ?></td>

                                        </tr>
                                        <?php $n0++ ?>
                                        <?php endforeach ?>
                                    </tbody>


                                </table>
                                </div>
                                <h4>Perkiraan untuk bulan berikutnya = <?=$bulan_selanjutnya?> Kg</h4>
                                <h4>MSE = <?=$mse?> Kg</h4>
                                <h4>MAD = <?=$mad?> Kg</h4>
                                <h4>MAPE = <?=$mape?> %</h4>
                            </div>
                        </div>
                    </div>

                </div>
            



            </div> <!-- container-fluid -->
        </div>
        <!-- end page-content-wrapper -->
    </div>
    <!-- End Page-content -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.bundle.js"></script>