* PO.CMD
* MICHAEL LYNN  8/23/83
ERASE
RESTORE FROM B:POMEM
@ 2, 15 SAY 'PURCHASE ORDER ENTRY'
@ 3, 15 SAY '********************'
@ 5, 1  SAY 'CURRENT PO NUMBER:' GET mponum PICTURE '9999'
@ 6, 1  SAY 'ENTER VENDOR NUMBER' GET mvendor PICTURE '99'
READ
SELECT SECONDARY
ERASE
	DO WHILE z<21
        @ 22, 1 SAY "ENTER A T TO END ITEM ENTRY"
	STORE '          ' TO snum
	STORE 00 TO mquan
   
		IF z=20
		@ 20, 1 SAY '***THIS IS THE LAST ITEM WHICH CAN BE ENTERED***'
		ENDIF

		IF z>9
		STORE '2' TO e
		ELSE 
		STORE '1' TO e
		ENDIF

	STORE STR(z,&e) TO a
	STORE '@ '+STR(z,2)+',' TO b

	&b 1 SAY 'CATALOGUE NUMBER AND QUANTITY OF ITEM &a';
		GET snum PICTURE '!!!!!!!!!!' 
	&b 53 GET mquan PICTURE '99'	
	READ
	FIND &snum
		IF # <> 0
			IF vendor # mvendor .and. snum # 'T'
			@ 21, 1 SAY "ITEM IS NOT FROM THIS VENDOR - ENTER;
 ANYWAY (Y/N)"
			SET CONSOLE OFF
			WAIT TO ahead
			SET CONSOLE ON
			   IF !(ahead) ='N'
			   @ 21, 1
			   LOOP
			   ENDIF
			@ 21, 1
			RELE ahead
			ENDIF	 
		STORE STR(mquan,2) TO quan
		REPLACE S.ordered WITH mquan
		STORE quan+'  == '+S.catnum+' '+S.descr TO mitem&a
		REPLACE S.podate WITH date()
		REPLACE S.ponum WITH mponum
		ELSE
			IF snum ='T'
			STORE 22 TO z
			ELSE
			@ 21, 1 SAY 'NOT IN DATABASE - RE-ENTER'	
			SET CONSOLE OFF
			WAIT
			SET CONSOLE ON
			@ 21, 0
			LOOP
			ENDIF
		ENDIF
	STORE z+1 TO z
	ENDDO

SELECT PRIMARY
APPEND BLANK
REPLACE P.ponum WITH mponum
REPLACE P.vendor WITH mvendor
REPLACE P.date WITH date()
REPLACE recv WITH F
REPLACE paid WITH F
REPLACE item1 WITH mitem1    
REPLACE item2 WITH mitem2
REPLACE item3 WITH mitem3
REPLACE item4 WITH mitem4
REPLACE item5 WITH mitem5
REPLACE item6 WITH mitem6
REPLACE item7 WITH mitem7
REPLACE item8 WITH mitem8
REPLACE item9 WITH mitem9
REPLACE item10 WITH mitem10
REPLACE item11 WITH mitem11 
REPLACE item12 WITH mitem12
REPLACE item13 WITH mitem13
REPLACE item14 WITH mitem14
REPLACE item15 WITH mitem15
REPLACE item16 WITH mitem16
REPLACE item17 WITH mitem17
REPLACE item18 WITH mitem18
REPLACE item19 WITH mitem19
REPLACE item20 WITH mitem20

ERASE
@ 3, 1 SAY "PRINT PURCHASE ORDER NOW? (Y/N)"
SET CONSOLE OFF
WAIT TO print
SET CONSOLE ON
STORE !(print) TO print
STORE 1 TO mpage
STORE 1 TO cpage

IF print ='Y'
@ 5, 1 SAY "ENTER NUMBER OF COPIES TO PRINT" GET mpage PICTURE '9'
READ
SET PRINT ON
SET EJECT OFF
SET FORMAT TO PRINT
SET MARGIN TO 8
ENDIF

