VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{C4DED68B-C40F-11D6-AD1A-000795CA0957}#49.0#0"; "pry_list.ocx"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form FReimpresionCierre 
   Caption         =   "Reimpresión de Cierres"
   ClientHeight    =   5655
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8985
   LinkTopic       =   "Form1"
   ScaleHeight     =   5655
   ScaleWidth      =   8985
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Height          =   5625
      Left            =   0
      TabIndex        =   0
      Top             =   -30
      Width           =   8955
      Begin VB.Frame Frame3 
         Caption         =   " Destino "
         Height          =   1125
         Left            =   6420
         TabIndex        =   13
         Top             =   3240
         Width           =   2415
         Begin VB.OptionButton optImpresora 
            Caption         =   "Impresora"
            Height          =   285
            Left            =   540
            TabIndex        =   15
            Top             =   690
            Width           =   1215
         End
         Begin VB.OptionButton optPantalla 
            Caption         =   "Pantalla"
            Height          =   285
            Left            =   540
            TabIndex        =   14
            Top             =   330
            Value           =   -1  'True
            Width           =   1515
         End
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "&Salir"
         Height          =   765
         Left            =   7710
         Picture         =   "FReimpresionCierre.frx":0000
         Style           =   1  'Graphical
         TabIndex        =   12
         Top             =   4515
         Width           =   945
      End
      Begin VB.CommandButton cmdGenerar 
         Caption         =   "&Generar"
         Height          =   765
         Left            =   6690
         Picture         =   "FReimpresionCierre.frx":030A
         Style           =   1  'Graphical
         TabIndex        =   11
         Top             =   4515
         Width           =   975
      End
      Begin VB.Frame Frame2 
         Caption         =   " Fecha de Proceso "
         Height          =   1185
         Left            =   6420
         TabIndex        =   6
         Top             =   1770
         Width           =   2415
         Begin MSComCtl2.DTPicker dtphasta 
            Height          =   315
            Left            =   840
            TabIndex        =   7
            Top             =   750
            Width           =   1365
            _ExtentX        =   2408
            _ExtentY        =   556
            _Version        =   393216
            Format          =   59113473
            CurrentDate     =   37641
         End
         Begin MSComCtl2.DTPicker dtpdesde 
            Height          =   345
            Left            =   840
            TabIndex        =   8
            Top             =   300
            Width           =   1365
            _ExtentX        =   2408
            _ExtentY        =   609
            _Version        =   393216
            Format          =   59113473
            CurrentDate     =   37641
         End
         Begin VB.Label Label5 
            Caption         =   "Hasta"
            Height          =   255
            Left            =   150
            TabIndex        =   10
            Top             =   810
            Width           =   1395
         End
         Begin VB.Label Label4 
            Caption         =   "Desde"
            Height          =   195
            Left            =   150
            TabIndex        =   9
            Top             =   390
            Width           =   1365
         End
      End
      Begin MSDataListLib.DataCombo dtcEstacion 
         Height          =   315
         Left            =   1230
         TabIndex        =   1
         Top             =   1230
         Width           =   2895
         _ExtentX        =   5106
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   "DataCombo1"
      End
      Begin pry_list.ctrl_listarray lstPtoVta 
         Height          =   2595
         Left            =   270
         TabIndex        =   3
         Top             =   2370
         Width           =   5925
         _ExtentX        =   10451
         _ExtentY        =   4577
      End
      Begin VB.Line Line1 
         X1              =   150
         X2              =   8820
         Y1              =   780
         Y2              =   780
      End
      Begin VB.Label Label3 
         BackStyle       =   0  'Transparent
         Caption         =   "Reimpresión de Cierres Z"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00404080&
         Height          =   345
         Left            =   150
         TabIndex        =   5
         Top             =   390
         Width           =   5655
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Caption         =   "Puntos de Venta"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   300
         TabIndex        =   4
         Top             =   2040
         Width           =   5835
      End
      Begin VB.Label Label1 
         Caption         =   "Estación :"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   270
         TabIndex        =   2
         Top             =   1290
         Width           =   975
      End
      Begin VB.Shape Shape1 
         Height          =   3525
         Left            =   90
         Top             =   1800
         Width           =   6255
      End
   End
