326 lines
12 KiB
Java
326 lines
12 KiB
Java
package it.acxent.pg.servlet;
|
|
|
|
import it.acxent.anag.Clifor;
|
|
import it.acxent.anag.TipoPagamento;
|
|
import it.acxent.contab.Documento;
|
|
import it.acxent.contab.DocumentoCR;
|
|
import it.acxent.contab.RigaDocumento;
|
|
import it.acxent.contab.RigaDocumentoCR;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.CRAdapter;
|
|
import it.acxent.db.DBAdapter;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.pg.Coupon;
|
|
import it.acxent.pg.Users;
|
|
import it.acxent.util.AbMessages;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
public class OrdineSvlt extends it.acxent.www.servlet.OrdineSvlt {
|
|
protected void fillComboAfterDetail(DBAdapter l_bean, HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = (Documento)l_bean;
|
|
ApplParmFull apFUll = getApFull(req);
|
|
req.setAttribute("listaTipoPagamento", new TipoPagamento(apFUll).findPagamentiWww(false, false));
|
|
RigaDocumento rd = new RigaDocumento(apFUll);
|
|
RigaDocumentoCR rdCR = new RigaDocumentoCR(apFUll);
|
|
long l_id_users = getLoginUserId(req);
|
|
Users users = new Users(apFUll);
|
|
users.findByPrimaryKey(l_id_users);
|
|
if (users.getId_clifor() > 0L) {
|
|
rdCR.setId_clifor(users.getId_clifor());
|
|
req.setAttribute("listRD", rd.findByCR(rdCR, 0, 0));
|
|
}
|
|
if (req.getAttribute("msg").equals("Lettura effettuata"))
|
|
req.setAttribute("msg", "");
|
|
}
|
|
|
|
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
|
|
|
|
protected DBAdapter getBean(HttpServletRequest req) {
|
|
sendMessage(req, ".");
|
|
return new Documento(getApFull(req));
|
|
}
|
|
|
|
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
|
return new DocumentoCR(getApFull(req));
|
|
}
|
|
|
|
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {}
|
|
|
|
protected void payBonifico(HttpServletRequest req, HttpServletResponse res) {
|
|
try {
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
bean.setDataPagamento(DBAdapter.getToday());
|
|
ResParm rp = bean.save();
|
|
String theMsg = "";
|
|
if (rp.getStatus());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
forceMessage(req, e.getMessage());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
protected void payCc(HttpServletRequest req, HttpServletResponse res) {
|
|
try {
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
long l_flgTipoPagamento = getRequestLongParameter(req, "flgTipoPagamento");
|
|
ResParm rp = bean.save();
|
|
String theMsg = "";
|
|
req.setAttribute("bean", bean);
|
|
if (rp.getStatus()) {
|
|
forceJspPageRelative("DocumentoCc.jsp", req);
|
|
int ordineInverso = (bean.getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0;
|
|
req.setAttribute("righeDocumento", bean.findRigheDocumento(0, 0, ordineInverso));
|
|
callJsp(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
forceMessage(req, e.getMessage());
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
protected void refreshPayment(HttpServletRequest req, HttpServletResponse res) {
|
|
try {
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
long l_id_tipoPagamento = getRequestLongParameter(req, "id_tipoPagamento");
|
|
bean.setId_tipoPagamento(l_id_tipoPagamento);
|
|
ResParm rp = bean.save();
|
|
String theMsg = "";
|
|
req.setAttribute("bean", bean);
|
|
forceJspPageRelative("Documento.jsp", req);
|
|
callJsp(req, res);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
forceMessage(req, e.getMessage());
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
protected void cancelOrder(HttpServletRequest req, HttpServletResponse res) {
|
|
try {
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
bean.setFlgStatoOrdineWww(99L);
|
|
bean.setFlgStatoPrenotazione(100L);
|
|
ResParm rp = bean.save();
|
|
String theMsg = "";
|
|
req.setAttribute("bean", bean);
|
|
sendMessage(req, "Documento annullato");
|
|
showBean(req, res);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
forceMessage(req, e.getMessage());
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
protected void sendMailOrder(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(getApFull(req));
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
rp = bean.sendOrderMailMessageRavinale(getLang(req), true, true, false);
|
|
sendMessage(req, rp.getMsg());
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
protected String getCRAttribute(HttpServletRequest req) {
|
|
return "CROrd";
|
|
}
|
|
|
|
protected ResParm beforeSearch(HttpServletRequest req, HttpServletResponse res) {
|
|
DocumentoCR CR = new DocumentoCR(getApFull(req));
|
|
fillObject(req, CR);
|
|
if (getLoginUserId(req) != null && getLoginUserId(req) > 0L) {
|
|
it.acxent.anag.Users user = (it.acxent.anag.Users)getLoginUser(req);
|
|
if (user.getId_clifor() == 0L) {
|
|
req.setAttribute("id_clifor", "-1");
|
|
} else {
|
|
req.setAttribute("id_clifor", String.valueOf(user.getId_clifor()));
|
|
}
|
|
req.setAttribute("id_tipoDocumento", Long.valueOf(getParm("ID_DOC_ORDINE_WWW").getNumeroLong()));
|
|
if (CR.getFlgStatoOrdineWww() < 0L)
|
|
req.setAttribute("flgStatoOrdineWww", "0");
|
|
req.setAttribute("id_users", "0");
|
|
} else {
|
|
sendMessage(req, " ");
|
|
}
|
|
return new ResParm(true);
|
|
}
|
|
|
|
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
|
String idCryptParm = "idcrypt";
|
|
String l_id_ordineCript = (String)req.getSession().getAttribute(idCryptParm);
|
|
if (l_id_ordineCript != null && !l_id_ordineCript.isEmpty()) {
|
|
_vediOrdineCrypt(req, res);
|
|
} else {
|
|
String cmd = getCmd(req);
|
|
if (cmd.equals("payBon")) {
|
|
payBonifico(req, res);
|
|
} else if (cmd.equals("payCc")) {
|
|
payCc(req, res);
|
|
} else if (cmd.equals("refreshPayment")) {
|
|
refreshPayment(req, res);
|
|
} else if (cmd.equals("cancelOrder")) {
|
|
cancelOrder(req, res);
|
|
} else if (cmd.equals("sendMailOrder")) {
|
|
sendMailOrder(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void showBean(HttpServletRequest req, HttpServletResponse res) {
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
if (bean.getDBState() == 1 && bean.getId_tipoPagamento() == 4L && bean.getFlgProcediPagamento() == 1L &&
|
|
bean.getDescTransaction().isEmpty())
|
|
bean.agiornaNuovoId_documentoXpay();
|
|
super.showBean(req, res);
|
|
}
|
|
|
|
public void _aggiornaRichiediFatturaMd(HttpServletRequest req, HttpServletResponse res) {
|
|
it.acxent.anag.Users user = (it.acxent.anag.Users)getLoginUser(req);
|
|
ApplParmFull apFull = getApFull(req);
|
|
if (user != null && user.getDBState() == 1) {
|
|
Documento bean = new Documento(apFull);
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
long l_flgWwwRichiedeFattura = getRequestLongParameter(req, "flgWwwRichiedeFattura");
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
if (bean.getId_documento() > 0L) {
|
|
bean.setFlgWwwRichiedeFattura(l_flgWwwRichiedeFattura);
|
|
bean.superSave();
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
public void _inviaCoupon(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Users user = new Users(apFull);
|
|
long l_id_users = getLoginUserId(req);
|
|
user.findByPrimaryKey(l_id_users);
|
|
ResParm rp = new ResParm(true);
|
|
if (user != null && user.getDBState() == 1) {
|
|
if (user.isDaRinnovare()) {
|
|
Coupon coupon = new Coupon(apFull);
|
|
String l_coupon = getRequestParameter(req, "coupon");
|
|
coupon.findByCodice(l_coupon);
|
|
if (coupon.isValido()) {
|
|
if (user.getId_clifor() == 0L) {
|
|
Clifor clifor = new Clifor(apFull);
|
|
clifor.setFlgTipo("C");
|
|
clifor.setNome(user.getNome());
|
|
clifor.setCognome(user.getCognome());
|
|
clifor.setIndirizzo(user.getIndirizzo());
|
|
clifor.setNumeroCivico(user.getNumeroCivico());
|
|
clifor.setFlgSesso(user.getFlgSesso());
|
|
clifor.setDescrizioneComune(user.getCitta());
|
|
clifor.setCapComune(user.getCap());
|
|
clifor.setId_nazione(user.getId_nazione());
|
|
clifor.setCodFisc(user.getCodFisc());
|
|
clifor.setTelefono(user.getTelefono());
|
|
clifor.setContatto(user.getContatto());
|
|
rp = clifor.save();
|
|
if (rp.getStatus()) {
|
|
user.setId_clifor(clifor.getId_clifor());
|
|
rp = user.save();
|
|
}
|
|
}
|
|
if (rp.getStatus()) {
|
|
if (coupon.getNFoto() >= 100L || coupon.hasCouponRegaloByCliente(user.getId_clifor()));
|
|
Documento doc = new Documento(apFull);
|
|
long l_id_tipo_doc_ordine_www = getParm("ID_DOC_ORDINE_WWW").getNumeroLong();
|
|
doc.setId_tipoDocumento(l_id_tipo_doc_ordine_www);
|
|
doc.setDataDocumento(DBAdapter.getToday());
|
|
doc.setId_clifor(user.getId_clifor());
|
|
doc.setFlgPagata(1L);
|
|
doc.setDataPagamento(DBAdapter.getToday());
|
|
rp = doc.save();
|
|
if (rp.getStatus()) {
|
|
RigaDocumento rd = new RigaDocumento(apFull);
|
|
rd.setId_documento(doc.getId_documento());
|
|
rd.setDescrizioneRiga("Rinnovo abbonamento coupon " + l_coupon);
|
|
rd.setQuantita(1.0D);
|
|
rd.setId_iva(getParm("CODICE_IVA_STD_ACQ").getNumeroLong());
|
|
rp = rd.save();
|
|
if (rp.getStatus())
|
|
rp = user.rinnovaAnno(coupon.getNFoto(), 1);
|
|
if (rp.getStatus()) {
|
|
coupon.setId_rigaDocumento(rd.getId_rigaDocumento());
|
|
rp = coupon.save();
|
|
}
|
|
}
|
|
if (coupon.getNFoto() == 1000L) {
|
|
user.sendRinnovoMailMessage(coupon.getNFoto(), 1);
|
|
} else if (coupon.getNFoto() < 100L) {
|
|
user.sendCouponOmaggioMailMessage();
|
|
}
|
|
}
|
|
} else {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Attenzione! Coupon non trovato o non valido!!");
|
|
}
|
|
} else {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Attenzione! Il tuo account non e' da rinnovare");
|
|
}
|
|
} else {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Attenzione! Utente non valido");
|
|
}
|
|
if (rp.getStatus()) {
|
|
forceMessage(req, "Rinnovo eseguito correttamente");
|
|
} else {
|
|
forceMessage(req, "Attenzione! Impossibile utilizzare il coupon: " + rp.getMsg());
|
|
}
|
|
search(req, res);
|
|
}
|
|
|
|
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
if (getLoginUserId(req) > 0L) {
|
|
Users bean = new Users(apFull);
|
|
bean.findByPrimaryKey(getLoginUserId(req));
|
|
req.setAttribute("user", bean);
|
|
RigaDocumento rd = new RigaDocumento(apFull);
|
|
RigaDocumentoCR rdCR = new RigaDocumentoCR();
|
|
rdCR.setId_clifor(bean.getId_clifor());
|
|
if (bean.getId_clifor() > 0L)
|
|
req.setAttribute("listRD", rd.findByCR(rdCR, 1, 10));
|
|
req.setAttribute("id_clifor", Long.valueOf(bean.getId_clifor()));
|
|
}
|
|
callJsp(req, res);
|
|
}
|
|
|
|
public void _aggiornaRichiediFattura(HttpServletRequest req, HttpServletResponse res) {
|
|
it.acxent.anag.Users user = (it.acxent.anag.Users)getLoginUser(req);
|
|
ApplParmFull apFull = getApFull(req);
|
|
if (user != null && user.getDBState() == 1) {
|
|
Documento bean = new Documento(apFull);
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
long l_flgWwwRichiedeFattura = getRequestLongParameter(req, "flgWwwRichiedeFattura");
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
if (bean.getId_documento() > 0L) {
|
|
bean.setFlgWwwRichiedeFattura(l_flgWwwRichiedeFattura);
|
|
bean.superSave();
|
|
}
|
|
}
|
|
}
|
|
}
|