VERSION 5.00
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.Form BaseItem_main 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   8175
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   11865
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Moveable        =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   8175
   ScaleWidth      =   11865
   ShowInTaskbar   =   0   'False
   Begin Project1.CTreeView tv_BI_Outline 
      Height          =   6370
      Left            =   0
      TabIndex        =   17
      Top             =   1800
      Width           =   3075
      _ExtentX        =   5424
      _ExtentY        =   11245
   End
   Begin VB.CommandButton cmd_Estimate 
      Caption         =   "cmd_Estimate"
      Height          =   396
      Left            =   10380
      TabIndex        =   16
      Top             =   0
      Width           =   1455
   End
   Begin VB.CommandButton cmd_Media 
      Caption         =   "cmd_Media"
      Height          =   396
      Left            =   8940
      TabIndex        =   15
      Top             =   0
      Width           =   1455
   End
   Begin VB.CommandButton cmd_Area 
      Caption         =   "cmd_Area"
      Height          =   396
      Left            =   7500
      TabIndex        =   14
      Top             =   0
      Width           =   1455
   End
   Begin VB.CommandButton cmd_Marketing 
      Caption         =   "cmd_Marketing"
      Height          =   396
      Left            =   6060
      TabIndex        =   13
      Top             =   0
      Width           =   1455
   End
   Begin VB.CommandButton cmd_Logistic 
      Caption         =   "cmd_Logistic"
      Height          =   396
      Left            =   4620
      TabIndex        =   12
      Top             =   0
      Width           =   1455
   End
   Begin VB.CommandButton cmd_General 
      Caption         =   "cmd_General"
      Height          =   396
      Left            =   3180
      TabIndex        =   11
      Top             =   0
      Width           =   1455
   End
   Begin VB.Frame Frame1 
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   1095
      Left            =   0
      TabIndex        =   4
      Top             =   660
      Width           =   3075
      Begin VB.ComboBox cbo_Dropped 
         ForeColor       =   &H00000000&
         Height          =   315
         ItemData        =   "BI_MAIN.frx":0000
         Left            =   1440
         List            =   "BI_MAIN.frx":0002
         Style           =   2  'Dropdown List
         TabIndex        =   6
         Top             =   60
         Width           =   1575
      End
      Begin VB.ComboBox cbo_year 
         ForeColor       =   &H00000000&
         Height          =   315
         ItemData        =   "BI_MAIN.frx":0004
         Left            =   1440
         List            =   "BI_MAIN.frx":0006
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   420
         Width           =   1575
      End
      Begin VB.Label lbl_View 
         Caption         =   "lbl_View"
         Height          =   255
         Left            =   60
         TabIndex        =   10
         Top             =   840
         Width           =   1305
      End
      Begin MSForms.ComboBox cbo_View 
         Height          =   315
         Left            =   1440
         TabIndex        =   9
         Top             =   780
         Width           =   1575
         VariousPropertyBits=   679495707
         DisplayStyle    =   7
         Size            =   "2778;556"
         MatchEntry      =   0
         ShowDropButtonWhen=   2
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
      End
      Begin VB.Label lbl_period 
         Caption         =   "lbl_periods"
         Height          =   255
         Left            =   60
         TabIndex        =   8
         Top             =   480
         Width           =   1815
      End
      Begin VB.Label lbl_Dropped 
         Caption         =   "lbl_Dropped"
         Height          =   255
         Left            =   75
         TabIndex        =   7
         Top             =   120
         Width           =   1380
      End
   End
   Begin VB.PictureBox ssp_ico 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ClipControls    =   0   'False
      ForeColor       =   &H80000008&
      Height          =   665
      Left            =   0
      ScaleHeight     =   630
      ScaleWidth      =   3045
      TabIndex        =   0
      Top             =   0
      Width           =   3075
      Begin VB.PictureBox pic_search 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "BI_MAIN.frx":0008
         DrawStyle       =   5  'Transparent
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   1800
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   3
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   2400
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   2
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox Picoutl_refresh 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H00FFFFFF&
         Height          =   480
         Left            =   40
         ScaleHeight     =   472.615
         ScaleLeft       =   20
         ScaleMode       =   0  'User
         ScaleWidth      =   472.615
         TabIndex        =   1
         Top             =   60
         Width           =   480
      End
   End
