Module Invt.wo

     1Use cWebBusinessProcess.pkg
     2Use DataDict.pkg
     3Use cWebReport.pkg
     4Use Vendor.DD
     5Use Invt.DD
     6
     7Object oInvt is a cWebBusinessProcess
     8
     9    // private. Determines if Invt is constrained to Vendor.
    10    //          This is set with ConstrainVendor
    11    Property Integer pbConstrained False
    12
    13    Set pbClearAfterSave to False
    14    Set psDescription to "Inventory; Entry, report and Maintenance"
    15
    16    Object Vendor_DD is a Vendor_DataDictionary
    17        Send DefineAllExtendedFields
    18    End_Object    // Vendor_DD
    19
    20    Object Invt_DD is a Invt_DataDictionary
    21        Set DDO_Server to Vendor_DD
    22        Send DefineAllExtendedFields
    23    End_Object    // Invt_DD
    24
    25    Set Main_DD to Invt_DD
    26
    27    Object oReport is a cWebReport
    28
    29        Property String psVendorHRef
    30
    31        Procedure OnPageTop
    32            Send WriteHtmlTableBegin 'border="0" width="99%" Class="ReportTable"'
    33
    34            Send WriteHtmlRowBegin
    35                Send WriteHtmlCellHeader 'Item ID' 'Class="Header" Align="left"'
    36                Send WriteHtmlCellHeader 'Description' 'Class="Header" Align="left"'
    37                Send WriteHtmlCellHeader 'Vndr ID' 'Class="Header" Align="right"'
    38                Send WriteHtmlCellHeader 'Name' 'Class="Header" Align="left"'
    39                Send WriteHtmlCellHeader 'Vendor Part ID' 'Class="Header" Align="left"'
    40                Send WriteHtmlCellHeader 'Unit Price' 'Class="Header" Align="right"'
    41                Send WriteHtmlCellHeader 'On Hand' 'Class="Header" Align="right"'
    42            Send WriteHtmlRowEnd
    43        End_Procedure // OnPageTop
    44
    45        Procedure OnBody
    46            String sText sVLink sURL
    47            Number nVendorId nUnitPrice nOnHand
    48            String sVendorName sDescription sPartId sItemId
    49
    50            Get ddValueEncode "Vendor.ID"        to nVendorID
    51            Get ddValueEncode "Vendor.Name"      to sVendorName
    52            Get ddValueEncode "Invt.Item_ID"     to sItemID
    53            Get ddValueEncode "Invt.Description" to sDescription
    54            Get ddValueEncode "Invt.Vendor_Part_ID" to sPartID
    55            Get ddValueEncode "Invt.Unit_Price"  to nUnitPrice
    56            Get ddValueEncode "Invt.On_Hand"     to nOnHand
    57
    58            Send WriteHtmlRowBegin
    59                Get AddRowIdLink sItemId to sText
    60                Send WriteHtmlCell sText 'Class="Data" Align="left"'
    61
    62                Send WriteHtmlCell sDescription 'Class="Data" Align="left"'
    63
    64                // third cell will provide a link to the Vendor ASP file.
    65                // Use the VendorName for the URL and pass VendorRowId="xxx"
    66                // as the query string
    67                Get psVendorHRef to sVLink
    68                Move (sVLink - "?RowId="- SerializeRowId(GetRowId(Vendor.File_Number))) to sUrl
    69                Get  HtmlLink sUrl (FormatNumber(nVendorID,0)) to sText
    70                Send WriteHtmlCell sText 'Class="Data" Align="right"'
    71
    72                Send WriteHtmlCell sVendorName 'Class="Data" Align="left"'
    73                Send WriteHtmlCell sPartID 'Class="Data" Align="left"'
    74                Send WriteHtmlCell (FormatNumber(nUnitPrice,2)) 'Class="Data" Align="right"'
    75                Send WriteHtmlCell (FormatNumber(nOnHand,0)) 'Class="Data" Align="right"'
    76            Send WriteHtmlRowEnd
    77        End_Procedure // OnBody
    78
    79        Procedure OnPageBottom
    80            Send WriteHtmlTableEnd
    81        End_Procedure // OnPageBottom
    82
    83        Function RunInvtList integer iIndex RowId riStart integer iMax Returns RowId
    84            RowId   riEnd
    85            Integer iStat
    86            Set piOrdering           to iIndex
    87            Set piMaxCount           to iMax
    88            Set piMaxCountBreakLevel to 0
    89            Set priStartRowId         to riStart
    90            Get DoRunReport          to iStat
    91            Get priLastRowId         to riEnd
    92            Function_return riEnd
    93        End_Function // RunInvtList
    94
    95    End_Object    // oReport
    96
    97    { Published = True  }
    98    { Description = ""  }
    99    Procedure SetHRefName String sName
   100        Set psHRefname Of oReport To sName
   101    End_Procedure // SetHRefName
   102
   103    { Published = True  }
   104    { Description = ""  }
   105    Procedure SetVendorHRefName String sName
   106        Set psVendorHRef Of oReport To sName
   107    End_Procedure
   108
   109    // Public: can be used to determine if INVT should be constrained to Vendor
   110    //         Remember that this DDO is used for data entry and reports. So if
   111    //         you set a constraint for the report you might want to remember to
   112    //         clear it when you are done
   113    { Published = True  }
   114    { Description = ""  }
   115    Procedure ConstrainVendor Integer bState
   116        Integer iFile
   117
   118        If bState Move Vendor.File_Number To iFile
   119        Else      Move 0 To iFile
   120        Set Constrain_File Of Invt_DD To iFile
   121        Send Rebuild_Constraints Of Invt_DD
   122        Set pbConstrained To bState
   123    End_Procedure
   124
   125    { Published = True  }
   126    { Description = ""  }
   127    Function RunInvtList Integer iIndex string Start Integer iMax Returns string
   128        RowId   riEnd
   129        Integer bOld
   130
   131        // make sure constraints are off - we want all
   132        Get pbConstrained To bOld
   133        Send ConstrainVendor False
   134        Get RunInvtList Of oReport iIndex (DeSerializeRowId(Start)) iMax To riEnd
   135        // restore contraints
   136        Send ConstrainVendor bOld
   137        Function_Return (SerializeRowId(riEnd))
   138    End_Function // RunInvtList
   139
   140    // Run report for all Invt items for passed vendor.
   141    // Pass: VendorRowId,ASP name of Invt and Vendor URLs
   142    //
   143    // Called from ASP: bpo.dffunc "msg_RunInvtReport" Index "Invt.asp" "Vendor.asp"
   144    { Published = True  }
   145    { Description = ""  }
   146    Procedure RunVndrInvtList String sVndr
   147       Integer bFound
   148       Integer bOld
   149       Integer iIndex
   150       RowId   riEnd riStart
   151       String sName sPhone sId
   152
   153       // find the passed Vendor rowid
   154       Get ddFindbyRowId "Vendor" sVndr To bFound
   155       If Not (bFound) Procedure_Return // no vendor...error
   156
   157       Move 2 To iIndex  // index is always 2 - by vendor id
   158       // turn on relates to contraints for report
   159       Get pbConstrained To bOld
   160       Send ConstrainVendor True
   161
   162       // generate a header with current vendor to be printed
   163       Get ddValueEncode "Vendor.ID" To sID
   164       Get ddValueEncode "Vendor.Name" To sName
   165       Get ddValueEncode "Vendor.Phone_Number" To sPhone
   166       Send WriteHtml ("
" + sID + " - " + ; 167 sName+"  " + ; 168 sPhone+"
"
) 169 170 Send Find of Invt_DD GE 2 171 If not (Found); 172 Send WriteHtml ("
No Inventory Items found for this Vendor
"
) 173 Else; 174 Get RunInvtList Of oReport iIndex (nullrowid()) 0 To riEnd 175 176 // restore old constraints 177 Send ConstrainVendor bOld 178 End_Procedure 179 180 // Register WBO interfaces 181 Send RegisterStandardInterface 182 // Send RegisterDebugInterface 183 // Send RegisterFullErrorInterface 184 // Send RegisterAutoEntryInterface 185 186End_Object // oInvt 187