; ORDER.FS
;

#AUTO MACRO Go


MENU BillingMenu
{
; The main menu displayed when the billing form is active
;
POPUP "&File"
  BEGIN
    MENUITEM "&New Record", GetNewRecord
    MENUITEM "&Save Record", DataUpDateRecord
    MENUITEM SEPARATOR
    MENUITEM "S&hipping", GetShipTo
    MENUITEM SEPARATOR
    MENUITEM "Form &Info...", FileFormInfo
    MENUITEM SEPARATOR
    MENUITEM "E&xit", CheckExit
  END
POPUP "&Edit"
  BEGIN
    MENUITEM "&Cut", EditCut
    MENUITEM "Co&py", EditCopy
    MENUITEM "&Paste", EditPaste
  END
POPUP "&View"
  BEGIN
    MENUITEM "&Enlarge", ViewEnlarge
    MENUITEM "&Real Size", ViewRealSize
    MENUITEM "Fit &Sides", ViewFitSides
    MENUITEM "&Full Page", ViewFitInWindow
  END
POPUP "&Search"
  BEGIN
    MENUITEM "&Search", SearchCustnum
    MENUITEM "&Locate", LocateSearchOnExpression
  END
POPUP "&Help"
  BEGIN
    MENUITEM "&Index", HelpHelpIndex
    POPUP "&About"
      BEGIN
        MENUITEM "&PerForm PRO Filler...", HelpAboutPerFORMPRO
        MENUITEM "&This Form System...", FormSysInfo
      END
  END
}


MENU ShippingMenu
{
; The menu displayed when the shipping form is active
;
POPUP "&File"
  BEGIN
    MENUITEM "&Save Record", DataUpDateRecord
    MENUITEM SEPARATOR
    MENUITEM "&Orders", LoadOrders
    MENUITEM SEPARATOR
    MENUITEM "Form &Info...", FileFormInfo
  END
POPUP "&Edit"
  BEGIN
    MENUITEM "&Cut", EditCut
    MENUITEM "Co&py", EditCopy
    MENUITEM "&Paste", EditPaste
  END
POPUP "&View"
  BEGIN
    MENUITEM "&Enlarge", ViewEnlarge
    MENUITEM "&Real Size", ViewRealSize
    MENUITEM "Fit &Sides", ViewFitSides
    MENUITEM "&Full Page", ViewFitInWindow
  END
POPUP "&Help"
  BEGIN
    MENUITEM "&Index", HelpHelpIndex
    POPUP "&About"
      BEGIN
        MENUITEM "&PerForm PRO Filler...", HelpAboutPerFORMPRO
        MENUITEM "&This Form System...", FormSysInfo
      END
  END
}


MENU OrdersMenu
{
; The menu displayed when the order form is active
;
POPUP "&File"
  BEGIN
    MENUITEM "&Save Record", DataUpDateRecord
    MENUITEM SEPARATOR
    MENUITEM "&Billing", GetBilling
    MENUITEM SEPARATOR
    MENUITEM "Form &Info", FileFormInfo
    MENUITEM SEPARATOR
    MENUITEM "&Print Order", PrintOrder
    MENUITEM "Printer Set&up", FilePrinterSetup
    MENUITEM SEPARATOR
    MENUITEM "&Close", GetBilling
  END
POPUP "&View"
  BEGIN
    MENUITEM "&Enlarge", ViewEnlarge
    MENUITEM "&Real Size", ViewRealSize
    MENUITEM "Fit &Sides", ViewFitSides
    MENUITEM "&Full Page", ViewFitInWindow
  END
POPUP "&Help"
  BEGIN
    MENUITEM "&Index", HelpHelpIndex
    POPUP "&About"
      BEGIN
        MENUITEM "&PerForm PRO Filler...", HelpAboutPerFORMPRO
        MENUITEM "&This Form System...", FormSysInfo
      END
  END
}


RIBBON BillingRibbon
{
; The main ribbon displayed when the billing form is active
;
BitmapText "CAR,Shipping", GetShipTo
Space
BitmapText "FILENEW,New", GetNewRecord
BitmapText "FILESAVE,SAVE", DataUpDateRecord
Space
Bitmap "FILEQUIT", CheckExit
}


RIBBON ShippingRibbon
{
; The ribbon displayed when the shipping form is active (except when in the
; addressing sub-section)
;
BitmapText "GIFT,Orders", LoadOrders
Space
BitmapText "FILESAVE,SAVE", DataUpDateRecord
Space
Space
Button "Get Address", GetAddress
}


RIBBON ShippingRibbon2
{
; The ribbon displayed when the shipping form is active (except when in the
; addressing sub-section)
;
BitmapText "GIFT,Orders", LoadOrders
Space
BitmapText "FILESAVE,SAVE", DataUpDateRecord
}


