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

class Dashboard extends Admin_Controller {

    function __construct() {
        parent::__construct();
	}

	public function index() {
        
        
        $this->template
            ->set('view', 'admin/dashboard')
            ->render();
	}
	
	public function dbLog() {
        
        $where = '';
        
        if(isset($_POST['from_date']) && $_POST['from_date'] != '' && isset($_POST['to_date']) && $_POST['to_date'] != ''){
            $date_from  = date('Y-m-d 00:00:00', strtotime(str_replace('/','-',$_POST['from_date'])));
            $date_to    = date('Y-m-d 23:59:59', strtotime(str_replace('/','-',$_POST['to_date'])));
        }else{
            $date_from  = date('Y-m-d 00:00:00', strtotime('now'));
            $date_to    = date('Y-m-d 23:59:59', strtotime('now'));
        }

        $ar = $this->db->query("SELECT * FROM database_errors WHERE dateCreation BETWEEN '$date_from' AND '$date_to' ORDER BY id DESC LIMIT 100")->result();

        $this->template
            ->set('view', 'admin/leads/dbLog')
    		->set('ar', $ar)
            ->render();
	}
}
