223 lines
9.3 KiB
Java
223 lines
9.3 KiB
Java
|
|
package it.acxent.contab.servlet;
|
||
|
|
|
||
|
|
import it.acxent.anag.Esercizio;
|
||
|
|
import it.acxent.anag.Iva;
|
||
|
|
import it.acxent.anag.MagFisico;
|
||
|
|
import it.acxent.anag.TipoPagamento;
|
||
|
|
import it.acxent.anag.Vettore;
|
||
|
|
import it.acxent.art.Marca;
|
||
|
|
import it.acxent.contab.Documento;
|
||
|
|
import it.acxent.contab.Movimento;
|
||
|
|
import it.acxent.contab.MovimentoCR;
|
||
|
|
import it.acxent.contab.RigaDocumento;
|
||
|
|
import it.acxent.contab.RigaDocumentoCR;
|
||
|
|
import it.acxent.contab.TipoDocumento;
|
||
|
|
import it.acxent.contab.TipoDocumentoCR;
|
||
|
|
import it.acxent.db.ApplParmFull;
|
||
|
|
import it.acxent.db.CRAdapter;
|
||
|
|
import it.acxent.db.DBAdapter;
|
||
|
|
import it.acxent.db.ResParm;
|
||
|
|
import it.acxent.newsletter.CodaMessaggi;
|
||
|
|
import it.acxent.newsletter.TemplateMsg;
|
||
|
|
import it.acxent.util.AbMessages;
|
||
|
|
import it.acxent.util.Vectumerator;
|
||
|
|
import javax.servlet.annotation.WebServlet;
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
|
||
|
|
@WebServlet(urlPatterns = {"/admin/contab/RigaDocumento.abl"})
|
||
|
|
public class RigaDocumentoSvlt extends _ContabSvlt {
|
||
|
|
private static final long serialVersionUID = -4988119342406716471L;
|
||
|
|
|
||
|
|
protected void addRows(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);
|
||
|
|
fillObject(req, bean);
|
||
|
|
rp = bean.save();
|
||
|
|
req.setAttribute("id_documento", String.valueOf(bean.getId_documento()));
|
||
|
|
if (rp.getStatus() == true) {
|
||
|
|
if (getAct(req).equals("addRigaArticolo")) {
|
||
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
||
|
|
if (l_id != 0L) {
|
||
|
|
fillObject(req, row);
|
||
|
|
rp = Documento.addRigaDocumento(bean, row);
|
||
|
|
sendMessage(req, rp.getMsg());
|
||
|
|
} else {
|
||
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
||
|
|
}
|
||
|
|
showBean(req, res);
|
||
|
|
} else if (getAct(req).equals("delRigaArticolo")) {
|
||
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
||
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
||
|
|
if (l_id_rigaDocumento != 0L) {
|
||
|
|
fillObject(req, row);
|
||
|
|
bean.delRigaDocumento(row);
|
||
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "DELETE_OK"));
|
||
|
|
} else {
|
||
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
||
|
|
}
|
||
|
|
showBean(req, res);
|
||
|
|
} else if (getAct(req).equals("modRigaArticolo")) {
|
||
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
||
|
|
if (getRequestLongParameter(req, "id_rigaDocumento") != 0L) {
|
||
|
|
fillObject(req, row);
|
||
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
||
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
||
|
|
req.setAttribute("bean2", row);
|
||
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_OK"));
|
||
|
|
} else {
|
||
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
||
|
|
}
|
||
|
|
showBean(req, res);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
req.setAttribute("bean", bean);
|
||
|
|
sendMessage(req, rp.getMsg());
|
||
|
|
showBean(req, res);
|
||
|
|
}
|
||
|
|
} catch (Exception e) {
|
||
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
||
|
|
showBean(req, res);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void mail(HttpServletRequest req, HttpServletResponse res) {}
|
||
|
|
|
||
|
|
protected void print(HttpServletRequest req, HttpServletResponse res) {}
|
||
|
|
|
||
|
|
protected void processRequest(HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
super.processRequest(req, res);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
ApplParmFull apFull = getApFull(req);
|
||
|
|
RigaDocumento bean = (RigaDocumento)beanA;
|
||
|
|
req.setAttribute("listaTipoPagamento", new TipoPagamento(apFull).findAll());
|
||
|
|
req.setAttribute("listaVettore", new Vettore(apFull).findAll());
|
||
|
|
req.setAttribute("listaTipoDocumento", new TipoDocumento(apFull).findAll());
|
||
|
|
req.setAttribute("listaIva", new Iva(apFull).findAll());
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void fillComboAfterSearch(CRAdapter CRA, HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
ApplParmFull apFull = getApFull(req);
|
||
|
|
req.setAttribute("listaTipoDocumento", new TipoDocumento(apFull).findByCR(new TipoDocumentoCR(), 0, 0));
|
||
|
|
req.setAttribute("listaMagFisico", new MagFisico(apFull).findAll());
|
||
|
|
req.setAttribute("listaEsercizi", new Esercizio(apFull).findAll());
|
||
|
|
req.setAttribute("listaMarche", new Marca(apFull).findAll());
|
||
|
|
}
|
||
|
|
|
||
|
|
protected DBAdapter getBean(HttpServletRequest req) {
|
||
|
|
return new RigaDocumento(getApFull(req));
|
||
|
|
}
|
||
|
|
|
||
|
|
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||
|
|
return new RigaDocumentoCR(getApFull(req));
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {}
|
||
|
|
|
||
|
|
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
if (getCmd(req).equals("ov")) {
|
||
|
|
RigaDocumentoCR CR = new RigaDocumentoCR(getApFull(req));
|
||
|
|
fillObject(req, CR);
|
||
|
|
CR.setId_tipoDocumento(getId_docOrdine());
|
||
|
|
CR.setFlgTipoRicerca(0L);
|
||
|
|
req.setAttribute("CR", CR);
|
||
|
|
RigaDocumento bean = new RigaDocumento(getApFull(req));
|
||
|
|
req.setAttribute("list", bean.findByCR(CR, 0, 0));
|
||
|
|
setJspPageRelative("ordiniView.jsp", req);
|
||
|
|
callJsp(req, res);
|
||
|
|
} else if (getCmd(req).equals("creaCodaMsgTimCard")) {
|
||
|
|
creaCodaMessaggiTimCard(req, res);
|
||
|
|
}
|
||
|
|
search(req, res);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected ResParm beforeSearch(HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
if (!getAct(req).contains("back")) {
|
||
|
|
long l_id_esercizio = getRequestLongParameter(req, "id_esercizio");
|
||
|
|
if (l_id_esercizio == 0L)
|
||
|
|
req.setAttribute("id_esercizio", String.valueOf(DBAdapter.getCurrentYear()));
|
||
|
|
}
|
||
|
|
req.setAttribute("flgRicercaMag", Long.valueOf(RigaDocumentoCR.RICERCA_SOLO_MAGAZZINO));
|
||
|
|
return super.beforeSearch(req, res);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected void creaCodaMessaggiTimCard(HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
RigaDocumento bean = new RigaDocumento(getApFull(req));
|
||
|
|
RigaDocumentoCR CR = new RigaDocumentoCR(getApFull(req));
|
||
|
|
fillObject(req, CR);
|
||
|
|
CR.setFlgTipoRicerca(1L);
|
||
|
|
Vectumerator vec = bean.findByCR(CR, 0, 0);
|
||
|
|
long l_id_templateMsg = getRequestLongParameter(req, "id_templateMsg");
|
||
|
|
TemplateMsg ts = new TemplateMsg(getApFull(req));
|
||
|
|
ts.findByPrimaryKey(l_id_templateMsg);
|
||
|
|
String campagna = ts.getDescrizione() + " " + ts.getDescrizione();
|
||
|
|
while (vec.hasMoreElements()) {
|
||
|
|
RigaDocumento row = (RigaDocumento)vec.nextElement();
|
||
|
|
if (ts.getFlgTipo() == 1L)
|
||
|
|
continue;
|
||
|
|
if (row.getArticolo().getId_tipo() == 271L) {
|
||
|
|
CodaMessaggi cm = new CodaMessaggi(getApFull(req));
|
||
|
|
cm.setFlgTipo(ts.getFlgTipo());
|
||
|
|
cm.setCampagna(campagna);
|
||
|
|
cm.setCellulare(row.getSeriale().trim());
|
||
|
|
cm.setTestoMessaggio(ts.getTestoMessaggio());
|
||
|
|
cm.save();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void _statoRigaPre(HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
||
|
|
RigaDocumento bean = new RigaDocumento(getApFull(req));
|
||
|
|
bean.findByPrimaryKey(l_id_rigaDocumento);
|
||
|
|
if (getAct(req).equals("reset")) {
|
||
|
|
bean.setStatoPrenotazione(-1L);
|
||
|
|
bean.superSave();
|
||
|
|
}
|
||
|
|
long stato = bean.getStatoPrenotazione();
|
||
|
|
req.setAttribute("stato", String.valueOf(stato));
|
||
|
|
req.setAttribute("statoMsg", bean.getStatoRiga(stato));
|
||
|
|
req.setAttribute("id", String.valueOf(l_id_rigaDocumento));
|
||
|
|
sendCmdJspFetchPageResponse(req, res);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected int getPageRow(HttpServletRequest req) {
|
||
|
|
return 55;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void _creaReportCsv(HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
RigaDocumentoCR CR = (RigaDocumentoCR)req.getSession().getAttribute(
|
||
|
|
getATTR_CRBEAN(req));
|
||
|
|
CR.setFlgTipoReport(getRequestLongParameter(req, "flgTipoReport"));
|
||
|
|
CR.setId_users(getLoginUserId(req).longValue());
|
||
|
|
RigaDocumento bean = new RigaDocumento(getApFull(req));
|
||
|
|
bean.creaFileCvsMov(CR);
|
||
|
|
sendHtmlMsgResponse(req, res, "<a href='../../" + CR.getFileName() + "' target='_blank'>File report in formato cvs (Excel)</a>");
|
||
|
|
}
|
||
|
|
|
||
|
|
public void _loadDettaglio4(HttpServletRequest req, HttpServletResponse res) {
|
||
|
|
long l_id_articolo = getRequestLongParameter(req, "id_articolo");
|
||
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
||
|
|
long l_id_documento2 = getRequestLongParameter(req, "id_documento2");
|
||
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
||
|
|
MovimentoCR CR = new MovimentoCR();
|
||
|
|
CR.setId_articolo(l_id_articolo);
|
||
|
|
CR.setId_documento(l_id_documento);
|
||
|
|
CR.setId_documento2(l_id_documento2);
|
||
|
|
CR.setId_documento(l_id_rigaDocumento);
|
||
|
|
RigaDocumento bean = new RigaDocumento(getApFull(req));
|
||
|
|
req.setAttribute("list1", bean.findOrdiniByArticolo(l_id_articolo));
|
||
|
|
req.setAttribute("list2", bean.findMovimentiDiCaricoByArticoloDocumento(l_id_articolo, l_id_documento));
|
||
|
|
req.setAttribute("list3", bean.findDettaglioBollaByArticoloDocumento(l_id_articolo, l_id_documento2));
|
||
|
|
req.setAttribute("list4", new Movimento(getApFull(req)).findByRigaDocumento(l_id_rigaDocumento));
|
||
|
|
req.setAttribute("CR", CR);
|
||
|
|
showBean(req, res);
|
||
|
|
}
|
||
|
|
}
|