10	! ACXTAB.BAS,BA8
	! PROGRAM TO PRINT CROSS TABULATIONS FOR PROGRAMMER
	! TIME ACCOUNTING INFO. THIS PROGRAM ASSUMES EXISTENCE
	! OF VIRTUAL ARRAY CREATED BY PROGMON FOR THE MONTH
	! IN QUESTION.
100 DEF FNSU(PJ,DA,PG)=(PJ*32+DA)*11+PG
150 DIM M$[3](12),M&(12)
160 DIM PD(31,10),UD(31,60),UP(60,10)
200 DIM #16,PR%(21472)
210	PJ=50		! DEFINE NUMBER OF PROJECTS
	LM=5		! DEFINE LEFT MARGIN
	P1=2 : P2=6	! DEFINE LOWER, UPPER BOUNDS ON PROGRAMMER NUMBERS
430	M$(1)="JAN" : M&(1)=31 :
	M$(2)="FEB" : M&(2)=29 :
	M$(3)="MAR" : M&(3)=31 :
	M$(4)="APR" : M&(4)=30 :
	M$(5)="MAY" : M&(5)=31 :
	M$(6)="JUN" : M&(6)=30 :
	M$(7)="JUL" : M&(7)=31 :
	M$(8)="AUG" : M&(8)=31 :
	M$(9)="SEP" : M&(9)=30 :
	M$(10)="OCT" : M&(10)=31 :
	M$(11)="NOV" : M&(11)=30 :
	M$(12)="DEC" : M&(12)=31	! NAMES OF MONTHS, DAYS IN MONTH
600	 ! ASK USER FOR MONTH OF BILLING STATEMENT
610 INPUT "MONTH OF BILLING (MMYY) "; M
620 M&=INT(M/100) : IF M&<1 OR M&>12 THEN  PRINT "BAD MONTH" : GOTO 610
630 Y&=M-(M&*100) ! YEAR OF BILL
635 IF 4*INT(Y&/4)<>Y& THEN M&(2)=28	! CORRECT FOR NON LEAP YEAR
640 IF M&>6	 THEN FY&=Y&+1
		 ELSE FY&=Y&		! FISCAL YEAR IS JULY-JUNE
650 D1=DCEN(STR$(M&)+"/01/"+STR$(Y&))		! FIRST DAY OF MONTH
	D2=D1 + M&(M&)-1			! LAST  DAY OF MONTH
700 OPEN #16,M$(M&)+STR$(Y&)+".VPG/RO/BL"
710 OPEN #3,M$(M&)+STR$(Y&)+".PGA/WR/LN:132"
1000 ! ZERO ARRAYS
1010 FOR J=0 TO 31 : FOR K=0 TO 10 : PD(J,K)=0 : NEXT K,J
1020 FOR J=0 TO 31 : FOR I=0 TO 60 : UD(J,I)=0 : NEXT I,J
1030 FOR I=0 TO 60 : FOR K=0 TO 10 : UP(I,K)=0 : NEXT K,I
1100 ! ACCUMULATE TOTALS
1110 FOR I=1 TO PJ
1120 FOR J=1 TO M&(M&)
1130 FOR K=P1 TO P2
1140 HR=PR%(FNSU(I,J,K))/100
1150 IF HR <> 0 THEN
	PD(J,K)=PD(J,K)+HR : PD(0,K)=PD(0,K)+HR : PD(J,0)=PD(J,0)+HR : PD=PD+HR:
	UD(J,I)=UD(J,I)+HR : UD(0,I)=UD(0,I)+HR : UD(J,0)=UD(J,0)+HR : UD=UD+HR:
	UP(I,K)=UP(I,K)+HR : UP(0,K)=UP(0,K)+HR : UP(I,0)=UP(I,0)+HR : UP=UP+HR
