
/******************************************************************\
|Menu System:													   |
|							MenuSystem.h						   |
|			        											   |
|						     apr.4.00							   |
|																   |
|													ver: 1.0	   |
\******************************************************************/
#include "plist.h"
#include "Shift.h"
#include "RegularShift.h"
#include "DetailShift.h"
#include "Precinct.h"



class menuclass {
	private:
		int  ans, switchcase;
		bool greenlight, submenu;
		string temp; /* for converting first part string to int */
		int  mainmenu();
		void detailmenu();
		void detailswitch(int num);
		void officermenu();
		void officerswitch(int num);
		void currentofficermenu();
		void currentswitch(int num,Officer *O);
		void splashscreen();
      void amusingone();
		void moremenu();
		void moreswitch(int num);
      void woman();

		void sleep(int num);
      Precinct P;
	public:
		menuclass();
		void menusystem();
};
#include "woman.h"
menuclass::menuclass(){
		ans			= 0;
		switchcase	= 0;
		submenu		= true;
		greenlight	= true;
		splashscreen();
      P.Load();               // loads database when constructed
      sleep(1000);
      clrscr();
}

int  menuclass::mainmenu(){
		clrscr();
      textcolor(YELLOW);
		cprintf("\nWelcome to the Detail Scheduler Program. \r\n");
      textcolor(WHITE);
		cprintf("\nPlease choose one of the following commands: \n");
      plist mainp(7);
		mainp.insert("1.      Detail Menu.          ");
		mainp.insert("2.      Officer Menu.         ");
		mainp.insert("3.      More Options.         ");
		mainp.insert("4.      Quit this program.    ");
		temp = mainp.printList();
		ans = (int) temp[0] - 48;
		return  ans;
}

void menuclass::menusystem(){
		while(greenlight){
			switchcase = mainmenu();
			switch (switchcase){
				case 1:
					detailmenu();
					clrscr();
					break;
				case 2:
					officermenu();
					clrscr();
					break;
				case 3:
					clrscr();
					moremenu();
					break;
				case 4:
					clrscr();
               P.Save();                // saves when user quits
					greenlight = false;
					break;
				default:
					cout << "invalid entry...  try again" << endl << endl;
					sleep(500);
					clrscr();
			}//end switch
		}// end while
}

void menuclass::detailmenu(){
		submenu = true;
		while (submenu){
			clrscr();
         textcolor(YELLOW);
			cprintf("\nThis is the Detail Menu. \r\n");
         textcolor(WHITE);
			cprintf("\nSelect one of the following commands: \n");
         plist detail(6);
			detail.insert("1.      New Detail.         ");
			detail.insert("2.      Assign Detail.      ");
			detail.insert("3.      Unassign Detail.    ");
			detail.insert("4.      Remove Detail.      ");
			detail.insert("5.      List Details.       ");
			detail.insert("6.      Back.               ");	
			temp = detail.printList();
			ans = (int) temp[0] - 48;
			detailswitch(ans);
		}// end while
}

void menuclass::detailswitch(int num){
      char z[2];
      gets(z);
		switch (num){
			case 1:
				clrscr();
				P.Add_Detail();
				/*  call create new detail function  */
				break;
			case 2:
				clrscr();
				P.Assign_Detail();
				/*  call assign detail function  */
				break;
			case 3:
				clrscr();
				cout << "option 3 works correctly. " << endl;
				sleep(500);
				/*  call find detail function  */
				break;
			case 4:
				clrscr();
				cout << "option 4 works correctly. " << endl;
				sleep(500);
				/*  call remove detail function  */
				break;
			case 5:
				clrscr();
				P.List_Details();
				/*  call list details function  */
				break;
			case 6:
				submenu = false;
				clrscr();
				break;
			default:
				cout << "invalid entry...  please try again" << endl << endl;
				sleep(500);
				clrscr();
		}// end switch
}