End
Attribute VB_Name = "BaseItem_main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim ms_Dropped As String, ms_Year As String
Dim mb_Refresh As Boolean
Dim mb_BILockEvents As Boolean

Public Property Let BILockEvents(ByVal ab_lock As Boolean)
    mb_BILockEvents = ab_lock
End Property

Public Property Get BILockEvents() As Boolean
    BILockEvents = mb_BILockEvents
End Property

Private Sub cbo_Dropped_Click()

    If cbo_Dropped.Visible Then
        MouseOff
        Select Case cbo_Dropped.ItemData(cbo_Dropped.ListIndex)
        Case 0
            ms_Dropped = "N"
        Case 1
            ms_Dropped = "Y"
        Case 2
            ms_Dropped = " "
        End Select
        tv_BI_Outline.s_FilterValue(1) = ms_Dropped
        If mb_Refresh Then
            tv_BI_Outline.UpdateComboView
        End If
        MouseOn
    End If

End Sub

Private Sub Cbo_View_Click()

' Allow Media display only on default vue
Select Case LCase(Cbo_View.Column(2))
    Case "default": cmd_Media.Enabled = OK
    Case Else:
        cmd_Media.Enabled = KO
        If gs_ItemView = "Media" Then gs_ItemView = "General"
End Select

    If mb_Refresh Then
        MouseOff
        tv_BI_Outline.UpdateComboView
        MouseOn
    End If
End Sub

Private Sub cbo_year_Click()

    If cbo_year.Visible Then
        MouseOff
        Unload BaseItem_detail
        ms_Year = cbo_year
        If ms_Year = "All periods" Then
            ms_Year = ""
        End If
        tv_BI_Outline.s_FilterValue(2) = ms_Year
        If mb_Refresh Then
            tv_BI_Outline.UpdateComboView
        End If
        MouseOn
    End If

End Sub

Private Sub cbo_year_DropDown()

    MouseOff
    If cbo_year.ListCount = 0 Then
        FillCboYear
    End If
    MouseOn

End Sub

Private Sub cmd_Area_Click()
    MouseOff
    gs_ItemView = "Area"
    View_Screen
    MouseOn
End Sub

Private Sub cmd_Estimate_Click()
    MouseOff
    gs_ItemView = "Estimate"
    View_Screen
    MouseOn
End Sub

Private Sub cmd_General_Click()
    MouseOff
    gs_ItemView = "General"
    View_Screen
    MouseOn
End Sub

Private Sub cmd_Logistic_Click()
    MouseOff
    gs_ItemView = "Logistic"
    View_Screen
    MouseOn
End Sub

Private Sub cmd_Marketing_Click()
    MouseOff
    gs_ItemView = "Marketing"
    View_Screen
    MouseOn
End Sub

Private Sub cmd_Media_Click()
    MouseOff
    gs_ItemView = "Media"
    View_Screen
    MouseOn
End Sub