End
Attribute VB_Name = "FReimpresionCierre"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' VARIABLE PARA SABER SI ES CIERREX O CIERREZ
' 1 : CierreX
' 2 : CierreZ
Dim IntTipoCierre As Integer

' VARIABLE PARA SABER SI ES TIENDA O PLAYA
' 1 : Tienda
' 2 : Playa
Dim IntLugar As Integer

' VARIABLES DE PUNTO DE VENTA,VENDEDOR y FECHA DE CIERRE (FECHA DE PROCESO)
Dim StrNroPtoVta As String
Dim StrSalesPerID As String
Dim StrFechaCierre As String
Dim IntTurno As Integer

' DATOS DE IMPRESORA
Dim IntNroSaltosLineas As Integer
Dim StrCodCorte As String
Dim IntAnchoTicket As Integer

' LINEA DE SEPARACION
Dim StrLineaSeparacion As String

' variables de cabecera de cierre
Dim StrSerieMaqReg As String
Dim StrFecha As String
Dim DblMontoTipoCambio As Double
Dim IntNroTransacciones As Integer
Dim DblTicketBolIni As Double
Dim dblTicketFacIni As Double
Dim DblValorVta As Double
Dim DblVtaNoAfecta As Double
Dim DblIGV As Double
Dim DblVtaTotal As Double
Dim IntNroTicketAnul As Integer
Dim DblTotalTicketAnul As Double
Dim DblGranTotal As Double
Dim IntNroZeta As Integer
'dim IntTurno As Integer
Dim DblTipoCambio  As Double

' variables de resumen de ventas
Dim DblTotalTicketBol As Double
Dim DblTotalTicketFac As Double
Dim DblTotalGral As Double

' variables de resumen de tipos de pago
Dim DblEfectivo As Double
Dim DblVueltoEfectivo As Double
Dim DblNetoEfectivo As Double

Dim DblTarjeta As Double
Dim DblVueltoTarjeta As Double
Dim DblNetoTarjeta As Double

Dim DblVale As Double
Dim DblVueltoVale As Double
Dim DblNetoVale As Double

' variables para monedas
Dim StrMdaBase As String
Dim StrMdaCaja As String
Dim StrSimbMdaCaja As String
Dim StrSimbMdaExt As String

' cabeceras de ticket
Dim StrCab1 As String, StrCab2 As String, StrCab3 As String, StrCab4 As String, _
    StrCab5 As String

