% WRITTEN BY CAGDAS & MRIDULA
%SHOWS Main screen, nothing big deal just a couple of buttons
% the only trick is if the user is highlevel, we show account manager
% button too
function varargout = GUI_showMainScreen(varargin)
% GUI_SHOWMAINSCREEN MATLAB code for GUI_showMainScreen.fig
%      GUI_SHOWMAINSCREEN, by itself, creates a new GUI_SHOWMAINSCREEN or raises the existing
%      singleton*.
%
%      H = GUI_SHOWMAINSCREEN returns the handle to a new GUI_SHOWMAINSCREEN or the handle to
%      the existing singleton*.
%
%      GUI_SHOWMAINSCREEN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_SHOWMAINSCREEN.M with the given input arguments.
%
%      GUI_SHOWMAINSCREEN('Property','Value',...) creates a new GUI_SHOWMAINSCREEN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_showMainScreen_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_showMainScreen_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help GUI_showMainScreen

% Last Modified by GUIDE v2.5 31-Oct-2013 18:49:23

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_showMainScreen_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_showMainScreen_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before GUI_showMainScreen is made visible.
function GUI_showMainScreen_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to GUI_showMainScreen (see VARARGIN)
handles.ctrl = varargin{1};
user = handles.ctrl.getUser();
if user.type==1
%%if the user is not a previledged user
    set(handles.bt_AccountManager,'Visible','Off')
end
% Choose default command line output for GUI_showMainScreen
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GUI_showMainScreen wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = GUI_showMainScreen_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in bt_HeartRateManager.
function bt_HeartRateManager_Callback(hObject, eventdata, handles)
% hObject    handle to bt_HeartRateManager (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close all
GUI_showHeartRateScreen(handles.ctrl)

% --- Executes on button press in bt_SleepPatternManager.
function bt_SleepPatternManager_Callback(hObject, eventdata, handles)
% hObject    handle to bt_SleepPatternManager (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close all
GUI_showSleepPatternManager(handles.ctrl)


% --- Executes on button press in bt_SuggestionManger.
function bt_SuggestionManger_Callback(hObject, eventdata, handles)
% hObject    handle to bt_SuggestionManger (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close all
GUI_showSuggestionScreen(handles.ctrl)

% --- Executes on button press in bt_AccountManager.
function bt_AccountManager_Callback(hObject, eventdata, handles)
close all
GUI_showAccountManagementScreen(handles.ctrl);
% hObject    handle to bt_AccountManager (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in bt_LogOut.
function bt_LogOut_Callback(hObject, eventdata, handles)
clear all;
close all
Controller();


% hObject    handle to bt_LogOut (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
