3135 lines
135 KiB
Java
3135 lines
135 KiB
Java
package it.acxent.contab.servlet;
|
|
|
|
import it.acxent.anag.Aspetto;
|
|
import it.acxent.anag.Banca;
|
|
import it.acxent.anag.CausaleTrasporto;
|
|
import it.acxent.anag.Clifor;
|
|
import it.acxent.anag.Fornitore;
|
|
import it.acxent.anag.Iva;
|
|
import it.acxent.anag.MagFisico;
|
|
import it.acxent.anag.Porto;
|
|
import it.acxent.anag.TipoPagamento;
|
|
import it.acxent.anag.TipoPagamentoCR;
|
|
import it.acxent.anag.Users;
|
|
import it.acxent.anag.Vettore;
|
|
import it.acxent.api.ApiClientResult;
|
|
import it.acxent.art.Articolo;
|
|
import it.acxent.art.ArticoloTaglia;
|
|
import it.acxent.art.ArticoloVariante;
|
|
import it.acxent.art.Colore;
|
|
import it.acxent.art.Reparto;
|
|
import it.acxent.art.Taglia;
|
|
import it.acxent.brt.api.BrtApi;
|
|
import it.acxent.brt.api.json.PudoPoint;
|
|
import it.acxent.cc.Attivita;
|
|
import it.acxent.cc.api.CcApi;
|
|
import it.acxent.contab.AllegatoDocumento;
|
|
import it.acxent.contab.DocFiglioPadre;
|
|
import it.acxent.contab.DocPrel;
|
|
import it.acxent.contab.Documento;
|
|
import it.acxent.contab.DocumentoAgente;
|
|
import it.acxent.contab.DocumentoCR;
|
|
import it.acxent.contab.DocumentoInterface;
|
|
import it.acxent.contab.DocumentoPagamento;
|
|
import it.acxent.contab.DocumentoScadenza;
|
|
import it.acxent.contab.Movimento;
|
|
import it.acxent.contab.RigaDocumento;
|
|
import it.acxent.contab.RigaDocumentoCR;
|
|
import it.acxent.contab.RigaDocumentoP;
|
|
import it.acxent.contab.RigaDocumentoPKey;
|
|
import it.acxent.contab.RigaDocumentoPM;
|
|
import it.acxent.contab.RigaDocumentoProgettista;
|
|
import it.acxent.contab.TipoAllegatoDocumento;
|
|
import it.acxent.contab.TipoDocumento;
|
|
import it.acxent.contab.TipoDocumentoCR;
|
|
import it.acxent.contab.TipologiaDocumento;
|
|
import it.acxent.db.ApplParm;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.CRAdapter;
|
|
import it.acxent.db.DBAdapter;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.jsp.Ab;
|
|
import it.acxent.tex.anag.ArticoloTessutoColore;
|
|
import it.acxent.tex.anag.Lavorazione;
|
|
import it.acxent.tex.anag.Telaio;
|
|
import it.acxent.tex.anag.TelaioCR;
|
|
import it.acxent.tex.lav.LavPezza;
|
|
import it.acxent.util.AbMessages;
|
|
import it.acxent.util.ReturnItem;
|
|
import it.acxent.util.SimpleDateFormat;
|
|
import it.acxent.util.StringTokenizer;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.io.File;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import javax.servlet.RequestDispatcher;
|
|
import javax.servlet.ServletRequest;
|
|
import javax.servlet.ServletResponse;
|
|
import javax.servlet.annotation.WebServlet;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
@WebServlet(urlPatterns = {"/admin/contab/Documento.abl", "/admin/contab/Documento.abl.pdf"})
|
|
public class DocumentoSvlt extends _ContabSvlt {
|
|
private static final long serialVersionUID = 7285217818321285875L;
|
|
|
|
protected void addRows(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_tipoDocumento() == 1L && bean.isScontrinoEmesso() && getLoginUser(req).getId_userProfile() > 1L) {
|
|
forceMessage(req, "Attenzione! L'utente non ha i permessi per modificare uno scontrino emesso!!");
|
|
showBean(req, res);
|
|
} else {
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", String.valueOf(l_id));
|
|
bean.setFlgMantieniArticoloRiga(getRequestLongParameter(req, "flgMantieniArticoloRiga"));
|
|
bean.setFlgAutoAdd(getRequestLongParameter(req, "flgAutoAdd"));
|
|
bean.setFlgSingleLineArt(getRequestLongParameter(req, "flgSingleLineArt"));
|
|
if (rp.getStatus() == true) {
|
|
if (getAct(req).equals("addRigaArticolo")) {
|
|
final RigaDocumento row = new RigaDocumento(apFull);
|
|
if (l_id != 0L) {
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
if (l_id_rigaDocumento > 0L)
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
|
fillObject(req, row);
|
|
row.setLastUpdTmst(getRequestTmstParameter(req, "lastUpdTmstRow1"));
|
|
rp = Documento.addRigaDocumento(bean, row);
|
|
if (!rp.getStatus())
|
|
forceMessage(req, rp.getMsg());
|
|
if (row.getDocumento().getId_tipoDocumento() == row.getParm("ID_DOC_CASSA").getNumeroLong()) {
|
|
final Users theUser = (Users)getLoginUser(req);
|
|
new Thread() {
|
|
public void run() {
|
|
row.getDocumento().stampaDisplayCassa(theUser.getRegCassa(), row);
|
|
}
|
|
}.start();
|
|
}
|
|
sendMessage(req, rp.getMsg());
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
bean.findByPrimaryKey(l_id);
|
|
bean.setFlgMantieniArticoloRiga(getRequestLongParameter(req, "flgMantieniArticoloRiga"));
|
|
bean.setFlgAutoAdd(getRequestLongParameter(req, "flgAutoAdd"));
|
|
bean.setFlgSingleLineArt(getRequestLongParameter(req, "flgSingleLineArt"));
|
|
bean.setFlgInserisciReso(0L);
|
|
if (bean.getFlgMantieniArticoloRiga() == 1L) {
|
|
RigaDocumento row2 = new RigaDocumento(apFull);
|
|
row2.setId_articolo(row.getId_articolo());
|
|
row2.setId_articoloVariante(row.getId_articoloVariante());
|
|
row2.setDescrizioneRiga(row.getDescrizioneRiga());
|
|
row2.setImponibile(row.getImponibile());
|
|
row2.setId_iva(row.getId_iva());
|
|
req.setAttribute("bean2", row2);
|
|
}
|
|
bean.setCurrentFocus("descrizioneRiga");
|
|
req.setAttribute("bean", bean);
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("modRigaArticolo")) {
|
|
_modRigaArticolo(req, res);
|
|
} else if (getAct(req).equals("delRigaArticolo")) {
|
|
_delRigaArticolo(req, res);
|
|
} else if (getAct(req).equals("modRigaArticoloSeriale")) {
|
|
final 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);
|
|
req.setAttribute("bean2", row);
|
|
if (row.getFlgReso() == 1L) {
|
|
bean.setFlgInserisciReso(1L);
|
|
req.setAttribute("bean", bean);
|
|
}
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_OK"));
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("chiudiRigaArticolo")) {
|
|
final RigaDocumento row = new RigaDocumento(apFull);
|
|
if (getRequestLongParameter(req, "id_rigaDocumento") != 0L) {
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
|
rp = row.settaRigaPrelevata();
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK"));
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("apriRigaArticolo")) {
|
|
final RigaDocumento row = new RigaDocumento(apFull);
|
|
if (getRequestLongParameter(req, "id_rigaDocumento") != 0L) {
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
|
rp = row.annullaRigaPrelevata();
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK"));
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("prelevaArticolo")) {
|
|
final RigaDocumento row = new RigaDocumento(apFull);
|
|
if (getRequestLongParameter(req, "id_rigaDocumentoDaPrelevare") != 0L) {
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumentoDaPrelevare");
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
|
double qtaDaPrelevare = getRequestDoubleParameter(req, "qtaDaPrelevare");
|
|
rp = bean.addRigaDocumentoDaPrelevare(row, qtaDaPrelevare);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Documento prelevato correttamente!");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("delPrelevaArticolo")) {
|
|
final RigaDocumentoP row = new RigaDocumentoP(apFull);
|
|
RigaDocumentoPKey pKey = new RigaDocumentoPKey(0L, 0L);
|
|
fillObject(req, pKey);
|
|
row.findByKey(pKey);
|
|
Documento ordine = row.getRigaDocumentoPrelevata().getDocumento();
|
|
ordine.setFlgDocumentoPrelevato(0L);
|
|
ordine.superSave();
|
|
rp = row.delete();
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Associazione tra documenti eliminata correttamente!");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("addAllegato")) {
|
|
final AllegatoDocumento row = new AllegatoDocumento(apFull);
|
|
fillObject(req, row);
|
|
rp = bean.addAllegato(row);
|
|
rp.append(creaFileAllegato(bean, req, res));
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("delAllegato")) {
|
|
final AllegatoDocumento row = new AllegatoDocumento(apFull);
|
|
fillObject(req, row);
|
|
rp = bean.delAllegato(row);
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK") + ": Allegato Cancellato");
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("addSeriale")) {
|
|
long l_id_articolo = getRequestLongParameter(req, "id_articoloS");
|
|
long l_id_articoloVariante = getRequestLongParameter(req, "id_articoloVarianteS");
|
|
String l_seriale = getRequestParameter(req, "serialeS");
|
|
Movimento mov = new Movimento(apFull);
|
|
mov.findBySerialeDisponibile(l_seriale);
|
|
RigaDocumento rd = new RigaDocumento(apFull);
|
|
rd.findMagBySerialeDisponibile(l_seriale);
|
|
if (mov.getId_articolo() != rd.getId_articolo()) {
|
|
System.out.println("DocumentoSvlt:addrow:addSeriale: rd.findBySeriale non coincide con mov...");
|
|
rp.setMsg("ERRORE! Seriale " + l_seriale + " inesistente o non disponibile");
|
|
rp.setStatus(false);
|
|
} else if (rd.getId_articolo() != 0L) {
|
|
l_id_articolo = rd.getId_articolo();
|
|
l_id_articoloVariante = rd.getId_articoloVariante();
|
|
rp = Documento.addSerialeSuRigheDocumento(bean, l_id_articolo, l_id_articoloVariante, l_seriale);
|
|
} else {
|
|
rp.setMsg("ERRORE! Seriale " + l_seriale + " inesistente o non disponibile");
|
|
rp.setStatus(false);
|
|
}
|
|
bean.setFlgMantieniArticoloRiga(getRequestLongParameter(req, "flgMantieniArticoloRiga"));
|
|
bean.setFlgAutoAdd(getRequestLongParameter(req, "flgAutoAdd"));
|
|
bean.setFlgSingleLineArt(getRequestLongParameter(req, "flgSingleLineArt"));
|
|
bean.setFlgInserisciReso(0L);
|
|
forceMessage(req, rp.getMsg());
|
|
req.setAttribute("bean", bean);
|
|
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 processRequest(HttpServletRequest req, HttpServletResponse res) {
|
|
super.processRequest(req, res);
|
|
}
|
|
|
|
protected int getPageRow(HttpServletRequest req) {
|
|
long l_id_tipoDocumento = getRequestLongParameter(req, "id");
|
|
TipoDocumento tipoDocumento = new TipoDocumento(getApFull(req));
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
if (l_id > 0L) {
|
|
Documento bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
l_id_tipoDocumento = bean.getId_tipoDocumento();
|
|
}
|
|
if (l_id_tipoDocumento == getId_docCassa() && !getAct(req).equals("del"))
|
|
return 0;
|
|
return super.getPageRow(req);
|
|
}
|
|
|
|
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = (Documento)beanA;
|
|
long l_id_tipoDocumento = bean.getId_tipoDocumento();
|
|
if (l_id_tipoDocumento == getId_docRiparazione()) {
|
|
Vectumerator<RigaDocumento> vec = bean.findRigheDocumento(1, 1, 0);
|
|
if (vec.hasMoreElements()) {
|
|
RigaDocumento bean2 = (RigaDocumento)vec.nextElement();
|
|
req.setAttribute("bean2", bean2);
|
|
}
|
|
}
|
|
int ordineInverso = (bean.getTipoDocumento().getFlgOrdinamentoRigheEdit() == 1L) ? 1 : 0;
|
|
req.setAttribute("listaOperatori", new Users(apFull).findUsersByFlgOperatore());
|
|
if (bean.getId_tipoDocumento() == getId_docCassa()) {
|
|
req.setAttribute("listaTipoPagamento", new TipoPagamento(apFull).findCodiciTender());
|
|
req.setAttribute("listaReparti", new Reparto(apFull).findAll());
|
|
} else {
|
|
req.setAttribute("listaTipoPagamento", new TipoPagamento(apFull).findByCR(new TipoPagamentoCR(), 0, 0));
|
|
}
|
|
req.setAttribute("listaDestinazioneDiversa", bean.getClifor().getDestinazioniDiverse());
|
|
req.setAttribute("listaVettore", new Vettore(apFull).findAll());
|
|
req.setAttribute("listaTipoDocumento", new TipoDocumento(apFull).findAll());
|
|
req.setAttribute("listaAspetto", new Aspetto(apFull).findAll());
|
|
req.setAttribute("listaPorto", new Porto(apFull).findAll());
|
|
req.setAttribute("listaCausaleTrasporto", new CausaleTrasporto(apFull).findAll());
|
|
if (bean.getTipoDocumento().getFlgOss() == 2L) {
|
|
req.setAttribute("listaIva", new Iva(apFull).findAllNonOss());
|
|
} else if (bean.getTipoDocumento().getFlgOss() == 1L) {
|
|
req.setAttribute("listaIva", new Iva(apFull).findAllOss());
|
|
} else {
|
|
req.setAttribute("listaIva", new Iva(apFull).findAll());
|
|
}
|
|
RigaDocumentoCR CR2 = new RigaDocumentoCR();
|
|
fillObject(req, CR2);
|
|
req.setAttribute("CR2", CR2);
|
|
CR2.setFlgCodiceRiga(0L);
|
|
req.setAttribute("listaRigheDocumento", bean.findRigheDocumento(CR2.getSearchRighe(),
|
|
(int)getRequestLongParameter(req, "pageNumber_righe"), getPageRow(req) / 2, ordineInverso));
|
|
req.setAttribute("listaLavorazione", new Lavorazione(apFull).findByTipoDocumento(bean.getId_tipoDocumento()));
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 201L ||
|
|
bean.getTipoDocumento().getFlgTipologia() == 202L) {
|
|
long l_id_rdTessuto = 0L;
|
|
if (req.getAttribute("beanRDTessuto") == null) {
|
|
l_id_rdTessuto = getRequestLongParameter(req, "id_rigaDocumentoTessutoA");
|
|
} else {
|
|
RigaDocumento rigaDocumento = (RigaDocumento)req.getAttribute("beanRDTessuto");
|
|
if (rigaDocumento != null)
|
|
l_id_rdTessuto = rigaDocumento.getId_rigaDocumento();
|
|
}
|
|
if (l_id_rdTessuto > 0L) {
|
|
RigaDocumento rdTessuto = new RigaDocumento(apFull);
|
|
rdTessuto.findByPrimaryKey(l_id_rdTessuto);
|
|
req.setAttribute("beanRDTessuto", rdTessuto);
|
|
if (rdTessuto.getId_rigaDocumento() > 0L)
|
|
req.setAttribute("listaRigheDocumento2", rdTessuto.findRigheFilatiByRDTessuto(l_id_rdTessuto));
|
|
req.setAttribute("listaArticoloTessutoFilato", rdTessuto.getArticoloTessuto().findArticoliTessutoFilati(0, 0));
|
|
}
|
|
}
|
|
req.setAttribute("listaDocPadri", bean.findDocumentiPadre());
|
|
req.setAttribute("listaDocFigli", bean.findDocumentiFiglio());
|
|
req.setAttribute("listaDocFPPadri", bean.findDocFiglioPadreByFiglio());
|
|
req.setAttribute("listaDocFPFigli", bean.findDocFiglioPadreByPadre());
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
|
row = (RigaDocumento)req.getAttribute("bean2");
|
|
if (row == null || row.getId_iva() == 0L) {
|
|
if (row == null)
|
|
row = new RigaDocumento(apFull);
|
|
row.setId_iva(row.getCodiceIvaVendStd());
|
|
req.setAttribute("bean2", row);
|
|
}
|
|
if (bean.getTipoDocumento().hasDocPrel()) {
|
|
req.setAttribute("listaRigheDocumentoPrelevabili", bean.findRigheDocumentoPrelevabili(0, 0));
|
|
req.setAttribute("listaRigheDocumentoPrelevati", bean.findRigheDocumentoPrelevateAssociate(0, 0));
|
|
}
|
|
if (bean.getTipoDocumento().getFlgAllegato() == 1L) {
|
|
req.setAttribute("listaTipiAllegatoDocumento", new TipoAllegatoDocumento(apFull).findAll());
|
|
req.setAttribute("listaAllegati", bean.getAllegati(0L));
|
|
}
|
|
req.setAttribute("listaAgenti", new DocumentoAgente(apFull).findByDocumento(bean.getId_documento()));
|
|
req.setAttribute("totaleImportiAgenti", new DocumentoAgente(apFull));
|
|
if (bean.getTipoDocumento().getCausaleMagazzino().isMagPartenzaDaScegliere())
|
|
req.setAttribute("listaMagPartenza", new MagFisico(apFull)
|
|
.findByCausalePartenza(bean.getTipoDocumento().getCausaleMagazzino()));
|
|
if (bean.getTipoDocumento().getCausaleMagazzino().isMagArrivoDaScegliere())
|
|
req.setAttribute("listaMagArrivo", new MagFisico(apFull).findByCausaleArrivo(bean.getTipoDocumento().getCausaleMagazzino()));
|
|
if (bean.getTipoDocumento().getCausaleMagazzino2().isMagPartenzaDaScegliere())
|
|
req.setAttribute("listaMagPartenza2", new MagFisico(apFull)
|
|
.findByCausalePartenza(bean.getTipoDocumento().getCausaleMagazzino2()));
|
|
if (bean.getTipoDocumento().getCausaleMagazzino2().isMagArrivoDaScegliere())
|
|
req.setAttribute("listaMagArrivo2", new MagFisico(apFull)
|
|
.findByCausaleArrivo(bean.getTipoDocumento().getCausaleMagazzino2()));
|
|
req.setAttribute("listaBanche", new Banca(apFull).findAll());
|
|
req.setAttribute("listaPagamenti", new DocumentoPagamento(apFull).findByDocumento(bean.getId_documento()));
|
|
req.setAttribute("listaScadenze", new DocumentoScadenza(apFull).findByDocumento(bean.getId_documento()));
|
|
req.setAttribute("listaBancaAnticipo", new Banca(apFull).findAll());
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 200L)
|
|
req.setAttribute("listaTelaio", new Telaio(apFull).findByCR(new TelaioCR(), 0, 0));
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 210L) {
|
|
Vectumerator vecTaglia = new Taglia(apFull).findAll();
|
|
req.setAttribute("listaTaglie", vecTaglia);
|
|
if (vecTaglia.hasMoreElements()) {
|
|
Taglia tagliaPrima = (Taglia)vecTaglia.nextElement();
|
|
bean.setId_taglia(tagliaPrima.getId_taglia());
|
|
}
|
|
req.setAttribute("listaColoriDaAggiungere", new Colore(apFull).findAll());
|
|
req.setAttribute("listaRigheDocumento", bean.findRigheDocumento(CR2.getSearchRighe(), 0, 0, ordineInverso));
|
|
}
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 220L) {
|
|
req.setAttribute("listaOrdiniAssociati", new DocFiglioPadre(apFull).findByPadre(bean.getId_documento()));
|
|
req.setAttribute("listaRigheDocumento", bean.findRigheDocumento(CR2.getSearchRighe(), 0, 0, ordineInverso));
|
|
}
|
|
if (bean.getFlgDeliveryType() == 2L) {
|
|
BrtApi brtapi = new BrtApi(apFull);
|
|
Vectumerator<PudoPoint> vecPudo = brtapi.findPudoPointByPudoAddress(bean.getPudoAddress());
|
|
req.setAttribute("listaPudo", vecPudo);
|
|
}
|
|
}
|
|
|
|
protected void fillComboAfterSearch(CRAdapter CRA, HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
req.setAttribute("listaTipologiaDocumento", new TipologiaDocumento(apFull).findAll());
|
|
req.setAttribute("listaTipoPagamento", new TipoPagamento(apFull).findByCR(new TipoPagamentoCR(), 0, 0));
|
|
req.setAttribute("listaVettore", new Vettore(apFull).findAll());
|
|
if (getLoginUser(req).getId_userProfile() == 10L) {
|
|
req.setAttribute("listaTipoDocumento", new TipoDocumento(apFull)
|
|
.findByTipologiaClienteFornitoreAFT(-1L, "C", -1L, -1L));
|
|
} else {
|
|
req.setAttribute("listaTipoDocumento", new TipoDocumento(apFull).findByCR(new TipoDocumentoCR(), 0, 0));
|
|
}
|
|
req.setAttribute("listaOperatori", new Users(apFull).findUsersByFlgOperatore());
|
|
req.setAttribute("listaBancaAnticipo", new Banca(apFull).findAll());
|
|
req.setAttribute("listaRiferimenti", new TipoDocumento(apFull).findRiferimenti());
|
|
Vectumerator<TipoDocumento> vecRet = new Vectumerator();
|
|
Vectumerator<DocPrel> vec = CR.getTipoDocumento().findDocGen(1L, 0L, 0, 0);
|
|
while (vec.hasMoreElements()) {
|
|
DocPrel doc = (DocPrel)vec.nextElement();
|
|
vecRet.add(doc.getTipoDocumento());
|
|
}
|
|
req.setAttribute("listaIva", new Iva(apFull).findAll());
|
|
req.setAttribute("listaTipiDocumento", vecRet);
|
|
}
|
|
|
|
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) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
req.setAttribute("nf4", getNf4());
|
|
req.setAttribute("listaOperatori", new Users(apFull).findUsersByFlgOperatore());
|
|
long l_id_tipoDocumento = getRequestLongParameter(req, "id");
|
|
if (l_id_tipoDocumento == 0L)
|
|
l_id_tipoDocumento = getRequestLongParameter(req, "id_tipoDocumento");
|
|
Documento bean = new Documento(apFull);
|
|
bean.setId_tipoDocumento(l_id_tipoDocumento);
|
|
if (l_id_tipoDocumento == bean.getId_docOrdineTaglio()) {
|
|
long l_id_articolo = getRequestLongParameter(req, "id_articolo");
|
|
bean.setId_articolo(l_id_articolo);
|
|
}
|
|
if (l_id_tipoDocumento == 1L) {
|
|
bean.findPrimoScontrinoAperto(getLoginUserId(req).longValue());
|
|
if (bean.getDBState() == 0) {
|
|
bean.setId_tipoDocumento(l_id_tipoDocumento);
|
|
bean.setId_clifor(1L);
|
|
} else {
|
|
fillComboAfterDetail(bean, req, res);
|
|
}
|
|
req.setAttribute("listaDocGen", bean.getTipoDocumento().findDocGen(1L, 0L, 0, 0));
|
|
}
|
|
req.setAttribute("listaLavorazione", new Lavorazione(apFull).findByTipoDocumento(bean.getId_tipoDocumento()));
|
|
bean.setFlgStato(1L);
|
|
bean.setId_tipoPagamento(1L);
|
|
bean.setId_ivaDoc(getParm("CODICE_IVA_STD_VEND").getNumeroLong());
|
|
bean.setPercContIntegrativo(getParm("PERC_CONT_INTEGRATIVO").getNumeroDouble());
|
|
bean.setPercRitenutaAcconto(getParm("PERC_RITENUTA_ACCONTO").getNumeroDouble());
|
|
req.setAttribute("bean", bean);
|
|
if (bean.getId_tipoDocumento() == 1L) {
|
|
req.setAttribute("listaTipoPagamento", new TipoPagamento(apFull).findCodiciTender());
|
|
req.setAttribute("listaReparti", new Reparto(apFull).findAll());
|
|
} else {
|
|
req.setAttribute("listaTipoPagamento", new TipoPagamento(apFull).findByCR(new TipoPagamentoCR(), 0, 0));
|
|
}
|
|
req.setAttribute("listaVettore", new Vettore(apFull).findAll());
|
|
req.setAttribute("listaTipoDocumento", new TipoDocumento(apFull).findAll());
|
|
req.setAttribute("listaIva", new Iva(apFull).findAll());
|
|
req.setAttribute("listaAspetto", new Aspetto(apFull).findAll());
|
|
req.setAttribute("listaPorto", new Porto(apFull).findAll());
|
|
if (bean.getTipoDocumento().getCausaleMagazzino().isMagPartenzaDaScegliere())
|
|
req.setAttribute("listaMagPartenza", new MagFisico(apFull)
|
|
.findByCausalePartenza(bean.getTipoDocumento().getCausaleMagazzino()));
|
|
if (bean.getTipoDocumento().getCausaleMagazzino().isMagArrivoDaScegliere())
|
|
req.setAttribute("listaMagArrivo", new MagFisico(apFull).findByCausaleArrivo(bean.getTipoDocumento().getCausaleMagazzino()));
|
|
if (bean.getTipoDocumento().getCausaleMagazzino2().isMagPartenzaDaScegliere())
|
|
req.setAttribute("listaMagPartenza2", new MagFisico(apFull)
|
|
.findByCausalePartenza(bean.getTipoDocumento().getCausaleMagazzino2()));
|
|
if (bean.getTipoDocumento().getCausaleMagazzino2().isMagArrivoDaScegliere())
|
|
req.setAttribute("listaMagArrivo2", new MagFisico(apFull)
|
|
.findByCausaleArrivo(bean.getTipoDocumento().getCausaleMagazzino2()));
|
|
req.setAttribute("listaBanche", new Banca(apFull).findAll());
|
|
RigaDocumento bean2 = new RigaDocumento(apFull);
|
|
bean2.setId_iva(getParm("CODICE_IVA_STD_VEND").getNumeroLong());
|
|
req.setAttribute("bean2", bean2);
|
|
}
|
|
|
|
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
|
System.out.println(getCmd(req));
|
|
search(req, res);
|
|
}
|
|
|
|
protected ResParm afterSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = (Documento)beanA;
|
|
bean.setFlgAutoAdd(getRequestLongParameter(req, "flgAutoAdd"));
|
|
bean.setFlgSingleLineArt(getRequestLongParameter(req, "flgSingleLineArt"));
|
|
if (getAct(req).equals("saveDisposizioneTaglio"))
|
|
bean.setId_clifor(bean.getArticolo().getId_fornitoreAbituale());
|
|
req.setAttribute("bean", bean);
|
|
return super.afterSave(beanA, req, res);
|
|
}
|
|
|
|
protected void print(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Users theUser = (Users)getLoginUser(req);
|
|
Users operatore = null;
|
|
long l_id_users = getRequestLongParameter(req, "id_oper");
|
|
if (l_id_users > 0L) {
|
|
operatore = new Users(apFull);
|
|
operatore.findByPrimaryKey(l_id_users);
|
|
}
|
|
try {
|
|
if (getAct(req).equals("doc")) {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getTipoDocumento().getFlgTipoStampa() == 10L) {
|
|
ResParm rp = bean.stampaScontrinoPrenotazione(false, theUser.getRegCassa());
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
} else {
|
|
DocumentoCR CR = new DocumentoCR();
|
|
fillObject(req, CR);
|
|
CR.setId_documentoS(l_id);
|
|
sendPdf(res, bean.creaDocumentoPdf(CR, false), "Doc " + bean.getNumeroDocumentoPdf() + DBAdapter.getDayTimeTimestamp());
|
|
}
|
|
} else if (getAct(req).equals("lblArt")) {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR();
|
|
fillObject(req, CR);
|
|
CR.setId_documentoS(l_id);
|
|
if (!getParm("LABEL_ART_A4_ZEBRA").isTrue()) {
|
|
sendPdf(res, bean.creaLabelDocumentoArticoliA4Pdf(CR), "Label Art Doc A4 " +
|
|
bean.getNumeroDocumentoPdf() + DBAdapter.getDayTimeTimestamp());
|
|
} else {
|
|
sendPdf(res, bean.creaLabelDocumentoArticoliZebraPdf(CR), "Label Art Zebra " +
|
|
bean.getNumeroDocumentoPdf() + DBAdapter.getDayTimeTimestamp());
|
|
}
|
|
} else if (getAct(req).equals("slip")) {
|
|
Documento bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR();
|
|
fillObject(req, CR);
|
|
sendPdf(res, bean.creaSlip(CR), "Slip Doc " + bean.getNumeroDocumentoPdf() + DBAdapter.getDayTimeTimestamp());
|
|
} else if (getAct(req).equals("lblArtAcc")) {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR();
|
|
fillObject(req, CR);
|
|
CR.setId_documentoS(l_id);
|
|
if (getParm("LABEL_ART_A4_ZEBRA").getNumeroInt() == 0) {
|
|
sendPdf(res, bean.creaLabelDocumentoArticoliAccA4Pdf(CR), "Label Accessori A4 Doc " +
|
|
bean.getNumeroDocumentoPdf() + DBAdapter.getDayTimeTimestamp());
|
|
} else {
|
|
sendPdf(res, bean.creaLabelDocumentoArticoliAccZebraPdf(CR), "Label Accessori Zebra Doc " +
|
|
bean.getNumeroDocumentoPdf() + DBAdapter.getDayTimeTimestamp());
|
|
}
|
|
} else if (getAct(req).equals("ristampaScontrino")) {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id);
|
|
ResParm rp = bean.stampaScontrino(true, theUser.getRegCassa());
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
} else if (getAct(req).equals("ristampaListaScontrini")) {
|
|
Documento bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
ResParm rp = bean.ristampaListaScontrini(CR, true, theUser.getRegCassa());
|
|
sendMessage(req, rp.getMsg());
|
|
req.setAttribute("CR", CR);
|
|
forceJspPageRelative("documentoCR.jsp", req);
|
|
callJsp(req, res);
|
|
} else if (getAct(req).equals("stampaScontrinoNonFiscale")) {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id);
|
|
if (operatore != null) {
|
|
bean.setId_users(operatore.getId_users());
|
|
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
|
|
bean.setLogRecord(bean.getLogRecord() + "<br />Scontrino Salvato - Operatore " + bean.getLogRecord() + " il " + operatore.getCognomeNome() + " " +
|
|
df.format(DBAdapter.getToday()));
|
|
}
|
|
ResParm rp = bean.stampaScontrino(false, theUser.getRegCassa());
|
|
sendHtmlMsgResponse(req, res, "<span>Scontrino non fiscale stampato. " + rp.getMsg() + "</span>");
|
|
} else if (getAct(req).equals("stampaScontrinoESalva")) {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
if (operatore != null) {
|
|
bean.setId_users(operatore.getId_users());
|
|
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
|
|
StringBuffer sb = new StringBuffer();
|
|
sb.append(bean.getLogRecord());
|
|
if (!bean.getLogRecord().isEmpty())
|
|
sb.append("<br />");
|
|
sb.append("Scontrino Salvato - Operatore ");
|
|
sb.append(operatore.getCognomeNome());
|
|
sb.append(" il ");
|
|
sb.append(df.format(DBAdapter.getToday()));
|
|
sb.append(" ");
|
|
sb.append(DBAdapter.getNow());
|
|
bean.setLogRecord(sb.toString());
|
|
}
|
|
ResParm rp = bean.save();
|
|
if (rp.getStatus()) {
|
|
if (bean.getFlgEmettiFatturaScontrino() == 0L) {
|
|
rp = bean.stampaScontrino(true, theUser.getRegCassa());
|
|
} else {
|
|
rp.setMsg("Documento salvato. Scontrino NON STAMPATO (emissione fattura)!");
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, rp.getMsg());
|
|
newRecord(req, res);
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
}
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
}
|
|
} else if (getAct(req).equals("chiudiScontrinoESalva")) {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
if (operatore != null) {
|
|
bean.setId_users(operatore.getId_users());
|
|
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
|
|
StringBuffer sb = new StringBuffer();
|
|
sb.append(bean.getLogRecord());
|
|
if (!bean.getLogRecord().isEmpty())
|
|
sb.append("<br />");
|
|
sb.append("Scontrino Salvato - Operatore ");
|
|
sb.append(operatore.getCognomeNome());
|
|
sb.append(" il ");
|
|
sb.append(df.format(DBAdapter.getToday()));
|
|
sb.append(" ");
|
|
sb.append(DBAdapter.getNow());
|
|
bean.setLogRecord(sb.toString());
|
|
}
|
|
ResParm rp = bean.save();
|
|
if (rp.getStatus()) {
|
|
if (bean.getFlgEmettiFatturaScontrino() == 0L) {
|
|
bean.setEchoScontrino("CHIUSO");
|
|
rp = bean.save();
|
|
} else {
|
|
rp.setMsg("Documento salvato. Scontrino NON CHIUSO (emissione fattura)!");
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, rp.getMsg());
|
|
newRecord(req, res);
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
}
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
}
|
|
} else if (getAct(req).equals("stampaReportFinanziario")) {
|
|
Documento bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
ResParm rp = bean.stampaReportFinanziario(theUser.getRegCassa());
|
|
sendHtmlMsgResponse(req, res, "<span>Report finanziario stampato. " + rp.getMsg() + "</span>");
|
|
} else if (getAct(req).equals("stampaReportGiornaliero")) {
|
|
Documento bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
ResParm rp = bean.stampaReportGiornaliero(theUser.getRegCassa());
|
|
sendHtmlMsgResponse(req, res, "<span>Report giornaliero stampato. " + rp.getMsg() + "</span>");
|
|
} else if (getAct(req).equals("apriCassa")) {
|
|
Documento bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
bean.apriCassa(theUser.getRegCassa());
|
|
sendHtmlMsgResponse(req, res, "<span>Cassa Aperta</span>");
|
|
} else if (getAct(req).equals("report")) {
|
|
int l_flgTipo = (int)getRequestLongParameter(req, "flgTipoReport");
|
|
Documento bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
sendPdf(res, bean.creaReportPdf(l_flgTipo, CR), "ReportDoc " + DBAdapter.getDayTimeTimestamp());
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
protected String getBeanPageName(HttpServletRequest req) {
|
|
String temp;
|
|
ApplParmFull apFull = getApFull(req);
|
|
TipoDocumento tipoDocumento = new TipoDocumento(apFull);
|
|
TipologiaDocumento tipologiaDocumento = new TipologiaDocumento(apFull);
|
|
if (getCmd(req).equals("ni")) {
|
|
long l_id_tipoDocumento = getRequestLongParameter(req, "id");
|
|
tipoDocumento.findByPrimaryKey(l_id_tipoDocumento);
|
|
} else if (!getCmd(req).equals("search")) {
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
if (l_id_documento > 0L) {
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
tipoDocumento = bean.getTipoDocumento();
|
|
} else {
|
|
long l_id_tipoDocumento = getRequestLongParameter(req, "id_tipoDocumento");
|
|
tipoDocumento.findByPrimaryKey(l_id_tipoDocumento);
|
|
}
|
|
} else if (getCmd(req).equals("search")) {
|
|
long l_flgTipologia = getRequestLongParameter(req, "flgTipologia");
|
|
tipologiaDocumento.findByCodice(l_flgTipologia);
|
|
}
|
|
if (getCmd(req).equals("asq") || (!getCmd(req).equals("search") && !getAct(req).equals("del"))) {
|
|
if (tipoDocumento.getId_tipoDocumento() > 0L) {
|
|
if (!tipoDocumento.getSuffissoPD().isEmpty()) {
|
|
temp = super.getBeanPageName(req) + super.getBeanPageName(req);
|
|
} else if (!tipoDocumento.getTipologiaDocumento().getSuffissoPD().isEmpty()) {
|
|
temp = super.getBeanPageName(req) + super.getBeanPageName(req);
|
|
} else {
|
|
temp = super.getBeanPageName(req);
|
|
}
|
|
if (getLoginUser(req).getId_userProfile() == 10L)
|
|
temp = temp + "Cli";
|
|
return temp;
|
|
}
|
|
return super.getBeanPageName(req);
|
|
}
|
|
if (!tipoDocumento.getSuffissoCR().isEmpty()) {
|
|
temp = super.getBeanPageName(req) + super.getBeanPageName(req);
|
|
} else if (!tipologiaDocumento.getSuffissoCR().isEmpty()) {
|
|
temp = super.getBeanPageName(req) + super.getBeanPageName(req);
|
|
} else {
|
|
temp = super.getBeanPageName(req);
|
|
}
|
|
if (getLoginUser(req).getId_userProfile() == 10L)
|
|
temp = temp + "Cli";
|
|
return temp;
|
|
}
|
|
|
|
protected void showBean(HttpServletRequest req, HttpServletResponse res) {
|
|
super.showBean(req, res);
|
|
}
|
|
|
|
protected void mail(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
Documento bean = new Documento(apFull);
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
String eMail = getRequestParameter(req, "eMailInvio");
|
|
String testoAgg = getRequestParameter(req, "testoAgg");
|
|
if (getAct(req).equals("web")) {
|
|
bean.findByPrimaryKey(l_id);
|
|
eMail = bean.getClifor().getEMail();
|
|
String lang = "it";
|
|
if (!bean.getClifor().getNazione().getCodice().equals("IT"))
|
|
lang = "en";
|
|
ResParm rp = new ResParm();
|
|
long tipoInvio = getParm("WEB_SEND_ORDER_MAIL_CODE").getNumeroLong();
|
|
if (tipoInvio == 0L) {
|
|
rp = bean.sendOrderMailMessageRavinale(lang, false, true, false);
|
|
} else if (tipoInvio == 1L) {
|
|
rp = bean.sendOrderMailMessageRavinale(lang, false, true, false);
|
|
} else if (tipoInvio == 2L) {
|
|
Users utente = bean.getClifor().getUserWww();
|
|
rp = bean.sendOrderMailMessageTuttofoto(utente, true, true, false, false);
|
|
} else if (tipoInvio == 99L) {
|
|
Attivita attivita = Attivita.getDefaultInstance(apFull);
|
|
Users user = new Users(apFull);
|
|
user.findFirstByClifor(bean.getId_clifor());
|
|
boolean spedito = (bean.getFlgStatoOrdineWww() == 2L);
|
|
rp = attivita.sendOrderMailMessageCC(bean, user, lang, true, true, false, spedito, req);
|
|
}
|
|
sendMessage(req, rp.getMsg());
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
} else if (getAct(req).equals("clifor") || getAct(req).equals("ext")) {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (getAct(req).equals("clifor"))
|
|
eMail = bean.getClifor().getEMail();
|
|
if (!testoAgg.isEmpty())
|
|
bean.setTestoAgg(testoAgg);
|
|
if (eMail.isEmpty()) {
|
|
sendMessage(req, "Errore! indirizzo email non valido!");
|
|
if (l_id != 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
} else {
|
|
CR.setId_documentoS(l_id);
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
ResParm rp = bean.sendDocumentiMailMessage(CR, eMail, path);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Mail inviata con successo");
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
} else if (getAct(req).equals("cli")) {
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
bean.sendDocumentiMailMessage(CR, eMail, path);
|
|
search(req, res);
|
|
} else {
|
|
CR.setId_documentoS(l_id);
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
ResParm rp = bean.sendDocumentiMailMessage(CR, eMail, path);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Mail inviata con successo");
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void mailOLD(HttpServletRequest req, HttpServletResponse res) {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
String eMail = getRequestParameter(req, "eMailInvio");
|
|
String testoAgg = getRequestParameter(req, "testoAgg");
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
if (getAct(req).equals("web")) {
|
|
eMail = bean.getClifor().getEMail();
|
|
ResParm rp = bean.sendOrderMailMessage(getLang(req), false, true, false);
|
|
sendMessage(req, rp.getMsg());
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
} else {
|
|
if (!testoAgg.isEmpty())
|
|
bean.setTestoAgg(testoAgg);
|
|
if (getAct(req).equals("clifor"))
|
|
eMail = bean.getClifor().getEMail();
|
|
if (eMail.isEmpty()) {
|
|
sendMessage(req, "Errore! indirizzo email non valido!");
|
|
if (l_id != 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
} else {
|
|
DocumentoCR CR = new DocumentoCR(getApFull(req));
|
|
fillObject(req, CR);
|
|
CR.setId_documentoS(l_id);
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
ResParm rp = bean.sendDocumentiMailMessage(CR, eMail, path);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Mail inviata con successo");
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected ResParm beforeSearch(HttpServletRequest req, HttpServletResponse res) {
|
|
long l_id_tipoDocumento = getRequestLongParameter(req, "id");
|
|
if (getId_docPrenotazione() > 0L && (l_id_tipoDocumento == getId_docPrenotazione() || l_id_tipoDocumento == getId_docRiparazione()))
|
|
req.setAttribute("id_tipoDocumento", String.valueOf(l_id_tipoDocumento));
|
|
it.acxent.common.Users users = getLoginUser(req);
|
|
req.setAttribute("flgSuper", Long.valueOf(users.getFlgSuper()));
|
|
return super.beforeSearch(req, res);
|
|
}
|
|
|
|
public void _associaOrdineTaglioS(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
forceJspPageRelative("documentiOrdineTaglioLista.jsp", req);
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
if (bean.getId_documento() > 0L) {
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
CR.setFlgTipologia(210L);
|
|
req.setAttribute("listaOrdiniTaglio", bean.findOrdiniTaglioAperti());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _creaFattureDaDDtTessitura(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = new Documento(apFull);
|
|
long l_id_cliforR = getRequestLongParameter(req, "id_cliforR");
|
|
long l_id = getRequestLongParameter(req, "id_documentoR");
|
|
long l_flgTipoGenerazione = getRequestLongParameter(req, "flgTipoGenerazione");
|
|
Users operatore = null;
|
|
long l_id_users = getRequestLongParameter(req, "id_oper");
|
|
if (l_id_users > 0L) {
|
|
operatore = new Users(apFull);
|
|
operatore.findByPrimaryKey(l_id_users);
|
|
} else {
|
|
operatore = bean.getUsers();
|
|
}
|
|
ResParm rp = new ResParm(true);
|
|
long l_id_tipoDocumentoFiglio = getRequestLongParameter(req, "id_tipoDocumentoF");
|
|
TipoDocumento tdDaGenerare = new TipoDocumento(apFull);
|
|
tdDaGenerare.findByPrimaryKey(l_id_tipoDocumentoFiglio);
|
|
if (tdDaGenerare.hasPadreConTipologia(200L)) {
|
|
if (l_id_cliforR == 0L || l_id == 0L) {
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
if (CR.getId_tipoDocumento() == 0L) {
|
|
rp.setMsg("Errore! Tipo del documento non trovata!");
|
|
rp.setStatus(false);
|
|
} else {
|
|
Vectumerator<Clifor> vecClifor = bean.findCliforByCR(CR);
|
|
while (vecClifor.hasMoreElements()) {
|
|
Clifor rowClifor = (Clifor)vecClifor.nextElement();
|
|
HashMap<Long, Documento> hmDdt = new HashMap<>();
|
|
HashMap<Long, Documento> hmDispTess = new HashMap<>();
|
|
CR.setId_clifor(rowClifor.getId_clifor());
|
|
Vectumerator<Documento> vec = bean.findByCR(CR, 0, 0);
|
|
while (vec.hasMoreElements()) {
|
|
Documento row = (Documento)vec.nextElement();
|
|
hmDdt.put(new Long(row.getId_documento()), row);
|
|
LavPezza lp = new LavPezza(apFull);
|
|
Vectumerator<LavPezza> vecLP = lp.findByDocumentoBolla(row.getId_documento());
|
|
while (vecLP.hasMoreElements()) {
|
|
LavPezza rowLP = (LavPezza)vecLP.nextElement();
|
|
Long lpKey = new Long(rowLP.getRigaDocumento().getId_documento());
|
|
if (!hmDispTess.containsKey(lpKey))
|
|
hmDispTess.put(lpKey, rowLP.getRigaDocumento().getDocumento());
|
|
}
|
|
for (Map.Entry<Long, Documento> entry : hmDispTess.entrySet()) {
|
|
System.out.println("Key = " + String.valueOf(entry.getKey()) + ", Value = " + entry.getValue().getNumeroDocumentoCompleto());
|
|
rp = entry.getValue().creaDocumentoFiglioDaDisposizioniTessitura(rowClifor.getId_clifor(), l_id_tipoDocumentoFiglio, operatore, true, l_flgTipoGenerazione, hmDdt);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
bean.findByPrimaryKey(l_id);
|
|
HashMap<Long, Documento> hmDdt = new HashMap<>();
|
|
HashMap<Long, Documento> hmDispTess = new HashMap<>();
|
|
hmDdt.put(new Long(l_id), bean);
|
|
LavPezza lp = new LavPezza(apFull);
|
|
Vectumerator<LavPezza> vecLP = lp.findByDocumentoBolla(l_id);
|
|
while (vecLP.hasMoreElements()) {
|
|
LavPezza rowLP = (LavPezza)vecLP.nextElement();
|
|
Long lpKey = new Long(rowLP.getRigaDocumento().getId_documento());
|
|
if (!hmDispTess.containsKey(lpKey))
|
|
hmDispTess.put(lpKey, rowLP.getRigaDocumento().getDocumento());
|
|
}
|
|
for (Map.Entry<Long, Documento> entry : hmDispTess.entrySet()) {
|
|
System.out.println("Key = " + String.valueOf(entry.getKey()) + ", Value = " + entry.getValue().getNumeroDocumentoCompleto());
|
|
rp = entry.getValue().creaDocumentoFiglioDaDisposizioniTessitura(bean.getId_clifor(), l_id_tipoDocumentoFiglio, operatore, true, l_flgTipoGenerazione, hmDdt);
|
|
}
|
|
}
|
|
} else {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Errore! Documento generabile non ha come padre una disposizione tessitura!");
|
|
}
|
|
if (rp.getStatus()) {
|
|
afterCreaDocFigli(req, res, bean, l_id_tipoDocumentoFiglio);
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
String theForm = getRequestParameter(req, "theForm");
|
|
String pageType = getRequestParameter(req, "pageType");
|
|
if (theForm.equals("ricerca") || pageType.equals("R")) {
|
|
search(req, res);
|
|
} else {
|
|
req.setAttribute("id_documento", Long.valueOf(l_id));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
protected void callJsp(HttpServletRequest req, HttpServletResponse res) {
|
|
req.setAttribute("nf4", getNf4());
|
|
super.callJsp(req, res);
|
|
}
|
|
|
|
protected ResParm creaFileAllegato(DocumentoInterface beanA, HttpServletRequest req, HttpServletResponse res) {
|
|
synchronized (this) {
|
|
ResParm rp = new ResParm(true, "");
|
|
Documento bean = (Documento)beanA;
|
|
String targetDir = bean.getPathAllegato();
|
|
File pathDir = new File(targetDir);
|
|
if (!pathDir.exists())
|
|
pathDir.mkdirs();
|
|
String targetFile = targetDir + "/" + targetDir + "_";
|
|
Vectumerator completeFileNames = (Vectumerator)req.getAttribute("completeAttachName");
|
|
Vectumerator fileNames = (Vectumerator)req.getAttribute("attachName");
|
|
if (completeFileNames.hasMoreElements()) {
|
|
String sourceFile = (String)completeFileNames.nextElement();
|
|
String fileName = (String)fileNames.elementAt(0);
|
|
targetFile = targetFile + targetFile;
|
|
if (isFileExist(sourceFile)) {
|
|
new File(targetFile).delete();
|
|
new File(sourceFile).renameTo(new File(targetFile));
|
|
}
|
|
}
|
|
return rp;
|
|
}
|
|
}
|
|
|
|
protected boolean isLoadImageServlet() {
|
|
return true;
|
|
}
|
|
|
|
public void _listaPrenotazioni(HttpServletRequest req, HttpServletResponse res) {
|
|
forceJspPageRelative("documentoListaPrenotazioni.jsp", req);
|
|
DocumentoCR CRDoc = new DocumentoCR(getApFull(req));
|
|
fillObject(req, CRDoc);
|
|
CRDoc.setFlgTipologia(4L);
|
|
CRDoc.setFlgStatoPrenotazione(200L);
|
|
CRDoc.setFlgDocumentoPrelevato(0L);
|
|
req.setAttribute("listaPrenota", new Documento(getApFull(req)).findByCR(CRDoc, CRDoc.getPageNumber(), 10));
|
|
req.setAttribute("CR", CRDoc);
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _loadPrenotazioniMagazzino(HttpServletRequest req, HttpServletResponse res) {
|
|
long id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
RigaDocumento rd = new RigaDocumento(getApFull(req));
|
|
rd.findByPrimaryKey(id_rigaDocumento);
|
|
sendHtmlMsgResponse(req, res, rd.getQuantitaMagazzinoMovimentoHtml());
|
|
}
|
|
|
|
public void _listaOrdiniPrenotazione(HttpServletRequest req, HttpServletResponse res) {
|
|
forceJspPageRelative("documentoListaFigli.jsp", req);
|
|
long l_id = getRequestLongParameter(req, "id_rigaDocumento");
|
|
req.setAttribute("listaFigli", new Documento(getApFull(req)).findDocumentiOrdiniByRigaPrenotazione(l_id));
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _riordinaCR(HttpServletRequest req, HttpServletResponse res) {
|
|
Articolo bean = new Articolo(getApFull(req));
|
|
long l_id_fornitore = getRequestLongParameter(req, "id_cliforR");
|
|
long l_id = getRequestLongParameter(req, "id_articoloR");
|
|
long l_id_rigaPrenotazione = getRequestLongParameter(req, "id_rigaDocumentoR");
|
|
long l_id_av = getRequestLongParameter(req, "id_articoloVarianteR");
|
|
double l_qta = getRequestDoubleParameter(req, "qtaR");
|
|
ResParm rp = new ResParm(true);
|
|
if (l_id_fornitore == 0L || l_id == 0L) {
|
|
rp.setMsg("Errore! Codice fornitore o articolo non valido");
|
|
rp.setStatus(false);
|
|
} else {
|
|
RigaDocumento rd = new RigaDocumento(getApFull(req));
|
|
rd.findByPrimaryKey(l_id_rigaPrenotazione);
|
|
double qtaDaRiordinare = bean.getQtaDaRiordinare(l_id_rigaPrenotazione);
|
|
if (l_id_rigaPrenotazione > 0L && qtaDaRiordinare < l_qta) {
|
|
rp.setMsg("Errore! Da questa prenotazione puoi ordinare al massimo " + qtaDaRiordinare + " articolo.");
|
|
rp.setStatus(false);
|
|
} else {
|
|
bean.findByPrimaryKey(l_id);
|
|
rp = Articolo.creaOrdine(bean, l_id_av, l_id_fornitore, l_qta);
|
|
if (rp.getStatus() && l_id_rigaPrenotazione > 0L) {
|
|
Documento beanR = (Documento)rp.getReturnObj();
|
|
beanR.addRigaPrenotazionePrelevataDaOrdine(rd, l_qta);
|
|
}
|
|
}
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK") + AbMessages.getMessage(getLocale(req), "SAVE_OK"));
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _riordinaAVCR(HttpServletRequest req, HttpServletResponse res) {
|
|
long l_id_fornitore = getRequestLongParameter(req, "id_cliforR");
|
|
long l_id_rigaPrenotazione = getRequestLongParameter(req, "id_rigaDocumentoR");
|
|
String l_id_articoloVarianteRV = getRequestParameter(req, "id_articoloVarianteRV");
|
|
String l_qtaArticoloVarianteRV = getRequestParameter(req, "qtaArticoloVarianteRV");
|
|
ResParm rp = new ResParm(true);
|
|
if (l_id_fornitore == 0L || l_id_articoloVarianteRV.isEmpty()) {
|
|
rp.setMsg("Errore! Codice fornitore o articoli variante non validi");
|
|
rp.setStatus(false);
|
|
} else {
|
|
StringTokenizer st = new StringTokenizer(l_id_articoloVarianteRV, ";");
|
|
StringTokenizer stQta = new StringTokenizer(l_qtaArticoloVarianteRV, ";");
|
|
while (st.hasMoreTokens()) {
|
|
String token = st.nextToken();
|
|
long l_id_articoloVariante = Long.valueOf(token);
|
|
ArticoloVariante bean = new ArticoloVariante(getApFull(req));
|
|
bean.findByPrimaryKey(l_id_articoloVariante);
|
|
double l_qta = Double.valueOf(stQta.nextToken().replace(',', '.'));
|
|
if (l_qta > 0.0D) {
|
|
rp = Articolo.creaOrdine(bean.getArticolo(), l_id_articoloVariante, l_id_fornitore, l_qta);
|
|
if (rp.getStatus() && l_id_rigaPrenotazione > 0L) {
|
|
Documento beanR = (Documento)rp.getReturnObj();
|
|
RigaDocumento rd = new RigaDocumento(getApFull(req));
|
|
rd.findByPrimaryKey(l_id_rigaPrenotazione);
|
|
beanR.addRigaPrenotazionePrelevataDaOrdine(rd, l_qta);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK") + AbMessages.getMessage(getLocale(req), "SAVE_OK"));
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _riordinaPrenotazione(HttpServletRequest req, HttpServletResponse res) {
|
|
ResParm rp = new ResParm(true);
|
|
Documento bean = new Documento(getApFull(req));
|
|
fillObject(req, bean);
|
|
RigaDocumento rd = new RigaDocumento(getApFull(req));
|
|
Vectumerator<RigaDocumento> vec = rd.findByDocumento(0L, bean.getId_documento(), "", 0, 0, 0);
|
|
while (vec.hasMoreElements()) {
|
|
rd = (RigaDocumento)vec.nextElement();
|
|
if (RigaDocumentoPM.isRigaPrenotazionePrelevata(rd)) {
|
|
ResParm rpe = new ResParm(false);
|
|
rpe.setMsg("L'articolo " + rd.getArticolo().getNome() + " ha gia' un ordine!");
|
|
rp.append(rpe);
|
|
continue;
|
|
}
|
|
if (rd.getId_articoloVariante() != 0L) {
|
|
if (rd.getArticoloVariante().getId_fornitoreAbituale() != 0L) {
|
|
if (rd.getArticoloVariante().getQuantitaEffettivaAv() < 0.0D) {
|
|
rp.append(Articolo.creaOrdine(rd.getArticolo(), rd.getId_articoloVariante(),
|
|
rd.getArticoloVariante().getId_fornitoreAbituale(), rd.getQuantita()));
|
|
if (rp.getStatus()) {
|
|
Documento beanR = (Documento)rp.getReturnObj();
|
|
beanR.addRigaPrenotazionePrelevataDaOrdine(rd, rd.getQuantita());
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
ResParm rpe = new ResParm(false);
|
|
rpe.setMsg("L'articolo " + rd.getArticolo().getNome() + " non ha il fornitore abituale!");
|
|
rp.append(rpe);
|
|
continue;
|
|
}
|
|
if (rd.getArticolo().getQuantitaEffettiva() < 0.0D) {
|
|
if (rd.getArticolo().getId_fornitoreAbituale() != 0L) {
|
|
rp.append(
|
|
Articolo.creaOrdine(rd.getArticolo(), 0L, rd.getArticolo().getId_fornitoreAbituale(), rd.getQuantita()));
|
|
if (rp.getStatus()) {
|
|
Documento beanR = (Documento)rp.getReturnObj();
|
|
beanR.addRigaPrenotazionePrelevataDaOrdine(rd, rd.getQuantita());
|
|
}
|
|
continue;
|
|
}
|
|
ResParm rpe = new ResParm(false);
|
|
rpe.setMsg("L'articolo " + rd.getArticolo().getNome() + " non ha il fornitore abituale!");
|
|
rp.append(rpe);
|
|
}
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK") + AbMessages.getMessage(getLocale(req), "SAVE_OK"));
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _listaFigli(HttpServletRequest req, HttpServletResponse res) {
|
|
forceJspPageRelative("documentoListaFigli.jsp", req);
|
|
long l_id = getRequestLongParameter(req, "id_rigaDocumento");
|
|
req.setAttribute("listaFigli", new Documento(getApFull(req)).findDocumentiFiglioRiga(l_id));
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _listaFigliOrdine(HttpServletRequest req, HttpServletResponse res) {
|
|
caricaListaFigliPadriOrdine(req, res, 0L);
|
|
}
|
|
|
|
protected void afterCreaDocFigli(HttpServletRequest req, HttpServletResponse res, Documento bean, long l_id_tipoDocumentoFiglio) {
|
|
TipoDocumento td = new TipoDocumento(getApFull(req));
|
|
td.findByPrimaryKey(l_id_tipoDocumentoFiglio);
|
|
if (td.getId_tipologiaDocumento() == 5L) {
|
|
if (td.getFlgClienteFornitore().equals("F")) {
|
|
bean.setFlgStatoRiparazione(1L);
|
|
} else {
|
|
bean.setFlgStatoRiparazione(99L);
|
|
bean.setDataChiusura(DBAdapter.getToday());
|
|
}
|
|
bean.save();
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_OK"));
|
|
}
|
|
}
|
|
|
|
public void _generaDocumento(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
long l_flgTipoCreazione = getRequestLongParameter(req, "flgTipoCreazione");
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
bean.save();
|
|
ResParm rp = new ResParm();
|
|
long l_id_cliforFiglio = getRequestLongParameter(req, "id_clifor2");
|
|
long l_id_tipoDocumentoFiglio = getRequestLongParameter(req, "flgEmettiFatturaScontrino");
|
|
rp = bean.creaDocumentoFiglio(l_id_cliforFiglio, l_id_tipoDocumentoFiglio, (Users)getLoginUser(req), false, l_flgTipoCreazione);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Documento generata correttamente");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _generaDocumentoDaScontrino(HttpServletRequest req, HttpServletResponse res) {
|
|
Users operatore = null;
|
|
long l_id_users = getRequestLongParameter(req, "id_oper");
|
|
long l_flgTipoCreazione = getRequestLongParameter(req, "flgTipoCreazione");
|
|
if (l_id_users > 0L) {
|
|
operatore = new Users(getApFull(req));
|
|
operatore.findByPrimaryKey(l_id_users);
|
|
}
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
bean.save();
|
|
ResParm rp = new ResParm();
|
|
long l_id_cliforFiglio = getRequestLongParameter(req, "id_cliforListino");
|
|
long l_id_tipoDocumentoFiglio = getRequestLongParameter(req, "flgEmettiFatturaScontrino");
|
|
rp = bean.creaDocumentoFiglio(l_id_cliforFiglio, l_id_tipoDocumentoFiglio, operatore, false, l_flgTipoCreazione);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Documento generata correttamente");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _procediPagamento(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
ResParm rp = new ResParm();
|
|
if (bean.getDBState() == 0) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Errore! Codice documento non valido");
|
|
} else {
|
|
bean.setFlgProcediPagamento(1L);
|
|
rp = bean.superSave();
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Documento " + bean.getNumeroDocumentoCompleto() + ": Procedi pagamento OK.");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
search(req, res);
|
|
}
|
|
|
|
public void _aggionraSPCR(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
long l_flgStatoPrenotazione = getRequestLongParameter(req, "flgStatoPrenotazioneS");
|
|
ResParm rp = new ResParm();
|
|
if (bean.getDBState() == 0) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Errore! Codice documento non valido");
|
|
} else {
|
|
rp = bean.aggiornaStatoPrenotazione(bean.getFlgStatoPrenotazione(), l_flgStatoPrenotazione);
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Stato Prenotazione aggiornato.");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
req.setAttribute("cmd", "search");
|
|
search(req, res);
|
|
}
|
|
|
|
public void _inviaAvviso(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
ResParm rp = new ResParm();
|
|
if (bean.getDBState() == 0) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Errore! Codice documento non valido");
|
|
} else {
|
|
rp = bean.sendAvvisoRiparazione();
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Avviso inviato correttamente.");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
search(req, res);
|
|
}
|
|
|
|
public void _inviaSpedizioneAvvenuta(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
ResParm rp = new ResParm();
|
|
if (bean.getDBState() == 0) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Errore! Codice documento non valido");
|
|
} else {
|
|
rp = bean.sendSpeditoMailMessage(getLang(req));
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Avviso inviato correttamente.");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
search(req, res);
|
|
}
|
|
|
|
public void _creaCodaSms(HttpServletRequest req, HttpServletResponse res) {
|
|
RigaDocumentoCR CR = new RigaDocumentoCR();
|
|
fillObject(req, CR);
|
|
CR.setId_tipoDocumento(getId_docCassa());
|
|
CR.setFlgTipoRicerca(0L);
|
|
RigaDocumento bean = new RigaDocumento(getApFull(req));
|
|
Vectumerator vec = bean.findByCR(CR, 0, 0);
|
|
String l_msg = getRequestParameter(req, "testoMessaggio").trim();
|
|
ResParm rp = new ResParm(true);
|
|
if (l_msg.isEmpty()) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("ERRORE! Testo del messaggio vuoto!!");
|
|
} else {
|
|
int i = 0;
|
|
int j = 0;
|
|
while (vec.hasMoreElements()) {
|
|
RigaDocumento row = (RigaDocumento)vec.nextElement();
|
|
rp = row.creaCodaMessaggio(l_msg);
|
|
if (rp.getStatus()) {
|
|
i++;
|
|
continue;
|
|
}
|
|
j++;
|
|
}
|
|
sendMessage(req, "Creazione coda messaggi eseguita correttamente. Messaggi creati: " + i + " messaggi NON creati: " + j);
|
|
search(req, res);
|
|
}
|
|
}
|
|
|
|
public void _applicaListino(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
if (l_id > 0L) {
|
|
bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
if (bean.getId_cliforListino() > 0L) {
|
|
if (bean.getCliforListino().getId_tipoPagamento() == 0L) {
|
|
bean.setId_tipoPagamento(1L);
|
|
} else if (bean.getCliforListino().getTipoPagamento().getCodiceTenderCassa().isEmpty()) {
|
|
bean.setId_tipoPagamento(bean.getTipoPagamentoScontrinoConFattura().getId_tipoPagamento());
|
|
} else {
|
|
bean.setId_tipoPagamento(bean.getCliforListino().getId_tipoPagamento());
|
|
}
|
|
bean.save();
|
|
bean.applicaListinoByClifor(bean.getCliforListino());
|
|
} else {
|
|
if (bean.getId_clifor() > 0L)
|
|
if (bean.getClifor().getId_tipoPagamento() == 0L) {
|
|
bean.setId_tipoPagamento(1L);
|
|
} else if (bean.getClifor().getTipoPagamento().getCodiceTenderCassa().isEmpty()) {
|
|
bean.setId_tipoPagamento(bean.getTipoPagamentoScontrinoConFattura().getId_tipoPagamento());
|
|
} else {
|
|
bean.setId_tipoPagamento(bean.getClifor().getId_tipoPagamento());
|
|
}
|
|
bean.save();
|
|
bean.applicaListinoByClifor(bean.getClifor());
|
|
}
|
|
sendMessage(req, "Prezzi sul documenti aggiornati secondo il listino di " + bean.getCliforListino().getDescrizioneCompleta());
|
|
} else {
|
|
bean = new Documento(apFull);
|
|
fillObject(req, bean);
|
|
if (bean.getId_cliforListino() > 0L) {
|
|
if (bean.getCliforListino().getId_tipoPagamento() == 0L) {
|
|
bean.setId_tipoPagamento(1L);
|
|
} else if (bean.getCliforListino().getTipoPagamento().getCodiceTenderCassa().isEmpty()) {
|
|
bean.setId_tipoPagamento(bean.getTipoPagamentoScontrinoConFattura().getId_tipoPagamento());
|
|
} else {
|
|
bean.setId_tipoPagamento(bean.getCliforListino().getId_tipoPagamento());
|
|
}
|
|
} else {
|
|
bean.setId_tipoPagamento(1L);
|
|
}
|
|
req.setAttribute("bean", bean);
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _applicaListinoDoc(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
if (l_id > 0L) {
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
bean.save();
|
|
bean.applicaListinoByClifor(bean.getCliforListino());
|
|
sendMessage(req, "Pressi sul documenti aggiornati secondo il listino di " + bean.getCliforListino().getDescrizioneCompleta());
|
|
} else {
|
|
sendMessage(req, "Attenzione! Cliente per listino non trovato");
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _annAssPren(HttpServletRequest req, HttpServletResponse res) {
|
|
RigaDocumento row = new RigaDocumento(getApFull(req));
|
|
long l_id = getRequestLongParameter(req, "id_rigaDocumento");
|
|
row.findByPrimaryKey(l_id);
|
|
row.setFlgPrenotazioneArrivata(0L);
|
|
ResParm rp = row.save();
|
|
rp.append(row.getDocumento().aggiornaStatoPrenotazione(row.getDocumento().getFlgStatoPrenotazione(), 0L));
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Prenotazione riga aggiornata con successo!");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _annullaSlip(HttpServletRequest req, HttpServletResponse res) {
|
|
RigaDocumento row = new RigaDocumento(getApFull(req));
|
|
long l_id = getRequestLongParameter(req, "id_rigaDocumento");
|
|
row.findByPrimaryKey(l_id);
|
|
row.setQtaSlipStampate(0L);
|
|
ResParm rp = row.save();
|
|
rp.append(row.getDocumento().aggiornaStatoPrenotazione(row.getDocumento().getFlgStatoPrenotazione(), 0L));
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Stampa slip azzerata. Prenotazione riga aggiornata con successo!");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
private void caricaListaFigliPadriOrdine(HttpServletRequest req, HttpServletResponse res, long tipoDoc) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
forceJspPageRelative("documentoListaOrdine.jsp", req);
|
|
long l_id = getRequestLongParameter(req, "id_rigaDocumento");
|
|
if (tipoDoc == 0L) {
|
|
req.setAttribute("listaFigliOrdine", new Documento(apFull).findDocumentiPrelievoOrdine(l_id));
|
|
} else if (tipoDoc == 1L) {
|
|
req.setAttribute("listaFigliOrdine", new Documento(apFull).findDocumentiPrelievoOrdineP(l_id));
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _listaPadriOrdine(HttpServletRequest req, HttpServletResponse res) {
|
|
caricaListaFigliPadriOrdine(req, res, 1L);
|
|
}
|
|
|
|
public void _sbloccaDocumento(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
StringBuilder sb = new StringBuilder();
|
|
long id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(id_documento);
|
|
sb.append(bean.getNotaSblocco());
|
|
sb.append("\nSbloccato da: " + apFull.getLastUpdUser().getLogin());
|
|
bean.setFlgEmsta(1L);
|
|
bean.setNotaSblocco(sb.toString());
|
|
bean.superSave();
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _calcolaTessutiTaglio(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_documento() > 0L) {
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
if (rp.getStatus())
|
|
rp = Documento.calcolaTessutiTaglio(bean, getLang(req));
|
|
if (rp.getStatus() == true) {
|
|
sendMessage(req, "Calcolo tessuti effettuato");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void mailOLD2(HttpServletRequest req, HttpServletResponse res) {
|
|
DocumentoCR CR = new DocumentoCR(getApFull(req));
|
|
fillObject(req, CR);
|
|
Documento bean = new Documento(getApFull(req));
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean.findByPrimaryKey(l_id);
|
|
String eMail = getRequestParameter(req, "eMailInvio");
|
|
String testoAgg = getRequestParameter(req, "testoAgg");
|
|
if (getAct(req).equals("web")) {
|
|
eMail = bean.getClifor().getEMail();
|
|
ResParm rp = bean.sendOrderMailMessage(getLang(req), false, true, false);
|
|
sendMessage(req, rp.getMsg());
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
} else if (getAct(req).equals("clifor") || getAct(req).equals("ext")) {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (getAct(req).equals("clifor"))
|
|
eMail = bean.getClifor().getEMail();
|
|
if (!testoAgg.isEmpty())
|
|
bean.setTestoAgg(testoAgg);
|
|
if (eMail.isEmpty()) {
|
|
sendMessage(req, "Errore! indirizzo email non valido!");
|
|
if (l_id != 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
} else {
|
|
CR.setId_documentoS(l_id);
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
ResParm rp = bean.sendDocumentiMailMessage(CR, eMail, path);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Mail inviata con successo");
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
} else if (getAct(req).equals("cli")) {
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
search(req, res);
|
|
}
|
|
}
|
|
|
|
protected void mailxx(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
Documento bean = new Documento(apFull);
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean.findByPrimaryKey(l_id);
|
|
String eMail = getRequestParameter(req, "eMailInvio");
|
|
String testoAgg = getRequestParameter(req, "testoAgg");
|
|
if (getAct(req).equals("web")) {
|
|
eMail = bean.getClifor().getEMail();
|
|
ResParm rp = bean.sendOrderMailMessage(getLang(req), false, true, false);
|
|
sendMessage(req, rp.getMsg());
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
} else if (getAct(req).equals("clifor") || getAct(req).equals("ext")) {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (getAct(req).equals("clifor"))
|
|
eMail = bean.getClifor().getEMail();
|
|
if (!testoAgg.isEmpty())
|
|
bean.setTestoAgg(testoAgg);
|
|
if (eMail.isEmpty()) {
|
|
sendMessage(req, "Errore! indirizzo email non valido!");
|
|
if (l_id != 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
} else if (getAct(req).equals("cli")) {
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
search(req, res);
|
|
} else {
|
|
CR.setId_documentoS(l_id);
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
ResParm rp = bean.sendDocumentiMailMessage(CR, eMail, path);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Mail inviata con successo");
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _creaReportCsvNoSession(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
CR.setId_users(getUser(req).getId_users());
|
|
Documento bean = new Documento(apFull);
|
|
bean.creaFileCvsRigheDocumento(CR);
|
|
sendHtmlMsgResponse(req, res, "<a href='../../" + CR.getFileName() + "' target='_blank'>File report in formato cvs (Excel)</a>");
|
|
}
|
|
|
|
public void _impostaOrdineWww(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = new Documento(apFull);
|
|
long l_id_documento = getRequestLongParameter(req, "id");
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
if (bean.getId_documento() > 0L) {
|
|
long l_progOrdineWww = getRequestLongParameter(req, "progOrdineWww");
|
|
bean.setProgOrdineWww(l_progOrdineWww);
|
|
ResParm rp = bean.superSave();
|
|
if (rp.getStatus())
|
|
sendHtmlMsgResponse(req, res, String.valueOf(bean.getProgOrdineWww()));
|
|
}
|
|
}
|
|
|
|
public void _generaFatture(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
ResParm rp = new ResParm(true);
|
|
long id_tipoDocumentoF = getRequestLongParameter(req, "id_tipoDocumentoF");
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
CR.setUsers((Users)getUser(req));
|
|
CR.setId_tipoDocumentoF(id_tipoDocumentoF);
|
|
Documento bean = new Documento(apFull);
|
|
rp.append(bean.creaFattureDaLista(CR));
|
|
if (rp.getStatus()) {
|
|
req.setAttribute("listaDocumenti", rp.getMsg());
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
search(req, res);
|
|
}
|
|
|
|
public void _aggiornaThreadMsg(HttpServletRequest req, HttpServletResponse res) {
|
|
sendHtmlMsgResponse(req, res, Documento.threadSendMailMsg);
|
|
}
|
|
|
|
public void _creaPdfEtichettePackingList(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(new Long(l_id));
|
|
if (!getParm("LABEL_PK_LIST_A4_ZEBRA").isTrue()) {
|
|
DocumentoCR CR = new DocumentoCR();
|
|
fillObject(req, CR);
|
|
CR.setId_documentoS(l_id);
|
|
sendPdf(res, bean.creaPdfEtichettePackingListA4(CR), "LabelPackingListA4 " + DBAdapter.getDayTimeTimestamp());
|
|
} else {
|
|
sendPdf(res, bean.creaPdfEtichettePackingListZEBRA(null), "LabelPackingList " + DBAdapter.getDayTimeTimestamp());
|
|
}
|
|
}
|
|
|
|
public void _annullaDocumentiWeb(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = new Documento(apFull);
|
|
ResParm rp = bean.annullaOrdiniWebVecchi();
|
|
sendMessage(req, rp.getMsg());
|
|
search(req, res);
|
|
}
|
|
|
|
public void _bloccaDocumento(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
StringBuilder sb = new StringBuilder();
|
|
long id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(id_documento);
|
|
sb.append(bean.getNotaSblocco());
|
|
sb.append("\nBloccato da: " + apFull.getLastUpdUser().getLogin());
|
|
bean.setFlgEmsta(0L);
|
|
bean.setNotaSblocco(sb.toString());
|
|
bean.superSave();
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _addRigaTessuto(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", String.valueOf(l_id));
|
|
if (rp.getStatus() == true) {
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
|
if (l_id != 0L) {
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
if (l_id_rigaDocumento > 0L)
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
|
fillObject(req, row);
|
|
row.setLastUpdTmst(getRequestTmstParameter(req, "lastUpdTmstRow1"));
|
|
row.setId_rigaDocumentoTessutoA(0L);
|
|
row.setMt(getRequestDoubleParameter(req, "mtT"));
|
|
row.setKg(getRequestDoubleParameter(req, "kgT"));
|
|
long l_id_colore = getRequestLongParameter(req, "id_colore");
|
|
if ((l_id_colore > 0L && row.getId_articoloTessutoColore() == 0L) || (row.getId_articoloTessutoColore() > 0L && l_id_colore !=
|
|
row.getArticoloTessutoColore().getId_colore()))
|
|
if ((l_id_colore == 0L && row.getId_articoloTessutoColore() == 0L) || row.getId_articoloTessuto() == 0L) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Attenzione! Tessuto o Colore non selezionato!");
|
|
} else {
|
|
ArticoloTessutoColore av = new ArticoloTessutoColore(apFull);
|
|
if (row.getId_articoloTessutoColore() > 0L) {
|
|
av.findByPrimaryKey(row.getId_articoloTessutoColore());
|
|
} else {
|
|
av.findByArticoloTessutoColore(row.getId_articoloTessuto(), l_id_colore);
|
|
if (av.getId_articoloTessutoColore() == 0L) {
|
|
av.setId_articoloTessuto(row.getId_articoloTessuto());
|
|
av.setId_colore(l_id_colore);
|
|
av.save();
|
|
}
|
|
}
|
|
if (av.getId_articoloTessutoColore() == 0L) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Attenzione! Non e' stato possibile salvare il colore per il tessuto!");
|
|
} else {
|
|
row.setId_articoloTessutoColore(av.getId_articoloTessutoColore());
|
|
row.setDescrizioneRiga(row.getArticoloTessutoColore().getDescrizioneCompleta(getLang(req)));
|
|
}
|
|
}
|
|
if (row.getId_articoloTessutoColore() > 0L)
|
|
row.setDescrizioneRiga(row.getArticoloTessutoColore().getDescrizioneCompleta(getLang(req)));
|
|
if (rp.getStatus())
|
|
rp = Documento.addRigaDocumentoTessuto(bean, row, 0L);
|
|
if (!rp.getStatus())
|
|
forceMessage(req, rp.getMsg());
|
|
sendMessage(req, rp.getMsg());
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
bean.findByPrimaryKey(l_id);
|
|
bean.setCurrentFocus("descrizioneRiga");
|
|
req.setAttribute("bean", bean);
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _creaXmlFE(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
System.out.println("_creaXmlFE: prima di getFatturaElettronicaXml");
|
|
rp = bean.getFatturaElettronicaXml();
|
|
if (rp.getStatus()) {
|
|
sendHtmlMsgResponse(req, res, "<a href='../../" +
|
|
rp.getMsg() + "' target='_blank' download>Fattura Elettronica XML</a><br>Warning<br>" +
|
|
DBAdapter.convertStringToHtml(rp.getInfoMsg()));
|
|
} else {
|
|
sendHtmlMsgResponse(req, res, "Errori:<br>" + DBAdapter.convertStringToHtml(rp.getMsg()) + "Warning:<br>" +
|
|
DBAdapter.convertStringToHtml(rp.getInfoMsg()));
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
sendHtmlMsgResponse(req, res, e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _delAgente(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", String.valueOf(l_id));
|
|
if (rp.getStatus() == true) {
|
|
long id_documentoAgente = getRequestLongParameter(req, "id_documentoAgente");
|
|
DocumentoAgente row = new DocumentoAgente(apFull);
|
|
row.findByPrimaryKey(id_documentoAgente);
|
|
rp = row.delete();
|
|
sendMessage(req, "Agente Cancellato");
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _delProgettista(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", String.valueOf(l_id));
|
|
if (rp.getStatus() == true) {
|
|
long id_rigaDocumentoProgettista = getRequestLongParameter(req, "id_rigaDocumentoProgettista");
|
|
RigaDocumentoProgettista row = new RigaDocumentoProgettista(apFull);
|
|
row.findByPrimaryKey(id_rigaDocumentoProgettista);
|
|
rp = row.delete();
|
|
sendMessage(req, "Progettista Cancellato");
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _stampaDocumentiCR(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
Documento bean = new Documento(apFull);
|
|
bean.creaDocumentoPdfMerge(CR, true);
|
|
String fileName = CR.getFilePdf().substring(CR.getFilePdf().lastIndexOf('/'));
|
|
String sr = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/" + req.getContextPath() +
|
|
getPathTmp();
|
|
try {
|
|
res.sendRedirect(sr);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void _aggiungiColoreTaglio(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
long l_id_articolo = getRequestLongParameter(req, "id_articolo");
|
|
long l_id_taglia = getRequestLongParameter(req, "id_taglia");
|
|
long l_id_colore = getRequestLongParameter(req, "id_coloreDaAggiungere");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
if (l_id == 0L) {
|
|
fillObject(req, bean);
|
|
bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", Long.valueOf(l_id));
|
|
} else {
|
|
bean.findByPrimaryKey(l_id);
|
|
bean.setId_articolo(l_id_articolo);
|
|
bean.setId_taglia(l_id_taglia);
|
|
rp = bean.save();
|
|
}
|
|
if (rp.getStatus())
|
|
if (bean.getArticolo().isArticoloConfezioneOk()) {
|
|
ArticoloVariante av = new ArticoloVariante(apFull);
|
|
av.findByArticoloColore(l_id_articolo, l_id_colore);
|
|
if (av.getId_articoloVariante() == 0L) {
|
|
av.setId_articolo(l_id_articolo);
|
|
av.setId_colore(l_id_colore);
|
|
av.save();
|
|
}
|
|
if (av.getId_articoloVariante() > 0L) {
|
|
rp = av.creaComposizioneDaArticoloBase();
|
|
if (!rp.getStatus())
|
|
forceMessage(req, "ERRORE! " + rp.getMsg());
|
|
ArticoloTaglia at = new ArticoloTaglia(apFull);
|
|
at.findByArticoloTaglia(l_id_articolo, av.getId_articoloVariante(), l_id_taglia);
|
|
if (at.getId_articoloTaglia() == 0L) {
|
|
at.setId_articolo(l_id_articolo);
|
|
at.setId_articoloVariante(av.getId_articoloVariante());
|
|
at.setId_taglia(l_id_taglia);
|
|
at.save();
|
|
}
|
|
if (at.getId_articoloTaglia() > 0L) {
|
|
RigaDocumento rd = new RigaDocumento(apFull);
|
|
rd.findByDocumentoArticoloArticoloVarianteTaglia(bean.getId_documento(), at.getId_articolo(),
|
|
at.getId_articoloVariante(), at.getId_articoloTaglia());
|
|
if (rd.getId_rigaDocumento() == 0L) {
|
|
rd.setId_documento(bean.getId_documento());
|
|
rd.setId_articolo(at.getId_articolo());
|
|
rd.setId_articoloVariante(at.getId_articoloVariante());
|
|
rd.setId_articoloTaglia(at.getId_articoloTaglia());
|
|
rd.setDescrizioneRiga(at.getDescrizioneCompleta(getLang(req)));
|
|
rd.setNr(1.0D);
|
|
rp = Documento.addRigaDocumento(bean, rd);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Articolo messo correttamente");
|
|
} else {
|
|
sendMessage(req, "ERRORE! " + rp.getMsg());
|
|
}
|
|
} else {
|
|
sendMessage(req, "ERRORE! Articolo già inserito");
|
|
}
|
|
}
|
|
showBean(req, res);
|
|
} else {
|
|
sendMessage(req, "ERRORE! Variante Colore per quell'articolo non immessa");
|
|
showBean(req, res);
|
|
}
|
|
} else {
|
|
sendMessage(req, "ERRORE! Articolo non completo!!! Aggiornare anagrafica con composizione tessuti e simboli lavaggio");
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _mailCommandExtCR(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
CR.setFlgInvioMail(getRequestLongParameter(req, "flgInvioMailM"));
|
|
Documento bean = new Documento(apFull);
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
String eMail = getRequestParameter(req, "eMailInvio");
|
|
String testoAgg = getRequestParameter(req, "testoAgg");
|
|
bean.findByPrimaryKey(l_id);
|
|
if (getAct(req).equals("clifor"))
|
|
eMail = bean.getClifor().getEMail();
|
|
if (!testoAgg.isEmpty())
|
|
bean.setTestoAgg(testoAgg);
|
|
if (eMail.isEmpty()) {
|
|
sendMessage(req, "Errore! indirizzo email non valido!");
|
|
search(req, res);
|
|
} else {
|
|
CR.setId_documentoS(l_id);
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
ResParm rp = bean.startInvioMailExt(CR, eMail, path, testoAgg);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Mail inviata con successo");
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _mailCommandCliForCR(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
CR.setFlgInvioMail(getRequestLongParameter(req, "flgInvioMailM"));
|
|
Documento bean = new Documento(apFull);
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
String testoAgg = getRequestParameter(req, "testoAgg");
|
|
bean.findByPrimaryKey(l_id);
|
|
if (!testoAgg.isEmpty())
|
|
bean.setTestoAgg(testoAgg);
|
|
CR.setId_documentoS(l_id);
|
|
String path = req.getScheme() + "://" + req.getScheme() + ":" + req.getServerName() + req.getServerPort() + "/GetFile.abl?id=";
|
|
ResParm rp = bean.startInvioMailClifor(CR, path, testoAgg);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Mail inviata con successo");
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
if (l_id > 0L) {
|
|
showBean(req, res);
|
|
} else {
|
|
search(req, res);
|
|
}
|
|
}
|
|
|
|
public void _creaXmlCRFE(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR();
|
|
fillObject(req, CR);
|
|
CR.setFlgXmlGenerato(0L);
|
|
ResParm rp = new ResParm(true, "");
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
rp = bean.getFattureElettronicaXmlZip(CR);
|
|
if (rp.getStatus()) {
|
|
sendHtmlMsgResponse(req, res, "<a href='../../" +
|
|
rp.getMsg() + "' target='_blank' download>Zip Fatture Elettroniche XML</a><br>Warning:<br>" +
|
|
DBAdapter.convertStringToHtml(rp.getInfoMsg()));
|
|
} else {
|
|
sendHtmlMsgResponse(req, res, "Errori:<br>" + DBAdapter.convertStringToHtml(rp.getMsg()) + " Warning:<br>" +
|
|
DBAdapter.convertStringToHtml(rp.getInfoMsg()));
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
sendHtmlMsgResponse(req, res, e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _creaXmlRowFE(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
search(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
rp = bean.getFatturaElettronicaXml();
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Fattura elettronica " +
|
|
bean.getNumeroDocumentoCompleto() + " " + rp.getInfoMsg() + " creata correttamente!");
|
|
} else {
|
|
sendMessage(req, "ERRORE! Fattura elettronica " + bean.getNumeroDocumentoCompleto() + ": " + rp.getInfoMsg());
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
sendHtmlMsgResponse(req, res, e.getMessage());
|
|
}
|
|
search(req, res);
|
|
}
|
|
}
|
|
|
|
public void _impostaXmlInviatoRowFE(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
search(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_documento() > 0L) {
|
|
bean.setTmstInvioXml(DBAdapter.getTimestamp());
|
|
rp = bean.superSave();
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Fattura elettronica " + bean.getNumeroDocumentoCompleto() + " impostata ad Inviata!");
|
|
} else {
|
|
sendMessage(req, "ERRORE! Fattura elettronica " + bean.getNumeroDocumentoCompleto() + ": " + rp.getInfoMsg());
|
|
}
|
|
} else {
|
|
sendMessage(req, "ERRORE! Codice documento a zero o documento non trovato!");
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
sendHtmlMsgResponse(req, res, e.getMessage());
|
|
}
|
|
search(req, res);
|
|
}
|
|
}
|
|
|
|
public void _riapriXmlBloccatoFE(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
search(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_documento() > 0L) {
|
|
bean.setTmstInvioXml(null);
|
|
rp = bean.superSave();
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Fattura elettronica " + bean.getNumeroDocumentoCompleto() + " sbloccata per un nuovo invio!");
|
|
} else {
|
|
sendMessage(req, "ERRORE! Fattura elettronica " + bean.getNumeroDocumentoCompleto() + ": " + rp.getInfoMsg());
|
|
}
|
|
} else {
|
|
sendMessage(req, "ERRORE! Codice documento a zero o documento non trovato!");
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
sendHtmlMsgResponse(req, res, e.getMessage());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
protected String getBeanPageNameOLD(HttpServletRequest req) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
long l_id_tipoDocumento = getRequestLongParameter(req, "id");
|
|
if ((!getCmd(req).equals("search") && l_id_tipoDocumento != getId_docPrenotazione()) || l_id_tipoDocumento ==
|
|
getId_docPrenotazione() || l_id_tipoDocumento == getId_docRiparazione()) {
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
if (l_id > 0L) {
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id);
|
|
l_id_tipoDocumento = bean.getId_tipoDocumento();
|
|
if (getId_docCassa() > 0L && l_id_tipoDocumento == getId_docCassa())
|
|
return "documentoCash";
|
|
if (getId_docPrenotazione() > 0L && l_id_tipoDocumento == getId_docPrenotazione()) {
|
|
if (getCmd(req).equals("search"))
|
|
return "documentoPre";
|
|
return "documento";
|
|
}
|
|
if (getId_docRiparazione() > 0L && l_id_tipoDocumento == getId_docRiparazione())
|
|
return "documentoRip";
|
|
if (getId_docRicevuta() > 0L && l_id_tipoDocumento == getId_docRicevuta())
|
|
return "documentoRic";
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 200L)
|
|
return "documentoLav";
|
|
return super.getBeanPageName(req);
|
|
}
|
|
return super.getBeanPageName(req);
|
|
}
|
|
return super.getBeanPageName(req);
|
|
}
|
|
|
|
public void _ordineTaglioByArticolo(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id_articolo = getRequestLongParameter(req, "id_articolo");
|
|
Documento bean = new Documento(apFull);
|
|
long l_id_tipoDocumento = bean.getId_docOrdineTaglio();
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
CR.setId_tipoDocumento(l_id_tipoDocumento);
|
|
CR.setId_articoloDocumento(l_id_articolo);
|
|
CR.setFlgStatoLavorazione(0L);
|
|
Vectumerator<Documento> vecDoc = bean.findByCR(CR, 0, 0);
|
|
boolean ordineTrovato = false;
|
|
while (vecDoc.hasMoreElements()) {
|
|
Documento rowDoc = (Documento)vecDoc.nextElement();
|
|
if (!rowDoc.hasRigheDocumento()) {
|
|
ordineTrovato = true;
|
|
req.setAttribute("id_documento", Long.valueOf(rowDoc.getId_documento()));
|
|
req.setAttribute("cmd", "md");
|
|
try {
|
|
checkLangJspPage(req);
|
|
RequestDispatcher rd = getServletContext().getRequestDispatcher("/admin/contab/Documento.abl");
|
|
rd.forward((ServletRequest)req, (ServletResponse)res);
|
|
break;
|
|
} catch (Exception e) {
|
|
StringBuilder msg = new StringBuilder();
|
|
if (e.getCause() != null) {
|
|
msg.append("Causa:\n");
|
|
msg.append(e.getCause().getMessage());
|
|
msg.append("\n");
|
|
}
|
|
msg.append(e.getMessage());
|
|
handleDebug(e, 2);
|
|
forceMessage(req, getJspPage(req));
|
|
req.setAttribute("errorMsg", msg.toString());
|
|
RequestDispatcher rd = getServletContext().getRequestDispatcher("/admin/config/error.jsp");
|
|
try {
|
|
rd.forward((ServletRequest)req, (ServletResponse)res);
|
|
} catch (Exception exception) {}
|
|
}
|
|
} else {
|
|
|
|
}
|
|
}
|
|
if (!ordineTrovato) {
|
|
req.setAttribute("id_tipoDocumento", Long.valueOf(l_id_tipoDocumento));
|
|
req.setAttribute("id_articolo", Long.valueOf(l_id_articolo));
|
|
newRecord(req, res);
|
|
}
|
|
}
|
|
|
|
public void _addRigaTessuto2(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", String.valueOf(l_id));
|
|
if (rp.getStatus() == true) {
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
|
if (l_id != 0L) {
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
if (l_id_rigaDocumento > 0L)
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
|
fillObject(req, row);
|
|
row.setLastUpdTmst(getRequestTmstParameter(req, "lastUpdTmstRow2"));
|
|
bean.setCurrentTab(row.getCurrentTab());
|
|
bean.setCurrentTabId(row.getCurrentTabId());
|
|
row.setId_articoloTessutoColore(getRequestLongParameter(req, "id_articoloTessutoColore2"));
|
|
row.setId_articoloTessuto(getRequestLongParameter(req, "id_articoloTessuto2"));
|
|
row.setSeriale(getRequestParameter(req, "seriale2"));
|
|
row.setDescrizioneRiga(getRequestParameter(req, "descrizioneRiga2"));
|
|
row.setMt(getRequestDoubleParameter(req, "mtT2"));
|
|
row.setKg(getRequestDoubleParameter(req, "kgT2"));
|
|
row.setFlgCodiceRiga(1L);
|
|
row.setId_causaleMagazzino(getRequestLongParameter(req, "id_causaleMagazzino2"));
|
|
row.setId_magFisico(getRequestLongParameter(req, "id_magFisico2"));
|
|
System.out.println(getRequestDoubleParameter(req, "quantita2"));
|
|
long l_id_colore = getRequestLongParameter(req, "id_colore2");
|
|
if ((l_id_colore > 0L && row.getId_articoloTessutoColore() == 0L) || (row.getId_articoloTessutoColore() > 0L && l_id_colore !=
|
|
row.getArticoloTessutoColore().getId_colore()))
|
|
if ((l_id_colore == 0L && row.getId_articoloTessutoColore() == 0L) || row.getId_articoloTessuto() == 0L) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Attenzione! Tessuto o Colore non selezionato!");
|
|
} else {
|
|
ArticoloTessutoColore av = new ArticoloTessutoColore(apFull);
|
|
if (row.getId_articoloTessutoColore() > 0L) {
|
|
av.findByPrimaryKey(row.getId_articoloTessutoColore());
|
|
} else {
|
|
av.findByArticoloTessutoColore(row.getId_articoloTessuto(), l_id_colore);
|
|
if (av.getId_articoloTessutoColore() == 0L) {
|
|
av.setId_articoloTessuto(row.getId_articoloTessuto());
|
|
av.setId_colore(l_id_colore);
|
|
av.save();
|
|
}
|
|
}
|
|
if (av.getId_articoloTessutoColore() == 0L) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Attenzione! Non e' stato possibile salvare il colore per il tessuto!");
|
|
} else {
|
|
row.setId_articoloTessutoColore(av.getId_articoloTessutoColore());
|
|
}
|
|
}
|
|
if (row.getId_articoloTessutoColore() > 0L)
|
|
row.setDescrizioneRiga(row.getArticoloTessutoColore().getDescrizioneCompleta(getLang(req)));
|
|
if (rp.getStatus())
|
|
rp = Documento.addRigaDocumentoTessuto(bean, row, 1L);
|
|
if (!rp.getStatus())
|
|
forceMessage(req, rp.getMsg());
|
|
sendMessage(req, rp.getMsg());
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
bean.findByPrimaryKey(l_id);
|
|
bean.setCurrentFocus("descrizioneRiga");
|
|
req.setAttribute("bean", bean);
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _codBarreDispoTessitura(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
DocumentoCR CR = new DocumentoCR();
|
|
fillObject(req, CR);
|
|
CR.setId_documentoS(l_id);
|
|
sendPdf(res, bean.creaLabelDispoTessitura4x2(CR), "LabelDispoTessitura 4x2" + DBAdapter.getDayTimeTimestamp());
|
|
}
|
|
|
|
public void _aggiornaCapiRigaDocumentoTaglio(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
RigaDocumento rd = new RigaDocumento(apFull);
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_rigaDocumento");
|
|
long l_qta = getRequestLongParameter(req, "nrNew");
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
rd.findByPrimaryKey(l_id);
|
|
if (rd.getId_rigaDocumento() > 0L) {
|
|
Documento bean = rd.getDocumento();
|
|
System.out.println("" + rd.getQuantita() + " " + rd.getQuantita());
|
|
rd.setNr((double)l_qta);
|
|
rd.setQuantita((double)l_qta);
|
|
rp = Documento.addRigaDocumento(bean, rd);
|
|
if (rp.getStatus()) {
|
|
Vectumerator<DocFiglioPadre> vec = bean.findDocFiglioPadreByFiglio();
|
|
if (vec.hasMoreElements()) {
|
|
Documento docDisposizioneTaglio = ((DocFiglioPadre)vec.nextElement()).getDocumentoPadre();
|
|
System.out.println(docDisposizioneTaglio.getNumeroDocumentoCompleto());
|
|
rp = docDisposizioneTaglio.ricalcolaDisposizioneTaglio();
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendHtmlMsgResponse(req, res, Ab.formatBeanMsg("Articolo aggiornato correttamente"));
|
|
} else {
|
|
sendHtmlMsgResponse(req, res, Ab.formatBeanMsg(rp.getMsg()));
|
|
}
|
|
} else {
|
|
sendHtmlMsgResponse(req, res, Ab.formatBeanMsg("ERRORE! " + rp.getMsg()));
|
|
}
|
|
} else {
|
|
sendHtmlMsgResponse(req, res, Ab.formatBeanMsg("Attenzione! Riga Documento non trovata!"));
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _modRigaArticolo(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
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);
|
|
bean.setCurrentTab(row.getCurrentTab());
|
|
bean.setCurrentTabId(row.getCurrentTabId());
|
|
req.setAttribute("bean2", row);
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 201L) {
|
|
long l_id_rdTessuto = getRequestLongParameter(req, "id_rigaDocumentoTessutoA");
|
|
RigaDocumento rdt = new RigaDocumento(apFull);
|
|
rdt.findByPrimaryKey(l_id_rdTessuto);
|
|
req.setAttribute("beanRDTessuto", rdt);
|
|
req.setAttribute("id_rigaDocumentoTessutoA", Long.valueOf(rdt.getId_rigaDocumentoTessutoA()));
|
|
}
|
|
if (row.getFlgReso() == 1L) {
|
|
bean.setFlgInserisciReso(1L);
|
|
req.setAttribute("bean", bean);
|
|
}
|
|
bean.setFlgAutoAdd(0L);
|
|
req.setAttribute("bean", bean);
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_OK"));
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
showBean(req, res);
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _dissociaOrdineTaglio(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
String l_lang = getLang(req);
|
|
long l_id = getRequestLongParameter(req, "id_docFiglioPadre");
|
|
DocFiglioPadre bean = new DocFiglioPadre(apFull);
|
|
ResParm rp = new ResParm();
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_docFiglioPadre() > 0L)
|
|
rp = bean.delete();
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, bean.translate("Ordine scollegato correttamente", l_lang));
|
|
} else {
|
|
sendMessage(req, bean.translate("Errore! Impossibile scollegare ordine di taglio: " + rp.getMsg(), l_lang));
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _creaDocFigliS(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
forceJspPageRelative("documentoFigliCrea.jsp", req);
|
|
long l_id_tipoDocumento = getRequestLongParameter(req, "id_tipoDocumento");
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
TipoDocumento TD = new TipoDocumento(apFull);
|
|
Vectumerator<DocPrel> vecListaDocGen = new Vectumerator();
|
|
if (l_id_documento > 0L) {
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
TD = bean.getTipoDocumento();
|
|
vecListaDocGen = bean.getTipoDocumento().findDocGen(1L, 0L, 0, 0);
|
|
} else if (l_id_tipoDocumento > 0L) {
|
|
TD.findByPrimaryKey(l_id_tipoDocumento);
|
|
vecListaDocGen = TD.findDocGen(1L, 0L, 0, 0);
|
|
}
|
|
req.setAttribute("listaDocGen", vecListaDocGen);
|
|
req.setAttribute("listaFornitori", new Fornitore(getApFull(req)).findAll());
|
|
boolean creaFtTess = false;
|
|
if (TD.getTipologiaDocumento().getCodice() != 200L)
|
|
while (vecListaDocGen.hasMoreElements()) {
|
|
DocPrel docPrel = (DocPrel)vecListaDocGen.nextElement();
|
|
if (docPrel.getTipoDocumento().hasPadreConTipologia(200L)) {
|
|
creaFtTess = true;
|
|
break;
|
|
}
|
|
}
|
|
req.setAttribute("creaFtTess", String.valueOf(creaFtTess));
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _associaOrdiniTaglio(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
String l_lang = getLang(req);
|
|
String ordiniTaglio = getRequestParameter(req, "id_documenti");
|
|
String[] id_documenti = ordiniTaglio.split(",");
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(apFull);
|
|
ResParm rp = new ResParm(true);
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
if (bean.getId_documento() > 0L && id_documenti.length > 0)
|
|
for (int i = 0; i < id_documenti.length; i++) {
|
|
long l_id_documentoOrdineTaglio = Long.valueOf(id_documenti[i]);
|
|
rp.append(bean.associaOrdineTaglioADosposizioneTaglio(l_id_documentoOrdineTaglio));
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, bean.translate("Ordine associato correttamente", l_lang));
|
|
} else {
|
|
sendMessage(req, bean.translate("Errore! Impossibile associare ordine di taglio: " + rp.getMsg(), l_lang));
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _impostaXmlInviatoFE(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
search(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_documento() > 0L) {
|
|
bean.setTmstInvioXml(DBAdapter.getTimestamp());
|
|
rp = bean.superSave();
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Fattura elettronica " + bean.getNumeroDocumentoCompleto() + " impostata ad Inviata!");
|
|
} else {
|
|
sendMessage(req, "ERRORE! Fattura elettronica " + bean.getNumeroDocumentoCompleto() + ": " + rp.getInfoMsg());
|
|
}
|
|
} else {
|
|
sendMessage(req, "ERRORE! Codice documento a zero o documento non trovato!");
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
sendHtmlMsgResponse(req, res, e.getMessage());
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
public void _associaOrdineTaglio(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
String l_lang = getLang(req);
|
|
long l_id_documentoOrdineTaglio = getRequestLongParameter(req, "id_documentoOrdineTaglio");
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(apFull);
|
|
ResParm rp = new ResParm();
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
if (bean.getId_documento() > 0L && l_id_documentoOrdineTaglio > 0L)
|
|
rp = bean.associaOrdineTaglioADosposizioneTaglio(l_id_documentoOrdineTaglio);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, bean.translate("Ordine associato correttamente", l_lang));
|
|
} else {
|
|
sendMessage(req, bean.translate("Errore! Impossibile associare ordine di taglio: " + rp.getMsg(), l_lang));
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _printDisposizioneTaglio(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Users theUser = (Users)getLoginUser(req);
|
|
Users operatore = null;
|
|
long l_id_users = getRequestLongParameter(req, "id_oper");
|
|
if (l_id_users > 0L) {
|
|
operatore = new Users(apFull);
|
|
operatore.findByPrimaryKey(l_id_users);
|
|
}
|
|
try {
|
|
long l_id = 0L;
|
|
Documento bean = null;
|
|
l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id);
|
|
bean.setCurrentLang(getLang(req));
|
|
DocumentoCR CR = new DocumentoCR();
|
|
fillObject(req, CR);
|
|
CR.setId_documentoS(l_id);
|
|
new File(bean.getPathStampaDocumentoFull()).delete();
|
|
bean.setPrtCommand(0L);
|
|
sendPdf(res, bean.creaDocumentoPdf(CR, false), "Dispo " + bean.getNumeroDocumentoCompleto() + DBAdapter.getDayTimeTimestamp());
|
|
if (bean.getPrtCommand() == 1L && bean.getFlgStatoLavorazione() != 30L) {
|
|
bean.setFlgStatoLavorazione(30L);
|
|
bean.save();
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void _addRigaFilato(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", String.valueOf(l_id));
|
|
if (rp.getStatus() == true) {
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
|
if (l_id != 0L) {
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
if (l_id_rigaDocumento > 0L)
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
|
fillObject(req, row);
|
|
row.setLastUpdTmst(getRequestTmstParameter(req, "lastUpdTmstRow1"));
|
|
row.setKg(getRequestDoubleParameter(req, "kgF"));
|
|
System.out.println(getRequestDoubleParameter(req, "quantita"));
|
|
rp = Documento.addRigaDocumentoFilato(bean, row);
|
|
if (!rp.getStatus())
|
|
forceMessage(req, rp.getMsg());
|
|
sendMessage(req, rp.getMsg());
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
bean.findByPrimaryKey(l_id);
|
|
req.setAttribute("bean", bean);
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void newRecord(HttpServletRequest req, HttpServletResponse res) {
|
|
prepareNewRecord(req, res);
|
|
if (getRequestLongParameter(req, "id_tipoDocumento") > 0L)
|
|
req.setAttribute("id", Long.valueOf(getRequestLongParameter(req, "id_tipoDocumento")));
|
|
setJspPageRelative(getBeanPrimaryPageName(req), req);
|
|
req.setAttribute("RI", new ReturnItem(req.getParameter("RI")));
|
|
callJsp(req, res);
|
|
}
|
|
|
|
public void _docPagato(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = null;
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = new Documento(getApFull(req));
|
|
bean.findByPrimaryKey(l_id);
|
|
ResParm rp = new ResParm();
|
|
if (bean.getDBState() == 0) {
|
|
rp.setStatus(false);
|
|
rp.setMsg("Errore! Codice documento non valido");
|
|
} else {
|
|
rp = bean.impostaFlgPagata(1L);
|
|
}
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Documento " + bean.getNumeroDocumentoCompleto() + " pagato.");
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
search(req, res);
|
|
}
|
|
|
|
public void _creaElencoMail(HttpServletRequest req, HttpServletResponse res) {
|
|
Documento bean = new Documento(getApFull(req));
|
|
DocumentoCR CR = new DocumentoCR(getApFull(req));
|
|
fillObject(req, CR);
|
|
ResParm rp = bean.creaFileMailingList(CR);
|
|
if (rp.getStatus()) {
|
|
sendHtmlMsgResponse(req, res, "<a href='../../" + rp.getMsg() + "' target='_blank' download>File Mailing List</a>");
|
|
} else {
|
|
sendHtmlMsgResponse(req, res, "Errori:<br>" + DBAdapter.convertStringToHtml(rp.getMsg()));
|
|
}
|
|
}
|
|
|
|
public void _creaDocFigli(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = new Documento(apFull);
|
|
long l_id_fornitore = getRequestLongParameter(req, "id_cliforR");
|
|
long l_id = getRequestLongParameter(req, "id_documentoR");
|
|
long l_flgTipoGenerazione = getRequestLongParameter(req, "flgTipoGenerazione");
|
|
Users operatore = null;
|
|
long l_id_users = getRequestLongParameter(req, "id_oper");
|
|
if (l_id_users > 0L) {
|
|
operatore = new Users(apFull);
|
|
operatore.findByPrimaryKey(l_id_users);
|
|
} else {
|
|
operatore = bean.getUsers();
|
|
}
|
|
ResParm rp = new ResParm(true);
|
|
long l_id_tipoDocumentoFiglio = getRequestLongParameter(req, "id_tipoDocumentoF");
|
|
if (l_id_fornitore == 0L || l_id == 0L) {
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
if (CR.getId_tipoDocumento() == 0L) {
|
|
rp.setMsg("Errore! Intestazione del documento non trovata!");
|
|
rp.setStatus(false);
|
|
} else {
|
|
Vectumerator<Documento> vec = bean.findByCR(CR, 0, 0);
|
|
while (vec.hasMoreElements()) {
|
|
Documento row = (Documento)vec.nextElement();
|
|
if (l_id_tipoDocumentoFiglio == getId_docCassa()) {
|
|
rp = row.creaDocumentoFiglio(row.getId_clifor(), l_id_tipoDocumentoFiglio, operatore, false, l_flgTipoGenerazione);
|
|
continue;
|
|
}
|
|
rp = row.creaDocumentoFiglio(row.getId_clifor(), l_id_tipoDocumentoFiglio, operatore, true, l_flgTipoGenerazione);
|
|
}
|
|
}
|
|
} else {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (l_id_tipoDocumentoFiglio == getId_docCassa()) {
|
|
rp = bean.creaDocumentoFiglio(l_id_fornitore, l_id_tipoDocumentoFiglio, operatore, false, l_flgTipoGenerazione);
|
|
} else {
|
|
rp = bean.creaDocumentoFiglio(l_id_fornitore, l_id_tipoDocumentoFiglio, operatore, false, l_flgTipoGenerazione);
|
|
}
|
|
}
|
|
if (rp.getStatus()) {
|
|
afterCreaDocFigli(req, res, bean, l_id_tipoDocumentoFiglio);
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
String theForm = getRequestParameter(req, "theForm");
|
|
String pageType = getRequestParameter(req, "pageType");
|
|
if (theForm.equals("ricerca") || pageType.equals("R")) {
|
|
search(req, res);
|
|
} else {
|
|
req.setAttribute("id_documento", Long.valueOf(l_id));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
public void _creaFattureDaDDtTessituraThread(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = new Documento(apFull);
|
|
long l_id_cliforR = getRequestLongParameter(req, "id_cliforR");
|
|
long l_id = getRequestLongParameter(req, "id_documentoR");
|
|
long l_flgTipoGenerazione = getRequestLongParameter(req, "flgTipoGenerazione");
|
|
Users operatore = null;
|
|
long l_id_users = getRequestLongParameter(req, "id_oper");
|
|
if (l_id_users > 0L) {
|
|
operatore = new Users(apFull);
|
|
operatore.findByPrimaryKey(l_id_users);
|
|
} else {
|
|
operatore = bean.getUsers();
|
|
}
|
|
long l_id_tipoDocumentoFiglio = getRequestLongParameter(req, "id_tipoDocumentoF");
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
ResParm rp = bean.startThreadCreaFtTessitura(CR, l_id_cliforR, l_id, l_id_tipoDocumentoFiglio, l_flgTipoGenerazione, operatore);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, "Mail inviata con successo");
|
|
} else {
|
|
sendMessage(req, rp.getErrMsg());
|
|
}
|
|
String theForm = getRequestParameter(req, "theForm");
|
|
String pageType = getRequestParameter(req, "pageType");
|
|
if (theForm.equals("ricerca") || pageType.equals("R")) {
|
|
search(req, res);
|
|
} else {
|
|
req.setAttribute("id_documento", Long.valueOf(l_id));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
public void _creaReportArticoliCsv(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoCR CR = new DocumentoCR(apFull);
|
|
fillObject(req, CR);
|
|
CR.setId_users(getUser(req).getId_users());
|
|
Documento bean = new Documento(apFull);
|
|
CR.setFlgReport("S");
|
|
bean.creaFileArticoliCvs(CR);
|
|
sendHtmlMsgResponse(req, res, "<a href='../../" + CR.getFileName() + "' target='_blank'>File report in formato cvs (Excel)</a>");
|
|
}
|
|
|
|
public void _esportaSuATR(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_documento() > 0L) {
|
|
fillObject(req, bean);
|
|
bean.setFlgStatoOrdineWwwPrecedente(9L);
|
|
bean.save();
|
|
System.out.println("_esportaSuATR: APATR...");
|
|
System.out.println("_esportaSuATR: chiamaga rest");
|
|
CcApi ccapi = new CcApi(apFull);
|
|
ApiClientResult result = ccapi._postImportcc(bean.getId_documento());
|
|
rp.setStatus(result.isOk());
|
|
rp.setMsg(result.getMsg());
|
|
bean.setCurrentTab(getRequestParameter(req, "currentTab"));
|
|
bean.refreshBean();
|
|
req.setAttribute("bean", bean);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, rp.getErrMsg());
|
|
} else {
|
|
sendMessage(req, "Esport su FTR effettuata!");
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
System.out.println("_esportaSuATR: exc:" + e.getMessage());
|
|
e.printStackTrace();
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _esportaSuATROLD(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_documento() > 0L) {
|
|
System.out.println("_esportaSuATR: APATR...");
|
|
ApplParmFull apAtr = new ApplParmFull(new ApplParm(getApFull().getParm("dbDriver2").getNumeroInt(),
|
|
getApFull().getParm("database2").getTesto(),
|
|
getApFull().getParm("user2").getTesto(),
|
|
getApFull().getParm("password2").getTesto()));
|
|
System.out.println("_esportaSuATR: APATR:" + apAtr.getApDescription());
|
|
bean.setCurrentTab(getRequestParameter(req, "currentTab"));
|
|
req.setAttribute("bean", bean);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, rp.getErrMsg());
|
|
} else {
|
|
sendMessage(req, "Esport su FTR effettuata!");
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
System.out.println("_esportaSuATR: exc:" + e.getMessage());
|
|
e.printStackTrace();
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _calcolaCostiWww(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
if (bean.getId_documento() > 0L) {
|
|
fillObject(req, bean);
|
|
bean.save();
|
|
bean.calcolaCostiWww();
|
|
bean.setCurrentTab(getRequestParameter(req, "currentTab"));
|
|
req.setAttribute("bean", bean);
|
|
sendMessage(req, "Calcolo costi WWW effettuato (non salvato)");
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _creaReportCsv(HttpServletRequest req, HttpServletResponse res) {
|
|
DocumentoCR CR = (DocumentoCR)req.getSession().getAttribute(getATTR_CRBEAN(req));
|
|
Documento bean = new Documento(getApFull(req));
|
|
bean.creaFileCvs(CR);
|
|
sendHtmlMsgResponse(req, res, "<a href='../../" +
|
|
CR.getFileName() + "' target='_blank'>File Elenco Documenti in formato cvs (Excel)</a>");
|
|
}
|
|
|
|
public void _ordinaRighePerTela(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", String.valueOf(l_id));
|
|
if (rp.getStatus() == true) {
|
|
if (l_id != 0L) {
|
|
rp = Documento.riordinaRigheDocPerRiferimento(bean);
|
|
if (!rp.getStatus())
|
|
forceMessage(req, rp.getMsg());
|
|
sendMessage(req, rp.getMsg());
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
bean.findByPrimaryKey(l_id);
|
|
req.setAttribute("bean", bean);
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _eliminaRigheAZero(HttpServletRequest req, HttpServletResponse res) {
|
|
ResParm rp;
|
|
ApplParmFull apFull = getApFull(req);
|
|
long l_id_documento = getRequestLongParameter(req, "id_documento");
|
|
Documento bean = new Documento(apFull);
|
|
bean.findByPrimaryKey(l_id_documento);
|
|
if (bean.getId_documento() > 0L) {
|
|
rp = bean.eliminaRigheAzero();
|
|
} else {
|
|
rp = new ResParm(false, "Errore!! Documento non trovato! " + l_id_documento);
|
|
}
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
}
|
|
|
|
public void _addAgente(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
long id_clifor = getRequestLongParameter(req, "id_cliforDA");
|
|
long id_documento = getRequestLongParameter(req, "id_documento");
|
|
double percDocumentoAgente = getRequestDoubleParameter(req, "percDocumentoAgente");
|
|
DocumentoAgente row = new DocumentoAgente(apFull);
|
|
row.findByDocumentoAgente(id_documento, id_clifor);
|
|
row.setId_documento(id_documento);
|
|
row.setId_cliforDA(id_clifor);
|
|
row.setPercDocumentoAgente(percDocumentoAgente);
|
|
rp = row.save();
|
|
sendMessage(req, rp.getMsg());
|
|
showBean(req, res);
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _sceltaTessuto(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
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);
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 201L) {
|
|
bean.setCurrentTab("#RIGHEF2");
|
|
} else if (bean.getTipoDocumento().getFlgTipologia() == 202L) {
|
|
bean.setCurrentTab("#RIGHET2");
|
|
}
|
|
row.setCurrentTabId(getRequestLongParameter(req, "currentTabId"));
|
|
req.setAttribute("beanRDTessuto", row);
|
|
req.setAttribute("id_rigaDocumentoTessutoA", Long.valueOf(row.getId_rigaDocumentoTessutoA()));
|
|
bean.setFlgAutoAdd(0L);
|
|
req.setAttribute("bean", bean);
|
|
req.setAttribute("listaArticoloTessutoFilato", row.getArticoloTessuto().findArticoliTessutoFilati(0, 0));
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_OK"));
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
showBean(req, res);
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _addRigaFilato2(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Documento bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (Documento)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
try {
|
|
bean.findByPrimaryKey(l_id);
|
|
fillObject(req, bean);
|
|
rp = bean.save();
|
|
l_id = bean.getId_documento();
|
|
req.setAttribute("id_documento", String.valueOf(l_id));
|
|
if (rp.getStatus() == true) {
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
|
if (l_id != 0L) {
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
if (l_id_rigaDocumento > 0L)
|
|
row.findByPrimaryKey(l_id_rigaDocumento);
|
|
fillObject(req, row);
|
|
row.setLastUpdTmst(getRequestTmstParameter(req, "lastUpdTmstRow2"));
|
|
bean.setCurrentTab(row.getCurrentTab());
|
|
bean.setCurrentTabId(row.getCurrentTabId());
|
|
row.setKg(getRequestDoubleParameter(req, "kgF2"));
|
|
row.setId_articoloFilatoColore(getRequestLongParameter(req, "id_articoloFilatoColore2"));
|
|
row.setSeriale(getRequestParameter(req, "seriale2"));
|
|
row.setDescrizioneRiga(getRequestParameter(req, "descrizioneRiga2"));
|
|
System.out.println(getRequestDoubleParameter(req, "quantita2"));
|
|
System.out.println(getRequestDoubleParameter(req, "id_rigaDocumentoTessutoA"));
|
|
row.setFlgCodiceRiga(1L);
|
|
rp = Documento.addRigaDocumentoFilato(bean, row);
|
|
if (!rp.getStatus())
|
|
forceMessage(req, rp.getMsg());
|
|
sendMessage(req, rp.getMsg());
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
bean.findByPrimaryKey(l_id);
|
|
req.setAttribute("bean", bean);
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 201L) {
|
|
long l_id_rdTessuto = getRequestLongParameter(req, "id_rigaDocumentoTessutoA");
|
|
RigaDocumento rdt = new RigaDocumento(apFull);
|
|
rdt.findByPrimaryKey(l_id_rdTessuto);
|
|
req.setAttribute("beanRDTessuto", rdt);
|
|
req.setAttribute("id_rigaDocumentoTessutoA", Long.valueOf(rdt.getId_rigaDocumentoTessutoA()));
|
|
}
|
|
showBean(req, res);
|
|
}
|
|
} catch (Exception e) {
|
|
forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL"));
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void _delRigaArticolo(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
DocumentoInterface bean = null;
|
|
ResParm rp = new ResParm(true, "");
|
|
long l_id = getRequestLongParameter(req, "id_documento");
|
|
bean = (DocumentoInterface)getBean(req);
|
|
if (getLoginUserGrant(req, getBean(req).getTableBeanName()) < 2L) {
|
|
sendGrantMessage(req, "Permessi di scrittura mancanti");
|
|
showBean(req, res);
|
|
} else {
|
|
bean.findByPrimaryKey(l_id);
|
|
long l_id_rigaDocumento = getRequestLongParameter(req, "id_rigaDocumento");
|
|
if (l_id_rigaDocumento != 0L) {
|
|
RigaDocumento row = new RigaDocumento(apFull);
|
|
fillObject(req, row);
|
|
row.setLastUpdTmst(getRequestTmstParameter(req, "lastUpdTmstRow1"));
|
|
bean.setCurrentTab(row.getCurrentTab());
|
|
bean.setCurrentTabId(row.getCurrentTabId());
|
|
rp = bean.delRigaDocumento(row);
|
|
if (rp.getStatus()) {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "DELETE_OK"));
|
|
} else {
|
|
sendMessage(req, rp.getMsg());
|
|
}
|
|
} else {
|
|
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_FAIL"));
|
|
}
|
|
if (bean.getTipoDocumento().getFlgTipologia() == 201L) {
|
|
long l_id_rdTessuto = getRequestLongParameter(req, "id_rigaDocumentoTessutoA");
|
|
RigaDocumento rdt = new RigaDocumento(apFull);
|
|
rdt.findByPrimaryKey(l_id_rdTessuto);
|
|
req.setAttribute("beanRDTessuto", rdt);
|
|
req.setAttribute("id_rigaDocumentoTessutoA", Long.valueOf(rdt.getId_rigaDocumentoTessutoA()));
|
|
}
|
|
if (!bean.hasRigheDocumento() && bean.getId_tipoDocumento() == getId_docCassa()) {
|
|
long l_id_tipoDocumento = bean.getId_tipoDocumento();
|
|
bean.delete();
|
|
bean.setId_tipoDocumento(l_id_tipoDocumento);
|
|
req.setAttribute("id_documento", "");
|
|
} else {
|
|
bean.save();
|
|
}
|
|
bean.setFlgMantieniArticoloRiga(getRequestLongParameter(req, "flgMantieniArticoloRiga"));
|
|
bean.setFlgAutoAdd(getRequestLongParameter(req, "flgAutoAdd"));
|
|
bean.setFlgSingleLineArt(getRequestLongParameter(req, "flgSingleLineArt"));
|
|
bean.setCurrentFocus("descrizioneRiga");
|
|
req.setAttribute("bean", bean);
|
|
showBean(req, res);
|
|
}
|
|
}
|
|
|
|
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
|
ApplParmFull apFull = getApFull(req);
|
|
Users theUser = new Users(apFull);
|
|
theUser.findByPrimaryKey(getLoginUserId(req));
|
|
if (theUser.getId_userProfile() != 10L) {
|
|
super.search(req, res);
|
|
} else if (theUser.getId_clifor() > 0L) {
|
|
req.setAttribute("id_clifor", String.valueOf(theUser.getId_clifor()));
|
|
super.search(req, res);
|
|
} else {
|
|
sendGrantMessage(req, "Attenzione!! Non è stato impostato il cliente all'utente " + theUser.getLogin());
|
|
callJsp(req, res);
|
|
}
|
|
}
|
|
}
|