function get_igrp

parameter mitem_no,mitem,mbalance,mrate,mitemtype,sele_criteria


private malias,lcbarcodeflg
lcbarcodeflg = 'N'
malias = alia()
if empt(mitem_no)
	mitem = ''
	retu 
ENDIF 	
sele itemmast
set orde to item_no
mitem_no = padr(alltrim(mitem_no),len(item_no))
*CLEAR TYPEAHEAD

IF ! EMPTY(gcItemSeperator)
	if ALLTRIM(gcItemSeperator) $ mitem_no 
		mitem_no = LEFT(ALLTRIM(mitem_no),AT(gcItemSeperator,mitem_no) - 1)
		mitem_no = padr(alltrim(mitem_no),len(item_no))
		lcbarcodeflg = 'Y'
	ENDIF 
ENDIF 
if seek(mitem_no)
	if  (! itemtype $ sele_criteria) and ! empt(sele_criteria)
		do err_beep
		do err_beep
		do alert with '!!! ATTENTION !!!;Item type of given Item No. is not a valid Item Type'
	else	
		mitem = itemmast.item
		mitem_no = itemmast.item_no
		mbalance = itemmast.balance
		mrate = itemmast.salerate
		mitemtype = itemmast.ITEMTYPE
		sele (malias)
		IF lcbarcodeflg = 'Y'
			REPLACE qty WITH 0
		ENDIF 
		retu
	endif	
else
	if ! seek(allt(mitem_no))
		do beep with 'Item Not Found !!! Press Ctrl+A to add new one',1
	endif	
endif
sele_rec = .f.
do while not sele_rec
	private lcon_enter,lctrl_m
	lcon_enter = on('KEY','ENTER')
	lctrl_m = ON('KEY','CTRL+M')
	if ! empt(sele_criteria)
		on key labe enter do sele_rec
		ON KEY LABEL CTRL+M MESSAGEBOX("Pressed key has no meaning here ..","AUTOSOFT",0+64)
		brow fiel itemmast.item_no :r :h='Item No',itemmast.item :25 :r, ;
			itemmast.balance :h= 'Stock' :r,itemmast.in_qty :h= 'IN QTY.', ;
			itemmast.out_qty :H='OUT QTY.',itemmast.unit :r,itemmast.salerate, ;
			itemmast.labour_rt :h='Lab Rt';
			wind itembr &gcview_clr ;
			noap node  ;
			title 'Ctrl+A Add | Ctrl+S Search | Ctrl+F10 Zoom | Enter to Select Item' ;
			rest ;
			for itemtype $ sele_criteria
		on key labe enter &lcon_enter			
		ON KEY LABEL ctrl+m &lctrl_m
	ELSE
		on key labe enter do sele_rec	
		ON KEY LABEL CTRL+M MESSAGEBOX("Pressed key has no meaning here ..","AUTOSOFT",0+64)
		brow fiel itemmast.item_no :r :h='Item No',itemmast.item :30 :r, ;
			itemmast.balance :h= 'Stock' :r,itemmast.in_qty :h= 'IN QTY.', ;
			itemmast.out_qty :H='OUT QTY.',itemmast.unit :r,itemmast.salerate ;
			wind itembr &gcview_clr  ;
			noap node  ;
			title 'Ctrl+A Add | Ctrl+S Search | Ctrl+F10 Zoom | Enter to Select Item' ;
			rest 
		on key labe enter &lcon_enter
		ON KEY LABEL ctrl+m &lctrl_m
	endif			
	if sele_rec
		mitem = itemmast.item
		mitem_no = itemmast.item_no
		mbalance = itemmast.balance
		mrate = itemmast.salerate
		mitemtype = itemmast.ITEMTYPE
		sele (malias)
	else
		private resp
		resp = 1
		do alert with "It is must to select Item;But You haven't selected any item;What Should I Do ?",1,'\<Try again;\<Cancel',resp
		if resp = 2
			do err_beep
			do err_beep
			sele_rec = .T.
		endif			
	endif
enddo
sele (malias)
retu