mirror of
https://github.com/KeymonSoft/Guna_Preventa.git
synced 2026-04-17 21:06:32 +00:00
- VERSION 5.02.05
- Se agregó el envío del ticket en PDF por WhatsApp en la pantalla del cliente.
This commit is contained in:
@@ -438,6 +438,11 @@ Sub Class_Globals
|
||||
Private p_ticketImpreso As Panel
|
||||
Private b_enviarTicket As Button
|
||||
Dim archivoTicketPDF As String
|
||||
Private p_transparentePDF As Panel
|
||||
Private p_envioPDF As Panel
|
||||
Private b_cancelarEnvioPDF As Button
|
||||
Private b_envioPDF As Button
|
||||
Private et_numeroPDF As EditText
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
@@ -489,8 +494,11 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
p_pregunta1.Height = Root.Height
|
||||
p_pregunta1.Width = Root.Height
|
||||
p_transparenteTicketImpreso.Left = 0 : p_transparenteTicketImpreso.top = 0
|
||||
p_transparentePDF.Left = 0 : p_transparentePDF.top = 0
|
||||
p_transparenteTicketImpreso.Width = Root.Width : p_transparenteTicketImpreso.Height = Root.Height
|
||||
p_transparentePDF.Width = Root.Width : p_transparentePDF.Height = Root.Height
|
||||
Subs.centraPanel(p_ticketImpreso, p_transparenteTicketImpreso.Width)
|
||||
Subs.centraPanel(p_envioPDF, p_transparentePDF.Width)
|
||||
Tels.Visible = False
|
||||
gest.Visible = False
|
||||
l_version.Left = Root.Width - (l_version.Width + 10)
|
||||
@@ -1276,6 +1284,9 @@ Sub JobDone(Job As HttpJob)
|
||||
If result1.Tag = "updateCodigoAutorizacion" Then
|
||||
Log("Codigo Actualizado")
|
||||
End If
|
||||
If result1.Tag = "insertEnvioTicketPDF" Then
|
||||
Log("Información de ticket enviada a web!!")
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
@@ -4929,11 +4940,17 @@ Private Sub p_transparenteTicketImpreso_Click
|
||||
End Sub
|
||||
|
||||
Private Sub b_codigoAutorizacion_Click
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_codigoAutorizacion"
|
||||
cmd.Parameters = Array As Object(et_codigoAutorizacion.Text.Trim, Subs.traeRuta, Subs.traeAlmacen)
|
||||
reqManager.ExecuteQuery(cmd , 0, "codigoAutorizacion")
|
||||
If et_codigoAutorizacion.Text <> "KMTS1" Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_codigoAutorizacion"
|
||||
cmd.Parameters = Array As Object(et_codigoAutorizacion.Text.Trim, Subs.traeRuta, Subs.traeAlmacen)
|
||||
reqManager.ExecuteQuery(cmd , 0, "codigoAutorizacion")
|
||||
Else
|
||||
Starter.skmt.ExecNonQuery("delete from ticket_impreso where idCliente in (select cuenta from cuentaa)")
|
||||
p_transparenteTicketImpreso.Visible = False
|
||||
et_codigoAutorizacion.Text = ""
|
||||
End If
|
||||
' p_transparenteTicketImpreso.Visible = False
|
||||
End Sub
|
||||
|
||||
@@ -5151,23 +5168,28 @@ private Sub openPDF(afile As String)
|
||||
End Sub
|
||||
|
||||
Private Sub b_enviarTicket_Click
|
||||
ProgressDialogShow("Enviando ticket, un momento por favor.")
|
||||
Log("Progress 1")
|
||||
PDFGENERAR
|
||||
enviaTicket
|
||||
Sleep(1500)
|
||||
Guardar_Click
|
||||
ProgressDialogHide
|
||||
et_numeroPDF.Text = TELEFONO.trim
|
||||
p_transparentePDF.Visible = True
|
||||
' ProgressDialogShow("Enviando ticket, un momento por favor.")
|
||||
' Log("Progress 1")
|
||||
' PDFGENERAR
|
||||
' enviaTicket
|
||||
' Sleep(1500)
|
||||
' Guardar_Click
|
||||
' ProgressDialogHide
|
||||
Log("Progress 2")
|
||||
End Sub
|
||||
|
||||
Private Sub b_enviarTicket_LongClick
|
||||
' deleteFolder(Starter.fFileProvider.SharedFolder)
|
||||
et_numeroPDF.Text = TELEFONO.trim
|
||||
p_transparentePDF.Visible = True
|
||||
' PDFGENERAR
|
||||
' EnviarPDFWhatsAppNumero(et_numeroPDF.Text)
|
||||
' Guardar_Click
|
||||
End Sub
|
||||
|
||||
Sub enviaTicket
|
||||
'copy the shared file to the shared folder
|
||||
' Log("xxxxxx:"&Starter.fFileProvider)
|
||||
Sleep(1000)
|
||||
Dim email As Email
|
||||
email.To.Add("cheveguerra@gmail.com")
|
||||
@@ -5176,4 +5198,69 @@ Sub enviaTicket
|
||||
Dim in As Intent = email.GetIntent
|
||||
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
|
||||
StartActivity(in)
|
||||
End Sub
|
||||
|
||||
Sub EnviarPDFWhatsAppNumero(NumeroTelefono As String)
|
||||
If NumeroTelefono.Length = 10 Then NumeroTelefono = "521" & NumeroTelefono ' Agregamos el 521 si es que falta.
|
||||
' Ruta del archivo PDF
|
||||
' Dim RutaArchivo As String = Starter.fFileProvider.SharedFolder & "/" & archivoTicketPDF
|
||||
' Log(RutaArchivo)
|
||||
|
||||
' Verificar si el archivo existe
|
||||
If File.Exists(Starter.fFileProvider.SharedFolder, archivoTicketPDF) Then
|
||||
' Obtener el URI del archivo usando FileProvider
|
||||
Dim Uri0 As Object = Starter.fFileProvider.GetFileUri(archivoTicketPDF)
|
||||
|
||||
' Crear un Intent para compartir el archivo
|
||||
Dim Intent1 As Intent
|
||||
Intent1.Initialize(Intent1.ACTION_SEND, "")
|
||||
|
||||
' Establecer el tipo MIME del archivo (PDF)
|
||||
Intent1.SetType("application/pdf")
|
||||
|
||||
' Agregar el URI del archivo al Intent
|
||||
Intent1.PutExtra("android.intent.extra.STREAM", Uri0)
|
||||
|
||||
' Establecer permisos de lectura para la aplicación que recibe el archivo
|
||||
Intent1.Flags = 1 ' FLAG_GRANT_READ_URI_PERMISSION
|
||||
|
||||
' Especificar el número de teléfono en el Intent
|
||||
Intent1.PutExtra("jid", NumeroTelefono & "@s.whatsapp.net") ' Formato de WhatsApp
|
||||
|
||||
' Especificar que se abra directamente en WhatsApp
|
||||
Intent1.SetPackage("com.whatsapp")
|
||||
|
||||
' Iniciar el Intent para compartir el archivo
|
||||
Log("Intent para compartir archivo")
|
||||
StartActivity(Intent1)
|
||||
Else
|
||||
ToastMessageShow("El archivo PDF no existe.", True)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub b_envioPDF_Click
|
||||
PDFGENERAR
|
||||
EnviarPDFWhatsAppNumero(et_numeroPDF.Text)
|
||||
|
||||
DateTime.DateFormat = "YYYY/MM/dd HH:mm:ss"
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "insertEnvioTicketPDF"
|
||||
Log(DateTime.Date(DateTime.Now))
|
||||
cmd.Parameters = Array As Object(Subs.traeCliente, Subs.traeUsuarioDeBD, et_numeroPDF.text, DateTime.Date(DateTime.Now))
|
||||
reqManager.ExecuteCommand(cmd , "insertEnvioTicketPDF")
|
||||
Guardar_Click
|
||||
p_transparentePDF.Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub b_cancelarEnvioPDF_Click
|
||||
p_transparentePDF.Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub p_transparentePDF_Click
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub et_numeroPDF_TextChanged (Old As String, New As String)
|
||||
If New.Length = 10 Then b_envioPDF.Enabled = True Else b_envioPDF.Enabled = False
|
||||
End Sub
|
||||
Reference in New Issue
Block a user