Private Sub Form_Load()
Dim lo_TempPicture As Object

    On Error GoTo Form_Load_Err
    
    MouseOff
    
    Debug.Print frmMain.Top, frmMain.Left

    Top = 800 + frmMain.Top
    Left = 60 + frmMain.Left
    
    If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me
    
    Picoutl_refresh.Picture = LoadResPicture(RES_REFRESH, 1)
    pic_search.Picture = LoadResPicture(RES_SEARCH, 1)
    pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
    gs_ItemView = "General"
    cmd_General.FontBold = OK
    gi_ChoosenTab = 0
    mb_Refresh = OK
    BILockEvents = KO
    GetConstants
    
    cbo_Dropped.ListIndex = ComboFindItemData(cbo_Dropped, 0)
    ms_Dropped = "N"
    FillCboYear
    cbo_year.ListIndex = ComboFindItem(cbo_year, Format(Year(Date), "0000"))
    If cbo_year.ListIndex = -1 Then
        ms_Year = ""
    Else
        ms_Year = cbo_year
    End If
    
    Set lo_TempPicture = LoadResPicture(RES_OUTLINEFOLDER, 0)
    tv_BI_Outline.ListImageAdd "RES" & CStr(RES_OUTLINEFOLDER), lo_TempPicture
    
    Set lo_TempPicture = LoadResPicture(RES_OUTLINELEAF, 0)
    tv_BI_Outline.ListImageAdd "RES" & CStr(RES_OUTLINELEAF), lo_TempPicture
    
    Set lo_TempPicture = LoadResPicture(RES_OUTLINEVOID, 0)
    tv_BI_Outline.ListImageAdd "RES" & CStr(RES_OUTLINEVOID), lo_TempPicture
    
    Set tv_BI_Outline.o_ViewCombo = Cbo_View
    tv_BI_Outline.b_FirstLevelInCombo = OK
    tv_BI_Outline.s_DefaultComboView = "Default"
    tv_BI_Outline.s_SearchReq = "Exec BaseItem_lst '$1$', '$2$', '$3$','$4$', '$6$', '$7$' "
    
    tv_BI_Outline.i_OutlineFilterCount = 3
    tv_BI_Outline.s_FilterValue(1) = ms_Dropped
    tv_BI_Outline.s_FilterValue(2) = ms_Year
    tv_BI_Outline.s_FilterValue(3) = gs_BIType
    tv_BI_Outline.s_LanguageCode = gut_LangLogin.Code
    tv_BI_Outline.s_ParamSystem = gs_TableName
    tv_BI_Outline.Reinit
    
    MCombo_CodeSelect(Cbo_View) = "T1"
    
    MouseOn
    Exit Sub

Form_Load_Err:
    StdError
End Sub

Private Sub Form_Unload(Cancel As Integer)

    MouseOff
    Unload BI_Area
    Unload BaseItem_detail
    Unload BaseItemLogistic_detail
    Unload BaseItemMarketing_detail
    Unload C_media
    Unload BI_Estimate
    frmMain.AllMenuEnabled
    SetOwner Me.hwnd, gl_BaseItemOldHwnd
    MouseOn

End Sub

Private Sub FillCboYear()
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer

    On Error GoTo FillCboYear_Err
    
    cbo_year.Clear
    ls_req = "EXEC Item_Activity_cbo"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            cbo_year.AddItem ODBCData(ll_Statement, 1)
        End If
    Loop
    'Clear the statement handle
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    cbo_year.AddItem "All periods"
    Exit Sub
    
FillCboYear_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Sub

Private Sub GetConstants()
Dim ll_Statement As Long
Dim ls_req As String, ls_Field As String, ls_Text As String
Dim li_Status As Integer
Dim ls_Title As String
   
    On Error GoTo GetConstants_Err
    
    Select Case gs_BIType
    Case "STD": ls_Title = frmMain.GetMenuCtrl(frmMain.mnu_subProducts, "PST").Caption  ' frmMain.mnu_Standard.Caption      ' task 415
    Case "SPC": ls_Title = frmMain.GetMenuCtrl(frmMain.mnu_subProducts, "PSP").Caption  'frmMain.mnu_Special.Caption        ' task 415
    Case "SSTD": ls_Title = frmMain.GetMenuCtrl(frmMain.mnu_subProducts, "PSE").Caption 'frmMain.mnu_SemiSpecial.Caption    ' task 415
    End Select
    cbo_Dropped.Clear
    ls_req = "EXEC Screen_Csts 'baseitm_outl','" & gut_LangLogin.Code & "'"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Field = ODBCData(ll_Statement, 1)
            ls_Text = ODBCData(ll_Statement, 2)
            Select Case ls_Field
            Case "title"
                Caption = ls_Title & " " & ls_Text
            Case "sso_dropp"
                cbo_Dropped.AddItem ls_Text
                cbo_Dropped.ItemData(cbo_Dropped.NewIndex) = 1
                lbl_Dropped = ls_Text
            Case "sso_ndropp"
                cbo_Dropped.AddItem ls_Text
                cbo_Dropped.ItemData(cbo_Dropped.NewIndex) = 0
            Case "lbl_period"
                lbl_period.Caption = ls_Text
            Case "sso_all"
                cbo_Dropped.AddItem ls_Text
                cbo_Dropped.ItemData(cbo_Dropped.NewIndex) = 2
            Case "lbl_View"
                lbl_View.Caption = ls_Text
            Case "cmd_general"
                cmd_General.Caption = ls_Text
            Case "cmd_logistic"
                cmd_Logistic.Caption = ls_Text
            Case "cmd_marketing"
                cmd_Marketing.Caption = ls_Text
            Case "cmd_area"
                cmd_Area.Caption = ls_Text
            Case "cmd_media"
                cmd_Media.Caption = ls_Text
            Case "cmd_estimate"
                cmd_Estimate.Caption = ls_Text
            End Select
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
    