DO WHILE cpage <= mpage
@  2,25 SAY "**************"
@  3,25 SAY "PURCHASE ORDER"
@  4,25 SAY "**************"
@  6,21 SAY "EARLY MUSIC FACSIMILES"
@  7,23 SAY "***Michael Lynn***"
@  8,25 SAY "P.O. Box  1813"
@  9,23 SAY "Ann Arbor, Michigan"
@ 10,25 SAY "48106    U.S.A."
@ 11,26 SAY "313-484-4297"
@ 13, 0 SAY "Fed. Id. 38-2209695"
@ 14, 0 SAY "PURCHASE ORDER NUMBER:"
@ 14,22 SAY ponum
@ 15, 0 SAY "DATE:"
@ 15, 6 SAY date
@ 17, 0 SAY "TO:"

SELECT SECONDARY
USE B:VENDOR
LOCATE FOR vendor=P.vendor

IF address2 <> ' '
@ 18, 0 SAY company
@ 19, 0 SAY TRIM(first)+' '+last
@ 20, 0 SAY address1
@ 21, 0 SAY address2
@ 22, 0 SAY TRIM(city)+', '+state+' '+zipcode
@ 23, 0 SAY country
ELSE
@ 18, 0 SAY company
@ 19, 0 SAY TRIM(first)+' '+last
@ 20, 0 SAY address1
@ 21, 0 SAY TRIM(city)+', '+state+' '+zipcode
@ 22, 0 SAY country
ENDIF

IF account <> ' '
@ 25, 0 SAY "ACCOUNT NUMBER:"
@ 25,15 SAY account
ENDIF

SELECT PRIMARY
@ 27, 0 SAY "QUANTITY  CATALOGUE       DESCRIPTION"

STORE 1 TO z
DO WHILE z<21

IF z>9
STORE '2' TO e
ELSE
STORE '1' TO e
ENDIF

STORE STR(z,&e) TO a
STORE '@ '+STR(27+z,2)+',' TO b	
IF mitem&a # '  '
&b 3 SAY mitem&a
ENDIF

STORE z+1 TO z
ENDDO


@ 49,17 SAY "PLEASE SHIP AS SOON AS POSSIBLE"
@ 51, 0 SAY "IF MAILING BY U.P.S. PLEASE SEND TO:"
@ 53,26 SAY "MICHAEL LYNN"
@ 54,24 SAY "221 S. Washington"
@ 55,25 SAY "Ypsilanti, MI."
@ 56,30 SAY "48197"
EJECT
STORE 1 + cpage TO cpage
ENDIF
ENDDO
SET FORMAT TO SCREEN
SET PRINT OFF
RELEASE cpage, mpage 

STORE mponum+1 TO mponum
STORE '          'to snum
STORE 1 to z
STORE F to mpaid
STORE 00 to mdisc
STORE 00 TO mvendor
STORE '                                      ' TO mitem1
STORE '                                      ' TO mitem2                
STORE '                                      ' TO mitem3               
STORE '                                      ' TO mitem4               
STORE '                                      ' TO mitem5               
STORE '                                      ' TO mitem6               
STORE '                                      ' TO mitem7               
STORE '                                      ' TO mitem8               
STORE '                                      ' TO mitem9               
STORE '                                      ' TO mitem10              
STORE '                                      ' TO mitem11              
STORE '                                      ' TO mitem12              
STORE '                                      ' TO mitem13              
STORE '                                      ' TO mitem14              
STORE '                                      ' TO mitem15              
STORE '                                      ' TO mitem16              
STORE '                                      ' TO mitem17              
STORE '                                      ' TO mitem18              
STORE '                                      ' TO mitem19              
STORE '                                      ' TO mitem20              
SAVE TO B:POMEM
ERASE
RETURN
