  ,#                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 VERSION =   3.00      dataenvironment      dataenvironment      Dataenvironment      mLeft = 1
Top = 220
Width = 520
Height = 200
InitialSelectedAlias = "inv_head"
Name = "Dataenvironment"
      cursor      cursor      Cursor1      Dataenvironment      Left = 10
Top = 20
Width = 90
Height = 90
Alias = "inv_head"
Order = "h_bname"
Database = ..\data\trackerdb.dbc
CursorSource = "inv_head"
Name = "Cursor1"
      cursor      cursor      Cursor2      Dataenvironment      Left = 150
Top = 20
Width = 90
Height = 90
Alias = "inv_data"
Database = ..\data\trackerdb.dbc
CursorSource = "inv_data"
Name = "Cursor2"
      relation      relation      	Relation1      Dataenvironment      ParentAlias = "inv_head"
RelationalExpr = "h_invnum"
ChildAlias = "inv_data"
ChildOrder = "d_invnum"
OneToMany = .T.
Name = "Relation1"
      cursor      cursor      Cursor3      Dataenvironment      Left = 290
Top = 20
Width = 95
Height = 90
Alias = "company"
Database = ..\data\trackerdb.dbc
CursorSource = "company"
Name = "Cursor3"
      5      1      t_form      ..\libs\t_base.vcx      form      frmPrintInvoice     zDataSession = 1
Height = 195
Width = 248
DoCreate = .T.
BufferMode = 0
AutoCenter = .T.
BorderStyle = 2
Caption = "Print Invoice"
ControlBox = .F.
Closable = .F.
MaxButton = .F.
MinButton = .F.
WindowType = 1
AlwaysOnTop = .F.
cprintwhat = All Invoices
cprintwhere = Printer
crpt_form = BTInvoice1.frx
cprintrecord = 
cwhatreport = 
Name = "frmPrintInvoice"
     
PROCEDURE doprintinvoice
#DEFINE c_browlist		'h_sname		:40 :H="Ship Name",;
	h_scity	:20	:H="City"'

DO CASE
	CASE ThisForm.opgPrintWhat.Value = 	'All Invoices'
		SET ORDER TO inv_key
		thisform.cPrintRecord = 'All'
		thisform.printrec
	
	CASE ThisForm.opgPrintWhat.Value = 'Starting Invoice'
		SET ORDER TO h_sname
		recnum = m_browse('',c_browlist, '', 'recno()')
		IF NOT EMPTY(recnum)
			GOTO recnum
			tstate = inv_head.h_bstate
			tcu_id = inv_head.h_cu_id
			SET FILTER TO ((h_bstate >= tstate) AND (h_cu_id >= tcu_id))
			SET ORDER TO inv_key
			thisform.cPrintRecord = 'All'
			thisform.printrec
		ELSE
			MESSAGEBOX("Search was cancelled",16,"Print Invoice")
		ENDIF
	
	CASE ThisForm.opgPrintWhat.Value = 'One Invoice'
		SET ORDER TO h_sname
		recnum = m_browse('',c_browlist, '', 'recno()')
		IF NOT EMPTY(recnum)
			GOTO recnum
			tstate = inv_head.h_bstate
			tcu_id = inv_head.h_cu_id
			SET FILTER TO h_bstate = tstate AND h_cu_id = tcu_id
			SET ORDER TO inv_key
			thisform.cPrintRecord = 'All'
			thisform.printrec
		ELSE
			MESSAGEBOX("Search was cancelled",16,"Print Invoice")
		ENDIF
	
	CASE ThisForm.opgPrintWhat.Value = 'Invoice Report'
		SET ORDER TO h_bname
		thisform.cRpt_form = "inv_rpt.frx"
		thisform.cPrintRecord= 'All'
		thisform.printrec
		thisform.cRpt_Form = "BTInvoice.frx"
ENDCASE

SET FILTER TO


ENDPROC
PROCEDURE printrec
LOCAL nSaveRec, cWhatReport

nSaveRec = RECNO()
cWhatReport = thisform.GetWhatReport()
 
m.pr_out=IIF(ThisForm.opgPrintWhere.Value = 'Printer', 'TO PRINT NOCONSOLE', 'PREVIEW')
m.pr_record=IIF(thisform.cPrintWhat = 'Current', 'NEXT 1', 'ALL')
REPORT FORM &cWhatReport &pr_out &pr_record
GO nSaverec

