<?php

	class Header {

		private $db;
		private $session;
		private $account_key = null;
		private $user = null;

		public function __construct() {
			global $db, $session;
			$this->db = $db;
			$this->session = $session;
		}

		public function getUser() {
			return $this->session->get('nome');
		}

		public function getModuleJS( $no_cache = false ) {
			if( isset($_GET['um']) && $_GET['um'] != '' ) {
				$fileName = $_GET['um'] . '/' . $_GET['um'] . '.js';
				if(file_exists(ROOT_PATH . 'modules/' . $fileName)) {
					return '<script type="text/javascript" src="/sistema/modules/' . $fileName . ($no_cache == true ? '?' . rand(0000, 9999) : null) . '"></script>';
				}
				return null;
			}
			return null;
		}

		public function getModuleCSS( $no_cache = false ) {
			if( isset($_GET['um']) && $_GET['um'] != '' ) {
				$fileName = $_GET['um'] . '/' . $_GET['um'] . '.css';
				if(file_exists(ROOT_PATH . 'modules/' . $fileName)) {
					return '<link rel="stylesheet" type="text/css" href="/sistema/modules/' . $fileName . ($no_cache == true ? '?' . rand(0000, 9999) : null) . '">';
				}
				return null;
			}
			return null;
		}

	}

	loadBaseView('header', new Header);