Regalamiunsorriso/decompiled-libs/www/acxent-common-1.0.1/it/acxent/cc/servlet/OrdineSvlt.java

274 lines
10 KiB
Java

package it.acxent.cc.servlet;
import it.acxent.anag.TipoPagamento;
import it.acxent.anag.Users;
import it.acxent.cc.Attivita;
import it.acxent.common.Access;
import it.acxent.contab.Documento;
import it.acxent.contab.DocumentoCR;
import it.acxent.db.ApplParmFull;
import it.acxent.db.CRAdapter;
import it.acxent.db.DBAdapter;
import it.acxent.db.ResParm;
import it.acxent.util.AbMessages;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class OrdineSvlt extends it.acxent.www.servlet.OrdineSvlt {
private static final long serialVersionUID = 8880000554136161006L;
protected void fillComboAfterDetail(DBAdapter l_bean, HttpServletRequest req, HttpServletResponse res) {
Documento bean = (Documento)l_bean;
req.setAttribute("listaTipoPagamento", new TipoPagamento(
getApFull(req)).findPagamentiWww(!bean.getClifor().getId_nazione().equals("I"),
(bean.getFlgDeliveryType() == 2L)));
int ordineInverso = (bean.getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0;
req.setAttribute("righeDocumento", bean.findRigheDocumento(0, 0, ordineInverso));
if (req.getAttribute("msg").equals("Lettura effettuata"))
req.setAttribute("msg", "");
}
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
protected DBAdapter getBean(HttpServletRequest 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) {
ApplParmFull apFull = getApFull(req);
Documento bean = null;
ResParm rp = new ResParm(true, "");
long l_id = getRequestLongParameter(req, "id_documento");
bean = new Documento(apFull);
try {
bean.findByPrimaryKey(l_id);
Attivita attivita = Attivita.getDefaultInstance(apFull);
Users utente = (Users)getLoginUser(req);
rp = attivita.sendOrderMailMessageCC(bean, utente, utente.getLang(), true, true, false, false, req);
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) {
Users user = (Users)getLoginUser(req);
System.out.println("ordinesvlt beforeSearch: id_clifor " + user.getId_clifor());
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, "&nbsp;");
}
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 {
forceJspPageRelative("documentoCR.jsp", req);
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 _impostaMP(HttpServletRequest req, HttpServletResponse res) {
Users user = (Users)getLoginUser(req);
ApplParmFull apFull = getApFull(req);
Attivita attivita = Attivita.getDefaultInstance(apFull);
if (user != null && user.getDBState() == 1) {
Documento bean = new Documento(apFull);
long l_id_documento = getRequestLongParameter(req, "id_documento");
long l_id_tipoPagamento = getRequestLongParameter(req, "id_tipoPagamento");
bean.findByPrimaryKey(l_id_documento);
if (bean.getId_documento() > 0L) {
bean.setId_tipoPagamento(l_id_tipoPagamento);
bean.setSpeseTrasporto(bean.getDeliveryCostOrdine(user.getClifor()));
ResParm rp = bean.save();
if (rp.getStatus())
attivita.sendOrderMailMessageCC(bean, user, user.getLang(), true, true, true, false, req);
}
showBean(req, res);
} else {
showBean(req, res);
}
}
public void _aggiornaRichiediFattura(HttpServletRequest req, HttpServletResponse res) {
Users user = (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();
}
}
}
protected ResParm beforeSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
return super.beforeSave(beanA, req, res);
}
protected String getBeanPageName(HttpServletRequest req) {
String temp = getBeanName(req);
Users user = (Users)getLoginUser(req);
ApplParmFull apFull = getApFull(req);
Access access = new Access(getApFull(req));
access.findByPrimaryKey(Access.convertFieldToTableName(temp));
if (getRequestParameter(req, "sw").equals("1")) {
if (!access.getSuffissoE().isEmpty())
return temp + temp + "E";
return temp + "E";
}
return temp;
}
public void _aggiornaRichiediFatturaMd(HttpServletRequest req, HttpServletResponse res) {
Users user = (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);
}
}
protected String getBEANAttribute(HttpServletRequest req) {
return super.getBEANAttribute(req);
}
protected boolean isCostoSpedizioneFull() {
return getParm("CC_COSTO_SPED_FULL").isTrue();
}
}