<?php
class Index_Model extends Model{
	function __construct(){
		parent::__construct();
	}
	
	function logout()
	{
		Session::destroy();
		header('location:'.URL);
	}
	function submit_user()
	{
		$userCheck = DAOFactory::getTblAdminDAO()->queryByUsername($_POST['username']);
		if(empty($userCheck))
		{
			$insert = new TblAdmin;
			$insert->username = $_POST['username'];
			$insert->password = $_POST['password'];
			$insert->status = $_POST['status'];
			
			DAOFactory::getTblAdminDAO()->insert($insert);
			
			Model::setLogs('admin transaction', 'User Creation of user '.$_POST['username']);
		}
		else
		{
			echo 'User already exist.';
		}
	}
	function getUser()
	{
		return DAOFactory::getTblAdminDAO()->queryAll();
	}
}