VERSION 5.00
Object = "{0F987290-56EE-11D0-9C43-00A0C90F29FC}#1.0#0"; "ActBar.ocx"
Object = "{B02F3647-766B-11CE-AF28-C3A2FBE76A13}#2.5#0"; "ss32x25.ocx"
Object = "{AB3877A8-B7B2-11CF-9097-444553540000}#1.0#0"; "gtdate32.ocx"
Begin VB.Form FCO2010 
   Caption         =   "Autorizaciones de Licencias"
   ClientHeight    =   4710
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11400
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Autorizaciones.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   4710
   ScaleWidth      =   11400
   Begin VB.TextBox txtBuscarNum 
      Height          =   315
      Left            =   6960
      TabIndex        =   7
      Top             =   120
      Width           =   1215
   End
   Begin VB.TextBox txtBuscarTrab 
      Height          =   315
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   1215
   End
   Begin VB.CheckBox chkDesglosar 
      Caption         =   "Incapacidades menores a 3 dias"
      Height          =   255
      Left            =   120
      TabIndex        =   6
      Top             =   3720
      Width           =   4335
   End
   Begin VB.TextBox txtBuscarPdo 
      Height          =   315
      Left            =   5385
      TabIndex        =   4
      Top             =   120
      Width           =   675
   End
   Begin VB.TextBox txtBuscarEnt 
      Height          =   315
      Left            =   3780
      TabIndex        =   2
      Top             =   120
      Visible         =   0   'False
      Width           =   600
   End
   Begin VB.TextBox txtBuscarTipo 
      Height          =   315
      Left            =   1350
      TabIndex        =   1
      Top             =   120
      Width           =   2415
   End
   Begin FPSpread.vaSpread sprDatos 
      Bindings        =   "Autorizaciones.frx":030A
      Height          =   3225
      Left            =   120
      TabIndex        =   5
      Top             =   480
      Width           =   11055
      _Version        =   131077
      _ExtentX        =   19500
      _ExtentY        =   5689
      _StockProps     =   64
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      MaxCols         =   1
      MaxRows         =   1
      SpreadDesigner  =   "Autorizaciones.frx":0320
   End
   Begin GTMaskDate.GTMaskDate GTdFecha 
      Height          =   300
      HelpContextID   =   722
      Left            =   4395
      TabIndex        =   3
      Top             =   120
      Width           =   975
      _Version        =   65537
      _ExtentX        =   1720
      _ExtentY        =   529
      _StockProps     =   77
      BackColor       =   -2147483643
      BeginProperty NullFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty CalFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty CalCaptionFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty CalDayCaptionFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty ToolTipFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ActiveBarLibraryCtl.ActiveBar abToolbar 
      Left            =   7080
      Top             =   3840
      _ExtentX        =   847
      _ExtentY        =   847
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Bands           =   "Autorizaciones.frx":0479
   End
End
Attribute VB_Name = "FCO2010"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private MBitacora As New ADAMBitacora.Bitacora
Private WithEvents clsSpread As NSpread
Attribute clsSpread.VB_VarHelpID = -1
Private MAdo As ODBC.ODBCDirecto
Private MiCx As Integer 'Conexión
Private MiX As Integer 'Ancho de la forma
Private MiY As Integer 'Alta de la forma

Private MsSqlIni As String
Private MsSql  As String
Private MsOrden As String
Private MbOrdenAsc As Boolean
Private MsAntOrden As String
Private msvista As String
Private MbRenovar  As Boolean
Private MsWhereAdi As String
Private MiKey As Integer

Private MiNumDecimales As Integer        ' Número de decimales

Private Sub abToolbar_Click(ByVal Tool As ActiveBarLibraryCtl.Tool)
    Select Case LCase(Tool.Name)
        Case "tlalta": Altas
        Case "tlbaja": Bajas
        Case "tltrabaja": TrabajarCon
        Case "tlguarda": GuardaCambios
        Case "tlordena": OrdenarDatos
        Case "tlrenueva": RenuevaDatos
        Case "tlsalida": Unload Me
    End Select
End Sub

