diff --git a/pom.xml b/pom.xml
index c811b5c65..ba93b18f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
br.com.rjconsultores
ventaboletosadm
- 1.119.2
+ 1.119.3
war
diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/expressos/CotizarExpresoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/expressos/CotizarExpresoController.java
index 2d9c56b32..077080d68 100644
--- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/expressos/CotizarExpresoController.java
+++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/expressos/CotizarExpresoController.java
@@ -2,12 +2,38 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.expressos;
import java.io.IOException;
import java.io.InputStream;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.xml.bind.DatatypeConverter;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.ssl.TrustStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
@@ -27,10 +53,12 @@ import org.zkoss.zul.Paging;
import com.rjconsultores.ventaboletos.entidad.Articulo;
import com.rjconsultores.ventaboletos.entidad.Ciudad;
+import com.rjconsultores.ventaboletos.entidad.Constante;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.SolicitudExpreso;
import com.rjconsultores.ventaboletos.entidad.TrayectosExpresos;
import com.rjconsultores.ventaboletos.service.CiudadService;
+import com.rjconsultores.ventaboletos.service.ConstanteService;
import com.rjconsultores.ventaboletos.service.SolicitudExpresosService;
import com.rjconsultores.ventaboletos.service.TrayectosExpresosService;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
@@ -39,6 +67,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox;
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject;
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper;
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTrayectosExpreso;
+import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
@Controller("cotizarExpresoController")
@Scope("prototype")
@@ -58,6 +87,9 @@ public class CotizarExpresoController extends MyGenericForwardComposer{
@Autowired
SolicitudExpresosService solicitudExpresosService;
+ @Autowired
+ ConstanteService constanteService;
+
SolicitudExpreso expreso;
TrayectosExpresos trayecto;
@@ -156,7 +188,7 @@ public class CotizarExpresoController extends MyGenericForwardComposer{
refreshLista();
}
- public void onClick$btnGuardarCotizacion(Event event) throws Exception {
+ public void onClick$btnGuardarCotizacion(Event event) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, Exception {
if(docCotizacion == null) {
Messagebox.show(
Labels.getLabel("expresoController.MSG.errorArchivo"),
@@ -166,6 +198,8 @@ public class CotizarExpresoController extends MyGenericForwardComposer{
expreso.setDocCotizacion(docCotizacion);
expreso.setStatusSolicitudExpresoId(2);
solicitudExpresosService.actualizacion(expreso);
+
+ enviarEmail();
}
}
@@ -185,6 +219,58 @@ public class CotizarExpresoController extends MyGenericForwardComposer{
refreshLista();
}
+
+ private void enviarEmail() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, ClientProtocolException, IOException, InterruptedException {
+
+ String urlAPIRJ = valorConstante("URL_API_RJ_INFOBIP");
+ String credenciais = valorConstante("CREDENCIAIS_API_RJ");
+ String tenant = valorConstante("TENANT_API_RJ");
+ String empresaId = valorConstante("EMPRESA_NOTIFICACOES_BOLIVARIANO");
+
+ urlAPIRJ = urlAPIRJ.concat("EnviarEmailGenerico");
+
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+
+ HttpPost request = new HttpPost(urlAPIRJ);
+
+ List urlParameters = new ArrayList();
+ urlParameters.add(new BasicNameValuePair("emailCliente", expreso.getDescEmail()));
+ urlParameters.add(new BasicNameValuePair("assunto", Labels.getLabel("expresoController.MSG.asuntoCorreoCotizacion")));
+ urlParameters.add(new BasicNameValuePair("texto", Labels.getLabel("expresoController.MSG.cuerpoCorreoCotizacion", new Object[] { expreso.getDescNombre() + " " + expreso.getDescApellidos(), "[INSERT LINK HERE]" })));
+ urlParameters.add(new BasicNameValuePair("empresaId", empresaId));
+
+ UrlEncodedFormEntity params = new UrlEncodedFormEntity(urlParameters, "UTF-8");
+
+ request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(credenciais.getBytes())));
+
+ if (StringUtils.isNotBlank(tenant)){
+ request.addHeader("x-tenant-id", tenant);
+ }
+
+ request.setEntity(params);
+
+ CloseableHttpResponse response = httpClient.execute(request);
+
+ if(response.getStatusLine().getStatusCode() == 200 && response.getStatusLine().getReasonPhrase().equalsIgnoreCase("OK")) {
+ Messagebox.show(
+ Labels.getLabel("cotizarExpresoController.MSG.emailEnviado"),
+ Labels.getLabel("expresosPorCotizarCotizar.window.title"),
+ Messagebox.OK, Messagebox.INFORMATION);
+ } else {
+ Messagebox.show(
+ Labels.getLabel("cotizarExpresoController.MSG.emailNoEnviado"),
+ Labels.getLabel("expresosPorCotizarCotizar.window.title"),
+ Messagebox.OK, Messagebox.ERROR);
+ }
+
+ this.closeWindow();
+ }
+
+ public String valorConstante(String nombreConstante) {
+ Constante constante = constanteService.buscarPorNomeConstante(nombreConstante);
+
+ return constante != null ? constante.getValorconstante() : null ;
+ }
public SolicitudExpreso getExpreso() {
return expreso;
diff --git a/web/WEB-INF/i3-label_en.label b/web/WEB-INF/i3-label_en.label
index ae30fb378..9fe3450ef 100644
--- a/web/WEB-INF/i3-label_en.label
+++ b/web/WEB-INF/i3-label_en.label
@@ -7591,6 +7591,10 @@ expresosController.lbl.idaVuelta = Going
expresoController.MSG.errorArchivo = Invalid or null file
cargaContratoController.MSG.errorExpresoNull = Select Express to Associate Contract
+cotizarExpresoController.MSG.emailEnviado = Correct Express Quote
+expresoController.MSG.emailNoEnviado = There's been a problem. Please check logs
+expresoController.MSG.asuntoCorreoCotizacion = Quoted Express Request
+expresoController.MSG.cuerpoCorreoCotizacion = Dear {0}, the express request has been quoted, in the following link {1} you can accept the quote and make the payment.
#GR
indexController.mnGR.label = Passing Stock
#Gestao de Pricing
diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label
index 534d662fd..309e8ff97 100644
--- a/web/WEB-INF/i3-label_es_MX.label
+++ b/web/WEB-INF/i3-label_es_MX.label
@@ -7462,6 +7462,10 @@ expresosController.lbl.idaVuelta = Ida
expresoController.MSG.errorArchivo = Archivo inválido o nulo
cargaContratoController.MSG.errorExpresoNull = Seleccione Expreso a Asociar Contrato
+cotizarExpresoController.MSG.emailEnviado = Cotización de Expreso Correcta
+expresoController.MSG.emailNoEnviado = Ocurrió un problema. Favor de revisar logs
+expresoController.MSG.asuntoCorreoCotizacion = Solicitud de Expreso Cotizada
+expresoController.MSG.cuerpoCorreoCotizacion = Estimado/a {0}, la solicitud de expreso ha sido cotizada, en el siguiente link {1} podrá aceptar la cotización y realizar el pago.
#GR
indexController.mnGR.label = GR
#Gestao de Pricing
diff --git a/web/WEB-INF/i3-label_fr_FR.label b/web/WEB-INF/i3-label_fr_FR.label
index a4b8aad64..577f00fd3 100644
--- a/web/WEB-INF/i3-label_fr_FR.label
+++ b/web/WEB-INF/i3-label_fr_FR.label
@@ -7460,6 +7460,10 @@ expresosController.lbl.idaVuelta = En allant
expresoController.MSG.errorArchivo = Fichier invalide ou nul
cargaContratoController.MSG.errorExpresoNull = Sélectionnez Express pour associer le contrat
+cotizarExpresoController.MSG.emailEnviado = Corriger le devis express
+expresoController.MSG.emailNoEnviado = Il y a eu un problème. Veuillez vérifier les journaux
+expresoController.MSG.asuntoCorreoCotizacion = Demande express citée
+expresoController.MSG.cuerpoCorreoCotizacion = Cher {0}, la demande expresse a été citée, dans le lien suivant {1} vous pouvez accepter le devis et effectuer le paiement.
#GR
indexController.mnGR.label = Passage de stock
#Gestao de Pricing
diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label
index 9858d4695..8c78ffa80 100644
--- a/web/WEB-INF/i3-label_pt_BR.label
+++ b/web/WEB-INF/i3-label_pt_BR.label
@@ -7596,6 +7596,10 @@ expresosController.lbl.idaVuelta = Ida
expresoController.MSG.errorArchivo = Arquivo inválido ou nulo
cargaContratoController.MSG.errorExpresoNull = Selecione Expresso para Associar Contrato
+cotizarExpresoController.MSG.emailEnviado = Cotação Expressa Correta
+expresoController.MSG.emailNoEnviado = Houve um problema. Verifique os registros
+expresoController.MSG.asuntoCorreoCotizacion = Solicitação expressa cotada
+expresoController.MSG.cuerpoCorreoCotizacion = Prezado {0}, o pedido expresso foi cotado, no link a seguir {1} você pode aceitar o orçamento e efetuar o pagamento.
#GR
indexController.mnGR.label = Estoque de Passagem
#Gestao de Pricing