ENDPROC
PROCEDURE getwhatreport
PRIVATE rvalue, nPosition, cCompanyCode

nPosition = ASCAN(thisform.aCompanyCode, ThisForm.cboCompanyCode.value) && Search for company
IF nPosition != 0
	nPosition = nPosition + 2
   *** Company found, get company code ***
   cCompanyCode = thisform.aCompanyCode[nPosition]
ENDIF

DO CASE
	CASE cCompanyCode = "BT"
		rvalue = "BTInvoice"
	CASE cCompanyCode = "NC"
		rvalue = "NCinvoice"
	CASE cCompanyCode = "PM"
		rvalue = "PMSCInvoice"
	CASE cCompanyCode = "LP"
		rvalue = "TLPInvoice"
	OTHERWISE
		rvalue = ""
ENDCASE

RETURN(rvalue)
ENDPROC
PROCEDURE Init
DODEFAULT()


  SET PATH TO PROGS, FORMS, LIBS, MENUS, DATA, ;
        REPORTS, INCLUDES, HELP, BITMAPS

* Build array for company codes
SELECT Company.co_name, Company.company_id, Company.co_code;
 FROM trackerdb!company;
 ORDER BY Company.co_name;
 INTO ARRAY thisform.aCompanyCode
 
ThisForm.cboCompanyCode.NumberOfElements = ALEN(thisform.aCompanyCode)
SELECT Company
USE

ThisForm.cboCompanyCode.value = "Baker & Taylor"

SELECT inv_head
ENDPROC
                                         %   S       h      b             U    C    U  THISFORM RELEASE Click,     1  1                       #       )                                                            B   %   W       l      f             U   
     U  THISFORM DOPRINTINVOICE Click,     1  1                       (       )                            !Arial, 0, 9, 5, 15, 12, 32, 3, 0
     >BoundColumn = 1
ColumnCount = (ALEN(aCompanyCode,2))
ColumnWidths = "205,70,70"
RowSourceType = 5
RowSource = "thisform.aCompanyCode"
ControlSource = "thisform.cWhatReport"
FirstElement = 1
Height = 24
Left = 52
NumberOfElements = 0
Style = 2
Top = 118
Width = 144
BoundTo = .F.
Name = "cboCompanyCode"
      frmPrintInvoice      cboCompanyCode      combobox      ..\libs\t_base.vcx      
t_combobox     AutoSize = .T.
Value = 
ControlSource = "thisform.cPrintWhere"
Height = 46
Left = 160
Top = 41
Width = 64
Name = "opgPrintWhere"
Option1.Caption = "Printer"
Option1.Value = 0
Option1.Height = 17
Option1.Left = 5
Option1.Style = 0
Option1.Top = 5
Option1.Width = 54
Option1.AutoSize = .F.
Option1.Name = "Option1"
Option2.Caption = "Screen"
Option2.Height = 17
Option2.Left = 5
Option2.Style = 0
Option2.Top = 24
Option2.Width = 54
Option2.AutoSize = .F.
Option2.Name = "Option2"
      frmPrintInvoice      opgPrintWhere      optiongroup      ..\libs\t_base.vcx      t_optiongroup      lBorderWidth = 2
Height = 0
Left = 8
Top = 184
Width = 232
BorderColor = 255,255,255
Name = "T_line2"
      frmPrintInvoice      T_line2      line      ..\libs\t_base.vcx      t_line      mBorderWidth = 2
Height = 172
Left = 241
Top = 12
Width = 0
BorderColor = 255,255,255
Name = "T_line1"
      frmPrintInvoice      T_line1      line      ..\libs\t_base.vcx      t_line      .PROCEDURE Click
thisform.release()
ENDPROC
      NTop = 153
Left = 136
Height = 24
Caption = "\<Cancel"
Name = "cmdCancel"
      frmPrintInvoice      	cmdCancel      commandbutton      ..\libs\t_base.vcx      t_commandbutton      3PROCEDURE Click
thisform.DoPrintInvoice
ENDPROC
      KTop = 153
