181 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			181 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| compile function INVOICE_SRPT5() 
 | |
| declare function msg, send_event, dialog_box, utility
 | |
| declare subroutine rlist, activate_save_select,  or_view
 | |
| $insert rlist_equates
 | |
| $insert msg_equates
 | |
| $insert rpt_cfg_equ
 | |
| 
 | |
| TimeX = Oconv(Time(),'MTS')
 | |
| 
 | |
| CrLf = Char(13):Char(10) 
 | |
| CurDte = OCONV(Date(),"D4/")
 | |
| 
 | |
| ReportID = "INVOICE005_SRPTCFG"
 | |
| ReportControl = "INVOICE_SRPT5"
 | |
| TableName = 'INVOICE'
 | |
| ListsId = ReportControl:'*':@station
 | |
| 
 | |
| TtlLin1 = ''
 | |
| TtlLin2 = ''
 | |
| TtlLin3 = ''
 | |
| TtlLin4 = ''
 | |
| TtlLin5 = ''
 | |
| 
 | |
| open 'CONFIG' to ConfigTable else
 | |
|     Void = msg( '', 'Unable to open CONFIG...' )
 | |
|     return 0
 | |
| end
 | |
| 
 | |
| Read SRptConfig From ConfigTable,ReportID Else
 | |
|    Void = msg( '', 'Unable to read ': ReportID:' From CONFIG table!' )
 | |
|    return 0
 | |
| End
 | |
| 
 | |
| Params = dialog_box( ReportControl, @window, '*CENTER' )
 | |
| 
 | |
| if Params = 'CANCEL' or Params = '' then
 | |
|     return 0
 | |
| end
 | |
| open 'SYSLISTS' to SysListsTable else
 | |
|    Void = msg( '', 'Unable to open SYSLISTS...' )
 | |
|    return 0
 | |
| end
 | |
| 
 | |
| write '' on SysListsTable, ListsId else
 | |
|    Void = msg( '', 'Unable to clear SYSLISTS ':ListsId:'...' )
 | |
|    return 0
 | |
| end
 | |
| 
 | |
| convert '*' to @fm in Params
 | |
| BegDte         = Params<1>
 | |
| EndDte         = Params<2>
 | |
| Custs          = Params<3>
 | |
| Quotes         = Params<4>
 | |
| POs            = Params<5>
 | |
| 
 | |
| Void = utility( 'CURSOR', 'H' )
 | |
| 
 | |
| WithStmt = 'SELECT ':TableName:' '
 | |
| WthSwt = 0
 | |
| Begin Case
 | |
|    Case BegDte and EndDte
 | |
|       TtlLin2 = 'Entry Dates: From ':BegDte:' To ':EndDte
 | |
|       WithStmt :=  " WITH ENTRY_DATE FROM '": BegDte:"' TO '":EndDte: "' "
 | |
|       WthSwt = 1
 | |
|    Case BegDte
 | |
|       TtlLin2 = 'Entry Dates: From ':BegDte:' To ':CurDte
 | |
|       WithStmt := " WITH ENTRY_DATE GE '":BegDte:"' "
 | |
|       WthSwt = 1
 | |
|    Case EndDte
 | |
|       TtlLin2 = 'Entry Dates: From Earliest To ':EndDte
 | |
|       WithStmt := " WITH ENTRY_DATE LE '":EndDte:"' "
 | |
|       WthSwt = 1
 | |
|    Case 1
 | |
|       TtlLin2 = 'Entry Dates: ALL'
 | |
| End Case
 | |
| 
 | |
| If Custs then
 | |
|    CustCnt = Count(@vm,Custs)
 | |
|    If CustCnt > 20 Then 
 | |
|       TtlLin3 = 'Customers: More Than 20 Selected'
 | |
|    End Else
 | |
|       TtlLin3 = Custs
 | |
|       swap @vm with ", " in TtlLin3
 | |
|       TtlLin3 = 'Customers: ':TtlLin3
 | |
|    End      
 | |
|    swap @vm with "' '" in Custs
 | |
|    Custs = "'":Custs:"'"
 | |
|    If WthSwt Then WithStmt := ' AND '
 | |
|    WithStmt := ' WITH CUST_NO = ':Custs
 | |
|    WthSwt = 1
 | |
| end else
 | |
|    TtlLin3 = 'Customers: ALL'
 | |
