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

class Dashboard extends CI_Controller
{

  function __construct()
  {
    parent::__construct();
    // $this->load->database();
    $this->load->helper('url');
    $this->load->library('session');
    $this->load->model('dashboard_model');
    $this->load->model('common');
  }

  public function settings()
  {
    $data["settings"] = $this->common->readdatafromcollectionbetween("Settings");


    $this->template->template_render('settings', $data);
  }
  public function saveSettings($id)
  {
    $post = $this->input->post();
    $response = $this->common->updatedatamodel("Settings", $id, $post);
    if ($response) {
      $this->session->set_flashdata('successmessage', 'Settings has been updated');
    } else {
      $this->session->set_flashdata('warningmessage', 'Error! Some issue with firebase.Please try again');
    }

    redirect(base_url('dashboard/settings'));
  }

  public function index()
  {
    
    $sessionData = $this->session->userdata('session_data');

    $data['userdetails'] = $sessionData;

//     print_r($data['userdetails']);

// die;
    $this->template->template_render('dashboard', $data);
  }

 
}