GetConstants_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Sub

Private Sub pic_quit_Click()

    MouseOff
    Unload Me
    MouseOn

End Sub

Private Sub pic_search_Click()

    MouseOff
    gs_Path = ""
    BaseItem_search.show 1
    If gs_Path <> "" Then
        mb_Refresh = KO
        cbo_Dropped.ListIndex = ComboFindItemData(cbo_Dropped, 2)
        cbo_year.ListIndex = ComboFindItem(cbo_year, "All periods")
        mb_Refresh = OK
        tv_BI_Outline.Reinit
        tv_BI_Outline.ClearLeafCode
        MCombo_CodeSelect(Cbo_View) = "T1"
        tv_BI_Outline.SearchLeaf gs_Path
    End If
    MouseOn

    

End Sub

Public Sub Picoutl_refresh_Click()
Dim ls_path As String
Dim li_Count As Integer
    
    MouseOff
    ls_path = tv_BI_Outline.GetPath
    tv_BI_Outline.Reinit
    If ls_path <> "" Then
        tv_BI_Outline.SetPath ls_path
    End If
    MouseOn

End Sub

' reinitialize tv_BI_Outline and navigate to leaf
' 26.05.2005 julo - tv repositioning
Public Sub SearchLeaf(ByVal as_leafID As String)
    ' reinit treeview
On Error GoTo ErrorHandler
    Dim lb_oldEvents As Boolean
    lb_oldEvents = BILockEvents
    If as_leafID <> "" Then
        Dim ls_Code_aux As String
        BILockEvents = OK
        ls_Code_aux = MCombo_GetCode(Cbo_View)
        tv_BI_Outline.Reinit
        tv_BI_Outline.ClearLeafCode
        If ls_Code_aux <> "" Then
            MCombo_CodeSelect(Cbo_View) = ls_Code_aux
        Else
            MCombo_CodeSelect(Cbo_View) = "T1"              ' general
        End If
        tv_BI_Outline.SearchLeaf as_leafID
        BILockEvents = lb_oldEvents
    End If
    Exit Sub
ErrorHandler:
        BILockEvents = lb_oldEvents
        Call Err.Raise(Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext)
End Sub

Private Sub View_Screen()
Dim ls_Category As String
Dim ls_Material As String
Dim ls_Family As String
Dim ls_Edge As String
Dim ls_path As String
Dim la_Bold As Variant

    ls_path = tv_BI_Outline.GetPath
    gs_SAPCode = OutlinePathPart(ls_path, 7)
    gs_CGCode = OutlinePathPart(ls_path, 3)
    
Select Case gs_CGCode
Case "C002", "C004"
    cmd_Estimate.Enabled = True
Case Else
    cmd_Estimate.Enabled = False
    If gs_ItemView = "Estimate" Then cmd_General_Click
