EXTERNAL PROC onlinejobcard.scx

DO FORM "onlinejobcard.scx" NAME _1J70R2VPQ LINKED 

*- [CONVERTER] Begin CLEANUP and other procedures from 2.x Form


procedure initdata

mtr_info = ' '
mrepl_reason = ' '
llbtry = .f.
lltermin = .f.
sele job_mast
if empt(screen_mod)
	private old_dt,lcoldjobcard_no
	lcoldjobcard_no = m.jobcard_no
	old_dt = m.job_dt
	scat memv memo blank
	m.jobcard_no = lcoldjobcard_no
	m.SERVICETYP = "FREE"
	lcptr = 'RES.'	
	show get lcptr
	if empt(old_dt)
		m.job_dt = sys_date
	else
		m.job_dt = old_dt
	endif	
	mclient = ' '
	mservice_typ = ' ' 
	sele job_mast
	if mauto_flg
 		m.jobcard_no = mautocard_no
 	ELSE
 		= nextcno('JOB_MAST','ZJOBCARDNO','JOBCARD_NO',m.jobcard_no,'0',.T.)
 	ENDIF 
	IF SEEK(m.jobcard_no,'JOB_MAST','JOBCARD_NO')
		DO ERR_MSG WITH 'DUPLICATE JOBCARD NO. FOUND' + CHR(13)+ 'ENTRY REJECTED'
		RETURN
	ENDIF 
	lltermin = .T.
    if mauto_flg
		mautocard_no = m.jobcard_no
	endif
	store ' ' to m.modelcolno,m.engine_no,m.chasis_no,m.SERVICESEQ,m.vehicle_no,moil_nam,LCMODELNO
	store ' ' to m.remark,m.complain,lcmechanic,m.issue_no,mgodown,m.godown_no,lcdel_key,lcpas_flg
	store 'Y' to L1,L2,L3,L4,L5,L6,L7
	store 'N' to L8
	store 0 to lnmisu,lnestamt,lnjob_rec
	store {  /  /  } to ldsale_dt,ldnext_dt
	store 000000 to lnnxt_kms,lnstartsecond,lnendsecond
	store ' ' to lcsrvtype,lcsrvseq,lcstart_time,lcend_time
	
	m.category = 'General'
	store time() to lctime
	show get lctime
	m.battery = 'NO'
	show get m.battery

	use in tmpissue
	dele file (tmp_file)
	dele file LEFT(TMP_FILE,AT('.',TMP_FILE)) + 'fpt'
	tmp_file = tmp_file('dbf')
	use (path_nam) + 'tmpissue' in 0 
	sele tmpissue
	copy to (tmp_file)
	use in tmpissue
	use (tmp_file) alias tmpissue in 0
else	
	sele client
	scat memv fiel vehicle_no
	sele job_mast
	lnjob_rec = recn('JOB_MAST')
	scat memv
	mclient = client.client
	lcpas_flg = client.passprtflg
	show get passprtflg
	set orde to common_no in common
	if seek(m.jobcard_no + 'C','COMMON')
		m.complain = common.detail
	endif	
	if seek(m.jobcard_no + 'R','COMMON')
		m.remark = common.detail
	endif	
	m.category = j_type(m.category)
	if m.servicetyp <> client.status
		do err_beep
		do alert with '!!! ATTENTION !!!;In Client Info. Client Service Status is ' + status(client.status) + ';but in Job card Service type is ' + servetyp(m.servicetyp)
	endif
	m.servicetyp = servetyp(m.servicetyp)
	if ! empt(m.mechanicno)
		if profseek(m.mechanicno,'MECHANIC','MECHANICNO')
			lcmechanic = mechanic.mechanic
		endif
	ENDIF
	SELE TMP_COMP
	IF SEEK(m.jobcard_no,'JOB_COMP','JOBCARD_NO')
		SELECT JOB_COMP
		SET ORDER TO JOBCARD_NO
		GO TOP IN TMP_COMP
		SCAN REST WHILE JOBCARD_NO = M.JOBCARD_NO
			IF SEEK(COMPLAINNO,'COMPLAINMASTER','COMPLAINNO')
				IF COMPLAINMASTER.GROUP_FLG = "Y"
					lccomp_no = complainmaster.complainno
					IF SEEK(lccomp_no,'COMP_GROUP','COMPLAINNO')
						SELECT COMP_GROUP
						SCAN REST WHILE COMPLAINNO = lccomp_no
							REPLACE tmp_comp.complainno WITH COMP_GROUP.COMPLAINNO ;
							tmp_comp.complain WITH COMP_GROUP.complain ;
							tmp_comp.frt_time WITH COMP_GROUP.frt_time ;
							tmp_comp.priority with IIF(EMPTY(COMP_GROUP.priority),99,COMP_GROUP.priority) ;
							tmp_comp.comp_flg with "C" ;
							tmp_comp.comp_group with "Y"							
							SKIP IN tmp_comp
							SELECT COMP_GROUP
						ENDSCAN 
					ENDIF	
				ELSE		
					REPLACE tmp_comp.complainno WITH COMPLAINMASTER.COMPLAINNO ;
						tmp_comp.complain WITH COMPLAINMASTER.complain ;
						tmp_comp.frt_time WITH COMPLAINMASTER.frt_time ;
						tmp_comp.priority with IIF(EMPTY(COMP_GROUP.priority),99,COMP_GROUP.priority) ;
						TMP_COMP.COMP_FLG WITH "C" ;
						tmp_comp.comp_group with "Y"
				ENDIF 				
				SKIP IN TMP_COMP
			ENDIF				
			SELECT JOB_COMP		
		ENDSCAN
	ENDIF
ENDIF
