VERSION 5.00
Object = "{F39CBE5C-2D1B-11D6-8D4A-0050043A2E60}#2.0#0"; "ProgBarProzent.ocx"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_Cuponeras_Pdtes 
   Caption         =   "Nuevas Cuponeras"
   ClientHeight    =   7470
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   12090
   Icon            =   "Form_Cuponeras_Pdtes.frx":0000
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7470
   ScaleWidth      =   12090
   Begin VB.CommandButton Btn_Salir 
      Caption         =   "Salir"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   7320
      TabIndex        =   5
      Top             =   6960
      Width           =   1455
   End
   Begin VB.CommandButton Btn_Imprimir 
      Caption         =   "Imprimir"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5520
      TabIndex        =   4
      Top             =   6960
      Width           =   1455
   End
   Begin VB.CommandButton Btn_Act_Pendientes 
      Caption         =   "Actualizar"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3720
      TabIndex        =   3
      Top             =   6960
      Width           =   1455
   End
   Begin VB.Frame Frame_Cup_Pendientes 
      Caption         =   "Alertas de Cuponeras según movimientos de matrícula"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   6735
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   11775
      Begin MSHierarchicalFlexGridLib.MSHFlexGrid Grd_Cup_Pendientes 
         Height          =   5775
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   11535
         _ExtentX        =   20346
         _ExtentY        =   10186
         _Version        =   393216
         BackColorSel    =   16761024
         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
         _NumberOfBands  =   1
         _Band(0).Cols   =   2
      End
      Begin ProgBarProzent.ProgBar ProgBar_Pendientes 
         Height          =   375
         Left            =   120
         TabIndex        =   2
         Top             =   6240
         Width           =   11535
         _ExtentX        =   20346
         _ExtentY        =   661
      End
   End
End
Attribute VB_Name = "Form_Cuponeras_Pdtes"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Btn_Act_Pendientes_Click()
Call CasosPendientes
End Sub

Function CasosPendientes() As Integer
Dim accion As String, Mes As Integer, MontoMes As Long, MontoCupon As Variant
Call IniGrillaPendientes
Set RsAux = New ADODB.Recordset
RsAux.CursorLocation = adUseClient
RsAux.Open "select min(fm.mes) as desde, max(fm.mes) as hasta, f.run_apo, f.forma_pago, concat(a.noms_apo,' ',a.ape1_apo,' ',a.ape2_apo)as nombreapo, fm.folio_mens, fm.agno, fm.monto_mens, h.nombre, f.fech_modificacion from fnza_apoderado_revisar f, apoderados a , fnza_mensualidad fm, hist_cod_colegio h where f.run_apo=a.rut_apo and f.folio_mens=fm.folio_mens and h.colegio=fm.colegio group by f.run_apo order by h.nombre, f.fech_modificacion, f.run_apo, f.folio_mens", conn
Me.ProgBar_Pendientes.Zusatztext = "% Procesado"
Me.ProgBar_Pendientes.ShowProgress 0
Me.ProgBar_Pendientes.MaxValue = RsAux.RecordCount
If RsAux.RecordCount > 0 Then
    For t = 1 To RsAux.RecordCount
        If UCase(RsAux!forma_pago) = "SINALUMNO" Then
            accion = "ELIMINAR"
        Else
            Set rs = New ADODB.Recordset: rs.CursorLocation = adUseClient
            rs.Open "select * from fnza_cuponeras fc, fnza_deta_cupones fd where fc.folio_cuponera=fd.folio_cuponera and fc.rut_apo='" & RsAux!run_apo & "' and fd.mes =" & Mes & " and (fd.estado <>'EL' and fd.estado <>'NU')", conn
            If rs.RecordCount > 0 Then
                'if ucase(fd!estado)="PA"' Si cupon pagado???
                MontoCupon = rs!Valor
                accion = "MODIFICAR"
            Else
                MontoCupon = "No Existe"
                accion = "GENERAR"
            End If
            rs.Close: Set rs = Nothing
        End If
        Me.Grd_Cup_Pendientes.AddItem ""
        Me.Grd_Cup_Pendientes.TextMatrix(t, 0) = t
        Me.Grd_Cup_Pendientes.TextMatrix(t, 1) = RsAux!nombre
        Me.Grd_Cup_Pendientes.TextMatrix(t, 2) = RsAux!fech_modificacion
        Me.Grd_Cup_Pendientes.TextMatrix(t, 3) = accion
        Me.Grd_Cup_Pendientes.TextMatrix(t, 4) = MesIngresoContable(RsAux!fech_modificacion) '  MesATexto(rsaux!desde)
        Me.Grd_Cup_Pendientes.TextMatrix(t, 5) = MesATexto(RsAux!Hasta)
        Me.Grd_Cup_Pendientes.TextMatrix(t, 6) = RsAux!run_apo
        Me.Grd_Cup_Pendientes.TextMatrix(t, 7) = RsAux!nombreapo
        Me.Grd_Cup_Pendientes.TextMatrix(t, 8) = MontoCupon
        Me.Grd_Cup_Pendientes.TextMatrix(t, 9) = RsAux!Monto_Mens
        Me.Grd_Cup_Pendientes.TextMatrix(t, 10) = RsAux!Folio_Mens
        RsAux.MoveNext
        Me.ProgBar_Pendientes.ShowProgress t + 0
        DoEvents
    Next t
