****************************************************************
** OTHER.PRG - menu of root-level options
** J Osako    29 Jan 1996	'This code is cursed'
** Copyright 1996 The Used Computer Store, All Rights Reserved
**
**	REVISION HISTORY
**  ----------------
**	v.1.1  
**		27 Mar 1996 - added simple employee-data
**			handler
**		26 Mar 1996 - fixed security loophole bug
**	v.1.00 	
**		20 Mar 1996 - written and completed
**
****************************************************************


*PROCEDURE main

	IF(!slaves.wheelp)		&& quickie security check
		RETURN
	ENDIF
	IF !USED('ROOTOPTS')
		USE RootOpts IN 10
	ENDIF
	SELECT RootOpts
	COPY TO ARRAY r_opt
	DEFINE WINDOW avatar FROM 1,1 TO 10,15 NONE
	MOVE WINDOW avatar CENTER
	ACTIVATE WINDOW avatar
	@0,0 GET comnd FROM r_opt;
		DEFAULT r_opt[1]
	READ
	DEACTIVATE WINDOW Avatar
	DO (ALLTRIM(comnd)) IN other	
RETURN


PROCEDURE duplicates
	ACTIVATE WINDOW Login
	@2,1 SAY 'Set default # of copies'
	@ROW()+1,1 SAY 'of receipts : '
	@ROW(), COL() GET M.dups
	READ
	DEACTIVATE WINDOW Login
RETURN
	
PROCEDURE close
	ACTIVATE WINDOW Login
	
	@1,3 SAY 'Shut down system?'
	@2,3 GET die_it FUNCTION '* OK;Cancel'; 
		DEFAULT 'Cancel' 
	READ
	DEACTIVATE WINDOW Login
	IF die_it = 'OK' 
		go_on = .F.
	ENDIF
RETURN


PROCEDURE employees
**********
** lusers() - controls data on users	

	SELECT Slaves
	DECLARE indentured[RECCOUNT()]
	M.wheelp = .F.
		
	DEFINE WINDOW abuser FROM 1,1 TO 10,60;
		DOUBLE TITLE 'Employee Data'
	MOVE WINDOW abuser CENTER
	ACTIVATE WINDOW abuser
	@2,45 GET slam;
		FUNCTION '^T Add;Disuser;Reinstate;Upgrade';
		DEFAULT 'Add'
	@6,45 GET fini FUNCTION '*V OK; Cancel';
		default 'OK'
	READ
	IF fini = 'OK'
		IF slam = 'Add'
			M.passwd = NULL
			M.hire_date = tr_date
			M.currentp = .T.
			@1,1       SAY 'First Name    ' GET M.first_name;
				DEFAULT NULL SIZE 1,20
			@ROW()+1,1 SAY 'Last Name     ' GET M.last_name;
				DEFAULT NULL SIZE 1,20
			@ROW()+1,1 SAY 'SSN :         ' GET M.ssn;
				DEFAULT NULL SIZE 1,20
				@ROW()+2,1 GET M.wheelp FUNCTION '*C Root';
				DEFAULT .F.
			@6,45 GET fini FUNCTION '*V OK; Cancel';
			DEFAULT 'OK'
			READ
			M.last_name = PROPER(M.last_name)
			M.first_name = PROPER(M.first_name)
			IF fini = 'OK'
				M.logname = LEFT(M.first_name,1) + LEFT(M.last_name,1)
				SET ORDER TO luser
				DO WHILE SEEK(M.logname)
					ACTIVATE WINDOW Login
					@1,1 SAY 'The login name ' + M.logname 
					@2,1 SAY 'is already used. Please'
					@3,1 SAY 'enter another :' 
					@4,1 GET M.logname SIZE 1,15
					READ
					M.logname = UPPER(M.logname)
					DEACTIVATE WINDOW Login
				ENDDO
				INSERT INTO Slaves FROM MEMVAR	
			ENDIF
		ELSE
			SET ORDER TO (IIF(slam = 'Reinstate', 'canned', 'stuck')) 
			GOTO TOP
			i = 0
			SCAN FOR IIF(slam = 'Reinstate', !currentp, currentp)
				i = i+1
				indentured[i] = (ALLTRIM(last_name) +', '+ ALLTRIM(first_name))	
			ENDSCAN
			@0,0 GET dorx FROM indentured;
				DEFAULT indentured[1] SIZE 8,32
			@6,20 GET fini FUNCTION '*V OK; Cancel';
				DEFAULT 'OK' 
			READ VALID (SEEK(dorx)) OR fini = 'Cancel'
			IF fini = 'OK'
				IF  slam = 'Upgrade'
					M.wheelp = .T.
					GATHER MEMVAR FIELD wheelp
				ELSE
					M.currentp = !currentp
					GATHER MEMVAR FIELD currentp
					M.currentp = .T.
				ENDIF
			ENDIF
		ENDIF
	ENDIF
	DEACTIVATE WINDOW Abuser
RETURN