' variable de comprobacion de error
Dim BlnOK As Boolean
'''***********************************************************

Public objAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Public objPtoVta As DB_INV_MANTENIMIENTOS.C_PTOVTA

Private Sub cmdGenerar_Click()
    Reimprimir
End Sub

Private Sub cmdSalir_Click()
    Unload Me
End Sub

Private Sub dtcEstacion_Change()
On Error GoTo errhandler
    Call Actualiza_lstPtoVta(Trim(dtcEstacion.BoundText))
    Exit Sub
errhandler:
End Sub

Private Sub Form_Load()
    Call InstanciaObjetos
    Call CargaDataCombo(dtcEstacion, objAlmacen.ListarAlmacenes, "SiteId", "Name")
    
    lstPtoVta.Size 15, 27
    
    dtpdesde.Value = Date
    dtphasta.Value = Date
End Sub

Public Sub CargaDataCombo(objDataCombo As DataCombo, rsSource As Recordset, istrCampo1 As String, istrCampo2 As String)

    Set objDataCombo.DataSource = rsSource
    objDataCombo.DataField = istrCampo2
    Set objDataCombo.RowSource = rsSource
    objDataCombo.ListField = istrCampo2
    objDataCombo.BoundColumn = istrCampo1
    
    If Not rsSource.EOF Then
        objDataCombo.BoundText = rsSource.Fields(istrCampo2)
    End If

End Sub

Public Sub Actualiza_lstPtoVta(StrSiteId As String)
On Error GoTo errhandler
    'If rsPtoVta.State = 1 Then rsPtoVta.Close
    lstPtoVta.Size 15, 27
    lstPtoVta.llena_lista objPtoVta.ListarPtoVta(StrSiteId)
    Exit Sub
errhandler:
    Err.Raise Err.Number, "PryVentasCombustible.Actualiza_lstPtoVta", Err.Description
End Sub

Private Sub InstanciaObjetos()
    Set objAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    Set objPtoVta = New DB_INV_MANTENIMIENTOS.C_PTOVTA
End Sub

Sub Reimprimir()
    Dim StrCierre As String
   
    Dim MobjTipoCambio As DB_OP_FACTURACION.C_VENTASGENERAL
    Dim MobjCierre As UTIL_SETUP.REIMPRESIONCIERRE
    
    Set MobjTipoCambio = New DB_OP_FACTURACION.C_VENTASGENERAL
    Set MobjCierre = New UTIL_SETUP.REIMPRESIONCIERRE
        
        Limpiar_Variables
    
        If optImpresora.Value = True Then
            ' 1 : por impresora  <------------------------------¸
            StrCierre = MobjCierre.reimpresion(lstPtoVta.listar_codigos_seleccionados, dtpdesde.Value, dtphasta.Value, IntTipoCierre, IntLugar, StrNroPtoVta, _
            StrSalesPerID, StrFechaCierre, IntTurno, IntNroSaltosLineas, _
            StrCodCorte, IntAnchoTicket, StrLineaSeparacion, StrSerieMaqReg, _
            StrFecha, DblMontoTipoCambio, IntNroTransacciones, DblTicketBolIni, _
            dblTicketFacIni, DblValorVta, DblVtaNoAfecta, DblIGV, DblVtaTotal, _
            IntNroTicketAnul, DblTotalTicketAnul, DblGranTotal, IntNroZeta, _
            DblTotalTicketBol, DblTotalTicketFac, DblTotalGral, _
            DblEfectivo, DblVueltoEfectivo, DblNetoEfectivo, DblTarjeta, _
            DblVueltoTarjeta, DblNetoTarjeta, DblVale, DblVueltoVale, _
            DblNetoVale, StrMdaBase, StrMdaCaja, StrSimbMdaCaja, StrSimbMdaExt, _
            StrCab1, StrCab2, StrCab3, StrCab4, StrCab5, BlnOK, GintDecResultado, GintDecStock)
    
            Printer.Print StrCierre
            Printer.EndDoc
                    
            ' actualiza el campo STKCLOSEDX=1 si no hubo fallas
            BlnOK = MobjCierre.MensajeOK
                    
            If BlnOK Then
                MsgBox "Proceso de Cierre Z realizado", vbInformation, "Mensaje"
            Else
                MsgBox "Proceso de Cierre Z fallido", vbInformation, "Mensaje"
            End If
        Else
            ' 2 : por pantalla  <-------------------------------¸
            StrCierre = MobjCierre.reimpresion(lstPtoVta.listar_codigos_seleccionados, dtpdesde.Value, dtphasta.Value, IntTipoCierre, IntLugar, StrNroPtoVta, _
            StrSalesPerID, StrFechaCierre, IntTurno, IntNroSaltosLineas, _
            StrCodCorte, IntAnchoTicket, StrLineaSeparacion, StrSerieMaqReg, _
            StrFecha, DblMontoTipoCambio, IntNroTransacciones, DblTicketBolIni, _
            dblTicketFacIni, DblValorVta, DblVtaNoAfecta, DblIGV, DblVtaTotal, _
            IntNroTicketAnul, DblTotalTicketAnul, DblGranTotal, IntNroZeta, _
            DblTotalTicketBol, DblTotalTicketFac, DblTotalGral, _
            DblEfectivo, DblVueltoEfectivo, DblNetoEfectivo, DblTarjeta, _
            DblVueltoTarjeta, DblNetoTarjeta, DblVale, DblVueltoVale, _
            DblNetoVale, StrMdaBase, StrMdaCaja, StrSimbMdaCaja, StrSimbMdaExt, _
            StrCab1, StrCab2, StrCab3, StrCab4, StrCab5, BlnOK, GintDecResultado, GintDecStock)
    
            Open "temp.txt" For Output As #1
                Print #1, StrCierre
            Close #1
                    
            Shell "wordpad.exe temp.txt", vbNormalFocus
                    
            BlnOK = MobjCierre.MensajeOK
                        
            If BlnOK Then
                    MsgBox "Proceso de Cierre Z realizado", vbInformation, "Mensaje"
            Else
                    MsgBox "Proceso de Cierre Z fallido", vbInformation, "Mensaje"
            End If
        End If
End Sub

Sub Limpiar_Variables()

    IntTipoCierre = 2 ' cierre z
    
    ' VARIABLE PARA SABER SI ES TIENDA O PLAYA
    ' 1 : Tienda
    ' 2 : Playa
    IntLugar = 0 ' puede ser Playa o Tienda
    
'    2, lblcaja.Caption, Val(lblTurno.Caption), GCUSERID, Str(GDatFechaProcesoVentas), 1
    StrNroPtoVta = ""
    StrSalesPerID = ""
    StrFechaCierre = ""
    IntTurno = 0 ' en Cierre Z el valor de IntTurno no importa
    'DblTipoCambio = DblTipoCambioActual
    BlnOK = True ' inicialmente todo bien
    
    ' VARIABLES DE PUNTO DE VENTA,VENDEDOR y FECHA DE CIERRE (FECHA DE PROCESO)
    'StrNroPtoVta = ""
    'StrSalesPerID = ""
    'StrFechaCierre = ""
    'IntTurno = 0
    
    ' DATOS DE IMPRESORA
    IntNroSaltosLineas = 0
    StrCodCorte = ""
    IntAnchoTicket = 0
    
    ' LINEA DE SEPARACION
    StrLineaSeparacion = ""
    
    ' variables de cabecera de cierre
    StrSerieMaqReg = ""
    StrFecha = ""
    DblTipoCambio = 0
    IntNroTransacciones = 0
    DblTicketBolIni = 0
    dblTicketFacIni = 0
    DblValorVta = 0
    DblVtaNoAfecta = 0
    DblIGV = 0
    DblVtaTotal = 0
    IntNroTicketAnul = 0
    DblTotalTicketAnul = 0
    DblGranTotal = 0
    IntNroZeta = 0
    'dim IntTurno As Integer
    
    ' variables de resumen de ventas
    DblTotalTicketBol = 0
    DblTotalTicketFac = 0
    DblTotalGral = 0
    
    ' variables de resumen de tipos de pago
    DblEfectivo = 0
    DblVueltoEfectivo = 0
    DblNetoEfectivo = 0
    
    DblTarjeta = 0
    DblVueltoTarjeta = 0
    DblNetoTarjeta = 0
    
    DblVale = 0
    DblVueltoVale = 0
    DblNetoVale = 0
    
    ' variables para monedas
    StrMdaBase = ""
    StrMdaCaja = ""
    StrSimbMdaCaja = ""
    StrSimbMdaExt = ""
    
    ' cabeceras de ticket
    StrCab1 = ""
    StrCab2 = ""
    StrCab3 = ""
    StrCab4 = ""
    StrCab5 = ""
    
    ' variable de comprobacion de error
    'BlnOK =
End Sub