End Select
    
    Unload BI_Area
    Unload BaseItem_detail
    Unload BaseItemLogistic_detail
    Unload BaseItemMarketing_detail
    Unload C_media
    Unload BI_Estimate
    
    la_Bold = Array(KO, KO, KO, KO, KO, KO)
    
    Select Case gs_ItemView
        Case "Area":    la_Bold(3) = OK
        Case "General": la_Bold(0) = OK
        Case "Logistic": la_Bold(1) = OK
        Case "Marketing": la_Bold(2) = OK
        Case "Media":   la_Bold(4) = OK
        Case "Estimate": la_Bold(5) = OK
    End Select
    
    cmd_General.FontBold = la_Bold(0)
    cmd_Logistic.FontBold = la_Bold(1)
    cmd_Marketing.FontBold = la_Bold(2)
    cmd_Area.FontBold = la_Bold(3)
    cmd_Media.FontBold = la_Bold(4)
    cmd_Estimate.FontBold = la_Bold(5)
        
    If (gs_ItemView = "Media" And gs_CGCode <> "") Or gs_SAPCode <> "" Then
        Select Case gs_ItemView
            Case "Area": BI_Area.show , BaseItem_main
            Case "General": BaseItem_detail.show , BaseItem_main
            Case "Logistic": BaseItemLogistic_detail.show , BaseItem_main
            Case "Marketing": BaseItemMarketing_detail.show , BaseItem_main
            Case "Media"
                gut_Param2.Str1 = "Display"
                If gs_SAPCode <> "" Then
                    gut_Param2.Str2 = "EXEC Media_Product_Classif_cnt2 '" & gs_SAPCode & "'"
                    gut_Param2.Str3 = "EXEC Media_t_lst2 '" & gs_SAPCode & "', '" & gut_LangWork.Code & "'"
                    gut_Param2.Str6 = "EXEC Media_All_t_lst2 '" & gs_SAPCode & "', '" & gut_LangWork.Code & "'"
                Else
                    ls_Category = OutlinePathPart(ls_path, 3)
                    ls_Material = OutlinePathPart(ls_path, 4)
                    ls_Family = OutlinePathPart(ls_path, 5)
                    ls_Edge = OutlinePathPart(ls_path, 6)
                    gut_Param2.Str2 = "EXEC Media_Product_Classif_cnt3 '" & ls_Category & "','" & ls_Material & "','" & ls_Family & "','" & ls_Edge & "', '" & gut_LangWork.Code & "'"
                    gut_Param2.Str3 = "EXEC Media_t_lst3 '" & gs_CGCode & "','" & ls_Material & "','" & ls_Family & "','" & ls_Edge & "', '" & gut_LangWork.Code & "'"
                    If ls_Material <> "" Then
                        gut_Param2.Str6 = "EXEC Media_All_1_t_lst3 '" & gs_CGCode & "', '" & gut_LangWork.Code & "'"
                        If ls_Family <> "" Then
                            gut_Param2.Str6 = "EXEC Media_All_2_t_lst3 '" & gs_CGCode & "', '" & ls_Material & "', '" & gut_LangWork.Code & "'"
                            If ls_Edge <> "" Then
                                gut_Param2.Str6 = "EXEC Media_All_3_t_lst3 '" & gs_CGCode & "','" & ls_Material & "', '" & ls_Family & "', '" & gut_LangWork.Code & "'"
                            End If
                        End If
                    Else
                        gut_Param2.Str6 = ""
                    End If
                End If
                gut_Param2.Str4 = Caption
                gut_Param2.Str5 = tv_BI_Outline.GetPathDesc
                C_media.show , BaseItem_main
            Case "Estimate": BI_Estimate.show , BaseItem_main
        End Select
    End If

End Sub

Private Sub tv_BI_Outline_EvtLeafClick(ByVal ls_OutLineCode As String, ByVal ls_OutlineDesc As String)
    
    On Error GoTo tv_BI_Outline_EvtLeafClick_Err
    
    If mb_BILockEvents Then Exit Sub

    MouseOff
    If gs_ItemView = "" Then Exit Sub
    View_Screen
    MouseOn
    Exit Sub
    
tv_BI_Outline_EvtLeafClick_Err:
    MouseOn
    Select Case Err.Number - C_ERRORRAISE ' Evaluate error number.
    Case 28
        SendMessage 9, "Too many branches on tree.", gut_LangLogin.Code
    Case Else
        StdError
    End Select

End Sub

Private Sub tv_BI_Outline_EvtNodeClick(ByVal ls_OutLineCode As String, ByVal ls_OutlineDesc As String)

    On Error GoTo tv_BI_Outline_EvtNodeClick_Err
    
    If mb_BILockEvents Then Exit Sub
    
    Unload BI_Area
    Unload BaseItem_detail
    Unload BaseItemLogistic_detail
    Unload BaseItemMarketing_detail
    Unload C_media
    Unload BI_Estimate
        
    If gs_ItemView = "Media" And tv_BI_Outline.GetPath <> "" Then
        MouseOff
        View_Screen
        MouseOn
    End If
    
    Exit Sub
    
tv_BI_Outline_EvtNodeClick_Err:
    MouseOn
    Select Case Err.Number  ' Evaluate error number.
    Case 28
        SendMessage 9, "Too many branches on tree.", gut_LangLogin.Code
    Case Else
        StdError
    End Select

End Sub
