Module ItemsPerOrderWP.rv

     1Use dfrptvw.pkg
     2Use DataDict.pkg
     3Use dfRadio.pkg
     4Use Windows.pkg
     5Use cWinReport2.pkg
     6Use VENDOR.DD
     7Use INVT.DD
     8Use CUSTOMER.DD
     9Use SALESP.DD
    10Use ORDERHEA.DD
    11Use ORDERDTL.DD
    12
    13ACTIVATE_VIEW Activate_oItemsPerOrderWP FOR oItemsPerOrderWP
    14
    15Object oItemsPerOrderWP is a ReportView
    16    Set Label to "Items per Order"
    17    Set Location to 6 6
    18    Set Size to 84 140
    19
    20    Object Vendor_DD is a Vendor_DataDictionary
    21        Send DefineAllExtendedFields
    22    End_Object    // Vendor_DD
    23
    24    Object Invt_DD is a Invt_DataDictionary
    25        Set DDO_Server to Vendor_DD
    26        Send DefineAllExtendedFields
    27    End_Object    // Invt_DD
    28
    29    Object Customer_DD is a Customer_DataDictionary
    30        Send DefineAllExtendedFields
    31    End_Object    // Customer_DD
    32
    33    Object SalesP_DD is a Salesp_DataDictionary
    34        Send DefineAllExtendedFields
    35    End_Object    // SalesP_DD
    36
    37    Object Orderhea_DD is a Orderhea_DataDictionary
    38        Set DDO_Server to Customer_DD
    39        Set DDO_Server to SalesP_DD
    40        Send DefineAllExtendedFields
    41    End_Object    // Orderhea_DD
    42
    43    Object Orderdtl_DD is a Orderdtl_DataDictionary
    44        Set DDO_Server to Orderhea_DD
    45        Set DDO_Server to Invt_DD
    46        Send DefineAllExtendedFields
    47    End_Object    // Orderdtl_DD
    48
    49    Object oPrintTo is a RadioGroup
    50        Set Size to 38 131
    51        Set Location to 5 5
    52        Set Label to "Print to"
    53        Object oRadio1 is a Radio
    54            Set Label to "Preview"
    55            Set Size to 10 42
    56            Set Location to 12 6
    57            Set Status_Help to "Prints the report to screen"
    58        End_Object    // oRadio1
    59
    60        Object oRadio2 is a Radio
    61            Set Label to "Printer"
    62            Set Size to 10 42
    63            Set Location to 24 6
    64            Set Status_Help to "Prints the report to printer"
    65        End_Object    // oRadio2
    66
    67    End_Object    // oPrintTo
    68
    69    Object oBtnPrint is a Button
    70        Set Label to "Print"
    71        Set Location to 48 85
    72        Set Status_Help to "Print the Selected report"
    73        Set Default_State to True
    74
    75        Procedure OnClick
    76            Send StartReport
    77        End_Procedure
    78
    79    End_Object    // oBtnPrint
    80
    81    Object oBtnCancel is a Button
    82        Set Label to "Cancel"
    83        Set Location to 66 85
    84        Set Status_Help to "Close this Panel"
    85
    86        Procedure OnClick
    87            Send Close_Panel
    88        End_Procedure
    89
    90    End_Object    // oBtnCancel
    91
    92    Object oOrders is a cWinReport2
    93        Set Report_Title to "Customer Report"
    94
    95        //Main File for the report
    96        Set Server to Orderdtl_DD
    97
    98        //Breaks and Index for the report
    99        Report_Breaks ORDERHEA.ORDER_NUMBER
   100        Set Ordering to 1
   101
   102        Function Starting_Main_Report Returns Integer
   103            Integer iRetVal
   104            Send DFSetMetrics WPM_CM
   105            Send DFSetmargins 1 1 1 1
   106            Forward Get Starting_Main_Report To iRetVal
   107            If iRetVal Function_return iRetVal
   108        End_Function
   109
   110        Procedure Page_Top
   111            DFFont "Arial" //  Use Arial
   112            DFFontSize 8
   113            DFBeginHeader DFPageTop
   114                DFHeaderPos   HDR_RIGHT
   115                DFHeaderFrame HDR_NOFRAME
   116                DFWriteLn ("Page:" * "#pagecount#")
   117            DFEndHeader
   118        End_Procedure
   119
   120        Procedure Page_Header
   121            DFFont "Arial"
   122            DFFontSize 14
   123            DFBeginHeader DFPageHeader
   124                DFHeaderFrame HDR_MARGINs 0 RGB_DGREY RGB_DGREY
   125                DFHEADERPOS HDR_LEFT
   126                DFHeaderMargin HM_BottomOuter 0.08
   127                DFWritelnPos "Orders by Order Number Report" 0.10 (FONT_BOLD+RGB_WHITE)
   128            DFEndHeader
   129        End_Procedure
   130
   131        Procedure Page_Title
   132            DFFont "Arial"
   133            DFFontSize 8
   134            DFBeginHeader DFPageTitle
   135                DFHeaderFrame HDR_MARGINs 0 RGB_GREY RGB_GREY
   136                DFHEADERPOS HDR_LEFT
   137                DFWritePos    "Item Id"                 0.1     (FONT_BOLD+RGB_DBLUE)            -1 1.36
   138                DFWritePos    "Description"             4.00    (FONT_BOLD+RGB_DBLUE)            -1 4.77
   139                DFWritePos    "Qty Ordered"             11.5     (FONT_BOLD+FONT_RIGHT+RGB_DBLUE) -1 1.87
   140                DFWritePos    "Price"                   13.22   (FONT_BOLD+FONT_RIGHT+RGB_DBLUE) -1 1.22
   141                DFWritePos    "Extended Price"          16.0    (FONT_BOLD+FONT_RIGHT+RGB_DBLUE) -1 2.38
   142                DFWriteln
   143            DFEndHeader
   144        End_Procedure
   145
   146        Procedure SubHeader1
   147
   148            DFFont "Arial" //  Use Arial
   149            DFFontSize 10
   150
   151            DFBeginHeader DFSubHeader 1    //Header of type DFSubHeader
   152
   153                Send Update_Status ("Order:" * String(OrderHea.Order_number))
   154
   155                DFHeaderWrap HDR_WRAP
   156                DFHeaderLineCheck 5            //Check that the header + 5 lines fits on the page, if not wrap
   157
   158                DFHeaderPos   HDR_LEFT         //Write data from left margin in the header
   159                DFHeaderFrame HDR_NoFrame      //Set the box from margin to margin using size 0.05
   160
   161                DFWriteLnPos    ("Order: "+string(Orderhea.ORDER_NUMBER)) 0.1 (FONT_BOLD)
   162
   163              DFEndHeader                     //End and print header
   164
   165        End_Procedure
   166
   167        Procedure Body
   168
   169            DFFont "Arial" //  Use Arial
   170            DFFontSize 8
   171
   172            DFLineCheck 5
   173
   174            DFWritePos    Invt.ITEM_ID                0.1     (FONT_DEFAULT)            -1 2.28
   175            DFWritePos    Invt.DESCRIPTION            4.00    (FONT_DEFAULT)            -1 4.77
   176            DFWritePos    Orderdtl.QTY_ORDERED        11.5     (FONT_DEFAULT+FONT_RIGHT)  0 1.87
   177            DFWritePos    Orderdtl.PRICE              13.22   (FONT_DEFAULT+FONT_RIGHT)  2 1.22
   178            DFWritePos    Orderdtl.EXTENDED_PRICE     16.0    (FONT_DEFAULT+FONT_RIGHT)  2 2.38
   179            DFWriteln ""
   180
   181            // Using SubTotal in WinPrint.
   182            Send Add_SubTotal 1 (Orderdtl.EXTENDED_PRICE)
   183
   184        End_Procedure
   185
   186        Procedure SubTotal1
   187            Number nAmount
   188            Get SubTotal 1 to nAmount
   189            Send Add_SubTotal 2 nAmount // subtotal 2 is total
   190
   191            DFFont "Arial" //  Use Arial
   192            DFFontSize 8
   193            DFBeginHeader DFSubTotal 1
   194
   195                DFHEADERPOS HDR_LEFT
   196                DFHEADERFRAME HDR_NOFRAME
   197
   198                DFWritelnPos  nAmount         16.0      (FONT_BOLD+FONT_RIGHT) 2 0
   199                DFWriteLine DFGR_CURRLINE DFGR_CURRLINE DFGR_RB_MARGIN DFGR_HORI Rgb_dGrey
   200
   201            DFEndHeader
   202
   203        End_Procedure
   204
   205        Procedure Total
   206            Number nTotal
   207            Get SubTotal 2 to nTotal
   208
   209            DFFont "Arial" //  Use Arial
   210            DFFontSize 8
   211            DFBeginHeader DFTotal           //Header of type DFTotal
   212
   213              DFHeaderPos   HDR_LEFT         //Write data from left margin in the header
   214              DFHeaderFrame HDR_MARGINs 0 RGB_DGREY RGB_GREY //rgb_Cyan rgb_Cyan
   215
   216              DFWritelnPos   nTotal         16.0      (FONT_BOLD+FONT_RIGHT) 2
   217
   218            DFEndHeader                     //End and print header
   219
   220        End_Procedure
   221
   222        Procedure Page_Bottom
   223            DateTime dtDT
   224            Move (CurrentDateTime()) to dtDT
   225
   226            DFFont "Arial" //  Use Arial
   227            DFFontSize 8
   228            DFBeginHeader DFPageBottom
   229                DFHeaderPos   HDR_CENTER       //Write data in center
   230                DFHeaderFrame HDR_MARGINS 0.01 rgb_dGrey
   231                DFWriteLn   ("Report Printed on: " +string(dtDT)) (rgb_dBlue)
   232            DFEndHeader
   233
   234        End_Procedure
   235
   236    End_Object    // oOrders
   237
   238    // Procedures and functions used by the user interface
   239
   240    //This function is called by the procedure StartReport
   241    Function Print_to_Screen_State Returns Integer
   242        Integer iRad
   243        Get Current_Radio of oPrintTo To iRad
   244        Function_Return (iRad=1)
   245    End_Function
   246
   247    // Use this procedure to do print setup
   248    Procedure SetupReport
   249        Boolean bSetupOk
   250        Get DFPrintSetupDialog of (Report_Object_Id(Self)) to bSetupOk
   251    End_Procedure
   252
   253    // Use this procedure to start the report
   254    Procedure StartReport
   255        Integer iToPrinter iRepObj
   256        String sVal
   257        Get Report_Object_Id To iRepObj
   258
   259        Get Print_to_Screen_State to iToPrinter
   260        If iToPrinter Set OutPut_Device_Mode to PRINT_TO_PRINTER
   261        Else Set OutPut_Device_Mode to PRINT_TO_WINDOW
   262
   263        Send Run_Report to iRepObj
   264
   265    End_Procedure
   266
   267End_Object    // oItemsPerOrderWP
   268