Private Sub chkDesglosar_Click()
If chkDesglosar.Value = vbChecked Then
        msvista = "vw_fco_ausentismos_menores "
    Else
        msvista = "vw_fco_ausentismos_mayores "
    End If
    AplicaFiltros
End Sub

Private Sub Form_Activate()
If Not MDIChild Then
    WindowState = 0
    Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
End If
    
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3: Unload Me
        Case vbKeyF5: RenuevaDatos
        Case vbKeyF6: Altas
        Case vbKeyF7
            Screen.MousePointer = vbHourglass
            MBitacora.mBorra
            Screen.MousePointer = vbDefault
        Case vbKeyF11: GuardaCambios
        Case vbKeyF12: abToolbar.Bands(1).TrackPopup -1, -1
    End Select
End Sub

Private Sub Form_Load()
    GbAError = False
    Me.Tag = GiVenMax%
    Gven(Val(Me.Tag)).icx = Gicx%
    MiCx = Gven(Val(Me.Tag)).icx
    Set MAdo = Gtc(MiCx).Ado
    Me.Icon = LoadPicture(sIconoForma)
    
    'Checa nivel de seguridad
    Gven(Val(Me.Tag)).iNivSeguridad = iObtenNivSeguridad(GsOper, GsUid, MiCx)
    If Gven(Val(Me.Tag)).iNivSeguridad = 0 Then
        Screen.MousePointer = vbDefault
        Me.Top = -10000
        GbAError = True
        Exit Sub
    End If
    
    Set clsSpread = New NSpread
    GAdam.ObtieneColores
    
    If Not MDIChild Then
        WindowState = 0
        Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
        Screen.MousePointer = vbDefault
    End If
    
    'Tamaño de la forma
    If Me.WindowState = 0 Then
        MiX = 11500
        MiY = 5115
        Me.Width = MiX
        Me.Height = MiY
    End If
        
    'Decimales según panel de control
    MiNumDecimales = iNumeroDecimalesImporte
        
    Caption = GsDsn & " / " & GsCveCia & " - Autorizaciones de Incapacidades y Licencias"
    AsignaIconos abToolbar, 3, LALTA, LBAJA, LTRABAJA, LORDENA, LRENUEVA, LGUARDA, LSALIDA
    ToolInicioGrupo abToolbar, 3, True, 3, 6

    GAdam.ConfiguraFecha GTdFecha, True
    msvista = "vw_fco_ausentismos_mayores"
    MsOrden = " ORDER BY trabajador"
    CreaBitacora
    MsSqlIni = "SELECT trabajador, autorizacion, descripcion, tiempo, fecha, periodo, valor_total, numero, replace(nombre,'/',' ')as nombre, case prorroga when 0 then 'NO' when 1 then 'SI' end prorroga, cod_incapacidad"
    MsSql = MsSqlIni & " FROM " & msvista
'    " WHERE M.tipo_incapacidad = C.item And C.campo='tipo_licencia'" & _
'    " And compania='" & GsCveCia & "'" '& _
'    " And (Nvl(RTrim(sucursal),'')='' OR sucursal in (select dato from vw_fco_sucursales_cia where clase_nomina='--' or" & _
'    " clase_nomina in (select clase_nomina from rel_usu_clase_nom where usuario = '" & GsUid & "')))"
    MsWhereAdi = ""
    RenuevaDatos
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 2 Then abToolbar.Bands(1).TrackPopup -1, -1
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set MAdo = Nothing
    Set MBitacora = Nothing
    Set clsSpread = Nothing
    Gtc(MiCx).ihijas = Gtc(MiCx).ihijas - 1
    Set FCO2010 = Nothing

End Sub

Private Sub Form_Unload(Cancel As Integer)
    If GbExterno Then End
End Sub

Private Sub Altas()
    GuardaCambios
    Screen.MousePointer = vbHourglass
    'GsArgumentos_Ent(0) = "0"
    'JCL. DIC.17/04 MEALS
    GbEdicion = False
    FCO2010A.Show 1
    RenuevaDatos
End Sub

Private Sub Bajas()
    If sprDatos.VirtualMaxRows <= 0 Then Exit Sub
    MBitacora.mBorra