void menuclass::officermenu(){
		submenu = true;
		while (submenu){
			clrscr();
         textcolor(YELLOW);
			cprintf("\nOfficer Information Menu\r\n");
         textcolor(WHITE);
			cprintf("\nPlease choose one of the following commands: \n");
         plist officer(5);
			officer.insert("1.      New Officer.          ");
			officer.insert("2.      Current Officer.      ");
			officer.insert("3.      Show Roster.          ");
			officer.insert("4.      Remove Officer.       ");
			officer.insert("5.      Go Back.              ");
			temp = officer.printList();
			ans = (int) temp[0] - 48;
			officerswitch(ans);
		}// end while
}

void menuclass::officerswitch(int num){
      char z[2];
      gets(z);
		switch (num){
			case 1:
				clrscr();
				P.Add_Officer();
				/*  call New Officer function  */
				break;
			case 2:
				currentofficermenu();
				/*  call Current Officerfunction  */
				break;
			case 3:
				P.List_Officers();
				/*  call Show Roster function  */
				break;
			case 4:
				clrscr();
				P.Remove_Officer();
				/*  call Remove Officerfunction  */
				break;
			case 5:
				submenu = false;
				clrscr();
				break;
			default:
				cout << "invalid entry...   try again" << endl << endl;
				sleep(500);
				clrscr();
		}// end switch
}

void menuclass::currentofficermenu(){
	Officer *O = P.Find_Officer();
	if(O != NULL){
		submenu = true;
		while (submenu){
			clrscr();
         textcolor(YELLOW);
			cprintf("\nCurrent Officer menu. \r\n");
         textcolor(LIGHTGRAY);
         O->Print();
         textcolor(WHITE);
			cprintf("\nSelect one of the following commands: \n");
         plist current(10);
			current.insert(" 1.      Edit Name.             ");
			current.insert(" 2.      Edit Badge Number.     ");
			current.insert(" 3.      Edit Phone Number.     ");
			current.insert(" 4.      Edit Alt. Phone Number.");
			current.insert(" 5.      New Regular Shift.     ");
			current.insert(" 6.      Edit Regular Shift.    ");
			current.insert(" 7.      Remove Regular Shift.  ");
			current.insert(" 8.      List Shifts.           ");
			current.insert(" 9.      List Details.          ");
			current.insert("10.      Go Back.               ");
			temp = current.printList();
			ans = (int) temp[1] - 48;
			currentswitch(ans,O);
		}// end while
	}
	submenu = true;
}

void menuclass::currentswitch(int num,Officer *O){
      char z[2];
 		gets(z);
		switch (num){
			case 1:
				clrscr();
				O->Set_Name();
				/*  call edit name function  */
				break;
			case 2:
				clrscr();
            O->Set_BadgeNum();
				/*  call edit badge function  */
				break;
			case 3:
				clrscr();
            O->Set_PhoneNum();
				/*  call edit phone function  */
				break;
			case 4:
				clrscr();
            O->Set_AltPhoneNum();
				/*  call edit alternate phone function  */
				break;
			case 5:
				clrscr();
				O->Add_RegularShift();
				/*  call new regular shift function  */
				break;
			case 6:
				clrscr();
				O->Get_RegularShift();
				/*  call edit regular shift function  */
				break;
			case 7:
				clrscr();
				O->Remove_RegularShift();
				/*  call remove regular shift function  */
				break;
			case 8:
				clrscr();
				O->List_Shifts();
            cout << "\nPress SPACE to continue. . .\n";
            getch();
				/*  call show shifts function  */
				break;
			case 9:
				clrscr();
				O->List_Details();
            cout << "\nPress SPACE to continue. . .\n";
            getch();
				/*  call show details function  */
				break;
			case 0:
				submenu = false;
				clrscr();
				break;
			default:
				cout << "invalid entry...  try again" << endl << endl;
				sleep(500);
				clrscr();
		}// end switch
}

void menuclass::moremenu(){
		submenu = true;
		while (submenu){
			clrscr();
         textcolor(YELLOW);
			cprintf("\nMore Options Menu. \r\n");
         textcolor(WHITE);
			cprintf("\nplease choose one of the following commands: \n");

         plist more(4);
			more.insert("1.      View the cool Splash Screen again.          ");
			more.insert("2.      Print something amusing on the screen.      ");
			more.insert("3.      Print something else amusing on the screen. ");
			more.insert("4.      Return to the main menu.                    ");			
			temp = more.printList();
			ans = (int) temp[0] - 48;
			moreswitch(ans);
		}// end while
}

