{
    "header": {
        "version": 1,
        "type": "record"
    },
    "body": {
        "record1": {
            "<1>": "declare function entid, repository, start_window, msg, key_sort, rowexists\r\ndeclare subroutine make.list, obj_Appwindow\r\n$insert msg_equates\r\n\r\nCustNo = .cust_no->text\r\nif CustNo then\r\n    * row one = call window with current key\r\n\t* row two = call window with no keys\r\n\t* row three = call window with all active keys for customer\r\n\t* row four = call popup allowing choice\r\n\tCurACID = .ac_id->text\r\n\tif CurACID then\r\n\t   if rowexists( 'ORDER', .order_no->text ) else\r\n\t      Tvar = iconv( CurACID, '[WIN_AC_NUM_VALID]' )\r\n\t      if status() then\r\n\t         .ac_id->text = ''\r\n\t      end\r\n\t   end\r\n\tend\r\n\tPopupId = entid( @appid<1>, 'POPUP', '', 'AC_LOOKUP_OPTS' )\r\n\tChoosenRow = repository( 'EXECUTE', PopupId, @window, '' )\r\n\tif ChoosenRow = 1 then\r\n\t    ;* go view current AC\r\n\t    if CurACID then\r\n\t        *RetVal = start_window( 'ANNUAL_CONTRACTS', @window, CurACID:'*CENTER', '', '' ) \r\n\t        obj_Appwindow('ViewRelated','ANN_CONT':@RM:CurACID)\r\n\t\tend else\r\n\t\t    MsgInfo = ''\r\n\t\t    Text = 'You have not entered an annual contract number...' \r\n\t\t    MsgInfo<mtext$> = Text\r\n\t\t    MsgInfo<micon$> = 'H'\r\n\t\t    Void = msg( '', MsgInfo )\r\n\t\t    return 0\r\n        end\r\n    end else\r\n        if ChoosenRow = 2 then\r\n\t        * call ANNUAL CONTRACT window\r\n\t\t\tRetVal = start_window( 'ANNUAL_CONTRACTS', @window, '*Choosing*Order*CENTER', '', '' )\r\n\t\tend else\r\n\t\t    if ChoosenRow = 3 then\r\n\t\t        *  call AC window with all active\r\n\t\t\t\tOpenKeys = xlate( 'COMPANY', CustNo, 'OPEN_ANNUAL_CONTRACT_KEYS', 'X' )\r\n\t\t\t\tif OpenKeys then\r\n\t\t            RetVal = start_window( 'ANNUAL_CONTRACTS', @window, OpenKeys:'*Choosing*Order*CENTER', '', '' )\r\n\t\t\t\tend else\r\n\t\t\t\t    gosub CustErr\r\n\t\t\t\t    return 0\r\n\t\t\t\tend\r\n\t\t\tend else\r\n\t\t\t    if ChoosenRow = 4 then\r\n\t\t\t        ;* show all open in popup allowing choice\r\n\t\t  \t\t\tOpenKeys = xlate( 'COMPANY', CustNo, 'OPEN_ANNUAL_CONTRACT_KEYS', 'X' )\r\n\t\t\t\t\tif OpenKeys then\r\n\t\t\t\t\t    convert @vm to @fm in OpenKeys\r\n\t\t\t         \tOpenKeys = key_sort( OpenKeys, 'ANNUAL_CONTRACTS', '#ENTRY_DATE', 1, '', '' )\r\n\t\t\t         \tmake.list( 0, OpenKeys, '', '' )\r\n\t\t         \t\tPopupId = entid( @appid<1>, 'POPUP', '', 'SHOW_ANNUAL_CONTRACTS' )\r\n\t\t    \t   \t\tChoosenRow = repository( 'EXECUTE', PopupId, @window, '' )\r\n\t\t    \t   \t\tif ChoosenRow <> '' then\r\n\t\t    \t   \t\t    .ac_id->text = ChoosenRow\r\n\t\t                end\r\n\t\t        \tend else\r\n\t\t\t\t\t    gosub CustErr\r\n\t\t\t\t\t    return 0\r\n\t\t\t\t\tend\r\n\t\t\t    end ;* user canceled\r\n\t\t    end\r\n\t    end\r\n    end    \r\nend else\r\n    MsgRec = ''\r\n    MsgRec<mtext$> = 'You must enter a customer first...' \r\n    MsgRec<micon$> = 'H'\r\n    Void = msg( '', MsgRec )    \r\nend\r\nRETURN 0\r\n*===========================================================================*\r\nCustErr:\r\n    Text = 'There are currently no OPEN Annual Contracts for '\t\t        \r\n    Text:= oconv( CustNo, '[XLATE_CONV,COMPANY*CO_NAME]' )  \r\n    MsgInfo = ''\r\n    MsgInfo<mtext$> = Text\r\n    MsgInfo<micon$> = 'H'\r\n    Void = msg( '', MsgInfo )\r\nreturn 0\r\n*===========================================================================*"
        }
    }
}