End Sub

Private Sub ConfiguraSpread()
    sprDatos.VisibleCols = 11
    With sprDatos
        .Visible = False
        .Action = 28
        GAdam.ConfiguracionSpread sprDatos
    
        .Row = 0:
        .Col = 1: .Text = "trabajador"
        .Col = 2: .Text = "Aut"
        .Col = 3: .Text = "Tipo"
        .Col = 4: .Text = "Dias"
        .Col = 5: .Text = "Fecha"
        .Col = 6: .Text = "Periodo"
        .Col = 7: .Text = "Valor total"
        .Col = 8: .Text = "Numero"
        .Col = 9: .Text = "Nombre Trabajador"
        .Col = 10: .Text = "Prorroga"
        .Col = 11: .Text = "Cod incapacidad"
        .Visible = True
        
        ConfiguraSpreadJCL sprDatos
        
    End With
End Sub

Private Sub CreaBitacora()
   MBitacora.mCreaBitacora sprDatos, MAdo.lhEnv, MAdo.lhDbc, MAdo.lhstmt, MAdo
   MBitacora.p_ConfirmaBaja = True
   MBitacora.mTablaSPInfo 1, "sp_fco_baja_autorizaciones", 1, 2
End Sub

Private Sub GuardaCambios()
    If sprDatos.MaxRows = 0 Then Exit Sub
    Screen.MousePointer = vbHourglass
    MbRenovar = MBitacora.mActualizaBD
    Screen.MousePointer = vbDefault
End Sub

Private Sub OrdenarDatos()
    Screen.MousePointer = vbHourglass
    If MsAntOrden = CStr(sprDatos.ActiveCol) Then
        MbOrdenAsc = Not (MbOrdenAsc)
    Else
        MbOrdenAsc = True
    End If
    MsOrden = " Order By " & CStr(sprDatos.ActiveCol) & IIf(MbOrdenAsc, "", "DESC")
    MsAntOrden = CStr(sprDatos.ActiveCol)
    RenuevaDatos
    Screen.MousePointer = vbDefault
        
End Sub

Private Sub RenuevaDatos()
    ConfiguraSpread
    
    MAdo.Sql = MsSql & MsWhereAdi & MsOrden
    If Not MAdo.SendSQL Then Exit Sub
    clsSpread.LlenaSpread 0, sprDatos, MAdo, MAdo.lhDbc, MAdo.lhstmt
    
    With sprDatos
        .ColWidth(1) = 10
        .ColWidth(2) = 6
        .ColWidth(3) = 20
        .ColWidth(4) = 5
        .ColWidth(5) = 8
        .ColWidth(6) = 6
        .ColWidth(7) = 7
        .ColWidth(8) = 10
        .ColWidth(9) = 30
        .ColWidth(10) = 9
        .ColWidth(11) = 12
        '.Col = 1: .Row = -1: .ColHidden = True
        
        .Col = 1: .Row = -1: .Lock = True
        .Col = 2: .Row = -1: .ColHidden = True
        '.Col = 2: .Row = -1: .Lock = True
        .Col = 3: .Row = -1: .Lock = True
        .Col = 4: .Row = -1: .Lock = True
        .Col = 5: .Row = -1: .Lock = True
        .Col = 6: .Row = -1: .Lock = True
        .Col = 7: .Row = -1: .Lock = True
        .Col = 8: .Row = -1: .Lock = True
        .Col = 9: .Row = -1: .Lock = True
        .Col = 10: .Row = -1: .Lock = True
        .Col = 11: .Row = -1: .Lock = True
        .Col = 2: .CellType = 3
        
        .ColsFrozen = 3
        
        .Col = 8: .Row = -1:  .CellType = 2: .TypeFloatSeparator = True:
                  .TypeFloatDecimalPlaces = MiNumDecimales: .TypeFloatMax = "99999999999999999": .TypeFloatMin = "0.00"
        
    End With
End Sub

