<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends MY_Controller {
    function __construct() {
        parent::__construct();
        $this->load->model('dashboard/dashboard_model');
    }
    public function index1() {
        var_dump($this->session->userdata('user'));
    }
    public function index() {
        $databoxes=$this->dashboard_model->getdataboxes();
        if($databoxes!=null) {
            $i=0;
            $url='';
            $xml = simplexml_load_string(htmlspecialchars_decode($databoxes));
            $pagedata[]='';
            foreach ($xml as $key0 => $value) {
                foreach ($value->attributes() as $attributeskey0 => $attributesvalue1) {
                    if($attributeskey0=='key') {
                        $url = $attributesvalue1;
                    } else if($attributeskey0=='count') {
                        $pagedata['count'] = $attributesvalue1;
                    } else if($attributeskey0=='days') {
                        $pagedata['days'] = $attributesvalue1;
                    }
                }
                $data['databoxes'][$i]=$this->load->view('dashboard/databoxes/'.$url, $pagedata, true);
                $i+=1;
                $url='';
            }
            $data['template'] = 'dashboard/dashboard_view';
            $this->load->view('template',$data);
        } else{
            $data['template'] = 'dashboard/dashboard_view';
            $this->load->view('template',$data);
        }
    }
}
