package it.acxent.anag; import com.lowagie.text.Cell; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Element; import com.lowagie.text.Font; import com.lowagie.text.HeaderFooter; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.Rectangle; import com.lowagie.text.Table; import com.lowagie.text.pdf.PdfWriter; import it.acxent.anag.tr.PersonaCarico; import it.acxent.brt.api.json.PudoAddress; import it.acxent.cart.Cart; import it.acxent.checkVatService.CheckVatClient; import it.acxent.contab.Documento; import it.acxent.db.AddImgInterface; import it.acxent.db.ApplParmFull; import it.acxent.db.DBAdapter; import it.acxent.db.ResParm; import it.acxent.db.WcString; import it.acxent.fattele.FEDatiAnagraficiInterface; import it.acxent.fattele.FESedeInterface; import it.acxent.newsletter.CodaMessaggi; import it.acxent.newsletter.TemplateMsg; import it.acxent.util.CodiceFiscale; import it.acxent.util.FileMailingListManager; import it.acxent.util.FileWr; import it.acxent.util.PdfFontFactory; import it.acxent.util.SimpleDateFormat; import it.acxent.util.StringTokenizer; import it.acxent.util.Vectumerator; import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.Serializable; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.NumberFormat; import java.util.Calendar; public class Clifor extends _AnagAdapter implements Serializable, CliforInterface, AddImgInterface, FEDatiAnagraficiInterface, FESedeInterface { private static final long serialVersionUID = -3173766478494140671L; public static final long DOCUMENTO_NON_VERIFICATO = 0L; public static final long DOCUMENTO_NON_VALIDO = 10L; public static final long DOCUMENTO_IN_SCADENZA = 15L; public static final long DOCUMENTO_SCADUTO = 20L; public static final long DOCUMENTO_VERIFICATO = 30L; public static final long STATO_CIVILE_NESSUNO = 0L; public static final long STATO_CIVILE_CELIBE_NUBILE = 1L; public static final long STATO_CIVILE_CONIUGATO = 2L; public static final long STATO_CIVILE_SEPARATO = 3L; public static final long STATO_CIVILE_DIVORZIATO = 4L; public static final long STATO_CONFERMA_DATI_NON_VERIFICATO = 0L; public static final long STATO_CONFERMA_DATI_DA_VERIFICARE = 1L; public static final long STATO_CONFERMA_DATI_VERIFICATO = 9L; private long id_tipoPagamento; private String codiceAlt; private long flgValido; private String flgTipo; private long flgAzienda; private String cellulare; private String contatto; private String nome; private String indirizzo; private String numeroCivico; private long id_comune; private long id_comuneNascita; private String id_nazione; private Date dataNascita; public static final String TIPO_TUTTI = ""; public static final String TIPO_CLIENTE = "C"; public static final String TIPO_FORNITORE = "F"; public static final String TIPO_RUBRICA = "R"; private String codFisc; private String pIva; private String capZona; private String fax; private String telefono; private String nota; private String imgTmst; private long flgPrivComunicazione; private long flgPrivSensibili; private long flgPrivTrattamento; private long flgSesso; private String www; private Date dataRegistrazioneDI; private String dichiarazioneIntento; private long flgRC; private TipoPagamento tipoPagamento; private Comune comune; private Comune comuneNascita; private Nazione nazione; private String codFiscCalc; private String iban; private String eMail; private String descrizioneComune; private String bancaDesc; private long id_listino; private Listino listino; private long closeCommand; private DestinazioneDiversa currentDD; private Clifor cliforDup; private long id_cliforDup; private long flgMl = 1L; private String provinciaComune; private String capComune; private String cognome; private long flgSplitPayment; private String codiceCartaFidelity; private String descrizioneComuneNascita; private String telefonoAmm; private String cellulareAmm; private String eMailAmm; private String telefonoAltro; private String cellulareAltro; private String descrizioneAltroContatto; private String eMailAltro; private String numeroDocumento; private Date dataScadenzaDocumento; private double percProvvigione; private long id_clifor; private String notaPerCliente; private long flgDocumentoVerificato; private long flgNascondiWeb; private String zona; private String importPrefissoCodice; private String importLinkFornitore; private String importLinkFornitoreEan; private long id_bancaAzienda; private Banca bancaAzienda; private String abi; private String bic; private String cab; private double speseIncasso; private long flgUsaContrattoOre; private Clifor agente; private long id_respCommerciale; private Clifor respCommerciale; private double percAgente; private double percRespCommerciale; private String pec; private String descAggiuntiva; private String codiceIdentificativoFE; private long flgPA; private double costoOrarioAssistenza; private long id_agente; private long flgArt8; private long flgAbilitaAF; private long flgUsato; private String provinciaComuneNascita; private long flgTaxFree; private double valoreMinimoAbilitaAF; private long flgStatoCivile; private long id_ottoxmille; private Ottoxmille ottoxmille; private String cf5xmille; private String codice2xmille; private double costoSpedizioneAggiuntivo; private long id_usersResponsabile; private Users usersResponsabile; private long flgStatoConfermaDati; private long flgStatoConfermaDatiDb; private double prezzoCatenaAlMt; private long annoCorrente; private long id_usersAttivita; private Users usersAttivita; private long flgEscludi; private long flgBlacklist; private String notaBlacklist; public Clifor(ApplParmFull newApplParmFull) { super(newApplParmFull); } public double getPercentualeProvvigioneAgente() { double perc = 0.0D; if (getId_agente() > 0L) if (getPercAgente() > 0.0D) { perc = getPercAgente(); } else { CliforTipoClifor ctc = new CliforTipoClifor(getApFull()); ctc.findByCliforTipologia(getId_agente(), 1L); if (ctc.getDBState() == 1) perc = ctc.getPercProvvigione(); } return perc; } public double getPercentualeProvvigioneRespCommerciale() { double perc = 0.0D; if (getPercRespCommerciale() > 0.0D) { perc = getPercRespCommerciale(); } else if (getId_respCommerciale() > 0L) { CliforTipoClifor ctc = new CliforTipoClifor(getApFull()); ctc.findByCliforTipologia(getId_respCommerciale(), 3L); if (ctc.getPercProvvigione() > 0.0D) perc = ctc.getPercProvvigione(); } else { CliforTipoClifor ctc = new CliforTipoClifor(getApFull()); ctc.findByCliforTipologia(getId_agente(), 1L); if (ctc.getClifor().getPercRespCommerciale() > 0.0D) { perc = ctc.getClifor().getPercRespCommerciale(); } else { long id_respCommerciale = ctc.getClifor().getId_respCommerciale(); ctc = new CliforTipoClifor(getApFull()); ctc.findByCliforTipologia(id_respCommerciale, 3L); if (ctc.getDBState() == 1) perc = ctc.getPercProvvigione(); } } return perc; } public Clifor() {} public void setId_clifor(long newId_cliFor) { this.id_clifor = newId_cliFor; } public void setId_tipoPagamento(long newId_tipoPagamento) { this.id_tipoPagamento = newId_tipoPagamento; setTipoPagamento(null); } public void setCodiceAlt(String newCodiceAlt) { this.codiceAlt = newCodiceAlt; } public void setFlgValido(long newFlgValido) { this.flgValido = newFlgValido; } public void setFlgTipo(String newFlgTipo) { this.flgTipo = newFlgTipo; } public void setFlgEscludi(long newFlgEscludi) { this.flgEscludi = newFlgEscludi; } public void setCognome(String newCognome) { this.cognome = newCognome; } public void setContatto(String newContatto) { this.contatto = newContatto; } public void setNome(String newNome) { this.nome = newNome; } public void setIndirizzo(String newIndirizzo) { this.indirizzo = newIndirizzo; } public void setNumeroCivico(String newNumeroCivico) { this.numeroCivico = newNumeroCivico; } public void setId_comune(long newId_comune) { this.id_comune = newId_comune; setComune(null); } public void setId_nazione(String newId_nazione) { this.id_nazione = newId_nazione; setNazione(null); } public void setDataNascita(Date newDataNascita) { this.dataNascita = newDataNascita; } public void setCodFisc(String newCodFisc) { this.codFisc = newCodFisc; } public void setPIva(String newPIva) { this.pIva = newPIva; } public void setEMail(String newEMail) { this.eMail = newEMail; } public void setFax(String newFax) { this.fax = newFax; } public void setTelefono(String newTelefono) { this.telefono = newTelefono; } public void setNota(String newNota) { this.nota = newNota; } public void setImgTmst(String newImgTmst) { this.imgTmst = newImgTmst; } public void setFlgPrivComunicazione(long newFlgPrivComunicazione) { this.flgPrivComunicazione = newFlgPrivComunicazione; } public void setFlgPrivSensibili(long newFlgPrivSensibili) { this.flgPrivSensibili = newFlgPrivSensibili; } public void setFlgPrivTrattamento(long newFlgPrivTrattamento) { this.flgPrivTrattamento = newFlgPrivTrattamento; } public void setFlgSesso(long newFlgSesso) { this.flgSesso = newFlgSesso; } public void setWww(String newWww) { this.www = newWww; } public void setDataRegistrazioneDI(Date newDataRegistrazioneDI) { this.dataRegistrazioneDI = newDataRegistrazioneDI; } public void setDichiarazioneIntento(String newDichiarazioneIntento) { this.dichiarazioneIntento = newDichiarazioneIntento; } public void setFlgArt8(long newFlgArt8) { this.flgArt8 = newFlgArt8; } public long getId_clifor() { return this.id_clifor; } public long getId_tipoPagamento() { return this.id_tipoPagamento; } public String getCodiceAlt() { return (this.codiceAlt == null) ? "" : this.codiceAlt.trim(); } public long getFlgValido() { return this.flgValido; } public String getFlgTipo() { return (this.flgTipo == null) ? "" : this.flgTipo.trim(); } public static final String getTipo(String l_flgTipo) { if (l_flgTipo.equals("C")) return "Cliente"; if (l_flgTipo.equals("F")) return "Fornitore"; if (l_flgTipo.equals("R")) return "Contatto"; return "??"; } public static final String getStatoCivile(long l_flgStatoCivile) { if (l_flgStatoCivile == 1L) return "Celibe/Nubile"; if (l_flgStatoCivile == 2L) return "Coniugato"; if (l_flgStatoCivile == 4L) return "Divorziato"; if (l_flgStatoCivile == 3L) return "Separato"; return ""; } public static final String getStatoConfermaDati(long l_flgStatoConfermaDati) { if (l_flgStatoConfermaDati == 1L) return "Da Verificare"; if (l_flgStatoConfermaDati == 9L) return "Verificato"; if (l_flgStatoConfermaDati == 0L) return "Non Verificato"; return ""; } public final String getStatoConfermaDati() { return getStatoConfermaDati(getFlgStatoConfermaDati()); } public String getStatoCivile() { return getStatoCivile(getFlgStatoCivile()); } public String getTipo() { return getTipo(getFlgTipo()); } public long getFlgAzienda() { return this.flgAzienda; } public String getDescrizioneCompleta() { if (getId_clifor() != 0L) { if (getParm("ANAG_DESC_COMPLETA_CON_TIPO").isTrue()) { StringBuffer stringBuffer = new StringBuffer(getFlgTipo() + " - "); if (!getCodiceAlt().isEmpty()) { stringBuffer.append(getCodiceAlt()); stringBuffer.append(" "); } stringBuffer.append(getNominativoCompleto()); return stringBuffer.toString(); } StringBuffer temp = new StringBuffer(); if (!getCodiceAlt().isEmpty()) { temp.append(getCodiceAlt()); temp.append(" "); } temp.append(getNominativoCompleto()); return temp.toString(); } return ""; } public String getCognomeNome() { return (getCognome() + " " + getCognome()).trim(); } public String getContatto() { return (this.contatto == null) ? "" : this.contatto.trim(); } public String getNome() { return (this.nome == null) ? "" : this.nome.trim(); } public String getIndirizzo() { return (this.indirizzo == null) ? "" : this.indirizzo.trim(); } public String getIndirizzoCompleto() { return getIndirizzo() + " " + getIndirizzo() + " " + getNumeroCivico() + " " + (getCapZona().isEmpty() ? getCapComune() : getCapZona()) + " (" + getDescrizioneComune() + ")"; } public String getIndirizzoCompletoHtml() { return getIndirizzoCompleto().replaceAll("\n", "
"); } public String getNumeroCivico() { return (this.numeroCivico == null) ? "" : this.numeroCivico.trim(); } public long getId_comune() { return this.id_comune; } public String getId_nazione() { return (this.id_nazione == null) ? "" : this.id_nazione.trim(); } public Date getDataNascita() { return this.dataNascita; } public String getCodFisc() { return (this.codFisc == null) ? "" : this.codFisc.trim().toUpperCase(); } public String getPIva() { return (this.pIva == null) ? "" : this.pIva.trim(); } public String getEMail() { return (this.eMail == null) ? "" : this.eMail.trim(); } public String getFax() { return (this.fax == null) ? "" : this.fax.trim(); } public String getTelefono() { return (this.telefono == null) ? "" : this.telefono.trim(); } public String getNota() { return (this.nota == null) ? "" : this.nota.trim(); } public String getImgTmst() { return (this.imgTmst == null) ? "" : this.imgTmst.trim(); } public long getFlgPrivComunicazione() { return this.flgPrivComunicazione; } public long getFlgPrivSensibili() { return this.flgPrivSensibili; } public long getFlgPrivTrattamento() { return this.flgPrivTrattamento; } public long getFlgSesso() { return this.flgSesso; } public String getWww() { return (this.www == null) ? "" : this.www.trim(); } public Date getDataRegistrazioneDI() { return this.dataRegistrazioneDI; } public String getDichiarazioneIntento() { return (this.dichiarazioneIntento == null) ? "" : this.dichiarazioneIntento.trim(); } public long getFlgArt8() { return this.flgArt8; } public void setTipoPagamento(TipoPagamento newTipoPagamento) { this.tipoPagamento = newTipoPagamento; } public TipoPagamento getTipoPagamento() { this.tipoPagamento = (TipoPagamento)getSecondaryObject(this.tipoPagamento, TipoPagamento.class, getId_tipoPagamento()); return this.tipoPagamento; } public void setComune(Comune newComune) { this.comune = newComune; } public Comune getComune() { this.comune = (Comune)getSecondaryObject(this.comune, Comune.class, getId_comune()); return this.comune; } public void setNazione(Nazione newNazione) { this.nazione = newNazione; } public Nazione getNazione() { this.nazione = (Nazione)getSecondaryObject(this.nazione, Nazione.class, getId_nazione()); return this.nazione; } protected void deleteCascade() {} public void findByCF(String l_codFisc, String l_flgTipo) { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc("A.codFisc='" + l_codFisc + "'"); wc.addWc("A.flgTipo='" + l_flgTipo + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findByPIva(String l_pIva, String l_flgTipo) { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc("A.pIva='" + l_pIva + "'"); wc.addWc("A.flgTipo='" + l_flgTipo + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findByImportPrefissoCodice(String l_importPrefissoCodice) { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc("A.importPrefissoCodice ='" + l_importPrefissoCodice + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findByEmail(String l_email) { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc("A.flgTipo='C'"); wc.addWc("A.eMail='" + l_email + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public String getCodFiscCalc() { if (this.codFiscCalc == null || this.codFiscCalc.isEmpty()) if (getFlgSesso() < 0L || getCognome().isEmpty() || getNome().isEmpty() || getId_comuneNascita() == 0L) { this.codFiscCalc = ""; } else { char sesso = getSesso().charAt(0); CodiceFiscale cf = new CodiceFiscale(getCognome(), getNome(), getDataNascita(), "", sesso); cf.setCodiceLuogoDiNascita(getComuneNascita().getCodice()); this.codFiscCalc = cf.getCodicefiscale(); } return this.codFiscCalc; } protected boolean isCodFiscDuplicated(String l_flgTipo) { if (!getCodFisc().isEmpty() && !l_flgTipo.isEmpty()) { String s_Sql_Find = "select * from CLIFOR AS A "; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.codFisc='" + getCodFisc() + "'"); wc.addWc("A.id_clifor !=" + getId_clifor()); wc.addWc("A.flgTipo ='" + l_flgTipo + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); Clifor bean = (Clifor)getFirstRecord(stmt); if (bean != null && bean.getDBState() == 1) return true; return false; } catch (Exception e) { handleDebug(e); return false; } } return false; } public boolean isCodFiscDuplicated() { return isCodFiscDuplicated(getFlgTipo()); } public boolean isPIvaDuplicated() { return isPIvaDuplicated(getFlgTipo()); } public boolean isPIvaCodfiscDuplicated() { return isPIvaCodfiscDuplicated(getFlgTipo()); } public boolean isCodFiscOk() { if (getFlgAzienda() != 1L) return (getCodFiscCalc().isEmpty() || getCodFiscCalc().equals(getCodFisc())); return true; } protected boolean isPIvaCodfiscDuplicated(String l_flgTipo) { return (isPIvaDuplicated(l_flgTipo) || isCodFiscDuplicated(l_flgTipo)); } protected boolean isPIvaDuplicated(String l_flgTipo) { if (!getPIva().isEmpty() && !l_flgTipo.isEmpty()) { String s_Sql_Find = "select * from CLIFOR AS A "; String s_Sql_Order = ""; String wc = ""; wc = buildWc(wc, "A.pIva='" + getPIva() + "'"); wc = buildWc(wc, "A.id_clifor !=" + getId_clifor()); wc = buildWc(wc, "A.flgTipo ='" + l_flgTipo + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc); Clifor bean = (Clifor)getFirstRecord(stmt); if (bean != null && bean.getDBState() == 1) return true; return false; } catch (Exception e) { handleDebug(e); return false; } } return false; } public long getId_comuneNascita() { return this.id_comuneNascita; } public void setId_comuneNascita(long id_comuneNascita) { this.id_comuneNascita = id_comuneNascita; setComuneNascita(null); } public Comune getComuneNascita() { this.comuneNascita = (Comune)getSecondaryObject(this.comuneNascita, Comune.class, getId_comuneNascita()); return this.comuneNascita; } public void setComuneNascita(Comune comuneNascita) { this.comuneNascita = comuneNascita; } public String getSesso() { return (getFlgSesso() == 0L) ? "M" : "F"; } protected void prepareSave(PreparedStatement ps) throws SQLException { synchronized (this) { if (getId_comune() > 0L) setDescrizioneComune(getComune().getDescrizione()); if (getId_comuneNascita() > 0L) setDescrizioneComuneNascita(getComuneNascita().getDescrizione()); super.prepareSave(ps); } } public Vectumerator findUsers(int pageNumber, int pageRows) { return new Users(getApFull()).findByClifor(getId_clifor(), pageNumber, pageRows); } public String getCognome() { return (this.cognome == null) ? "" : this.cognome.trim(); } public String getIban() { return (this.iban == null) ? "" : this.iban.trim().toUpperCase(); } public void setIban(String iban) { this.iban = iban; } public String getAbiIban() { if (getIban().length() < 11) return "??"; return getIban().substring(5, 10); } public String getCabIban() { if (getIban().length() < 16) return "??"; return getIban().substring(10, 15); } public String getConto() { if (getIban().length() < 27) return "??"; return getIban().substring(15); } public String getCapZona() { return (this.capZona == null) ? "" : this.capZona.trim(); } public void setCapZona(String capZona) { this.capZona = capZona; } protected int getStringValueCase(String l_columnName) { if (l_columnName.startsWith("eMail")) return 0; return super.getStringValueCase(l_columnName); } public Vectumerator getDestinazioniDiverse() { return new DestinazioneDiversa(getApFull()).findByClifor(getId_clifor(), 0, 0); } public ResParm addDestinazioneDiversa(DestinazioneDiversa row) { DestinazioneDiversa bean = new DestinazioneDiversa(getApFull()); bean.findByPrimaryKey(row.getId_destinazioneDiversa()); if (bean.getDBState() == 1) row.setDBState(bean.getDBState()); row.setId_clifor(getId_clifor()); ResParm rp = row.save(); return rp; } public ResParm delDestinazioneDiversa(DestinazioneDiversa row) { DestinazioneDiversa bean = new DestinazioneDiversa(getApFull()); bean.findByPrimaryKey(row.getId_destinazioneDiversa()); return bean.delete(); } public String getCellulare() { return (this.cellulare == null) ? "" : this.cellulare.trim(); } public void setCellulare(String cellulare) { this.cellulare = cellulare; } public String getBancaDesc() { return (this.bancaDesc == null) ? "" : this.bancaDesc.trim(); } public void setBancaDesc(String banca) { this.bancaDesc = banca; } public String getBancaCompleto() { return getBancaDesc() + " " + getBancaDesc(); } public long getId_listino() { return this.id_listino; } public void setId_listino(long id_listino) { this.id_listino = id_listino; setListino(null); } public Listino getListino() { this.listino = (Listino)getSecondaryObject(this.listino, Listino.class, getId_listino()); return this.listino; } public void setListino(Listino listino) { this.listino = listino; } public long getCloseCommand() { return this.closeCommand; } public void setCloseCommand(long closeCommand) { this.closeCommand = closeCommand; } public Clifor getCliforDup() { this.cliforDup = (Clifor)getSecondaryObject(this.cliforDup, Clifor.class, getId_cliforDup()); return this.cliforDup; } public void setId_cliforDup(long id_cliforDup) { this.id_cliforDup = id_cliforDup; setCliforDup(null); } public long getId_cliforDup() { return this.id_cliforDup; } public void setCliforDup(Clifor cliforDup) { this.cliforDup = cliforDup; } public Vectumerator getContratti() { return new Contratto(getApFull()).findByClifor(getId_clifor(), 0, 0); } public Vectumerator getDocumenti() { return new Documento(getApFull()).findByClifor(getId_clifor(), 0, 0); } public ResParm addContratto(Contratto row) { Contratto bean = new Contratto(getApFull()); bean.findByPrimaryKey(row.getId_contratto()); if (bean.getDBState() == 1) row.setDBState(bean.getDBState()); ResParm rp = row.save(); return rp; } public ResParm delContratto(Contratto row) { Contratto bean = new Contratto(getApFull()); bean.findByPrimaryKey(row.getId_contratto()); return bean.delete(); } public synchronized ResParm creaMailingListCR(CliforCR CR) { ResParm rp = new ResParm(true); resetMailingListFileCR(); CR.setFlgMl(1L); Vectumerator vec = findByCR(CR, 0, 0); long numEmail = 0L; boolean res = true; StringBuffer mail = new StringBuffer(); while (vec.hasMoreElements()) { Clifor row = (Clifor)vec.nextElement(); res = row.addToMailingListFileCR(); if (res) { mail.append(row.getEMail()); mail.append(", "); numEmail++; } } if (numEmail == 0L) { rp.setStatus(false); rp.setMsg("Errore!! Mailing list vuota. Verificare i criteri di ricerca."); } else { rp.setMsg("Mailing list creata correttamente. Inserite " + numEmail); rp.setInfoMsg(" email. " + mail.toString()); } return rp; } public void resetMailingListFileCR() { File mlFile = new File(getDocBase() + getDocBase()); boolean res = mlFile.delete(); } public synchronized boolean addToMailingListFileCR() { boolean mlRet = false; if (!getEMail().isEmpty()) { mlRet = FileMailingListManager.getInstance(getDocBase() + getDocBase()).addEmail(getEMail()); if (!mlRet) handleDebug(" Attenzione!! Mailing list non aggiornata. Contattare l'amministratore.", 2); } return mlRet; } protected String getMailingListFileCR() { return getParm("MAIL_LIST_FILE_CR").getTesto(); } public String getMailingMailCR() { return getParm("MAIL_LIST_MAIL_CR").getTesto(); } public static final synchronized ResParm unisciClifor(Clifor theClifor) { ResParm rp = new ResParm(true); if (theClifor.getId_clifor() != 0L && theClifor.getId_cliforDup() != 0L && theClifor.getId_clifor() != theClifor.getId_cliforDup()) { if (theClifor.getId_cliforDup() != 0L && theClifor.getId_cliforDup() != theClifor.getId_clifor()) if (rp.getStatus()) { String setSql = " set id_clifor=" + theClifor.getId_clifor() + " where id_clifor=" + theClifor.getId_cliforDup(); rp = theClifor.update("UPDATE DOCUMENTO" + setSql); rp = theClifor.update("UPDATE DOCUMENTO set id_cliforListino=" + theClifor.getId_clifor() + " where id_cliforListino=" + theClifor.getId_cliforDup()); rp.append(theClifor.update("UPDATE CLIFOR_USERS" + setSql)); rp.append(theClifor.update("UPDATE ARTICOLO_FORNITORE" + setSql)); rp.append(theClifor.update("UPDATE MAG_FISICO" + setSql)); rp.append(theClifor.update("UPDATE DESTINAZIONE_DIVERSA" + setSql)); rp.append(theClifor.update("UPDATE ALLEGATO_CLIFOR" + setSql)); rp.append(theClifor.update("UPDATE CLIFOR_USERS" + setSql)); rp.append(theClifor.update("UPDATE LISTINO_PERS" + setSql)); rp.append(theClifor.update("UPDATE MAG_FISICO" + setSql)); if (rp.getStatus()) rp.append(theClifor.update("delete from CLIFOR WHERE id_clifor=" + theClifor.getId_cliforDup())); } } else { rp.setStatus(false); rp.setMsg("Errore! Impossibile eseguire unione di oggetti nulli!."); } return rp; } public long getFlgMl() { return this.flgMl; } public void setFlgMl(long flgMl) { this.flgMl = flgMl; } public Vectumerator findByCR(CliforCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); if (CR.getId_tipoClifor() > 0L || CR.getFlgTipologiaClifor() > 0L) s_Sql_Find = s_Sql_Find + " JOIN CLIFOR_TIPO_CLIFOR AS B ON A.id_clifor = B.id_clifor JOIN TIPO_CLIFOR AS C ON B.id_tipoClifor = C.id_tipoClifor left join CLIFOR_TIPO_CLIFOR AS D ON A.id_clifor=D.id_clifor"; wc.addWc("A.id_clifor>1"); if (!CR.getFlgTipo().isEmpty()) wc.addWc("A.flgTipo='" + CR.getFlgTipo() + "'"); if (!CR.getSearchTxt().trim().isEmpty()) { StringBuffer txt = new StringBuffer("("); String temp = CR.getSearchTxt().trim().replace('*', '%'); int comma = temp.indexOf(","); if (comma > 0) { StringTokenizer st = new StringTokenizer(temp, ","); String token = st.nextToken().trim(); txt.append("(A.cognome like '" + token + "%')"); if (st.hasMoreTokens()) { token = st.nextToken().trim(); txt.append(" and "); txt.append("(A.nome like '" + token + "%' )"); } txt.append(")"); wc.addWc(txt.toString()); } else { StringTokenizer st = new StringTokenizer(temp, " "); while (st.hasMoreTokens()) { String token = prepareSqlString(st.nextToken()); txt.append("(A.cognome like '%" + token + "%' or A.nome like '%" + token + "%' or A.descAggiuntiva like '%" + token + "%' or A.codFisc like '%" + token + "%' or A.pIva like '%" + token + "%' or A.codiceCartaFidelity like '%" + token + "%' or A.contatto like '%" + token + "%' or A.telefono like '%" + token + "%' or A.cellulare like '%" + token + "%' or A.codiceAlt like '%" + token + "%' or A.eMail like '%" + token + "%')"); if (st.hasMoreTokens()) txt.append(" and "); } txt.append(")"); wc.addWc(txt.toString()); } } if (!CR.getSearchTxt2().trim().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getSearchTxt2().trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = prepareSqlString(st.nextToken()); txt.append("(A.cognome like '%" + token + "%' or A.nome like '%" + token + "%' or A.descAggiuntiva like '%" + token + "%' or A.codiceCartaFidelity like '%" + token + "%' or A.eMail like '%" + token + "%')"); if (st.hasMoreTokens()) txt.append(" and "); } txt.append(")"); wc.addWc(txt.toString()); } if (CR.getId_cliforEscludi() != 0L) wc.addWc("A.id_clifor !=" + CR.getId_cliforEscludi()); if (CR.getFlgAzienda() == 0L) { wc.addWc("(A.flgAzienda is null or A.flgAzienda=0)"); } else if (CR.getFlgAzienda() > 0L) { wc.addWc("A.flgAzienda =" + CR.getFlgAzienda()); } if (CR.getFlgNascondiWeb() == 0L) { wc.addWc("(A.flgNascondiWeb = 0 OR A.flgNascondiWeb IS NULL)"); } else if (CR.getFlgNascondiWeb() > 0L) { wc.addWc(" A.flgNascondiWeb =" + CR.getFlgNascondiWeb()); } if (CR.getFlgMl() == 0L) { wc.addWc("(A.flgMl is null or A.flgMl=0)"); } else if (CR.getFlgMl() > 0L) { wc.addWc("A.flgMl =" + CR.getFlgMl()); } if (CR.getFlgSplitPayment() == 0L) { wc.addWc("(A.flgSplitPayment is null or A.flgSplitPayment=0)"); } else if (CR.getFlgSplitPayment() > 0L) { wc.addWc("A.flgSplitPayment =" + CR.getFlgSplitPayment()); } if (CR.getFlgPA() == 0L) { wc.addWc("(A.flgPA is null or A.flgPA=0)"); } else if (CR.getFlgPA() > 0L) { wc.addWc("A.flgPA =" + CR.getFlgPA()); } if (CR.getFlgEscludi() == 0L) { wc.addWc("(A.flgEscludi is null or A.flgEscludi=0)"); } else if (CR.getFlgEscludi() > 0L) { wc.addWc("A.flgEscludi =" + CR.getFlgEscludi()); } if (CR.getId_usersResponsabile() > 0L) wc.addWc("A.id_usersResponsabile = " + CR.getId_usersResponsabile()); if (CR.getId_usersAttivita() > 0L) wc.addWc("A.id_usersAttivita = " + CR.getId_usersAttivita()); if (CR.getId_agente() > 0L) wc.addWc("A.id_agente = " + CR.getId_agente()); if (CR.getId_respCommerciale() > 0L) wc.addWc("A.id_respCommerciale = " + CR.getId_respCommerciale()); if (CR.getId_tipoClifor() > 0L) wc.addWc("(B.id_tipoClifor = " + CR.getId_tipoClifor() + " or D.id_tipoClifor=" + CR.getId_tipoClifor() + ")"); if (CR.getFlgTipologiaClifor() == 101L) { wc.addWc("(C.flgTipologia = 1 or C.flgTipologia = 3)"); } else if (CR.getFlgTipologiaClifor() == 102L) { wc.addWc("(C.flgTipologia = 1 or C.flgTipologia = 3 or C.flgTipologia = 2)"); } else if (CR.getFlgTipologiaClifor() > 0L) { wc.addWc("C.flgTipologia = " + CR.getFlgTipologiaClifor()); } if (!CR.getDescrizioneComune().isEmpty()) wc.addWc(" A.descrizioneComune LIKE '%" + CR.getDescrizioneComune() + "%'"); if (!CR.getProvinciaComune().isEmpty()) wc.addWc(" A.provinciaComune LIKE '%" + CR.getProvinciaComune() + "%'"); if (CR.getFlgStatoConfermaDati() == 0L) { wc.addWc("(A.flgStatoConfermaDati = 0 OR A.flgStatoConfermaDati IS NULL)"); } else if (CR.getFlgStatoConfermaDati() > 0L) { wc.addWc(" A.flgStatoConfermaDati =" + CR.getFlgStatoConfermaDati()); } try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } protected void initFields() { super.initFields(); setCurrentDD(null); setFlgStatoConfermaDatiDb(0L); setAnnoCorrente((long)getCurrentYear()); } public String getDescrizioneComune() { if (this.id_comune != 0L) return getComune().getDescrizione(); return (this.descrizioneComune == null) ? "" : this.descrizioneComune.trim(); } public void setDescrizioneComune(String descrizioneComune) { this.descrizioneComune = descrizioneComune; } public String getProvinciaComune() { if (this.id_comune != 0L) return getComune().getProvincia(); if (this.provinciaComune == null) return ""; if (this.provinciaComune.length() > 2) return this.provinciaComune.substring(0, 2); return this.provinciaComune; } public void setProvinciaComune(String provinciaComune) { this.provinciaComune = provinciaComune; } public String getCapComune() { if (this.id_comune != 0L) return getComune().getCap(); return (this.capComune == null) ? "" : this.capComune.trim(); } public void setCapComune(String capComune) { this.capComune = capComune; } public String getPathAllegato() { return getDocBase() + getDocBase() + getParm("CLIFOR_ATTACH_PATH").getTesto(); } public Vectumerator getAllegati(long l_id_tipoAllegatoClifor) { return new AllegatoClifor(getApFull()).findByCliforTipo(getId_clifor(), l_id_tipoAllegatoClifor, 0, 0); } public ResParm addAllegato(AllegatoClifor row) { AllegatoClifor bean = new AllegatoClifor(getApFull()); bean.findByCliforNomeFile(row.getId_clifor(), row.getNomeFile()); if (bean.getDBState() == 1) return new ResParm(false, "Nome File Duplicato"); row.setDBState(0); ResParm rp = row.save(); return rp; } public ResParm delAllegato(AllegatoClifor row) { AllegatoClifor bean = new AllegatoClifor(getApFull()); bean.findByPrimaryKey(row.getId_allegatoClifor()); return bean.delete(); } public synchronized void creaCodaMessaggi(CliforCR CR, long l_id_templateMsg) { CR.setFlgMl(1L); Vectumerator vec = findByCR(CR, 0, 0); TemplateMsg ts = new TemplateMsg(getApFull()); ts.findByPrimaryKey(l_id_templateMsg); String campagna = ts.getDescrizione() + " " + ts.getDescrizione(); while (vec.hasMoreElements()) { Clifor row = (Clifor)vec.nextElement(); if (ts.getFlgTipo() == 1L) { if (!row.getEMail().trim().isEmpty()) { CodaMessaggi cm = new CodaMessaggi(getApFull()); cm.setFlgTipo(ts.getFlgTipo()); cm.setCampagna(campagna); cm.setMailTo(row.getEMail().trim()); cm.setOggettoEmail(ts.getOggettoEmail()); ts.setParmMsgString("intestazione", row.getCognomeNome()); cm.setTestoMessaggio(ts.getTestoMessaggioWithParms()); cm.save(); } continue; } if (!row.getCellulare().trim().isEmpty()) { CodaMessaggi cm = new CodaMessaggi(getApFull()); cm.setFlgTipo(ts.getFlgTipo()); cm.setCampagna(campagna); cm.setCellulare(row.getCellulare().trim()); cm.setTestoMessaggio(ts.getTestoMessaggio()); cm.save(); } } } public long getFlgRC() { return this.flgRC; } public void setFlgRC(long flgRC) { this.flgRC = flgRC; } public String getNominativoCompleto() { if (getId_clifor() != 0L) { StringBuilder temp = new StringBuilder(); if (!getCognome().isEmpty()) { temp.append(" "); temp.append(getCognome()); } if (!getDescAggiuntiva().isEmpty()) { temp.append(" "); temp.append(getDescAggiuntiva()); } if (!getNome().isEmpty()) { temp.append(" "); temp.append(getNome()); } return temp.toString().trim(); } return ""; } public String getCodiceCartaFidelity() { return (this.codiceCartaFidelity == null) ? "" : this.codiceCartaFidelity.trim(); } public void setCodiceCartaFidelity(String codiceCartaFidelity) { this.codiceCartaFidelity = codiceCartaFidelity; } public ByteArrayOutputStream creaPdfEtichettaZebra(String l_printer) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { Chunk nome, indirizzo, citta; String dim = getParm("LABEL_ANAG_SIZE").getTesto(); long xx = Long.parseLong(dim.substring(0, dim.indexOf(','))); long yy = Long.parseLong(dim.substring(dim.indexOf(',') + 1)); int fontSize = getParm("LABEL_ANAG_FONT_SIZE").getNumeroInt(); Rectangle label = new Rectangle(getPdfPointSize(yy), getPdfPointSize(xx)); this.document = new Document(label.rotate(), 2.0F, 2.0F, 2.0F, 2.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); String sp = " "; String spp = " "; String sppp = " "; Font pdfTagliando = new Font(2, (float)fontSize, 1); Font pdfTagliandoP = new Font(2, (float)(fontSize - 1), 1); Font pdfTagliandoPP = new Font(2, (float)(fontSize - 2), 1); String temp = getCognomeNome(); if (temp.length() > 23) { nome = new Chunk(spp + spp + "\n", pdfTagliandoP); } else { nome = new Chunk(sp + sp + "\n", pdfTagliando); } temp = getIndirizzo() + " " + getIndirizzo(); if (temp.length() > 30) { indirizzo = new Chunk(sppp + sppp + "\n", pdfTagliandoPP); } else if (temp.length() > 23) { indirizzo = new Chunk(spp + spp + "\n", pdfTagliandoP); } else { indirizzo = new Chunk(sp + sp + "\n", pdfTagliando); } temp = getComune().getCap() + " - " + getComune().getCap() + " (" + getComune().getDescrizione() + ")"; if (temp.length() > 23) { citta = new Chunk(spp + spp, pdfTagliandoP); } else { citta = new Chunk(sp + sp, pdfTagliando); } Paragraph p = new Paragraph(nome); p.add(indirizzo); p.add(citta); this.document.add((Element)p); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public String getKoMsg() { StringBuffer msg = new StringBuffer(); if (getDBState() == 1) { if (getCodFisc().isEmpty()) msg.append("Codice fiscale mancante, "); if (getFlgAzienda() == 1L && getPIva().isEmpty()) msg.append("Partita Iva Mancante, "); if (!getCodiceCartaFidelity().isEmpty() && getId_listino() == 0L) msg.append("Listino mancante per cliente fidelity, "); if (getFlgUsato() == 1L && getFlgAzienda() == 0L && ( getDescrizioneComune().isEmpty() || getDataNascita() == null || getNumeroDocumento().isEmpty())) msg.append("Cliente privato usato senza comune/data nascita/numero documento, "); } return msg.toString(); } public String getKoMsgWww() { StringBuffer msg = new StringBuffer(); if (getDBState() == 1) { if ((getId_nazione().toLowerCase().equals("i") || getId_nazione().toLowerCase().equals("it")) && getCodFisc().isEmpty()) msg.append("Codice fiscale mancante, "); if (getFlgAzienda() == 1L && getPIva().isEmpty()) msg.append("Partita Iva Mancante, "); if (getFlgAzienda() == 0L && getNome().isEmpty()) msg.append("Nome mancante, "); if (!isIndirizzoOk()) msg.append("Indirizzo mancante, "); if (getFlgUsato() == 1L && getFlgAzienda() == 0L && ( getDescrizioneComune().isEmpty() || getDataNascita() == null || getNumeroDocumento().isEmpty())) msg.append("Cliente privato usato senza comune/data nascita/numero documento, "); } return msg.toString(); } public boolean isOk() { if (getId_clifor() == 0L) return false; if (getKoMsg().length() == 0) return true; return false; } public ResParm save() { ResParm rp = new ResParm(true); long l_flgStatoConfermaDatiDb = getFlgStatoConfermaDatiDb(); if (getCodFisc().isEmpty()) setCodFisc(getCodFiscCalc()); if (rp.getStatus()) { rp = super.save(); if (rp.getStatus()) { rp.append(aggiornaUsersAssociati()); if (getFlgStatoConfermaDati() != l_flgStatoConfermaDatiDb) { CliforLog clog = new CliforLog(getApFull()); clog.setId_users(getLastUpdId_user()); clog.setId_clifor(getId_clifor()); clog.setDescrizione("aggiornamento da admin"); rp.append(clog.save(l_flgStatoConfermaDatiDb)); } } return rp; } return rp; } public ResParm saveStatoVerifica(long l_flgStatoConfermaDati, String msg) { long l_flgStatoConfermaDatiDb = getFlgStatoConfermaDatiDb(); setFlgStatoConfermaDati(l_flgStatoConfermaDati); ResParm rp = super.save(); if (rp.getStatus()) { CliforLog clog = new CliforLog(getApFull()); clog.setId_users(getLastUpdId_user()); clog.setId_clifor(getId_clifor()); clog.setDescrizione(msg); rp.append(clog.save(l_flgStatoConfermaDatiDb)); } return rp; } public String getDescrizioneComuneNascita() { if (this.id_comuneNascita != 0L) return getComuneNascita().getDescrizione(); return (this.descrizioneComuneNascita == null) ? "" : this.descrizioneComuneNascita.trim(); } public void setDescrizioneComuneNascita(String descrizioneComuneNascita) { this.descrizioneComuneNascita = descrizioneComuneNascita; } public DestinazioneDiversa getCurrentDD() { if (this.currentDD == null && getId_clifor() > 0L) { this.currentDD = new DestinazioneDiversa(getApFull()); this.currentDD.findDefaultByClifor(getId_clifor()); } return (this.currentDD == null) ? new DestinazioneDiversa(getApFull()) : this.currentDD; } public void setCurrentDD(DestinazioneDiversa currentDD) { this.currentDD = currentDD; } protected void fillFields(ResultSet rst) { super.fillFields(rst); setCurrentDD(null); setFlgStatoConfermaDatiDb(getFlgStatoConfermaDati()); if (getAnnoCorrente() == 0L) setAnnoCorrente((long)getCurrentYear()); } public boolean hasCurrentDD() { if (getCurrentDD() == null || getCurrentDD().getId_destinazioneDiversa() == 0L) return false; return true; } public String getpIva() { return (this.pIva == null) ? "" : this.pIva.trim(); } public void setpIva(String pIva) { this.pIva = pIva; } public String getTelefonoAmm() { return (this.telefonoAmm == null) ? "" : this.telefonoAmm.trim(); } public void setTelefonoAmm(String telefonoAmm) { this.telefonoAmm = telefonoAmm; } public String getEMailAmm() { return (this.eMailAmm == null) ? "" : this.eMailAmm.trim(); } public void setEMailAmm(String eMailAmm) { this.eMailAmm = eMailAmm; } public String getTelefonoAltro() { return (this.telefonoAltro == null) ? "" : this.telefonoAltro.trim(); } public void setTelefonoAltro(String telefonoAltro) { this.telefonoAltro = telefonoAltro; } public String getEMailAltro() { return (this.eMailAltro == null) ? "" : this.eMailAltro.trim(); } public void setEMailAltro(String eMailAltro) { this.eMailAltro = eMailAltro; } public String getCellulareAmm() { return (this.cellulareAmm == null) ? "" : this.cellulareAmm.trim(); } public void setCellulareAmm(String cellulareAmm) { this.cellulareAmm = cellulareAmm; } public String getCellulareAltro() { return (this.cellulareAltro == null) ? "" : this.cellulareAltro.trim(); } public void setCellulareAltro(String cellulareAltro) { this.cellulareAltro = cellulareAltro; } public String getDescrizioneAltroContatto() { return (this.descrizioneAltroContatto == null) ? "" : this.descrizioneAltroContatto.trim(); } public void setDescrizioneAltroContatto(String descrizioneAltroContatto) { this.descrizioneAltroContatto = descrizioneAltroContatto; } public String getNumeroDocumento() { return (this.numeroDocumento == null) ? "" : this.numeroDocumento; } public void setNumeroDocumento(String numeroDocumento) { this.numeroDocumento = numeroDocumento; } public Date getDataScadenzaDocumento() { return this.dataScadenzaDocumento; } public void setDataScadenzaDocumento(Date dataScadenzaDocumento) { this.dataScadenzaDocumento = dataScadenzaDocumento; } public double getPercProvvigione() { return this.percProvvigione; } public void setPercProvvigione(double percProvvigione) { this.percProvvigione = percProvvigione; } public long getFlgDocumentoVerificato() { return this.flgDocumentoVerificato; } public void setFlgDocumentoVerificato(long flgDocumentoVerificato) { this.flgDocumentoVerificato = flgDocumentoVerificato; } public String getNotaPerCliente() { return (this.notaPerCliente == null) ? "" : this.notaPerCliente; } public void setNotaPerCliente(String notaPerCliente) { this.notaPerCliente = notaPerCliente; } public String getStatoDocumento() { String ret = ""; if (getFlgDocumentoVerificato() == 0L) { ret = "Documento non verificato"; } else if (getFlgDocumentoVerificato() == 10L) { ret = "Documento non valido"; } else if (getFlgDocumentoVerificato() == 15L) { ret = "Documento in scadenza"; } else if (getFlgDocumentoVerificato() == 20L) { ret = "Documento scaduto"; } else if (getFlgDocumentoVerificato() == 30L) { ret = "Documento verificato."; } return ret; } public Vectumerator findDocumentiScaduti() { String s_Sql_Find = "select A.* from CLIFOR AS A "; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc(" A.dataScadenzaDocumento < ? "); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); int dataCount = 0; dataCount++; Calendar cal = Calendar.getInstance(); Date data = new Date(cal.getTimeInMillis()); stmt.setDate(dataCount, data); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findDocumentiInScadenza() { String s_Sql_Find = "select A.* from CLIFOR AS A "; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc(" A.dataScadenzaDocumento >= ? "); wc.addWc(" A.dataScadenzaDocumento <= ? "); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); int dataCount = 0; dataCount++; Calendar cal = Calendar.getInstance(); Date data = new Date(cal.getTimeInMillis()); stmt.setDate(dataCount, data); dataCount++; cal.add(2, 1); Date data1 = new Date(cal.getTimeInMillis()); stmt.setDate(dataCount, data1); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public ResParm checkStatoDocumento() { ResParm rp = new ResParm(true); StringBuilder sb = new StringBuilder(); Vectumerator vec = findDocumentiScaduti(); while (vec.hasMoreElements()) { Clifor cli = (Clifor)vec.nextElement(); cli.setFlgDocumentoVerificato(20L); sb.append("Il cliente " + cli.getNominativoCompleto() + " ha il documento scaduto. \n"); cli.save(); } vec = findDocumentiInScadenza(); while (vec.hasMoreElements()) { Clifor cli = (Clifor)vec.nextElement(); cli.setFlgDocumentoVerificato(15L); sb.append("Il cliente " + cli.getNominativoCompleto() + " ha il documento in scadenza nel prossimo mese. \n"); cli.save(); } rp.setMsg(sb.toString()); return rp; } public Vectumerator findByRegione(String l_id_regione) { String s_Sql_Find = "select A.* from CLIFOR AS A, COMUNE AS B "; String s_Sql_Order = " order by B.provincia,A.cognome, B.descrizione "; WcString wc = new WcString(); wc.addWc(" A.id_comune = B.id_comune "); wc.addWc(" A.flgTipo ='C' "); wc.addWc(" B.id_regione = '" + l_id_regione + "' "); wc.addWc(" (A.flgNascondiWeb = 0 OR A.flgNascondiWeb IS NULL)"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public String getDescrizioneCliente() { if (getId_clifor() != 0L) return getNominativoCompleto().trim(); return ""; } public String getDescrizione() { return getDescrizioneCliente(); } public boolean hasDatiCompleti() { if (getIndirizzo().isEmpty()) return false; return true; } public long getFlgNascondiWeb() { return this.flgNascondiWeb; } public void setFlgNascondiWeb(long flgVisibileWeb) { this.flgNascondiWeb = flgVisibileWeb; } public ResParm addTipologia(CliforTipoClifor row) { return row.save(); } public ResParm delTipologia(CliforTipoClifor row) { CliforTipoClifor bean = new CliforTipoClifor(getApFull()); bean.findByPrimaryKey(row.getId_cliforTipoClifor()); return bean.delete(); } public boolean isPivaComunitariaOk() { if (!getPIva().isEmpty()) { boolean pivaOk = true; String l_nazione = "IT"; String l_pIva = getPIva(); if (!getId_nazione().isEmpty() && !getNazione().getCodice().toLowerCase().equals("it")) if (getPIva().length() > 11) { l_nazione = getPIva().substring(0, 2).toUpperCase(); l_pIva = getPIva().substring(2); } else { l_nazione = null; } if (l_nazione == null) { pivaOk = false; } else { CheckVatClient cvc = new CheckVatClient(l_nazione, l_pIva); if (!cvc.getValid()) pivaOk = false; } return pivaOk; } return true; } public String getZona() { return (this.zona == null) ? "" : this.zona.trim(); } public void setZona(String zona) { this.zona = zona; } public DestinazioneDiversa getDestinazioneDiversa(int index) { if (getApFull() != null) { Vectumerator vec = new DestinazioneDiversa(getApFull()).findByClifor(getId_clifor(), 0, 0); if (vec.hasMoreElements()) return (DestinazioneDiversa)vec.get(index); return new DestinazioneDiversa(getApFull()); } return new DestinazioneDiversa(); } public void creaFileCvs(CliforCR CR) { try { Vectumerator list = findByCR(CR, 0, 0); CR.setFileName(getPathTmp() + "exportClifor_" + getPathTmp() + "_" + CR.getFlgTipo() + "_" + CR.getId_users() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "Criteri di ricerca: " + CR.getDescrizioneCR() + "\nID;AZIENDA-COGNOME;NOME;CONTATTO;EMAIL;PEC;TELEFONO;FAX;CELL;NOTA;TIPO PAG.;COD. FISC;P.IVA;INDIRIZZO;N. CIVICO;COMUNE;CAP;CAP ZONA;NAZIONE;Responsabile;Attivita';INDIRIZZO DD;NUM CIVICO DD;COMUNE DD;CAP DD;CAP ZONA DD;NAZIONE DD"; outCvsFile.writeLine(s1); while (list.hasMoreElements()) { Clifor row = (Clifor)list.nextElement(); s1 = " " + row.getId_clifor() + SEP + row.getCognome() + SEP + row.getNome() + SEP + row.getContatto() + SEP + row.getEMail() + SEP + row.getPec() + SEP + row.getTelefono() + SEP + row.getFax() + SEP + row.getCellulare() + SEP + row.getNota() + SEP + row.getTipoPagamento().getDescrizione() + SEP + row.getCodFisc() + SEP + row.getpIva() + SEP + row.getIndirizzo() + SEP + row.getNumeroCivico() + SEP + row.getDescrizioneComune() + SEP + row.getCapComune() + SEP + row.getCapZona() + SEP + row.getNazione().getDescrizione_it() + SEP + row.getUsersResponsabile().getCognomeNome() + SEP + row.getUsersAttivita().getCognomeNome() + SEP; DestinazioneDiversa dd = row.getDestinazioneDiversa(0); s1 = s1 + s1 + dd.getIndirizzoDD() + SEP + dd.getNumeroCivicoDD() + SEP + dd.getDescrizioneComuneDD() + SEP + dd.getCapComuneDD() + SEP + dd.getCapZonaDD() + SEP; s1 = s1.replace("€", "€"); s1 = s1.replace("»", "-->"); s1 = s1.replace("\n", ", "); s1 = s1.replace("\r", ""); outCvsFile.writeLine(s1); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public void creaFileCvsGC(CliforCR CR) { try { Vectumerator list = findByCR(CR, 0, 0); CR.setFileName(getPathTmp() + "exportCliforGC_" + getPathTmp() + "_" + CR.getFlgTipo() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "AZIENDA;NOME;COGNOME;P. IVA;COD. FISC;TIPO PAG.;INDIRIZZO;COMUNE;CAP;PROV;NAZIONE;TELEFONO;FAX;EMAIL;DESCRIZIONE DD;INDIRIZZO DD;COMUNE DD;CAP DD; PROV DD;NAZIONE DD;TELEFONO DD;FAX DD;EMAIL DD"; outCvsFile.writeLine(s1); while (list.hasMoreElements()) { Clifor row = (Clifor)list.nextElement(); s1 = " " + SEP + row.getNome() + SEP + row.getCognome() + SEP + row.getpIva() + SEP + row.getCodFisc() + SEP + row.getTipoPagamento().getDescrizione() + SEP + row.getIndirizzo() + " " + row.getNumeroCivico() + SEP + row.getDescrizioneComune() + SEP + row.getCapComune() + SEP + row.getProvinciaComune() + SEP + row.getNazione().getDescrizione_it() + SEP + row.getTelefono() + SEP + row.getFax() + SEP + row.getEMail() + SEP; DestinazioneDiversa dd = row.getDestinazioneDiversa(0); s1 = s1 + s1 + " " + dd.getDescrizioneDD() + dd.getPressoDD() + SEP + " " + dd.getIndirizzoDD() + dd.getNumeroCivicoDD() + SEP + dd.getDescrizioneComuneDD() + SEP + dd.getCapComuneDD() + SEP + dd.getProvinciaComuneDD() + SEP + SEP + dd.getTelefonoDD() + SEP + SEP; s1 = s1.replace("€", "€"); s1 = s1.replace("»", "-->"); outCvsFile.writeLine(s1); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public void creaFileCvsGF(CliforCR CR) { try { Vectumerator list = findByCR(CR, 0, 0); CR.setFileName(getPathTmp() + "exportCliforGF_" + getPathTmp() + "_" + CR.getFlgTipo() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "AZIENDA;COD. FISC;P. IVA;INDIRIZZO;TELEFONO;cell;FAX;EMAIL;COMUNE;CAP;PROV;NAZIONE;DESCRIZIONE DD;INDIRIZZO DD;COMUNE DD;CAP DD; PROV DD;NAZIONE DD;TELEFONO DD;FAX DD;EMAIL DD"; outCvsFile.writeLine(s1); while (list.hasMoreElements()) { Clifor row = (Clifor)list.nextElement(); s1 = " " + row.getCognomeNome() + SEP + row.getCodFisc() + SEP + row.getpIva() + SEP + row.getIndirizzo() + " " + row.getNumeroCivico() + SEP + row.getTelefono() + SEP + row.getCellulare() + SEP + row.getFax() + SEP + row.getEMail() + SEP + row.getDescrizioneComune() + SEP + row.getCapComune() + SEP + row.getProvinciaComune() + SEP + row.getNazione().getDescrizione_it(); DestinazioneDiversa dd = row.getDestinazioneDiversa(0); s1 = s1 + s1 + " " + dd.getDescrizioneDD() + dd.getPressoDD() + SEP + " " + dd.getIndirizzoDD() + dd.getNumeroCivicoDD() + SEP + dd.getDescrizioneComuneDD() + SEP + dd.getCapComuneDD() + SEP + dd.getProvinciaComuneDD() + SEP + SEP + dd.getTelefonoDD() + SEP + SEP; s1 = s1.replace("€", "€"); s1 = s1.replace("»", "-->"); outCvsFile.writeLine(s1); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public long getId_bancaAzienda() { return this.id_bancaAzienda; } public void setId_bancaAzienda(long id_bancaAzienda) { this.id_bancaAzienda = id_bancaAzienda; setBancaAzienda(null); } public Banca getBancaAzienda() { this.bancaAzienda = (Banca)getSecondaryObject(this.bancaAzienda, Banca.class, getId_bancaAzienda()); return this.bancaAzienda; } public void setBancaAzienda(Banca bancaAzienda) { this.bancaAzienda = bancaAzienda; } public String getAbi() { return (this.abi == null) ? "" : this.abi.trim(); } public String getBic() { return (this.bic == null) ? "" : this.bic.trim(); } public String getCab() { return (this.cab == null) ? "" : this.cab.trim(); } public void setAbi(String abi) { this.abi = abi; } public void setBic(String bic) { this.bic = bic; } public void setCab(String cab) { this.cab = cab; } public double getSpeseIncasso() { return this.speseIncasso; } public void setSpeseIncasso(double speseIncasso) { this.speseIncasso = speseIncasso; } public void findClienteByCodiceAlt(String l_codiceAlt) { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc("A.flgTipo='C'"); wc.addWc("A.codiceAlt='" + l_codiceAlt + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findFornitoreByCodiceAlt(String l_codiceAlt) { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc("A.flgTipo='F'"); wc.addWc("A.codiceAlt='" + l_codiceAlt + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public ByteArrayOutputStream creaPdfListaClifor(CliforCR CR) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); Cell cell = new Cell(); int cellLeading = 10; int corpoPadding = 2; SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Calendar cal = Calendar.getInstance(); SimpleDateFormat sdfh = new SimpleDateFormat("hh:mm"); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); Date dataVisita = null; int col1 = 10, col2 = 9, col3 = 4, col4 = 4, col5 = 4, col6 = 4, col7 = 5; try { this.document = new Document(PageSize.A4.rotate(), 20.0F, 20.0F, 20.0F, 10.0F); String nomeFile = CR.getFileName(); if (nomeFile.isEmpty()) { this.writer = PdfWriter.getInstance(this.document, ba); } else { PdfWriter.getInstance(this.document, new FileOutputStream(nomeFile)); } Font PDF_riga = PdfFontFactory.PDF_fPiccolo; Phrase pHh = new Phrase(new Chunk("Lista clienti", PdfFontFactory.PDF_fGrandeB)); HeaderFooter header = new HeaderFooter(pHh, false); header.setAlignment(0); header.setBorder(0); this.document.setHeader(header); Phrase pH = new Phrase("Data/ora stampa: " + sdf.format(getToday()) + " " + sdfh.format(Long.valueOf(cal.getTimeInMillis())) + " pag. "); HeaderFooter footer = new HeaderFooter(pH, true); footer.setAlignment(2); footer.setBorder(0); this.document.setFooter(footer); this.document.open(); Clifor bean = new Clifor(getApFull()); Table corpo = null; corpo = new Table(40); corpo.setWidth(100.0F); corpo.setPadding((float)corpoPadding); corpo.setSpacing(0.0F); corpo.setWidths(colWidthsRighe40); corpo.setBorder(0); corpo.endHeaders(); cell = new Cell(); cell.add(new Chunk("Nominativo", PdfFontFactory.PDF_fGrandeBianco)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(col1); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("Indirizzo", PdfFontFactory.PDF_fGrandeBianco)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(col2); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("Tel.", PdfFontFactory.PDF_fGrandeBianco)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(col3); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("Cell.", PdfFontFactory.PDF_fGrandeBianco)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(col4); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("Email", PdfFontFactory.PDF_fGrandeBianco)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(col5); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("Listino ass.", PdfFontFactory.PDF_fGrandeBianco)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(col6); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("Note", PdfFontFactory.PDF_fGrandeBianco)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(col7); cell.setRowspan(1); corpo.addCell(cell); corpo.endHeaders(); Vectumerator vec = bean.findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Clifor row = (Clifor)vec.nextElement(); cell = new Cell(); cell.add(new Chunk(row.getDescrizioneCliente(), PDF_riga)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setColspan(col1); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(row.getIndirizzoCompleto(), PDF_riga)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setColspan(col2); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(row.getTelefono(), PdfFontFactory.PDF_fPiccolo)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setColspan(col3); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(String.valueOf(row.getCellulare()), PDF_riga)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setColspan(col4); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(row.getEMail(), PDF_riga)); if (!row.getPec().isEmpty()) cell.add(new Chunk("\n" + row.getPec(), PDF_riga)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setColspan(col5); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(row.getListino().getDescrizione(), PDF_riga)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setColspan(col6); cell.setRowspan(1); corpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(row.getNotaPerCliente(), PDF_riga)); cell.setLeading((float)cellLeading); cell.setHorizontalAlignment(0); cell.setColspan(col7); cell.setRowspan(1); corpo.addCell(cell); } this.document.add((Element)corpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public long getId_agente() { return this.id_agente; } public void setId_agente(long id_agente) { this.id_agente = id_agente; } public Clifor getAgente() { this.agente = (Clifor)getSecondaryObject(this.agente, Clifor.class, getId_agente()); return this.agente; } public void setAgente(Clifor agente) { this.agente = agente; } public long getId_respCommerciale() { return this.id_respCommerciale; } public void setId_respCommerciale(long id_respCommerciale) { this.id_respCommerciale = id_respCommerciale; } public Clifor getRespCommerciale() { this.respCommerciale = (Clifor)getSecondaryObject(this.respCommerciale, Clifor.class, getId_respCommerciale()); return this.respCommerciale; } public void setRespCommerciale(Clifor respCommerciale) { this.respCommerciale = respCommerciale; } public double getPercAgente() { return this.percAgente; } public void setPercAgente(double percAgente) { this.percAgente = percAgente; } public double getPercRespCommerciale() { return this.percRespCommerciale; } public void setPercRespCommerciale(double percRespCommerciale) { this.percRespCommerciale = percRespCommerciale; } public Vectumerator findByAgente(long l_id_agente) { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc("A.id_agente=" + l_id_agente); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public ResParm superSave() { return super.save(); } public boolean isAgenteOResponsabileCommerciale() { if (getDBState() == 0) return false; return new CliforTipoClifor(getApFull()).isAgenteORespondabileCommercialeByClifor(getId_clifor()); } public boolean isAgente() { if (getDBState() == 0) return false; return new CliforTipoClifor(getApFull()).isAgenteByClifor(getId_clifor()); } public boolean isPrezzoWebEsente() { if (getId_clifor() == 0L) return false; if (isIvaEsteroAziendaEsente()) { DestinazioneDiversa dd = getCurrentDD(); if (dd.getId_destinazioneDiversa() > 0L) { if (dd.getNazioneDD().getFlgCee() == 0L) return true; if (getNazione().getCodice().equals("IT")) { if (dd.getNazioneDD().getCodice().equals("IT")) return false; if (getFlgAzienda() == 1L && !getpIva().isEmpty()) return true; return false; } if (getNazione().getFlgCee() == 1L && getFlgAzienda() == 1L && !getpIva().isEmpty() && !dd.getNazioneDD().getCodice().equals("IT")) return true; return false; } if (getNazione().getCodice().equals("IT") || ( getNazione().getFlgCee() == 1L && getFlgAzienda() == 0L)) return false; return true; } return false; } public boolean isPrezzoWebOss() { if (isIvaCeeOneStopShop() && !getNazione().getCodice().toUpperCase().equals("IT") && getNazione().getFlgCee() == 1L) return true; return false; } public boolean isProgettista() { if (getDBState() == 0) return false; return new CliforTipoClifor(getApFull()).isProgettistaByClifor(getId_clifor()); } public boolean isResponsabileCommerciale() { if (getDBState() == 0) return false; return new CliforTipoClifor(getApFull()).isRespondabileCommercialeByClifor(getId_clifor()); } public String getDescrizioneAgenteResponsabileCommerciale() { if (getDBState() == 0) return ""; StringBuilder sb = new StringBuilder(); if (isAgente()) sb.append("Agente "); if (isResponsabileCommerciale()) sb.append("Resp. Comm."); return sb.toString().trim(); } public String getPec() { return (this.pec == null) ? "" : this.pec.trim(); } public void setPec(String pec) { this.pec = pec; } public String getDescAggiuntiva() { return (this.descAggiuntiva == null) ? "" : this.descAggiuntiva.trim(); } public void setDescAggiuntiva(String descAggiuntiva) { this.descAggiuntiva = descAggiuntiva; } public String getCodiceIdentificativoFE() { return (this.codiceIdentificativoFE == null) ? "" : this.codiceIdentificativoFE.trim().toUpperCase(); } public void setCodiceIdentificativoFE(String codiceIdentificativoFE) { this.codiceIdentificativoFE = codiceIdentificativoFE; } public long getFlgPA() { return this.flgPA; } public void setFlgPA(long flgPA) { this.flgPA = flgPA; } public double getCostoOrarioAssistenza() { return this.costoOrarioAssistenza; } public void setCostoOrarioAssistenza(double costoOrarioAssistenza) { this.costoOrarioAssistenza = costoOrarioAssistenza; } public long getFlgUsaContrattoOre() { return this.flgUsaContrattoOre; } public void setFlgUsaContrattoOre(long flgUsaContrattoOre) { this.flgUsaContrattoOre = flgUsaContrattoOre; } public String getFEIndirizzo() { return getIndirizzo(); } public String getFENumeroCivico() { return getNumeroCivico(); } public String getFECAP() { if (getCapZona().isEmpty()) return getCapComune(); return getCapZona(); } public String getFEComune() { return getDescrizioneComune(); } public String getFEProvincia() { return getProvinciaComune(); } public String getFENazione() { return getNazione().getCodice(); } public String getFEPartitaIva() { return getPIva(); } public String getFECodiceFiscale() { return getCodFisc(); } public String getFEDenominazione() { if (getFlgAzienda() == 1L) return getCognome(); return ""; } public String getFECognome() { return getCognome(); } public String getFENome() { return getNome(); } public String getFETitolo() { return null; } public String getFECodEORI() { return null; } public String getFEPaese() { return getNazione().getCodice(); } public boolean isFEPaeseCEE() { return (getNazione().getFlgCee() == 1L); } public boolean isDatiFEOK() { if (getNazione().getCodice().toUpperCase().equals("IT")) { if (getCodiceIdentificativoFE().isEmpty() && getPec().isEmpty()) return false; return true; } return true; } public long getFlgSplitPayment() { return this.flgSplitPayment; } public void setFlgSplitPayment(long flgSplitPayment) { this.flgSplitPayment = flgSplitPayment; } public boolean isDatiUsatoOk() { if (getFlgUsato() == 1L) { if (!getPIva().isEmpty()) return true; if (getDataNascita() == null || getDescrizioneComune().isEmpty() || getProvinciaComune().isEmpty() || getNumeroDocumento().isEmpty()) return false; return true; } return true; } public long getFlgUsato() { return this.flgUsato; } public void setFlgUsato(long flgUsato) { this.flgUsato = flgUsato; } public String getProvinciaComuneNascita() { if (this.id_comuneNascita != 0L) return getComuneNascita().getProvincia(); if (this.provinciaComuneNascita == null) return ""; if (this.provinciaComuneNascita.length() > 2) return this.provinciaComuneNascita.substring(0, 2); return this.provinciaComuneNascita; } public void setProvinciaComuneNascita(String provinciaComuneNascita) { this.provinciaComuneNascita = provinciaComuneNascita; } public String getDescrizioneCompletaA() { if (getId_clifor() != 0L) { if (getParm("ANAG_DESC_COMPLETA_CON_TIPO").isTrue()) { StringBuffer stringBuffer = new StringBuffer(getFlgTipo() + " - "); if (!getCodiceAlt().isEmpty()) { stringBuffer.append(getCodiceAlt()); stringBuffer.append(" "); } stringBuffer.append(getNominativoCompleto()); return stringBuffer.toString(); } StringBuffer temp = new StringBuffer(); if (getFlgAzienda() == 1L) temp.append("(A)"); if (!getCodiceAlt().isEmpty()) { temp.append(getCodiceAlt()); temp.append(" "); } temp.append(getNominativoCompleto()); return temp.toString(); } return ""; } public long getFlgTaxFree() { return this.flgTaxFree; } public void setFlgTaxFree(long flgTaxFree) { this.flgTaxFree = flgTaxFree; } public String getImportPrefissoCodice() { return (this.importPrefissoCodice == null) ? "" : this.importPrefissoCodice.trim(); } public void setImportPrefissoCodice(String importPrefissoCodice) { this.importPrefissoCodice = importPrefissoCodice; } public String getImportLinkFornitore() { return (this.importLinkFornitore == null) ? "" : this.importLinkFornitore.trim(); } public void setImportLinkFornitore(String importLinkFornitore) { this.importLinkFornitore = importLinkFornitore; } public Users getUserWww() { Vectumerator vec = new Users(getApFull()).findByClifor(getId_clifor(), 1, 1); if (vec.hasMoreElements()) return (Users)vec.nextElement(); return new Users(getApFull()); } public boolean isSpeseSpedizioneWwwPreventivo() { if (!getCurrentDD().getId_nazioneDD().isEmpty()) { if (getCurrentDD().getNazioneDD().getFlgPreventivoWww() == 0L) return false; return true; } if (getNazione().getFlgPreventivoWww() == 0L) return false; return true; } public boolean isIndirizzoOk() { if (getIndirizzo().isEmpty() || getNumeroCivico().isEmpty() || (getCapComune().isEmpty() && getCapZona().isEmpty()) || getDescrizioneComune().isEmpty() || getProvinciaComune().isEmpty() || getId_nazione().isEmpty()) return false; return true; } public long getFlgAbilitaAF() { return this.flgAbilitaAF; } public double getValoreMinimoAbilitaAF() { return this.valoreMinimoAbilitaAF; } public void setFlgAbilitaAF(long flgAbilitaAF) { this.flgAbilitaAF = flgAbilitaAF; } public Vectumerator findFornitoriConImportPrefissoCodice() { String s_Sql_Find = "select A.* from CLIFOR AS A"; String s_Sql_Order = " order by A.cognome, A.nome\t"; WcString wc = new WcString(); wc.addWc("A.importPrefissoCodice is not null"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public String getImportLinkFornitoreEan() { return (this.importLinkFornitoreEan == null) ? "" : this.importLinkFornitoreEan.trim(); } public void setImportLinkFornitoreEan(String importLinkFornitoreEan) { this.importLinkFornitoreEan = importLinkFornitoreEan; } public void setValoreMinimoAbilitaAF(double valoreMinimoAbilitaAF) { this.valoreMinimoAbilitaAF = valoreMinimoAbilitaAF; } public boolean isOkWww() { if (getId_clifor() == 0L) return false; if (getKoMsgWww().length() == 0) return true; return false; } public long getFlgStatoCivile() { return this.flgStatoCivile; } public void setFlgStatoCivile(long flgStatoCivile) { this.flgStatoCivile = flgStatoCivile; } public Vectumerator findPersoneCarico(int pageNumber, int pageRows) { return new PersonaCarico(getApFull()).findByCliente(getId_clifor(), pageNumber, pageRows); } public long getId_ottoxmille() { return this.id_ottoxmille; } public void setId_ottoxmille(long id_ottoxmille) { this.id_ottoxmille = id_ottoxmille; setOttoxmille(null); } public Ottoxmille getOttoxmille() { this.ottoxmille = (Ottoxmille)getSecondaryObject(this.ottoxmille, Ottoxmille.class, getId_ottoxmille()); return this.ottoxmille; } public void setOttoxmille(Ottoxmille ottoxmille) { this.ottoxmille = ottoxmille; } public String getCf5xmille() { return (this.cf5xmille == null) ? "" : this.cf5xmille.trim(); } public void setCf5xmille(String cf5xmille) { this.cf5xmille = cf5xmille; } public String getCodice2xmille() { return (this.codice2xmille == null) ? "" : this.codice2xmille; } public void setCodice2xmille(String codice2xmille) { this.codice2xmille = codice2xmille; } public double getCostoSpedizioneAggiuntivo() { return this.costoSpedizioneAggiuntivo; } public double getCostoSpedizioneAggiuntivoConIva() { return conIva(getCostoSpedizioneAggiuntivo(), getParm(Cart.P_DELIVERY_IVA_ALIQUOTA).getNumeroDouble()); } public void setCostoSpedizioneAggiuntivo(double costoSpedizioneAggiuntivo) { this.costoSpedizioneAggiuntivo = costoSpedizioneAggiuntivo; } public long getId_usersAttivita() { return this.id_usersAttivita; } public void setId_usersAttivita(long id_usersAttivita) { this.id_usersAttivita = id_usersAttivita; setUsersAttivita(null); } public Users getUsersAttivita() { this.usersAttivita = (Users)getSecondaryObject((DBAdapter)this.usersAttivita, Users.class, getId_usersAttivita()); return this.usersAttivita; } public void setUsersAttivita(Users usersAttivita) { this.usersAttivita = usersAttivita; } public String getPathImg() { return getPathAllegato(); } public long getFlgStatoConfermaDati() { return this.flgStatoConfermaDati; } public void setFlgStatoConfermaDati(long flgStatoConfermaDati) { this.flgStatoConfermaDati = flgStatoConfermaDati; } public long getFlgStatoConfermaDatiDb() { return this.flgStatoConfermaDatiDb; } public void setFlgStatoConfermaDatiDb(long flgStatoConfermaDatiDb) { this.flgStatoConfermaDatiDb = flgStatoConfermaDatiDb; } public final String getStatoConfermaDatiIcon() { if (getId_clifor() == 0L) return ""; if (getFlgStatoConfermaDati() == 1L) return " "; if (getFlgStatoConfermaDati() == 0L) return " "; if (getFlgStatoConfermaDati() == 9L) return " "; return ""; } public long getAnnoCorrente() { return this.annoCorrente; } public void setAnnoCorrente(long annoCorrente) { this.annoCorrente = annoCorrente; } public double getPrezzoCatenaAlMt() { return this.prezzoCatenaAlMt; } public void setPrezzoCatenaAlMt(double prezzoCatenaAlMt) { this.prezzoCatenaAlMt = prezzoCatenaAlMt; } public long getId_usersResponsabile() { return this.id_usersResponsabile; } public void setUsersResponsabile(Users usersResponsabile) { this.usersResponsabile = usersResponsabile; } public Users getUsersResponsabile() { this.usersResponsabile = (Users)getSecondaryObject((DBAdapter)this.usersResponsabile, Users.class, getId_usersResponsabile()); return this.usersResponsabile; } public void setId_usersResponsabile(long id_usersResponsabile) { this.id_usersResponsabile = id_usersResponsabile; setUsersResponsabile(null); } public long getFlgEscludi() { return this.flgEscludi; } public void setFlgAzienda(long newFlgAzienda) { this.flgAzienda = newFlgAzienda; } public ResParm cambiaFlg(String l_flg) { ResParm rp = new ResParm(true); if (l_flg.equals("flgEscludi")) setFlgEscludi((getFlgEscludi() == 1L) ? 0L : 1L); rp = superSave(); return rp; } public PudoAddress getPudoAddress() { String indirizzo = getIndirizzo() + ", " + getIndirizzo(); String zipCode = getCapZona().isEmpty() ? getCapComune() : getCapZona(); String city = getDescrizioneComune(); if (!getCurrentDD().getIndirizzoDD().isEmpty()) { indirizzo = getCurrentDD().getIndirizzoDD() + ", " + getCurrentDD().getIndirizzoDD(); if (getCurrentDD().getCapZonaDD().isEmpty()) { zipCode = getCurrentDD().getCapComuneDD(); } else { zipCode = getCurrentDD().getCapZonaDD(); } city = getCurrentDD().getDescrizioneComuneDD(); } PudoAddress pa = new PudoAddress(indirizzo, zipCode, city); return pa; } public long getFlgBlacklist() { return this.flgBlacklist; } public void setFlgBlacklist(long flgBlacklist) { this.flgBlacklist = flgBlacklist; } public String getNotaBlacklist() { return (this.notaBlacklist == null) ? "" : this.notaBlacklist.trim(); } public void setNotaBlacklist(String notaBlacklist) { this.notaBlacklist = notaBlacklist; } public boolean isTipologiaClifor(long l_id_tipologia) { if (getDBState() == 0) return false; CliforTipoClifor ctc = new CliforTipoClifor(getApFull()); return ctc.isTipologiaCliforByClifor(getId_clifor(), l_id_tipologia); } public ResParm aggiornaUsersAssociati() { ResParm rp = new ResParm(true); try { Vectumerator vec = new Users(getApFull()).findByClifor(getId_clifor(), 0, 0); while (vec.hasMoreElements()) { Users u = (Users)vec.nextElement(); rp = u.save(); if (!rp.getStatus()) return rp; } } catch (Exception e) { handleDebug(e); rp.setStatus(false); rp.setMsg("Eccezione in aggiornaUsersAssociati: " + e.getMessage()); } return rp; } }