Private Sub TrabajarCon()
    Dim Aux As Variant
    GuardaCambios
    Screen.MousePointer = vbHourglass
    'GsArgumentos_Ent(0) = "1"
    'JCL. DIC.17/04 MEALS
    GbEdicion = True
    With sprDatos
        .GetText 2, .ActiveRow, Aux
        GsCodDato = CStr(Aux)
    End With
    'FCO2010A.Show 1
    Dim alta As New FCO2010A
            alta.cargar msvista
            alta.Show
    RenuevaDatos
End Sub

Private Sub AplicaFiltros()

MsSql = MsSqlIni & " FROM " & msvista
  
  MsWhereAdi = ""
  
   If Trim(txtBuscarTrab) <> "" Then
      Select Case MiKey
          Case vbKeyReturn
              MsWhereAdi = " where trabajador Like '%" & txtBuscarTrab & "%'"
          Case 10
              MsWhereAdi = " where trabajador Like '" & txtBuscarTrab & "%'"
      End Select
  End If
                  
  If Trim(txtBuscarNum) <> "" Then
      Select Case MiKey
          Case vbKeyReturn
              MsWhereAdi = " where numero Like '%" & txtBuscarNum & "%'"
          Case 10
              MsWhereAdi = " where numero Like '" & txtBuscarNum & "%'"
      End Select
  End If
  
  If Trim(txtBuscarTipo) <> "" Then
      Select Case MiKey
          Case vbKeyReturn
              MsWhereAdi = " where descripcion Like '%" & txtBuscarTipo & "%'"
          Case 10
              MsWhereAdi = " where descripcion Like '" & txtBuscarTipo & "%'"
      End Select
  End If
  
  If Trim(txtBuscarEnt) <> "" Then
      Select Case MiKey
          Case vbKeyReturn
              MsWhereAdi = " where cod_entidad Like '%" & txtBuscarEnt & "%'"
          Case 10
              MsWhereAdi = " where cod_entidad Like '" & txtBuscarEnt & "%'"
      End Select
  End If
    
  Dim sFecha As String
  If Not IsNull(GTdFecha.DateValue) Then
     sFecha = GTdFecha.DateValue
      Select Case MiKey
          Case vbKeyReturn
              MsWhereAdi = " where fecha >= '" & Format(sFecha, "yyyymmdd") & "'"
      End Select
  End If
     
  If Trim(txtBuscarPdo) <> "" Then
      Select Case MiKey
          Case vbKeyReturn
              MsWhereAdi = " where periodo Like '%" & txtBuscarPdo & "%'"
          Case 10
              MsWhereAdi = " where periodo Like '" & txtBuscarPdo & "%'"
      End Select
  End If

  RenuevaDatos
End Sub

Private Sub GTdFecha_KeyPress(KeyAscii As Integer)
    If KeyAscii <> vbKeyReturn And KeyAscii <> 10 Then Exit Sub
    MiKey = KeyAscii
    AplicaFiltros
End Sub


Private Sub txtBuscarEnt_KeyPress(KeyAscii As Integer)
    If KeyAscii <> vbKeyReturn And KeyAscii <> 10 Then Exit Sub
    MiKey = KeyAscii
    AplicaFiltros

End Sub

Private Sub txtBuscarNum_KeyPress(KeyAscii As Integer)
    If KeyAscii <> vbKeyReturn And KeyAscii <> 10 Then Exit Sub
    MiKey = KeyAscii
    AplicaFiltros
End Sub

Private Sub txtBuscarPdo_KeyPress(KeyAscii As Integer)
    If KeyAscii <> vbKeyReturn And KeyAscii <> 10 Then Exit Sub
    MiKey = KeyAscii
    AplicaFiltros

End Sub

Private Sub txtBuscarTipo_KeyPress(KeyAscii As Integer)
    If KeyAscii <> vbKeyReturn And KeyAscii <> 10 Then Exit Sub
    MiKey = KeyAscii
    AplicaFiltros
End Sub


Private Sub txtBuscarTrab_KeyPress(KeyAscii As Integer)
If KeyAscii <> vbKeyReturn And KeyAscii <> 10 Then Exit Sub
    MiKey = KeyAscii
    AplicaFiltros
End Sub