RIBBON OrdersRibbon
{
; The ribbon displayed when the order form is active
;
BitmapText "IC_DOLLAR,Billing", GetBilling
Space
BitmapText "FILEPRNT,Print", PrintOrder
Space
BitmapText "FILESAVE,SAVE", DataUpDateRecord
}


MACRO Go
{
; Run automatically at startup
;
WindowSetTitle "Order Entry Model"
WindowCloseAll
ViewFitInWindow
WindowFormMaximize
ViewAutoRecalc 1
ViewShowRibbon 0
ViewShowGraphics 1
;
; Must load the custom keyboard before the menu to get the correct quick keys
; shown in the menu.
;
KeyboardMacro
BeginExec ViewPreferences
  OnNewRecord "RememberSelected"
  UpdateFillLogFile "NO"
  SignatureVerification "Automatic"
  BeepOnError "YES"
  SavePreferences "NO"
  AutoDataLookup "NO"
  ShowDeletedRecords "NO"
  HighlightField "YES"
EndExec
;
; Open the splash screen with a title and wait 2 seconds
;
BeginExec FileOpenForm
  File="Splash.frp"
  Title=" - Welcome - "
EndExec
WindowFormMaximize
WaitForIdle
TimeWait 200
;
; Load the scratch pad form in the background hidden
;
BeginExec FileOpenForm
  File="Scratch.frp"
  Title="Setting up..."
;   Show="Hidden"
EndExec
;
; Close the splash screen and load the billing form.
;
WindowFormActivate "Splash.frp"
LoadBilling
}


MACRO FormSysInfo
{
Message="[0][PerForm PRO Plus|Order Entry Form System|Version 1.0|by Michael Harris|Delrina Technology Inc.][Continue]"
}


MACRO LoadBilling
{
; Load the billing form and its associated ribbon and menu
;
FileCloseForm
BillingRibbon
BillingMenu
Beginexec FileOpenForm
  File="Sold_to.frp"
  Title="Billing Info"
Endexec
WindowFormMaximize
ViewFitInWindow
If ~CUSTNUM
  Scratch->NEWREC="New"
End
;
; If there is a customer number on the scratch form, move to that record
;
If Scratch->CUSTNUM
  GoToCustnum
End
}



MACRO GetBilling
{
WaitForIdle
DataUpDateRecord
LoadBilling
}


MACRO GetShipTo
{
DataUpDateRecord
Scratch->SERIALNO=SERIALNO
Scratch->CUSTNUM=CUSTNUM
Scratch->COMPANY=COMPANY
Scratch->CONTACT=CONTACT
Scratch->ADDR_1=ADDR_1
Scratch->ADDR_2=ADDR_2
Scratch->CITY=CITY
Scratch->STATE_PROV=STATE_PROV
Scratch->COUNTRY=COUNTRY
Scratch->ZIP=ZIP
Scratch->TELE=TELE
Scratch->FAX_NO=FAX_NO
LoadShipping
}


MACRO GetAddress
{
CUSTNUM=Scratch->CUSTNUM
SERIALNO=Scratch->SERIALNO
COMPANY=Scratch->COMPANY
CONTACT=Scratch->CONTACT
ADDR_1=Scratch->ADDR_1
ADDR_2=Scratch->ADDR_2
CITY=Scratch->CITY
STATE_PROV=Scratch->STATE_PROV
COUNTRY=Scratch->COUNTRY
ZIP=Scratch->ZIP
TELE=Scratch->TELE
FAX_NO=Scratch->FAX_NO
ShippingRibbon2
}


MACRO LoadShipping
{
DataUpDateRecord
FileCloseForm
ShippingMenu
BeginExec FileOpenForm
  File "Ship_to.frp"
  Title "Ship To"
EndExec
;
; If this is a new record, move to a new one, otherwise move to the record
; based on CUSTNUM.
;
If Scratch->NEWREC
  DataNewRecord
	ShippingRibbon
  Scratch->NEWREC=""
Else
  GoToShipToCustnum
	ShippingRibbon
End
EditAbandonChanges
}


MACRO GetNewRecord
{
DataNewRecord
Scratch->NEWREC="New"
}


MACRO LoadOrders
{
; Update the record on the current form, load the Order Form and automatically
; patch in some of the fill fields.
;
DataUpDateRecord
FileCloseForm
OrdersMenu
OrdersRibbon
BeginExec FileOpenForm
  File "Order.frp"
  Title "Order Form"
EndExec
GoToSerialNo
WindowFormMaximize
ViewFitSides
EditAbandonChanges
}