End If
RsAux.Close
Set RsAux = Nothing
End Function
Sub IniGrillaPendientes()
Me.Grd_Cup_Pendientes.Redraw = True
Me.Grd_Cup_Pendientes.Clear
Me.Grd_Cup_Pendientes.Rows = 2
Me.Grd_Cup_Pendientes.Cols = 11
Me.Grd_Cup_Pendientes.FixedCols = 0
Me.Grd_Cup_Pendientes.FixedRows = 1
                            '            0        1         2          3         4        5         6             7             8        9        10
Me.Grd_Cup_Pendientes.FormatString = "^ Item | Empresa  |Fec.Alerta|^ Acción |^ Desde |^ Hasta |^ Rut Apo |Nombre Apoderado |$ Actual|$ Nuevo|Folio_Mens"
Me.Grd_Cup_Pendientes.ColWidth(0) = 500 ' Item
Me.Grd_Cup_Pendientes.ColWidth(1) = 1800 ' Colegio
Me.Grd_Cup_Pendientes.ColWidth(2) = 800 ' Fecha Alerta
Me.Grd_Cup_Pendientes.ColWidth(3) = 1000 ' Acción
Me.Grd_Cup_Pendientes.ColWidth(4) = 800 ' Desde
Me.Grd_Cup_Pendientes.ColWidth(5) = 800 ' Hasta
Me.Grd_Cup_Pendientes.ColWidth(6) = 1000 ' Rut Apo
Me.Grd_Cup_Pendientes.ColWidth(7) = 3500 ' Nombre
Me.Grd_Cup_Pendientes.ColWidth(8) = 900 ' Monto Actual
Me.Grd_Cup_Pendientes.ColWidth(9) = 900 ' Monto Nuevo
Me.Grd_Cup_Pendientes.ColWidth(10) = 0 ' Folio_Mens

End Sub

Private Sub Btn_Imprimir_Click()
    Call CreaBD(DirAplicacion & "\rpt\cuptemp.mdb")
    Call CreaTabla(DirAplicacion & "\rpt\cuptemp.mdb", "Detalles", "11,10")
    Call RptGrillaTextH(Grd_Cup_Pendientes, Grd_Cup_Pendientes.Rows - 1, "\rpt\cuptemp.mdb", "Detalles")
    Titulo = "ALERTAS SEGÚN MOVIMIENTOS DE MATRÍCULA"
    Nombrecol = devuelvecampo("establecimientos", "", "nom_est", "nom_est <> ''", conn)
    Direccol = devuelvecampo("establecimientos", "", "dir_est", "dir_est <> ''", conn)
    ComunaCol = devuelvecampo("establecimientos", "", "localidad_est", "localidad_est <> ''", conn)
    Form_main.CrystalReport.WindowTitle = Titulo
    Form_main.CrystalReport.Formulas(0) = "nomcol = '" & Nombrecol & "'"
    Form_main.CrystalReport.Formulas(1) = "dircol = '" & Direccol & "'"
    Form_main.CrystalReport.Formulas(2) = "comunacol = '" & ComunaCol & "'"
    Form_main.CrystalReport.Formulas(3) = "titulo= '" & Titulo & "'"
    Form_main.CrystalReport.Formulas(4) = "hora = '" & Time & "'"
    Form_main.CrystalReport.ReportFileName = DirAplicacion & "\rpt\CuponerasMov.rpt"
    Form_main.CrystalReport.DataFiles(0) = DirAplicacion & "\rpt\cuptemp.mdb"
    Form_main.CrystalReport.WindowState = crptMaximized
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Form_main.CrystalReport.Action = 1
    Form_main.CrystalReport.ReplaceSelectionFormula ("")
    Call LimpiaFormulas(Form_main.CrystalReport, 20)
    'Kill (DirAplicacion & "\rpt\cuptemp.mdb")
End Sub

Private Sub Btn_Salir_Click()
Unload Me
End Sub

Private Sub Form_Load()
Me.Width = 11940
Me.Height = 7950
Me.Show
Call Btn_Act_Pendientes_Click
End Sub
