package it.acxent.contab.servlet; import it.acxent.anag.Iva; import it.acxent.anag.TipoPagamento; import it.acxent.anag.TipoPagamentoCR; import it.acxent.anag.Users; import it.acxent.anag.Vettore; import it.acxent.contab.Documento; import it.acxent.contab.DocumentoCR; import it.acxent.contab.RigaDocumento; import it.acxent.contab.TipoDocumento; import it.acxent.db.ApplParmFull; import it.acxent.db.DBAdapter; import it.acxent.db.ResParm; import it.acxent.util.Vectumerator; import java.sql.Date; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns = {"/admin/contab/DocumentoPre.abl"}) public class DocumentoPreSvlt extends DocumentoSvlt { private static final long serialVersionUID = -3181095019824437439L; protected String getBeanPageName(HttpServletRequest req) { if (getCmd(req).equals("search")) return "documentoPre"; return "documento"; } protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) { super.fillComboAfterDetail(beanA, req, res); } protected ResParm afterSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) { ResParm rp = new ResParm(true); return rp; } protected ResParm beforeSearch(HttpServletRequest req, HttpServletResponse res) { if (getRequestLongParameter(req, "flgTipologia") == 0L) req.setAttribute("flgStatoPrenotazione", Integer.valueOf(200)); req.setAttribute("flgTipologia", Integer.valueOf(4)); return new ResParm(true); } protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) { ApplParmFull apFull = getApFull(req); req.setAttribute("nf4", getNf4()); req.setAttribute("listaOperatori", new Users(apFull).findUsersByProfileMax(9L)); Documento bean = new Documento(apFull); bean.setId_tipoDocumento(getId_docPrenotazione()); bean.setFlgStato(1L); bean.setId_tipoPagamento(1L); req.setAttribute("bean", bean); 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()); 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) { super.otherCommands(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); } protected void XXXXotherCommands(HttpServletRequest req, HttpServletResponse res) { if (getCmd(req).equals("aggionraSRCR")) { Documento bean = null; long l_id = getRequestLongParameter(req, "id_documento"); bean = new Documento(getApFull(req)); bean.findByPrimaryKey(l_id); long l_flgStatoRiparazione = getRequestLongParameter(req, "flgStatoRiparazioneS"); ResParm rp = new ResParm(); if (bean.getDBState() == 0) { rp.setStatus(false); rp.setMsg("Errore! Codice documento non valido"); } else { rp = bean.aggiornaStatoRiparazione(l_flgStatoRiparazione); } if (rp.getStatus()) { sendMessage(req, "Stato Riparazione aggiornato."); } else { sendMessage(req, rp.getMsg()); } search(req, res); } else if (getCmd(req).equals("inviaAvviso")) { 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); } else if (getCmd(req).equals("annAssPren")) { 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); } else if (getCmd(req).equals("annullaSlip")) { 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); } else { super.otherCommands(req, res); } } public void _addRestituzioneAcconto(HttpServletRequest req, HttpServletResponse res) { ApplParmFull apFull = getApFull(req); ResParm rp = new ResParm(true); long id_documento = getRequestLongParameter(req, "id_documento"); Date dataRestituzione = getRequestDateParameter(req, "dataRestituzioneAcconto"); DocumentoCR CR = new DocumentoCR(apFull); fillObject(req, CR); req.setAttribute("CR", CR); req.setAttribute("cmd", "search"); if (id_documento > 0L) { Documento bean = new Documento(apFull); bean.findByPrimaryKey(id_documento); bean.setDataRestituzioneAcconto(dataRestituzione); rp = bean.aggiornaStatoPrenotazione(bean.getFlgStatoPrenotazione(), 100L); } else { rp = new ResParm(false, "ERRORE! Id documento non valido!"); } sendMessage(req, rp.getMsg()); search(req, res); } public void _creaReportCsvPrenotazioni(HttpServletRequest req, HttpServletResponse res) { DocumentoCR CR = (DocumentoCR)req.getSession().getAttribute("CRdocumentoPre"); Documento bean = new Documento(getApFull(req)); bean.creaFileCvsPrenotazioni(CR); sendHtmlMsgResponse(req, res, "File export in formato cvs (Excel)"); } protected void search(HttpServletRequest req, HttpServletResponse res) { DocumentoCR CR = new DocumentoCR(getApFull(req)); fillObject(req, CR); if (CR.getFlgReport().equals("S")) { req.getSession().setAttribute("CRdocumentoPre", CR); if (CR.getFlgStatoPrenotazioneArt() > -1L) { Documento bean = new Documento(getApFull(req)); Vectumerator vec = bean.findPrenotazioniByCR(CR); req.setAttribute("list", vec); req.setAttribute("CR", CR); callJsp(req, res); } else { super.search(req, res); } } else { super.search(req, res); } } }