;==File=================================================================;
; POIORDR.DBL
;=======================================================================;
; Copyright 1999 by TAH Software Systems (TAH), Oklahoma City, Oklahoma ;
;									;
;	TAH provides this software under a license and may only be	;
;	used in accordance with the terms and conditions of such	;
;	license and with the inclusion of the above Copyright notice.	;
;==Function=============================================================;
;	po_inq_order	Purchase order status search routine.
;	poll_poordr	Load List with order header information
;==Changes==============================================================;
; 07/14/1998 TAH - Modify list processing for Synergy V6
;=======================================================================;
.subroutine po_inq_order

	a_key		,a	; IN  - Key value for begin of search
	a_keyno		,n	; IN  - Key number for search
	a_selected	,n	; OUT - True if a valid record selected
				;	False if no record selected

.start nopage,nolist
.include "WND:tools.def"
.include "WND:system.def"
.include "WND:inpctl.def"
.include "UTS:dteut.def"
.include "POS:dtepo.def"

.include "UTS:utcomm.gbl"
.include "POS:pocomm.gbl"
.include "POS:pohedr.rec"

global data section list_pohedr, init
record	sel_line			; selection window item
	sel_order	,a6			; order number
	sel_name	,a30			; vendor name
	sel_odate	,a8			; order date
	sel_sdate	,a8			; received date
	sel_flag1	,a1			; flag 1
	sel_flag2	,a1			; flag 2
	sel_flag3	,a1			; flag 3
	sel_flag4	,a1			; flag 4
	sel_flag5	,a1			; status
endglobal

.align
record
	colid		,i4		; column id
	fndid		,i4		; find id
	inpid		,i4		; input column id
	selid		,i4		; selection column id
	req		,i4
	srch		,i4		; search parameter
	apos		,d2		; length of key to start
	field_no	,d3		; field number from i_fldinf
	lfind		,a*,	'i_lxxxxxx'
	  lfind_file	,a6	@lfind+3
	lclass		,a*,	'l_xxxxxx'
	  lclass_file	,a6	@lclass+2
	wind_header	,a160		; window header from script
	  wind_hleft	,a80	@wind_header
	  wind_hright	,a80	@wind_header+80
	wrk_rfa		,d6
.start nopage,list

.proc
	lfind_file = 'poordr'
	lclass_file = lfind_file
	if (a_key.eq.ut_blanks) xreturn		; return if no key value

.include "UTS:utfind.inc"

	if (g_entnam.eq.'O_EXIT')
	 then a_selected = FALSE
	 else a_selected = TRUE
	xcall e_exit
	xreturn

find_first_match,
	apos = %trim(a_key)
	xcall db_find (pohedr_chan,a_key(1:apos),a_keyno,'M',,,opcde)
	case opcde of
	  begincase
	  1: clear opcde
	  2: xcall message (DTER_LOK)
	  endcase
	return

utfind_find,
	return
.end
;=======================================================================;
.subroutine poll_poordr

	a_listid	,n	; IN  - ID for list
	a_request	,n	; IN  - List request code
	a_data		,a	; I/O - Data record area
	a_inpid		,n	; IN  - Input window ID
	a_disabled	,n	; IN  - True/False to disable list item
	a_index		,n	; IN  - List item index

.start nopage,nolist
.include "POS:pocomm.gbl"
.include "UTS:utcomm.gbl"

.include "POS:pohedr.rec"

global data section list_pohedr
record	sel_line			; selection window item
	sel_order	,a6			; order number
	sel_name	,a30			; vendor name
	sel_odate	,a8			; order date
	sel_sdate	,a8			; received date
	sel_flag1	,a1			; flag 1
	sel_flag2	,a1			; flag 2
	sel_flag3	,a1			; flag 3
	sel_flag4	,a1			; flag 4
	sel_flag5	,a1			; status
endglobal

record
	ndx		,d2		; loop control
	wrk_rfa		,d6
.start nopage,list

.proc
	xcall db_next (pohedr_chan,pohedr,'F','M',,,opcde)
	unlock pohedr_chan
	case opcde of
	  begincase
	  1: a_request = D_LEOF
	  2: a_request = D_LEOF
	  endcase
	 else
	  if (pom_comp.eq.ut_cmcomp) then
	    begin
	      sel_order = pom_order, 'XXXXXX'
	      sel_name = pom_name
	      sel_odate = pom_orddate
	      sel_sdate = pom_reqdate
	      sel_flag1 = pom_flag1
	      sel_flag2 = pom_flag2
	      sel_flag3 = pom_flag3
	      sel_flag4 = pom_flag4
	      clear sel_flag5
	      if (pom_status.eq.'C') sel_flag5 = 'Y'
	      xcall i_display (a_inpid,'set1',sel_line)
	    end
	   else a_request = D_LEOF
	return
.end
;=======================================================================;

