do set_menu
PRIVATE lctype
=get_pdt("RTO/INSURANCE PAYMENT REGISTER")
lctype = 'RTO'
DEFINE WINDOW lwbr FROM 0,0 TO 10,80 &gcrepo_clr
ACTIVATE WINDOW lwbr
MOVE WINDOW lwbr cent

@ 3,3 say 'Selection : ' 
KEYBOARD '{alt+dnarrow}' 
@ 3,25 get lctype pict '@^ RTO;INSURANCE'
READ
RELEASE WINDOWS lwbr 



wait wind "!!! WAIT !!! Gathering Report ...;" nowa
IF lctype = 'RTO'
	sele rtoinsurance.doc_no,rtoinsurance.tran_dt,;
	    client.client,rtoinsbody.rto_to_pay,rtoinsbody.rto_cust,;
	    rtoinsurance.paid_amt,client.chasis_no;
		from rtoinsurance,rtoinsbody,client ;
		where rtoinsurance.doc_no = rtoinsbody.doc_no ;
		and client.client_no = rtoinsbody.client_no ;
		and betw(rtoinsurance.tran_dt,date1,date2) ;
		AND RTOINSURANCE.DOC_NO = 'RTO' ;
		into cursor query
ELSE
	sele rtoinsurance.doc_no,rtoinsurance.tran_dt,;
	    client.client,rtoinsbody.ins_to_pay,rtoinsbody.insurance,;
	    rtoinsurance.paid_amt,client.chasis_no;
		from rtoinsurance,rtoinsbody,client ;
		where rtoinsurance.doc_no = rtoinsbody.doc_no ;
		and client.client_no = rtoinsbody.client_no ;
		and betw(rtoinsurance.tran_dt,date1,date2) ;
		AND RTOINSURANCE.DOC_NO = 'INS' ;
		into cursor query

ENDIF		
if _tally > 0
	do prinrepo with 'WRTOPAY','RTOPAY','','',''
else
	deac wind wait
	do alert with "No Data Found for given Condition"	
endif
use in query	
do cls_menu
	