MACRO SearchCustnum
{
; Display the Search on Index dialog with the following default entries
;	This search is selected from the BillingMenu
;	BeginDialog allows for user to select search criteria
;
BeginDialog LocateSearchOnIndexField
	BeginIndex
		File  "CUSTOMER.NDX"
		IndexExpression  "CUSTNUM"
		SortingIndex
		IndexUniqueRecords
	EndIndex
	SearchData  CUSTNUM=""
	SearchMatch  "Equal to"
	StartSearchFromFirst
EndDialog
}


MACRO GoToCustnum
{
; Move to the matching record
;	This macro is called from the LoadBilling Macro only
;
If Scratch->CUSTNUM
  BeginExec LocateSearchOnIndexField
    BeginIndex
		  File  "CUSTOMER.NDX"
  		IndexExpression  "CUSTNUM"
	  	SortingIndex
		  IndexUniqueRecords
  	EndIndex
	  SearchData  CUSTNUM=Scratch->CUSTNUM
  	SearchMatch  "Equal to"
	  StartSearchFromFirst
  EndExec
End
}


MACRO GoToSerialNo
{
;	This macro is called from within the LoadOrders Macro
;	Find the record containg the Serial number found on the hidden scratch form
;
If Scratch->SERIALNO
  BeginExec LocateSearchOnIndexField
	  BeginIndex
		  File  "TRANS.NDX"
  		IndexExpression  "SERIALNO"
	  	SortingIndex
		  IndexCaseSensitive
  	EndIndex
	  SearchData SERIALNO=Scratch->SERIALNO
  	SearchMatch  "Equal to"
	  StartSearchFromFirst
  EndExec
End
}


MACRO GoToShipToCustnum
{
; Move to the matching record
;	This macro is called from the LoadShipping macro.
;
If Scratch->CUSTNUM
  BeginExec LocateSearchOnIndexField
	  BeginIndex
		  File "SHIP_TO.NDX"
  		IndexExpression "CUSTNUM"
	  	SortingIndex
		  IndexUniqueRecords
  	EndIndex
	  SearchData CUSTNUM=Scratch->CUSTNUM
  	SearchMatch "Equal to"
	  StartSearchFromFirst
  EndExec
End
}


MACRO PrintOrder
{
; Print the order form from the data entered into the database.  Allow the
; user to adjust the print settings by displaying the dialog with the
; defaults filled in.
;
DataUpDateRecord
BeginDialog FilePrint
  PAGEFROM    "ALL"
  COPIES      1
  PRINTSPEED  "FAST"
  PRINTCOLORS "AS_COLOR"
  PRINTFORM   "YES"
  PRINTDATA   "YES"
  DATA        "CURRENT"
EndDialog
}


MACRO CheckExit
{
; Verify the user's intention when they press quit.
;
If FORMTITLE()="Billing Information Form"
  CHKEXIT=Message "[2][Exiting the Order Entry Form System.|What action do you wish to take?][&Exit Filler|Close Form &System|&Cancel]"
  If CHKEXIT=1
    ViewShowRibbon 1
    FileExit
  Else
    If CHKEXIT=2
      CleanUp
    End
  End
End
}


MACRO CleanUp
{
; Restore the system
;
WindowCloseAll
SystemRestoreSystem
;
; Restore the normal Filler defaults
;
ViewShowRibbon 1
}



KEYBOARD KeyboardMacro
{
; Restricted version of the full Filler keyboard
;
BackSpace=EditDelPreviousChar
Ctrl+2=InfoMemoryInfo
Ctrl+C=EditCopy
Ctrl+D=EditDelete
Ctrl+E=ViewEnlarge
Ctrl+G=LocateGoToRecordNumber
Ctrl+H=ViewFitSides
Ctrl+Home=LocateRecordFirst
Ctrl+I=FormSysInfo
Ctrl+Q=CleanUp
Ctrl+R=ViewRealSize
Ctrl+V=EditPaste
Ctrl+W=ViewFitInWindow
Ctrl+X=EditCut
Ctrl+Z=EditStampDate
Del=EditDelChar
DnArrow=EditLineDown
End=EditLineEnd
Esc=EditLineDelete
F1=InfoFieldHelp
F3=InfoLookup
F10=ViewRedrawScreen
F7=EditDoAutomatics
Home=EditLineBegin
Ins=EditPaste
LtArrow=EditCharLeft
Return=EditCarriageReturn
RtArrow=EditCharRight
Shift+Del=EditCopy
Shift+F1=HelpHelpIndex
Shift+F10=EditSelectEnd
Shift+F6=EditDeselect
Shift+F7=EditSelectWord
Shift+F8=EditSelectAll
Shift+F9=EditSelectBegin
Shift+TAB=LocateFieldPrevious
Tab=LocateFieldNext
UpArrow=EditLineUp
}