1190 NEXT K,J,I
1300 ! PRINT PROGRAMMER VS. DAY OF MONTH
1310 P=0 : GOSUB 3000
1320 PRINT #3,TAB(LM);"PROGRAMMER ->"
1330 PRINT #3,TAB(LM);"DAY OF MON";TAB(15);
1340 FOR K=P1 TO P2 : PRINT #3,FRMT$(K,7); : NEXT K
1350 PRINT #3,"  TOTAL"
1360 FOR J=1 TO M&(M&)
1370 PRINT #3,FRMT$(J,LM+3);TAB(15);
1380 FOR K=P1 TO P2 : PRINT #3,FRMT$(PD(J,K),7,2); : NEXT K
1390 PRINT #3,FRMT$(PD(J,0),7,2)
1400 NEXT J
1410 PRINT #3,TAB(15); : FOR K=P1 TO P2+1 : PRINT #3,"  -----"; : NEXT K : PRINT #3
1420 PRINT #3,TAB(15); 
1430 FOR K=P1 TO P2 : PRINT #3,FRMT$(PD(0,K),7,2); : NEXT K:
	PRINT #3,FRMT$(PD,7,2)
1500 ! PRINT PROJECT (USER) VS. DAY OF MONTH
1540 I1=1 : I2=10 : IT=0 : GOSUB 1600
1545 I1=11: I2=20 : IT=0 : GOSUB 1600
1550 I1=21: I2=30 : IT=0 : GOSUB 1600
1560 I1=31: I2=40 : IT=0 : GOSUB 1600
1570 I1=41: I2=50 : IT=0 : GOSUB 1600
1580 I1=51: I2=PJ : IT=1 : GOSUB 1600
1590 GOTO 1800
1600 GOSUB 3000 : PRINT #3,TAB(LM);"PROJECT ->"
1620 PRINT #3,TAB(LM);"DAY OF MON";TAB(15); : IF I2<I1 THEN 1640
1630 FOR I=I1 TO I2 : PRINT #3,FRMT$(I,6); : NEXT I
1640 IF IT=1 THEN PRINT #3," TOTAL" ELSE PRINT #3
1650 FOR J=1 TO M&(M&)
1660 PRINT #3,FRMT$(J,LM+3);TAB(15); : IF I2<I1 THEN 1680
1670 FOR I=I1 TO I2 : PRINT #3,FRMT$(UD(J,I),6,2); : NEXT I
1680 IF IT=1 THEN PRINT #3,FRMT$(UD(J,0),6,2) ELSE PRINT #3
1690 NEXT J
1700 PRINT #3,TAB(15); : IF I2<I1 THEN 1720
1710 FOR I=I1 TO I2 : PRINT #3," -----"; : NEXT I
1720 IF IT=1 THEN PRINT #3," -----" ELSE PRINT #3
1730 PRINT #3,TAB(LM);"TOTAL";TAB(15); : IF I2<I1 THEN 1750
1740 FOR I=I1 TO I2 : PRINT #3,FRMT$(UD(0,I),6,2); : NEXT I
1750 IF IT=1 THEN PRINT #3,FRMT$(UD,6,2) ELSE PRINT #3
1760 RETURN
1800 ! PRINT PROGRAMMER VS. PROJECT
1810 GOSUB 3000 : PRINT #3,TAB(LM);"PROGRAMMER ->"
1820 PRINT #3,TAB(LM);"PROJECT";TAB(15);
1830 FOR K=P1 TO P2 : PRINT #3,FRMT$(K,7); : NEXT K
1840 PRINT #3,"  TOTAL"
1850 FOR I=1 TO PJ
1860 PRINT #3,FRMT$(I,LM+3);TAB(15);
1870 FOR K=P1 TO P2 : PRINT #3,FRMT$(UP(I,K),7,2); : NEXT K
1880 PRINT #3,FRMT$(UP(I,0),7,2)
1890 NEXT I
1900 PRINT #3,TAB(15); : FOR K=P1 TO P2+1 : PRINT #3,"  -----"; : NEXT K : PRINT #3
1910 PRINT #3,TAB(LM);"TOTAL";TAB(15); : FOR K=P1 TO P2 : PRINT #3,FRMT$(UP(0,K),7,2);:
	NEXT K
1920 PRINT #3,FRMT$(UP,7,2)
2000 CLOSE : EXIT
3000 ! PRINT PAGE HEADER
3010 P=P+1 : PRINT #3,CHR$(12) : PRINT #3
3020 PRINT #3,TAB(LM);"BIOMEDICAL COMPUTER SECTION";
	TAB(78);M$(M&)+"-"+STR$(Y&)
3030 PRINT #3,TAB(LM);"MEDICAL PHYSICS DEPARTMENT";TAB(77);"PAGE "+FRMT$(P,2) :
	PRINT #3,TAB(38);"PROGRAMMER ACTIVITY SUMMARY":
	PRINT #3
3040 RETURN