void menuclass::moreswitch(int num){
      char z[2];
      gets(z);
		switch (num){
			case 1:
				clrscr();
				splashscreen();
            sleep(3000);
            clrscr();
				break;
			case 2:
				clrscr();
				amusingone();
				sleep(3000);
				break;
			case 3:
				clrscr();
				//cout << "\t\t\t\tHail to the king baby! " << endl;
            woman();
				sleep(500);
				break;
			case 4:
				submenu = false;
				clrscr();
				break;
			default:
				cout << "invalid entry...  try again" << endl << endl;
				sleep(500);
				clrscr();
		}// end switch
}		

void menuclass::splashscreen(){
      _setcursortype(_NOCURSOR);
		clrscr();
      textbackground(LIGHTBLUE);
      textcolor(WHITE);
      gotoxy(18,3);  cprintf(" +-----------------------------------------+ ");
		gotoxy(18,4);  cprintf(" |                                         | ");
		gotoxy(18,5);  cprintf(" |          Detail Shift Program           | ");
		gotoxy(18,6);  cprintf(" |                                         | ");
		gotoxy(18,7);  cprintf(" |                                         | ");
		gotoxy(18,8);  cprintf(" |            Coded by:                    | ");
		gotoxy(18,9);  cprintf(" |               Chris Huyler              | ");
		gotoxy(18,10); cprintf(" |                    &                    | ");
		gotoxy(18,11); cprintf(" |               Tim Cross                 | ");
		gotoxy(18,12); cprintf(" |                                         | ");
		gotoxy(18,13); cprintf(" |                                         | ");
		gotoxy(18,14); cprintf(" |                                         | ");
		gotoxy(18,15); cprintf(" |                                         | ");
		gotoxy(18,16); cprintf(" |  created 4.4.00          ver: 4.20.2000 | ");
		gotoxy(18,17); cprintf(" +-----------------------------------------+ ");

      textbackground(LIGHTGRAY);
      gotoxy(63,4); cprintf(" ");
      gotoxy(63,5); cprintf(" ");
      gotoxy(63,6); cprintf(" ");
      gotoxy(63,7); cprintf(" ");
      gotoxy(63,8); cprintf(" ");
      gotoxy(63,9); cprintf(" ");
      gotoxy(63,10); cprintf(" ");
      gotoxy(63,11); cprintf(" ");
      gotoxy(63,12); cprintf(" ");
      gotoxy(63,13); cprintf(" ");
      gotoxy(63,14); cprintf(" ");
      gotoxy(63,15); cprintf(" ");
      gotoxy(63,16); cprintf(" ");
      gotoxy(63,17); cprintf(" ");
      gotoxy(20,18); cprintf("                                            ");
//       _setcursortype(_NORMALCURSOR);
       textbackground(BLACK);
       textcolor(LIGHTGRAY);
}



void menuclass::sleep(int num){
		for (int i = 0; i < num*50000; i++);
}

void menuclass::amusingone(){
		_setcursortype(_NOCURSOR);
		clrscr();
		textbackground(WHITE);
		textcolor(BLACK);

        gotoxy(30,7);  cprintf("            .----.       ");
        gotoxy(30,8);  cprintf("         _.'__    `.     ");
		  gotoxy(30,9);  cprintf("     .--(#)(##)---/#\\    ");
        gotoxy(30,10); cprintf("   .' @          /###\\   ");
        gotoxy(30,11); cprintf("   :             #####   ");
        gotoxy(30,12); cprintf("    `-..__.-' _.-\\###/   ");
        gotoxy(30,13); cprintf("          `:_:    `''    ");
		textcolor(RED);
        gotoxy(30,14); cprintf("        .''''''`.        ");
        gotoxy(30,15); cprintf("       /         \\       ");
        gotoxy(30,16); cprintf("      //         \\\\      ");
        gotoxy(30,17); cprintf("      `-._______.-'      ");
		textcolor(BLACK);
        gotoxy(30,18); cprintf("      ___'. | .'___      ");
        gotoxy(30,19); cprintf("     (______|______)     ");
      textcolor(LIGHTGRAY);
      textbackground(BLACK);

}