| end
 | |
| 
 | |
| QuotesLimit = ''
 | |
| If Quotes then
 | |
|    QuoteCnt = Count(@vm,Quotes)
 | |
|    If QuoteCnt > 20 Then 
 | |
|       TtlLin4 = 'Quotes: More Than 20 Selected'
 | |
|    End Else
 | |
|       TtlLin4 = Quotes
 | |
|       swap @vm with ", " in TtlLin4
 | |
|       TtlLin4 = 'Quotes: ':TtlLin4
 | |
|    End      
 | |
|    swap @vm with "' '" in Quotes
 | |
|    Quotes = "'":Quotes:"'"
 | |
|    If WthSwt Then WithStmt := ' AND '
 | |
|    WithStmt := ' WITH QUOTES = ':Quotes
 | |
|    QuotesLimit = 'LIMIT QUOTES = ': Quotes  
 | |
|    WthSwt = 1
 | |
| end else
 | |
|    TtlLin4 = 'Quotes: ALL'
 | |
| end
 | |
| 
 | |
| If POs then
 | |
|    PO_Cnt = Count(@vm,POs)
 | |
|    If PO_Cnt > 20 Then 
 | |
|       TtlLin5 = 'POs: More Than 20 Selected'
 | |
|    End Else
 | |
|       TtlLin5 = POs
 | |
|       swap @vm with ", " in TtlLin5
 | |
|       TtlLin5 = 'POs: ':TtlLin5
 | |
|    End      
 | |
|    swap @vm with "' '" in POs
 | |
|    POs = "'":POs:"'"
 | |
|    If WthSwt Then WithStmt := ' AND '
 | |
|    WithStmt := ' WITH POs = ':POs
 | |
|    WthSwt = 1
 | |
| end else
 | |
|    TtlLin5 = 'POs: ALL'
 | |
| end
 | |
| 
 | |
| OsWrite WithStmt To 'C:\WithStmt.Txt'
 | |
| 
 | |
| rlist( WithStmt, target_savelist$, ListsId, '', '' )
 | |
| activate_save_select( ListsId )
 | |
| 
 | |
| Script = SRptConfig<SlistScript$>
 | |
| 
 | |
| *SEE SCHED_SRPT1 FOR LIMITS CLAUSE...
 | |
| 
 | |
| *** Report titles
 | |
| TitleLine2 = SRptConfig<Title2$ >
 | |
| TitleLine3 = SRptConfig<Title3$ >
 | |
| TitleLine4 = SRptConfig<Title4$ >
 | |
| RptWdt = SRptConfig<Width$>
 | |
| TtlMid = RptWdt/2
 | |
| Swap '~CurrDate~' With CurDte In Script
 | |
| 
 | |
| Swap "~Limit2~" With QuotesLimit In Script
 | |
| 
 | |
| If TitleLine2[1,1] = '~' Then
 | |
|    Filler = TtlMid - (Len(TtlLin2)/2)
 | |
|    If Filler < 0 Then Filler = 0
 | |
|    TtlLin2 = Space(Filler):TtlLin2
 | |
|    If TtlLin2 Then Swap '~SecondTitleLine~' With TtlLin2 In Script
 | |
| End
 | |
| If TitleLine3[1,1] = '~' Then
 | |
|    Filler = TtlMid - (Len(TtlLin3))/2
 | |
|    If Filler < 0 Then Filler = 0
 | |
|    If TtlLin3 Then Swap '~ThirdTitleLine~' With  Space(Filler):TtlLin3 In Script
 | |
| End
 | |
| If TitleLine4[1,1] = '~' Then
 | |
|    Filler = TtlMid - (Len(TtlLin4))/2
 | |
|    If Filler < 0 Then Filler = 0
 | |
|    If TtlLin3 Then Swap '~FourthTitleLine~' With  Space(Filler):TtlLin4 In Script
 | |
| End
 | |
| 
 | |
| *OsWrite Script To "C:\SLIST.txt"
 | |
| 
 | |
| 
 | |
| call slist( Script )
 | |
| Void = utility( 'CURSOR', 'A' )
 | |
| 
 | |
| write '' on SysListsTable, ListsId else
 | |
|     Void = msg( '', 'Unable to clear SYSLISTS ':ListsId:'...' )
 | |
|     return 0
 | |
| end
 | |
| 
 | |
| RETURN 0
 |