<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Dashboard extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        is_logedin();

        $this->load->model('Admin_model', 'admin');
    }

    public function index()
    {
        $data['title'] = "Dashboard";

        
        $data['causas2'] = 10;
        $data['causas3'] = 15;
        
        $data['clientes'] = $this->admin->count('tbl_clientes');
        $data['usuarios'] = $this->admin->count('tbl_user');

        $data['causas'] = 120;
        $data['ingresos'] = "15.550.000"; //$data['earnings'] = $this->admin->sum('barang_keluar', 'grand_total');
                
        // Line Chart
        $bln = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
        $data['cbm'] = [];
        $data['cbk'] = [];

        foreach ($bln as $b) {
            $data['cbm'][] = $this->admin->chartClientes1($b);
            $data['cbk'][] = $this->admin->chartClientes1($b);
        }

        $this->template->load('templates/dashboard', 'dashboard', $data);
    }
}