Left = 28
Height = 24
Caption = "\<Print"
Name = "cmdPrint"
      frmPrintInvoice      cmdPrint      commandbutton      ..\libs\t_base.vcx      t_commandbutton      frmPrintInvoice      opgPrintWhat      optiongroup      ..\libs\t_base.vcx      t_optiongroup      frmPrintInvoice      shpBox      shape      cprintwhat
cprintwhere
crpt_form
cprintrecord
cwhatreport
*doprintinvoice 
*printrec 
*getwhatreport 
^acompanycode[1,0] 
      t_shape      ..\libs\t_base.vcx      `Top = 10
Left = 6
Height = 175
Width = 236
BackStyle = 0
BorderWidth = 2
Name = "shpBox"
     AutoSize = .T.
ButtonCount = 4
Value = 1
ControlSource = "thisform.cPrintWhat"
Height = 84
Left = 24
Top = 24
Width = 111
Name = "opgPrintWhat"
Option1.Caption = "All Invoices"
Option1.Value = 1
Option1.Height = 17
Option1.Left = 5
Option1.Style = 0
Option1.Top = 5
Option1.Width = 101
Option1.AutoSize = .F.
Option1.Name = "Option1"
Option2.Caption = "Starting Invoice"
Option2.Height = 17
Option2.Left = 5
Option2.Style = 0
Option2.Top = 24
Option2.Width = 101
Option2.AutoSize = .F.
Option2.Name = "Option2"
Option3.Caption = "One Invoice"
Option3.Height = 17
Option3.Left = 5
Option3.Style = 0
Option3.Top = 43
Option3.Width = 101
Option3.AutoSize = .F.
Option3.Name = "Option3"
Option4.Caption = "Invoice Report"
Option4.Height = 17
Option4.Left = 5
Option4.Style = 0
Option4.Top = 62
Option4.Width = 101
Option4.AutoSize = .F.
Option4.Name = "Option4"
     
    
  
                        X~   %         	  P               U   H w#      All Invoices]  G(( inv_key T    All
    '      Starting Invoice G(( h_snameS T C  2 h_sname		:40 :H="Ship Name",	h_scity	:20	:H="City"   recno()  %C 
j	 #  T	 
   T 
   G( 	 	   	 G(( inv_key T    All
     3 C Search was cancelled Print Invoicex "      One Invoice G(( h_snameS T C  2 h_sname		:40 :H="Ship Name",	h_scity	:20	:H="City"   recno()  %C 
	 #  T	 
   T 
   G( 	    	 G(( inv_key T    All
     3 C Search was cancelled Print Invoicex %      Invoice Reportw G(( h_bname T    inv_rpt.frx T    All
     T    BTInvoice.frx  G( U  THISFORM OPGPRINTWHAT VALUE INV_KEY CPRINTRECORD PRINTREC H_SNAME RECNUM M_BROWSE TSTATE INV_HEAD H_BSTATE TCU_ID H_CU_ID H_BNAME	 CRPT_FORM      T  CO T C  G T C    Printer  TO PRINT NOCONSOLE
  PREVIEW64 T C   Current  NEXT 1  ALL6/ REPORT FORM &cWhatReport &pr_out &pr_record
	 #   U	  NSAVEREC CWHATREPORT THISFORM GETWHATREPORT PR_OUT OPGPRINTWHERE VALUE	 PR_RECORD
 CPRINTWHAT@ 5     T C      %  b  T   T C      Hs /   BT  T  	 BTInvoice   NC  T  	 NCinvoice   PM  T   PMSCInvoice   LP T  
 TLPInvoice 2/ T     
 B   U  RVALUE	 NPOSITION CCOMPANYCODE THISFORM ACOMPANYCODE CBOCOMPANYCODE VALUE 	 CK G)(B PROGS, FORMS, LIBS, MENUS, DATA,  REPORTS, INCLUDES, HELP, BITMAPSD o trackerdb!company           T  	 C   F  Q! T  
  Baker & Taylor F  U  PROGS COMPANY CO_NAME
 COMPANY_ID CO_CODE	 TRACKERDB THISFORM ACOMPANYCODE CBOCOMPANYCODE NUMBEROFELEMENTS VALUE INV_HEAD doprintinvoice,      printrecP     getwhatreport     Init+    1  11 r1 1  1A "1 1  1A R1 A b 4   rA 3  RA  1a1a11q  A  2  Fq A r 1                       h     +       5   3     	  A   G   (	  
  Z    )   
                  
