//==========================================================
//WINDOW 2 -  GENERAL LEDGER MENU
//=========================================================

//----------------------------------------------------------
//Window Addresse's
//----------------------------------------------------------
Fl_Double_Window*								men2;	
	Fl_Box*												men2_decoration;
		Fl_Output*									men2_title;
		Fl_Radio_Round_Button*			men2_but1;
		Fl_Radio_Round_Button*			men2_but2;
		Fl_Radio_Round_Button*			men2_but3;
		Fl_Radio_Round_Button*			men2_but4;
		Fl_Radio_Round_Button*			men2_but5;
		Fl_Radio_Round_Button*			men2_but6;
		Fl_Button*									men2_exit;

//----------------------------------------------------------
//Callbacks
//----------------------------------------------------------
void fmen2_but1_callback(Fl_Widget* w, void* data);
void fmen2_but2_callback(Fl_Widget* w, void* data);
void fmen2_but3_callback(Fl_Widget* w, void* data);
void fmen2_but4_callback(Fl_Widget* w, void* data);

//----------------------------------------------------------
//WINDOW Menu2
//----------------------------------------------------------
void window2(){

 	men2 = new Fl_Double_Window(40,80,300,250,"General Ledger");

		x=20; y=20; 

			men2_decoration = new Fl_Box(x, y, 260, 210);
				men2_decoration->box(FL_ENGRAVED_BOX);
				men2_decoration->color(0xE1E1E100);

			men2_title = new Fl_Output(x+5,y-10,100,20);
				men2_title->box(FL_FLAT_BOX);
				men2_title->color(0xE1E1E100);
				men2_title->value("General Ledger");

			men2_but1 = new Fl_Radio_Round_Button(x+15, y+1*20, 70, 15, "Chart Of Accounts");
				men2_but1->down_box(FL_ROUND_DOWN_BOX);
				men2_but1->callback(fmen2_but1_callback);
			men2_but2 = new Fl_Radio_Round_Button(x+15, y+2*20, 70, 15, "General Journal");
				men2_but2->down_box(FL_ROUND_DOWN_BOX);
				men2_but2->callback(fmen2_but2_callback,NULL);
			men2_but3 = new Fl_Radio_Round_Button(x+15, y+3*20, 70, 15, "Account Enquiry");
				men2_but3->down_box(FL_ROUND_DOWN_BOX);
				men2_but3->callback(fmen2_but3_callback);
			men2_but4 = new Fl_Radio_Round_Button(x+15, y+4*20, 70, 15, "Reports");	
				men2_but4->down_box(FL_ROUND_DOWN_BOX);
				men2_but4->callback(fmen2_but4_callback);
				
			men2_but5 = new Fl_Radio_Round_Button(x+15, y+5*20, 70, 15, "Generate Depreciation");
				men2_but5->down_box(FL_ROUND_DOWN_BOX);
			men2_but6 = new Fl_Radio_Round_Button(x+15, y+7*20, 70, 15, "End Of Year");	
				men2_but6->down_box(FL_ROUND_DOWN_BOX);

			lButton(men2_exit,x+90,y+175,"Exit",_windowExit_callback);

	men2->end();

	men2->callback(_windowExit_callback);
	men2->set_modal();

}

//----------------------------------------------------------
//	Window 2 button 1 callback -> ChartOfAccount
//----------------------------------------------------------
void fmen2_but1_callback(Fl_Widget* w, void* data){

		men2_but1->clear();

		if (A01_ParameterNo==3)
		{
			win4p_coa_StartAcctNo->value(1);
			win4p_coa_EndAcctNo->value(99999);
			fromWindowNo=2; windowNo=4; win4p_coa->show();
			return;
		}

	//-----------------------
	//Grab the transactions
	//-----------------------
		WIN4_COA_ACCOUNTS();

	//---------------
	//Open the window
	//---------------
		win4_coa_key->activate();
		win4_coa_details->deactivate();
		win4_coa_list->activate();

		fromWindowNo=2; windowNo=4; win4_coa->show();

}

//----------------------------------------------------------
//	Window 2 button 2 callback -> General Journal
//----------------------------------------------------------
void fmen2_but2_callback(Fl_Widget* w, void* data){

		men2_but2->clear();

	//-----------------------
	//Grab the transactions
	//-----------------------
		WIN5_GJ_TRANS();

	//-----------------------
	//Grab todays date
	//-----------------------
		L1_CALL(c_B99,c_B99_GetDate,0,0,0);
		str="";for (j=0; j<4; j++) {str = str + w_Date[j]; win5_gj_key_ccyy->value(str.c_str());}
		str="";for (j=5; j<7; j++) {str = str + w_Date[j]; win5_gj_key_mm->value(str.c_str());}
		str="";for (j=8; j<10;j++) {str = str + w_Date[j]; win5_gj_key_dd->value(str.c_str());}

	//---------------
	//Open the window
	//---------------
		win5_gj_key->activate();
			win5_gj_key_time->deactivate();

		win5_gj_details->deactivate();
		win5_gj_list->activate();

		win5_gj->resize(60,120,625,595); 
		win5_gj->redraw();

		fromWindowNo=2; windowNo=5; win5_gj->show();

}

//----------------------------------------------------------
//	Window 2 button 3 callback -> Account Enquiry
//----------------------------------------------------------
void fmen2_but3_callback(Fl_Widget* w, void* data){

		men2_but3->clear();
		win6_enq_key_acctno->value(0);
		win6_enq_browser->clear();

	//-------------------------------
	//Cannot serach when Consolidated
	//-------------------------------
		if (A01_ParameterNo==3)
		{
				win6_enq_key_spinner_up->hide();
				win6_enq_key_spinner_down->hide();
				win6_enq_key_search->hide();
		}
		else
		{
				win6_enq_key_spinner_up->show();
				win6_enq_key_spinner_down->show();
				win6_enq_key_search->show();
		}

	//-----------------------
	//Grab todays date
	//-----------------------
		win6_enq_key_start_dd->value("01");
		win6_enq_key_start_mm->value("07");
		win6_enq_key_start_ccyy->value("1970");

		L1_CALL(c_B99,c_B99_GetDate,0,0,0);
		str="";for (j=8; j<10;j++) {str = str + w_Date[j]; win6_enq_key_end_dd->value(str.c_str());}
		str="";for (j=5; j<7; j++) {str = str + w_Date[j]; win6_enq_key_end_mm->value(str.c_str());}
		str="";for (j=0; j<4; j++) {str = str + w_Date[j]; win6_enq_key_end_ccyy->value(str.c_str());}

	//---------------
	//Open the window
	//---------------
		win6_enq_key->activate();
		win6_enq_list->activate();
		fromWindowNo=2; windowNo=6; win6_enq->show();

}

//----------------------------------------------------------
//	Window 2 button 4 callback -> Reports
//----------------------------------------------------------
void fmen2_but4_callback(Fl_Widget* w, void* data){

		men2_but4->clear();

	//-----------------------
	//Grab todays date
	//-----------------------
		L1_CALL(c_B99,c_B99_GetDate,0,0,0);
		str="";for (j=0; j<4; j++) {str = str + w_Date[j]; win7p_rep_ccyy->value(str.c_str());}
		str="";for (j=5; j<7; j++) {str = str + w_Date[j]; win7p_rep_mm->value(str.c_str());}
		str="";for (j=8; j<10;j++) {str = str + w_Date[j]; win7p_rep_dd->value(str.c_str());}

	//---------------
	//Open the window
	//---------------
		fromWindowNo=2; windowNo=7; win7p_rep->show();

}

