PRIVATE lcoil_name,lnoil_rate,lnsrv_rate,lcjobcard_no,lnjob_rec,lcmechanic,lcsupname,lcteam, ;
	ldnext_dt,lnnxt_kms,lcsrvtype,lcsrvseq,lnTotalSpares,LcSuperName
PRIVATE currRepoBeha                	
currRepoBeha = SET("REPORTBEHAVIOR") 	

lnTotalSpares = 0.00
WAIT wind '!!! WAIT !!! Generating Report ...' nowa
STORE {  /  /  } to ldnext_dt
store ' ' to  lcoil_name,lcmechanic,lcsrvtype,lcsrvseq,LcSuperName
store 00000 to lnnxt_kms
store 0000.00 to lnoil_rate,lnsrv_rate
lcjobcard_no = job_mast.jobcard_no

lnjob_rec = recn('JOB_MAST')
IF ! EMPTY(JOB_MAST.SUPER_NO)
	IF SEEK(JOB_MAST.SUPER_NO,'MECHANIC','MECHANICNO')
		LcSuperName = mechanic.mechanic
	ENDIF
ENDIF
IF seek(job_mast.mechanicno,'MECHANIC','MECHANICNO')
	lcmechanic = mechanic.mechanic
ENDIF

CREATE CURSOR QUERY (JOBCARD_NO C(LEN(JOB_MAST.JOBCARD_NO)),ITEM C(LEN(ITEMMAST.ITEM)),;
	AMOUNT N(10,2),SR_NO C(3),QTY N(10,3),SERV_TAX N(9,2),BALANCE N(10,3),;
	location c(LEN(itemmast.location)),ITEM_NO C(LEN(ITEMMAST.ITEM_NO)) )
	
lciteminfo = ''

IF SEEK(lcjobcard_no,'requisition','JOBCARD_NO')
	SELECT requisition
	SET ORDER TO JOBCARD_NO
	SCAN REST WHILE requisition.jobcard_no = lcjobcard_no
		if SEEK(requisition.item_no,'itemmast','item_no')
			INSERT INTO QUERY ;
				(JOBCARD_NO,ITEM_NO,ITEM,AMOUNT,SR_NO,QTY,SERV_TAX,BALANCE,location) ;
			VALUES ;
				(requisition.jobcard_no,requisition.item_no,itemmast.item,requisition.amount,requisition.sr_no,requisition.qty,;
				(((requisition.LAB_RaTe*requisition.QTY)*GNSERVICETAX)/100),itemmast.balance,;
				itemmast.location)
			lciteminfo = lciteminfo + LEFT(itemmast.item,20) + STR(amount,10,2) + CHR(13)
			lnTotalSpares = lnTotalSpares + query.amount		
		ENDIF 			
	ENDSCAN 
ENDIF 

use (year_path) + 'common' in 0 agai alia common_a orde common_no
sele job_mast
set rela to jobcard_no + 'R' into common_a addi
set orde to common_no in common
set rela to jobcard_no + 'C' into common addi

*!*	SET orde to jobcard_no in requisition  
*!*	SET RELATION TO jobcard_no INTO requisition ADDITIVE
*!*	  
*!*	SELECT requisition
*!*	SET ORDER TO item_no IN itemmast
*!*	SET RELATION TO ITEM_NO INTO itemmast ADDITIVE

IF PROFSEEK(JOB_MAST.CLIENT_NO,'CLIENT','CLIENT_NO')
	if SEEK(client.modelcolno,'MODELCOL','MODELCOLNO')
		IF SEEK(MODELCOL.MODEL_NO,'MODEL','MODEL_NO')
			IF job_mast.servicetyp = 'R'		
				lnsrv_rate = MODEL.Labour_rt
			ENDIF 
		ENDIF 
	ENDIF 				
ENDIF
WAIT CLEAR 

PRIVATE lctmp_wind
lctmp_wind = SYS(2015)
DEFINE window (lctmp_wind) FROM 0,0 TO 40,100 IN SCREEN SYSTEM CLOSE TITLE 'REPORT PREVIEW' 
SELECT job_mast
SET REPORTBEHAVIOR 80
REPORT FORM WJOBMISU next 1 noconsole TO PRINTER 
SET REPORTBEHAVIOR currRepoBeha   
IF FILE('WJOBCARDBACKSIDE.FRX')
	IF RECCOUNT('query') = 0
		DO attention WITH 'No requision item is entered so job card back side can not be printed' 
	ELSE 
		IF YESNO("DO YOU WANT TO PRINT BACK SIDE OF jobcard ? ") = "YES"
			SELECT query
			SET REPORTBEHAVIOR 80
			REPORT FORM wjobcardbackside noconsole TO PRINTER   
			SET REPORTBEHAVIOR currRepoBeha   
			SELECT job_mast
		ENDIF
	ENDIF
ENDIF

*!*	SELECT requisition   &&
*!*	SET RELATION off INTO itemmast &&

sele job_mast
go (lnjob_rec)	
set rela off into common
set rela off into common_a
SET RELATION off INTO requisition &&

go (lnjob_rec) in job_mast
use in common_a
use in query
sele job_mast
go (lnjob_rec)
retu