package it.acxent.contab; 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.Image; 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.Barcode128; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; import it.acxent.anag.Aspetto; import it.acxent.anag.Banca; import it.acxent.anag.CausaleTrasporto; import it.acxent.anag.Clifor; import it.acxent.anag.Comune; import it.acxent.anag.DestinazioneDiversa; import it.acxent.anag.Esercizio; import it.acxent.anag.Iva; import it.acxent.anag.MagFisico; import it.acxent.anag.Nazione; import it.acxent.anag.NazioneCR; import it.acxent.anag.Porto; import it.acxent.anag.RegCassa; import it.acxent.anag.TipoPagamento; import it.acxent.anag.Users; import it.acxent.anag.Vettore; import it.acxent.anag._AnagAdapter; import it.acxent.art.Articolo; import it.acxent.art.ArticoloArticoloComponente; import it.acxent.art.ArticoloUsato; import it.acxent.art.Taglia; import it.acxent.brt.api.json.PudoAddress; import it.acxent.cart.Cart; import it.acxent.caship.BarcodeCash; import it.acxent.caship.EpsonCash; import it.acxent.common.Access; import it.acxent.common.CrontabInterface; import it.acxent.common.StatusMsg; import it.acxent.contab.iva.RigaRegistroIvaItem; import it.acxent.contab.iva.RigheRegistroIva; import it.acxent.db.AddImgInterface; import it.acxent.db.ApplParmFull; import it.acxent.db.DBAdapter; import it.acxent.db.DbInterface; import it.acxent.db.ResParm; import it.acxent.db.WcString; import it.acxent.fattele.FEAllegatiInterface; import it.acxent.fattele.FEDatiAnagraficiInterface; import it.acxent.fattele.FEDatiDDT; import it.acxent.fattele.FEDatiPagamento; import it.acxent.fattele.FEDatiRiepilogoInterface; import it.acxent.fattele.FEDatiRitenutaInterface; import it.acxent.fattele.FEDatiTrasportoInterface; import it.acxent.fattele.FEDettaglioLinea; import it.acxent.fattele.FEDettaglioLineeInterface; import it.acxent.fattele.FEDettaglioPagamento; import it.acxent.fattele.FEScontoMaggiorazione; import it.acxent.fattele.FEScontoMaggiorazioneInterface; import it.acxent.fattele.FESedeInterface; import it.acxent.fattele.FatturaElettronicaInterface; import it.acxent.fattele.FeXml; import it.acxent.mail.MailMessage; import it.acxent.mail.MailProperties; import it.acxent.newsletter.CodaMessaggi; import it.acxent.reg.EcDc; import it.acxent.tex.anag.ArticoloArticoloTessuto; import it.acxent.tex.anag.ArticoloTessuto; import it.acxent.tex.anag.ArticoloTessutoColore; import it.acxent.tex.anag.Lavorazione; import it.acxent.tex.conf.NumeroTeliRiga; import it.acxent.tex.lav.LavPezza; import it.acxent.tools.PDFMerger; import it.acxent.util.AbMessages; import it.acxent.util.DoubleOperator; import it.acxent.util.FileWr; import it.acxent.util.PdfFontFactory; import it.acxent.util.SimpleDateFormat; import it.acxent.util.StringTokenizer; import it.acxent.util.Timer; import it.acxent.util.Vectumerator; import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.Serializable; import java.net.URLEncoder; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Time; import java.sql.Timestamp; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; public class Documento extends _ContabAdapter implements Serializable, AddImgInterface, DocumentoInterface, CrontabInterface, FatturaElettronicaInterface, FEDatiTrasportoInterface { private static final long serialVersionUID = -7533437477318901983L; public static final int ST_BOZZA = 0; public static final int ST_EMESSA = 1; public static final int ST_PROFORMA = 2; public static final int TRASPORTO_MITTENTE = 1; public static final int TRASPORTO_VETTORE = 3; public static final int TRASPORTO_DESTINATARIO = 2; public static final String PARM_IDCRYPT = "idcrypt"; public static final String PARM_USER_CODE = "uc"; private static final String TAG_SEND_MAIL_DOCS_EXT = "Sendmail Docs Ext"; private static final String TAG_SEND_MAIL_DOCS_CLIFOR = "Sendmail Docs"; private static final long STAMPA_TIPO_CORPO_FATTURA_STANDARD_0 = 0L; private static final long STAMPA_TIPO_CORPO_FATTURA_SEMPLICE_1 = 1L; private static final long STAMPA_TIPO_CORPO_FATTURA_PROFESSIONISTA_SEMPLICE_3 = 2L; public static final int[] cols_FT_STD_ = new int[] { 23, 4, 4, 2, 4, 3 }; public static final int[] cols_FT_SEMPLICE_ = new int[] { 33, 4, 3 }; public static final int[] cols_FT_PRO_SEMPLICE_ = new int[] { 33, 7 }; public static final int[] cols_RICEVUTA_ = new int[] { 18, 8, 7, 7 }; public static final int[] cols_DDT_ = new int[] { 30, 10 }; public static final int[] cols_FT_ACQ_BOLLA_CARICO_ = new int[] { 18, 5, 2, 2, 2, 2, 2, 2, 2, 3 }; public static final int DELIVERY_TYPE_0_STANDARD = 0; public static final int DELIVERY_TYPE_1_IN_NEGOZIO = 1; public static final int DELIVERY_TYPE_2_PUDO = 2; private static final long DOCUMENTO_RIGHE_USATO_NO = 0L; private static final long DOCUMENTO_RIGHE_USATO_SOLO_USATO_RM = 1L; private static final long DOCUMENTO_RIGHE_USATO_USATO_RM_E_STD = 2L; private static final long DOCUMENTO_RIGHE_USATO_SOLO_USATO_IVA = 3L; private static final long DOCUMENTO_RIGHE_USATO_USATO_IVA_E_STD = 4L; private static final long DOCUMENTO_RIGHE_USATO_USATO_RM_E_USATO_IVA = 5L; private static final long DOCUMENTO_RIGHE_USATO_USATO_RM_USATO_IVA_E_STD = 6L; public static final long STATO_LAVORAZIONE_CONCLUSA = 100L; public static final long STATO_LAVORAZIONE_DA_PIANIFICARE = 0L; public static final long STATO_LAVORAZIONE_IN_LAVORAZIONE = 20L; public static final long STATO_LAVORAZIONE_FASE_TAGLIO = 30L; public static final long STATO_LAVORAZIONE_NESSUNA = -1L; public static final long STATO_LAVORAZIONE_PIANIFICATA = 10L; public static final long BARCODE_TYPE_LUNGHEZZA_TOTALE = 0L; public static final long BARCODE_TYPE_LUNGHEZZA_TOTALE_MENO_1 = 1L; public static final long BARCODE_TYPE_GENERATO = 100L; public static final String PERM_RIAPRI_FATTURA_XML = "RIAPRI_FATTURA_XML"; public static final int EXPORT_BARTOLINI_NO = 0; public static final int EXPORT_BARTOLINI_DA_FARE = 1; public static final int EXPORT_BARTOLINI_FATTO_NO_ETICHETTE = 2; public static final int EXPORT_BARTOLINI_FATTO_CON_ETICHETTE = 3; private static final String BART_TIPO_SERVIZIO = "BART_TIPO_SERVIZIO"; private static final String BART_GEST_CONTRASS = "BART_GEST_CONTRASS"; private static final String BART_P_OPER_PARTENZA = "BART_P_OPER"; private static final String BART_COD_CLIENTE_MITTENTE = "BART_COD_CLI"; private static final String BART_SEGNO = " "; public static final String VABCTR_ITALIA = "000"; public static final String VABCTR_EUROPA = "303"; public static final String VABCTR_EXTRA_EUROPA = "305"; public static final String VABCTR_PUDO_ITALIA = "309"; public static final int TIPO_RITIRO_NORMALE = 0; public static final int TIPO_RITIRO_CONTESTUALE = 1; public static final int TIPO_CONSEGNA_NORMALE = 0; public static final int TIPO_CONSEGNA_PER_APPUNTAMENTO = 1; public static final int TIPO_CONSEGNA_FUORI_MISURA = 2; public static final int TIPO_CONSEGNA_AI_PIANI = 3; public static final int TIPO_CONSEGNA_SUPERMERCATI = 4; public static final int MOD_ACCREDITO_SU_CC = 0; public static final int MOD_ACCREDITO_ASS_VID = 1; public static final int MOD_ACCREDITO_CONTANTE = 2; public static final int MOD_ACCREDITO_ASS_INT_MITTENTE = 3; public static final int MOD_ACCREDITO_ASS_CIRC_INT_MITTENTE = 4; public static final int WWW_TIPO_ORDINE_INTERNO = 0; public static final int WWW_TIPO_ORDINE_EBAY = 1; public static final int WWW_TIPO_ORDINE_AMAZON = 2; private RigheRegistroIva rigaRegistroIva; private RigheRegistroIva rigaRegistroIvaCompleto; private long id_documento; private long id_tipoDocumento; private long id_clifor; private long id_vettore; private long id_tipoPagamento; private long flgSys; private long flgStato = 1L; private long flgStatoPrecedente; private Date dataDocumento; private long progDocumento; private long progOrdineWww; private long id_esercizio; private String riferimento; private String note; private Date dataRiferimento; private long flgTipoDocumento; private double scontoIncondizionato; private Date dataPagamento; private Date dataRegistrazioneDI; private String dichiarazioneIntento; private long flgWwwRichiedeFattura; private long flgPagata; private long flgExport; private long flgTrasporto; private double abbuono; private long nColli; private Date dataAvviso; private Date dataStampaIva; private long flgTrasportoAssicurato; private String notaSpedizione; private Date dataConsegna; private Time oraConsegna; private double speseTrasporto; private double speseIncasso; private String descSpeseAltre; private long id_bancaAnticipo; private Banca bancaAnticipo; private long flgEmsta; private String notaSblocco; private TipoDocumento tipoDocumento; private Clifor clifor; private Vettore vettore; private TipoPagamento tipoPagamento; private Esercizio esercizio; private Aspetto aspetto; private double acconto; private double importoIvaTotale; private double importoRMRighe; private double imponibileTotale; private double importoIvaRighe; private long flgMantieniArticoloRiga; private long flgSingleLineArt; private Documento documentoFiglio; private long id_documentoFiglio; private long flgEmettiFatturaScontrino; private String echoScontrino; private String indirizzoSped; private double prezzo1000Colpi; private double prezzoAnnodatura; private Comune comuneSped; private long id_comuneSped; private String numeroCivicoSped; private long flgInEsaurimento; private double importoTotale; private long flgAutoAdd; private double percContIntegrativo; private long numPagDocumento; private double kgNetto; private double volume; private double kgLordo; private CausaleTrasporto causaleTrasporto; private long id_causaleTrasporto; private double speseAltre; private String ibanCF; private String cellDocumento; private long id_contatore; private long flgStatoPrenotazione; private String iban; private String notePagamento; private long id_destinazioneDiversa; private DestinazioneDiversa destinazioneDiversa; private String causale; private String progDocumentoAgg; private Date dataStampaBollato; private Date dataChiusura; private long id_users; private Users users; private long flgInserisciReso; private String eMailDocumento; private double percRitenutaAcconto; private double imponibileRighe; private double rimborsoArt15; private Date dataScadenzaPagamento; private long flgPagamentoDataFissa; private long flgHaDocumentoPadre; public long getProgOrdineWww() { return this.progOrdineWww; } public void setProgOrdineWww(long progOrdineWww) { this.progOrdineWww = progOrdineWww; } private long flgInviaAvviso = 1L; private long flgStatoRiparazione; private double cauzione; private long flgDocumentoPrelevato; private long flgHasDocumentiPrelevabili = -1L; private String descrizioneDifetto; private String interventoEffettuato; private long flgPreventivo; private double importoPreventivo; private String notaMail; private String descrizionePreventivo; private String faxDocumento; private String telDocumento; private long id_usersIntervento; private long id_usersChiusura; private Users usersIntervento; private Users usersChiusura; private long flgStatoRiparazionePrecedente; private Documento documentoFiglioUno; private long id_porto; private Porto porto; private long id_tipoDocumentoFiglio; private long progDocumentoB; private String progDocumentoAggB; private long id_esercizioB; private long flgTipoMovimento = 0L; private String nominativoDocumento; private long id_cliforListino; private Clifor cliforListino; private String descrizioneAllegato; private long id_ivaDoc = getCodiceIvaVendStd(); private Iva ivaDoc; private double importoConsuntivo; private String descTransaction; private Date dataTransaction; private long flgProcediPagamento; private long flgStatoOrdineWww = 0L; private String capSped; private String cittaSped; private String provinciaSped; private String id_documentoXpay; private double contanti; private long flgRitiroNegozio; private long flgStatoPrenotazionePrecedene; private long id_magFisicoPartenza; private long id_magFisicoArrivo; private MagFisico magFisicoArrivo; private MagFisico magFisicoPartenza; private Date dataDownload; private Time oraDownload; private String ipDownload; private long flgDownload; private Timestamp tmstStampato; private String testoAgg; private String bic; private long id_magFisicoPartenza2; private long flgDocumentoPrelevatoPrecedente; private long flgSuper; private String clienteNome; private String clienteCognome; private String clienteIndirizzo; private String clienteCf; private String clientePiva; private Date dataRestituzioneAcconto; private String descrizioneRighePrenotazione; private double percAgente; private double percRespCommerciale; private Timestamp tmstFileXml; private Timestamp tmstInvioMail; private long flgArt8; private long id_cliforPrecedente; private String bancaCFDesc; private String descrizioneDocumento; private double percScontoIncondizionato; private String id_nazioneSped; private Nazione nazioneSped; private Timestamp tmstFilePdf; private double importoBolloEsenzione; private double imponibileBolloEsenzione; private String progFileFE; private long flgStatoInvioXml; private Timestamp tmstInvioXml; private String codiceCIG; private String codiceCUP; private String codiceCommessa; private String bancaDesc; private long id_aspetto; private long id_magFisicoArrivo2; private MagFisico magFisicoArrivo2; private MagFisico magFisicoPartenza2; private Timestamp tsFineLavorazione; private Timestamp tsInizioLavorazione; private long flgStatoLavorazione = 100L; private long flgBarcodeType; private long flgBarcodeSequenzaNumeri; private String ordineCodiceCIG; private String ordineCodiceCUP; private Articolo articolo; private long id_articolo; private String presso; private long id_taglia; private Taglia taglia; private String trackingSpedizione; private long flgWwwTipoOrdine; private double wwwCostoOrdine; private double wwwCostoSpedizione; private double wwwCostoTariffa; private long id_rigaBollaAtr; private long totaleColpi; private long flgTipoGenerazione; private long flgBartolini; private long flgTipoRitiro; private long flgAvvisoConsegna; private Date dataSpedizione; private Date dataInvioMailSped; private double valoreDichiarato; private double costoEffettivoSped; private long flgModoAccredito; private Documento documentoPadreUno; private long flgInGaranzia; private Timestamp tmstInvioMailOrdine; private long flgStatoOrdineWwwPrecedente = 0L; private String descDocumenti; private String notaAggiuntiva; private long flgOrdineWwwAppenaCreato = 0L; private long flgOrdineWwwAppenaPagato = 0L; private String stripeClientSecret; private String FERiferimentoTipoDato; private String FERiferimentoTesto; private double FERiferimentoNumero; private Date FERiferimentoData; private long id_lavorazione; private Lavorazione lavorazione; private String descTransactionStripe; private long flgStatoLavorazionePrecedente; private double prezzoCatenaAlMt; private Date dataCambioStatoLavorazione; private long flgGRS; private double totaleDocumento; private long flgDeliveryType; private String pudoId; private String pudoDesc; public double getImponibileBolloEsenzione() { return this.imponibileBolloEsenzione; } public void setImponibileBolloEsenzione(double imponibileBolloEsenzione) { this.imponibileBolloEsenzione = imponibileBolloEsenzione; } public static boolean threadSendMail = false; public static boolean threadCreaFattureTessitura = false; public static String threadSendMailMsg = ""; public static final int RIGHE_DISPONIBILI_NO = 0; public static final int RIGHE_DISPONIBILI_TUTTE = 2; public static final int RIGHE_DISPONIBILI_NON_TUTTE = 1; public static final long ORDINE_WWW_RESO_NESSUNA_RICHIESTA = 0L; public static final long ORDINE_WWW_RESO_RICHIESTA_ACCETTATA = 2L; public static final long ORDINE_WWW_RESO_RICHIESTA_COMPLETATA = 3L; public static final long ORDINE_WWW_RESO_RICHIESTA_IN_CORSO = 1L; public static final long ORDINE_WWW_RESO_RICHIESTA_RESPINTA = 99L; public static final long ORDINE_WWW_STATO_APERTO_CONFERMATO = 0L; public static final long ORDINE_WWW_STATO_IN_LAVORAZIONE = 1L; public static final long ORDINE_WWW_STATO_SPEDITO = 2L; public static final long ORDINE_WWW_STATO_CHIUSO = 9L; public static final long ORDINE_WWW_STATO_CHIUSI_E_ANNULLATI_CR = 11L; public static final long ORDINE_WWW_STATO_APERTI_FINO_A_SPEDITO_CR = 10L; public static final long ORDINE_WWW_STATO_ANNULLATO = 99L; public static final long ORDINE_WWW_STATO_PAG_NON_PAGATO = 0L; public static final long ORDINE_WWW_STATO_PAG_PAGATO = 2L; public static final long ORDINE_WWW_STATO_PAG_TRANS_OK = 1L; public static final long TIPO_MOVIMENTO_SCARICO = 2L; public static final long TIPO_MOVIMENTO_CARICO_E_SCARICO = 3L; public static final long TIPO_MOVIMENTO_CARICO = 1L; public static final long TIPO_MOVIMENTO_IND = 0L; public static final int ST_GARANZIA_NO = 0; public static final int ST_GARANZIA_SI = 1; public static final int ST_GARANZIA_DOA = 2; public static final int ST_PRENOTAZIONE_ACCETTATO = 0; public static final int ST_PRENOTAZIONE_ORDINATA = 10; public static final int ST_PRENOTAZIONE_ARRIVATO = 20; public static final int ST_PRENOTAZIONE_SPEDITO = 30; public static final int ST_PRENOTAZIONE_CHIUSA = 90; public static final int ST_PRENOTAZIONE_ANNULLATO = 100; public static final int ST_PRENOTAZIONE_APERTE = 200; public static final int AVVISO_FAX = 4; public static final int AVVISO_SMS = 2; public static final int AVVISO_EMAIL_SMS = 3; public static final int AVVISO_EMAIL = 1; public static final int ST_RIPARAZIONE_NON_VISIONATO = 0; public static final int ST_RIPARAZIONE_IN_RIP_ESTERNA = 1; public static final int ST_RIPARAZIONE_ATTESA_PREVENTIVO = 2; public static final int ST_RIPARAZIONE_PREVENTIVO_ACCETTATO = 3; public static final int ST_RIPARAZIONE_PREVENTIVO_NON_ACCETTATO = 4; public static final int ST_RIPARAZIONE_RIPARATO = 10; public static final int ST_RIPARAZIONE_NON_RIPARATO = 11; public static final int ST_RIPARAZIONE_RICONSEGNATO = 99; public static final int RPT_VENDITE_GIORNALIERE = 0; public static final int RPT_VENDITE_COMPLETO = 1; public static final int RPT_VENDITE_COMPATTO = 2; public static final int RPT_VENDITE_GIORN_PIUGIORNI = 3; public static final int RPT_ORDINI_INEVASI = 4; public static final int RPT_FATTURATO = 5; public static final int RPT_VENDITE_SERVIZI = 6; public static final int RPT_DOCUMENTI_GIORNALIERO = 7; public static final int RPT_DOCUMENTI_DETTAGLIO = 8; public static final int RPT_DOCUMENTI_GIORNALIERO_PER_NAZIONE = 9; public static final int RPT_DOCUMENTI_DETTAGLIO_CON_DDT = 10; public static final int AVVISO_ERR = 9; public static final int AVVISO_MANUALE = 5; public static final long TIPO_CARICO_SCARICO_NESSUNO = -1L; public static final long TIPO_CARICO_SCARICO_ANAGRAFICHE = 0L; public static final long TIPO_CARICO_SCARICO_DISPO = 1L; private static Hashtable tipoDocumentoHT; private class ArticoloGroup { private String descrizione; private double quantita; private double valore; public String getDescrizione() { return (this.descrizione == null) ? "" : this.descrizione.trim(); } public void setDescrizione(String descrizione) { this.descrizione = descrizione; } public double getQuantita() { return this.quantita; } public void setQuantita(double quantita) { this.quantita = quantita; } public double getValore() { return this.valore; } public void setValore(double valore) { this.valore = valore; } } public static String getStato(long l_flgStato) { switch ((int)l_flgStato) { case 0: return "Bozza"; case 1: return "Emessa"; case 2: return "Proforma"; case -1: return "-- Tutti --"; } return "????"; } public static String getBartolini(long l_flgBartolini) { switch ((int)l_flgBartolini) { case 1: return "Da Fare"; case 3: return "Fatto Con Etich."; case 2: return "Fatto No Etich."; case 0: return "No"; case -1: return "-"; } return "????"; } public static String getTipoRitiro(long l_flgTipoRitiro) { switch ((int)l_flgTipoRitiro) { case 1: return "Contestuale"; case 0: return "Normale"; } return "????"; } public static String getAvvisoConsegna(long l_flgTipoConsegna) { switch ((int)l_flgTipoConsegna) { case 3: return "Ai Piani"; case 2: return "Fuori Misura"; case 0: return "Normale"; case 1: return "Per Appuntamento"; case 4: return "Supermercati"; } return "????"; } public static String getWwwTipoOrdine(long l_flgWwwTipoOrdine) { switch ((int)l_flgWwwTipoOrdine) { case 1: return "Ebay"; case 2: return "Amazon"; case 0: return "Interno"; } return "????"; } public String getWwwTipoOrdine() { return getWwwTipoOrdine(getFlgWwwTipoOrdine()); } public static String getModoAccredito(long l_flgModAccredito) { switch ((int)l_flgModAccredito) { case 4: return "Ass. Circ. Int. Mittente"; case 3: return "Ass. Int. Mittente"; case 1: return "Normale"; case 2: return "Contante"; case 0: return "Su c.c."; } return "????"; } public static String getTrasportoAssicurato(long l_flgTrasportoAssicurato) { switch ((int)l_flgTrasportoAssicurato) { case 0: return "No"; case 1: return "Si"; } return "????"; } class ThreadSendMailExt extends Thread { private DocumentoCR CR; private String email; private String path; private String testoAgg; public ThreadSendMailExt(DocumentoCR l_CR, String l_email, String l_path, String l_testoAgg) { this.CR = l_CR; this.email = l_email; this.path = l_path; this.testoAgg = l_testoAgg; if (!Documento.isThreadAttivo()) { Documento.threadSendMail = true; start(); } } public void run() { Timestamp start = new Timestamp(Calendar.getInstance().getTimeInMillis()); System.out.println("##############\nSendmail thread\nSTART: " + start.toString()); ResParm rp = new ResParm(true); StatusMsg.updateMsgByTag(Documento.this.getApFull(), "Sendmail Docs Ext", "Attenzione! Thread invio email in esecuzione!!! "); rp = Documento.this.sendDocumentiMailMessageExt(this.CR, this.email, this.path, this.testoAgg); Timestamp stop = new Timestamp(Calendar.getInstance().getTimeInMillis()); System.out.println("STOP: " + start.toString()); SimpleDateFormat dfMS = new SimpleDateFormat("HH:mm:ss "); System.out.println("DURATA: " + dfMS.format(new Time(stop.getTime() - start.getTime() - 3600000L)) + "Risultato invio email:\n" + rp.getMsg() + "\n\nInvio email concluso\n****************"); try { sleep(3000L); } catch (Exception e) {} Documento.threadSendMail = false; StatusMsg.deleteMsgByTag(Documento.this.getApFull(), "Sendmail Docs Ext"); } } class ThreadSendMailClifor extends Thread { private DocumentoCR CR; private String path; private String testoAgg; public ThreadSendMailClifor(DocumentoCR l_CR, String l_path, String l_testoAgg) { this.CR = l_CR; this.path = l_path; this.testoAgg = l_testoAgg; if (!Documento.isThreadAttivo()) { Documento.threadSendMail = true; start(); } } public void run() { Timestamp start = new Timestamp(Calendar.getInstance().getTimeInMillis()); System.out.println("##############\nSendmail thread\nSTART: " + start.toString()); ResParm rp = new ResParm(true); StatusMsg.updateMsgByTag(Documento.this.getApFull(), "Sendmail Docs", "Attenzione! Thread invio email in esecuzione!!! "); rp = Documento.this.sendDocumentiMailMessagePerClifor(this.CR, this.path, this.testoAgg); Timestamp stop = new Timestamp(Calendar.getInstance().getTimeInMillis()); System.out.println("STOP: " + start.toString()); SimpleDateFormat dfMS = new SimpleDateFormat("HH:mm:ss "); System.out.println("DURATA: " + dfMS.format(new Time(stop.getTime() - start.getTime() - 3600000L)) + "Risultato invio email:\n" + rp.getMsg() + "\n\ninvio email concluso\n****************"); try { sleep(3000L); } catch (Exception e) {} Documento.threadSendMail = false; StatusMsg.deleteMsgByTag(Documento.this.getApFull(), "Sendmail Docs"); } } class ThreadCreaFtTessitura extends Thread { private DocumentoCR CR; private long l_id_cliforR; private long l_id; private long l_id_tipoDocumentoFiglio; private long l_flgTipoGenerazione; private Users operatore; public ThreadCreaFtTessitura(DocumentoCR l_CR, long l_id_cliforR, long l_id, long l_id_tipoDocumentoFiglio, long l_flgTipoGenerazione, Users operatore) { this.CR = l_CR; this.l_flgTipoGenerazione = l_flgTipoGenerazione; this.l_id = l_id; this.l_id_cliforR = l_id_cliforR; this.l_id_tipoDocumentoFiglio = l_id_tipoDocumentoFiglio; this.operatore = operatore; if (!Documento.isThreadAttivo()) { Documento.threadCreaFattureTessitura = true; start(); } } public void run() { Timer timer = new Timer(); timer.start(); String TAG_THREAD_MSG = "CREAZIONE FT TESSITURA"; StatusMsg.updateMsgByTag(Documento.this.getApFull(), TAG_THREAD_MSG, "INIZIO CREAZIONE FATTURE....."); ResParm rp = new ResParm(true); ApplParmFull apFull = Documento.this.getApFull(); Documento bean = new Documento(apFull); TipoDocumento tdDaGenerare = new TipoDocumento(apFull); tdDaGenerare.findByPrimaryKey(this.l_id_tipoDocumentoFiglio); if (tdDaGenerare.hasPadreConTipologia(200L)) { if (this.l_id_cliforR == 0L || this.l_id == 0L) { if (this.CR.getId_tipoDocumento() == 0L) { rp.setMsg("Errore! Tipo del documento non trovata!"); rp.setStatus(false); } else { StatusMsg.updateMsgByTag(Documento.this.getApFull(), TAG_THREAD_MSG, "Inizio ciclo Clienti ....."); Vectumerator vecClifor = bean.findCliforByCR(this.CR); while (vecClifor.hasMoreElements()) { Clifor rowClifor = (Clifor)vecClifor.nextElement(); HashMap hmDdt = new HashMap<>(); HashMap hmDispTess = new HashMap<>(); this.CR.setId_clifor(rowClifor.getId_clifor()); Vectumerator vec = bean.findByCR(this.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 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()); } StatusMsg.updateMsgByTag(Documento.this.getApFull(), TAG_THREAD_MSG, "Inizio ciclo Fatturazione per " + rowClifor.getCognomeNome() + " ..."); for (Map.Entry entry : hmDispTess.entrySet()) { System.out.println("Key = " + String.valueOf(entry.getKey()) + ", Value = " + entry.getValue().getNumeroDocumentoCompleto()); rp = entry.getValue().creaDocumentoFiglioDaDisposizioniTessitura(rowClifor.getId_clifor(), this.l_id_tipoDocumentoFiglio, this.operatore, true, this.l_flgTipoGenerazione, hmDdt); } } } } } else { bean.findByPrimaryKey(this.l_id); HashMap hmDdt = new HashMap<>(); HashMap hmDispTess = new HashMap<>(); hmDdt.put(new Long(this.l_id), bean); LavPezza lp = new LavPezza(apFull); Vectumerator vecLP = lp.findByDocumentoBolla(this.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()); } StatusMsg.updateMsgByTag(Documento.this.getApFull(), TAG_THREAD_MSG, "Inizio ciclo Fatturazione per DDT " + bean.getNumeroDocumentoCompleto() + " ..."); for (Map.Entry entry : hmDispTess.entrySet()) { System.out.println("Key = " + String.valueOf(entry.getKey()) + ", Value = " + entry.getValue().getNumeroDocumentoCompleto()); rp = entry.getValue().creaDocumentoFiglioDaDisposizioniTessitura(bean.getId_clifor(), this.l_id_tipoDocumentoFiglio, this.operatore, true, this.l_flgTipoGenerazione, hmDdt); } } timer.stop(); StatusMsg.updateMsgByTag(Documento.this.getApFull(), TAG_THREAD_MSG, "Preparazione Fattura Tessitura conclusa: " + timer.getDurataHourMin()); } else { timer.stop(); StatusMsg.updateMsgByTag(Documento.this.getApFull(), TAG_THREAD_MSG, "Errore! Documento generabile non ha come padre una disposizione tessitura!" + timer.getDurataHourMin()); } try { sleep(3000L); } catch (Exception e) {} StatusMsg.deleteMsgByTag(Documento.this.getApFull(), TAG_THREAD_MSG); Documento.threadCreaFattureTessitura = false; } } private static boolean ripristinoThreadRun = false; public Documento(ApplParmFull newApplParmFull) { super(newApplParmFull); } public Documento() {} public void setId_documento(long newId_documento) { this.id_documento = newId_documento; } public void setId_tipoDocumento(long newId_tipoDocumento) { this.id_tipoDocumento = newId_tipoDocumento; setTipoDocumento(null); setFlgAutoAdd(getTipoDocumento().getFlgAutoAdd()); setFlgSingleLineArt(getTipoDocumento().getFlgSingleLineArt()); } public void setId_clifor(long newId_clifor) { this.id_clifor = newId_clifor; setClifor(null); } public void setId_vettore(long newId_vettore) { this.id_vettore = newId_vettore; setVettore(null); } public void setId_tipoPagamento(long newId_tipoPagamento) { this.id_tipoPagamento = newId_tipoPagamento; setTipoPagamento(null); } public void setFlgSys(long newFlgSys) { this.flgSys = newFlgSys; } public void setFlgStato(long newFlgStato) { this.flgStato = newFlgStato; } public void setDataDocumento(Date newDataDocumento) { this.dataDocumento = newDataDocumento; } public void setProgDocumento(long newProgDocumento) { this.progDocumento = newProgDocumento; } public void setId_esercizio(long newId_esercizio) { this.id_esercizio = newId_esercizio; setEsercizio(null); } public void setRiferimento(String newRiferimento) { this.riferimento = newRiferimento; } public void setDataRiferimento(Date newDataRiferimento) { this.dataRiferimento = newDataRiferimento; } public void setFlgTipoDocumento(long newFlgTipoDocumento) { this.flgTipoDocumento = newFlgTipoDocumento; } public void setScontoIncondizionato(double newSconto) { this.scontoIncondizionato = newSconto; } public void setDataPagamento(Date newDataPagamento) { this.dataPagamento = newDataPagamento; } 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 void setFlgPagata(long newFlgPagata) { this.flgPagata = newFlgPagata; } public void setFlgExport(long newFlgExport) { this.flgExport = newFlgExport; } public void setFlgTrasporto(long newFlgTrasporto) { this.flgTrasporto = newFlgTrasporto; } public void setKgLordo(double newKg) { this.kgLordo = newKg; } public void setNColli(long newNColli) { this.nColli = newNColli; } public void setDataStampaBollato(Date newDataStampaBollato) { this.dataStampaBollato = newDataStampaBollato; } public void setDataStampaIva(Date newDataStampaIva) { this.dataStampaIva = newDataStampaIva; } public void setFlgTrasportoAssicurato(long newFlgTrasportoAssicurato) { this.flgTrasportoAssicurato = newFlgTrasportoAssicurato; } public void setNotaSpedizione(String newNotaSpedizione) { this.notaSpedizione = newNotaSpedizione; } public void setDataConsegna(Date newDataConsegna) { this.dataConsegna = newDataConsegna; } public void setOraConsegna(Time newOraConsegna) { this.oraConsegna = newOraConsegna; } public void setSpeseTrasporto(double newSpeseTrasporto) { this.speseTrasporto = newSpeseTrasporto; } public void setSpeseAltre(double newSpeseAltre) { this.speseAltre = newSpeseAltre; } public void setDescSpeseAltre(String newDescSpeseAltre) { this.descSpeseAltre = newDescSpeseAltre; } public void setId_aspetto(long newId_aspetto) { this.id_aspetto = newId_aspetto; setAspetto(null); } public long getId_documento() { return this.id_documento; } public long getId_tipoDocumento() { return this.id_tipoDocumento; } public long getId_clifor() { return this.id_clifor; } public long getId_vettore() { return this.id_vettore; } public long getId_tipoPagamento() { return this.id_tipoPagamento; } public long getFlgSys() { return this.flgSys; } public long getFlgStato() { return this.flgStato; } public Date getDataDocumento() { return this.dataDocumento; } public long getProgDocumento() { return this.progDocumento; } public long getId_esercizio() { return this.id_esercizio; } public long getId_contatore() { return getTipoDocumento().getId_contatore(); } public String getRiferimento() { return (this.riferimento == null) ? "" : this.riferimento.trim(); } public Date getDataRiferimento() { return this.dataRiferimento; } public long getFlgTipoDocumento() { return this.flgTipoDocumento; } public double getScontoIncondizionato() { return this.scontoIncondizionato; } public Date getDataPagamento() { return this.dataPagamento; } public Date getDataRegistrazioneDI() { return this.dataRegistrazioneDI; } public String getDichiarazioneIntento() { return (this.dichiarazioneIntento == null) ? "" : this.dichiarazioneIntento.trim(); } public long getFlgArt8() { return this.flgArt8; } public long getFlgPagata() { return this.flgPagata; } public long getFlgExport() { return this.flgExport; } public long getFlgTrasporto() { return this.flgTrasporto; } public double getKgLordo() { return this.kgLordo; } public long getNColli() { return this.nColli; } public Date getDataStampaBollato() { return this.dataStampaBollato; } public Date getDataStampaIva() { return this.dataStampaIva; } public long getFlgTrasportoAssicurato() { return this.flgTrasportoAssicurato; } public String getNotaSpedizione() { return (this.notaSpedizione == null) ? "" : this.notaSpedizione.trim(); } public Date getDataConsegna() { return this.dataConsegna; } public Time getOraConsegna() { return this.oraConsegna; } public double getSpeseTrasporto() { return this.speseTrasporto; } public double getSpeseTrasportoConIva() { return conIva(getSpeseTrasporto(), (double)getIvaDoc().getAliquota()); } public double getSpeseIncassoConIva() { return conIva(getSpeseIncasso(), (double)getIvaDoc().getAliquota()); } public double getSpeseAltreConIva() { return conIva(getSpeseAltre(), (double)getIvaDoc().getAliquota()); } public double getSpeseAltre() { return this.speseAltre; } public String getDescSpeseAltre() { return (this.descSpeseAltre == null) ? "" : this.descSpeseAltre.trim(); } public long getId_aspetto() { return this.id_aspetto; } public void setTipoDocumento(TipoDocumento newTipoDocumento) { this.tipoDocumento = newTipoDocumento; } public TipoDocumento getTipoDocumento() { this.tipoDocumento = (TipoDocumento)getSecondaryObject(this.tipoDocumento, TipoDocumento.class, getId_tipoDocumento()); return this.tipoDocumento; } public void setClifor(Clifor newClifor) { this.clifor = newClifor; } public Clifor getClifor() { this.clifor = (Clifor)getSecondaryObject(this.clifor, Clifor.class, getId_clifor()); return this.clifor; } public void setVettore(Vettore newVettore) { this.vettore = newVettore; } public Vettore getVettore() { this.vettore = (Vettore)getSecondaryObject(this.vettore, Vettore.class, getId_vettore()); return this.vettore; } 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 setEsercizio(Esercizio newEsercizio) { this.esercizio = newEsercizio; } public Esercizio getEsercizio() { this.esercizio = (Esercizio)getSecondaryObject(this.esercizio, Esercizio.class, getId_esercizio()); return this.esercizio; } public void setAspetto(Aspetto newAspetto) { this.aspetto = newAspetto; } public Aspetto getAspetto() { this.aspetto = (Aspetto)getSecondaryObject(this.aspetto, Aspetto.class, getId_aspetto()); return this.aspetto; } protected ResParm checkDeleteCascade() { Access access = new Access(getApFull()); access.findByPrimaryKey(getTableBeanName()); ResParm rp = checkEMSTA(); if (rp.getStatus() && hasScadenzeSuRiba()) { rp.setStatus(false); rp.setMsg("ERRORE! Esistono delle distinte riba già legate alle scadenze"); } if (rp.getStatus()) { Vectumerator vec = findRigheDocumento(0, 0, 0); if (vec.hasMoreElements() && access.getFlgDeleteCascade() == 0L) return new ResParm(false, "Attenzione!! Cancellazione in cascaTa non abilitata"); } return rp; } protected void deleteCascade() { Access access = new Access(getApFull()); access.findByPrimaryKey(getTableBeanName()); String currentPdfFile = getPathStampaDocumentoFull(); File pdfFile = new File(currentPdfFile); if (pdfFile.exists()) pdfFile.delete(); if (getId_tipoDocumento() == getId_docRiparazione() || access.getFlgDeleteCascade() == 1L) { Vectumerator vecR = findRigheDocumento(0L, 0, 0, 0); while (vecR.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecR.nextElement(); row.delete(); } vecR = findRigheDocumento(1L, 0, 0, 0); while (vecR.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecR.nextElement(); row.delete(); } vecR = findRigheDocumento(100L, 0, 0, 0); while (vecR.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecR.nextElement(); row.delete(); } } Vectumerator vec = findDocFiglioPadreByFiglio(); while (vec.hasMoreElements()) { DbInterface row = (DbInterface)vec.nextElement(); row.delete(); } vec = findDocFiglioPadreByPadre(); while (vec.hasMoreElements()) { DbInterface row = (DbInterface)vec.nextElement(); row.delete(); } ResParm rp = update("update DOCUMENTO set id_documentoFiglio=null where id_documentoFiglio=" + getId_documento()); rp = update("update RIGA_DOCUMENTO set id_documentoPadre=null where id_documentoPadre=" + getId_documento()); DocumentoAgente da = new DocumentoAgente(getApFull()); da.deleteAgentiByDocumento(getId_documento()); DocumentoPagamento dp = new DocumentoPagamento(getApFull()); Vectumerator vecDp = dp.findByDocumento(getId_documento()); while (vecDp.hasMoreElements()) { DocumentoPagamento rowDp = (DocumentoPagamento)vecDp.nextElement(); rowDp.delete(); } Vectumerator vecs = new DocumentoScadenza(getApFull()).findByDocumento(getId_documento()); while (vecs.hasMoreElements()) { DocumentoScadenza ds = (DocumentoScadenza)vecs.nextElement(); ds.delete(); } rp.append(update("DELETE FROM PROMOZIONE_USER where id_documento=" + getId_documento())); } public String getBartolini() { return getBartolini(getFlgBartolini()); } public String getModoAccredito() { return getModoAccredito(getFlgModoAccredito()); } public String getTipoRitiro() { return getTipoRitiro(getFlgTipoRitiro()); } public String getAvvisoConsegna() { return getAvvisoConsegna(getFlgAvvisoConsegna()); } public String getTrasportoAssicurato() { return getTrasportoAssicurato(getFlgTrasportoAssicurato()); } public String getTrasporto() { return getTrasporto(getFlgTrasporto()); } public boolean isRigheConSeriali() { if (getTipoCaricoScarico() == -1L) return false; if (getTipoCaricoScarico() == 1L) return true; Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getArticolo().getTipo().getFlgTipoMagazzino() == 2L && row.getSeriale().isEmpty()) return false; } return true; } public boolean isProgConBuchi() { Calendar cal = Calendar.getInstance(); return isProgConBuchi((long)cal.get(1)); } public boolean isProgConBuchi(long anno) { if (getFlgStato() == 0L || getFlgStato() == 2L) return false; if (getTipoDocumento().getContatore().getFlgControllo() == 0L) return false; String l_progPrimoBuco = trovaProgPrimoBuco(anno); if (l_progPrimoBuco.isEmpty()) return false; return true; } protected void prepareSave(PreparedStatement ps) throws SQLException { setRigaRegistroIva(null); setRigaRegistroIvaCompleto(null); if (getId_clifor() == 0L) setId_clifor(1L); if (getId_clifor() > 1L) setNominativoDocumento(getClifor().getDescrizioneCompleta()); Calendar cal = Calendar.getInstance(); if (getDataDocumento() == null) setDataDocumento(getToday()); if (getTmstInvioXml() == null && getClifor().getFlgArt8() == 1L) { setFlgArt8(getClifor().getFlgArt8()); setDichiarazioneIntento(getClifor().getDichiarazioneIntento()); setDataRegistrazioneDI(getClifor().getDataRegistrazioneDI()); if (getNote().indexOf(getDichiarazioneIntento()) < 0) { String temp = "Operazione non imponibile ai sensi dell’articolo 8, comma 1, lettera c) D.P.R. 633/1972, come da vostra dichiarazione di intento riferimento dell'agenzia delle entrate al nr. " + getDichiarazioneIntento() + " del " + getDataFormat().format(getDataRegistrazioneDI()); if (getNote().length() > 0) { setNote(temp + "\n" + temp); } else { setNote(temp); } } } if (getBancaDesc().isEmpty() || getIban().isEmpty() || getBic().isEmpty()) { Banca banca = new Banca(getApFull()); banca.findBancaDefault(); if (banca.getId_banca() > 0L) { setBancaDesc(banca.getDescrizione()); setIban(banca.getIban()); setBic(banca.getBic()); } } cal.setTime(getDataDocumento()); setId_esercizio((long)cal.get(1)); if (getFlgStato() != getFlgStatoPrecedente() || getProgDocumento() == 0L) { if (getFlgStato() == 0L || getFlgStato() == 2L) if (getProgDocumento() != 0L) { setProgDocumentoB(getProgDocumento()); setProgDocumentoAggB(getProgDocumentoAgg()); setId_esercizioB(getId_esercizio()); } else { setProgDocumentoB(0L); setProgDocumentoAggB(null); setId_esercizioB(0L); } if (getId_tipoDocumento() == getId_docOrdineWWW() && getProgOrdineWww() == 0L) try { Documento fatt = (Documento)clone(); setProgOrdineWww(fatt.calcolaProgOrdineWww()); } catch (CloneNotSupportedException e) { e.printStackTrace(); throw new SQLException(e.getMessage()); } cal.setTime(getDataDocumento()); try { Documento fatt = (Documento)clone(); setProgDocumento(fatt.calcolaProgDocumento()); } catch (CloneNotSupportedException e) { e.printStackTrace(); throw new SQLException(e.getMessage()); } if (getParm("DATA_FATTURA_PRIMA_DISPONIBILE").getNumeroInt() == 1 && getId_tipoDocumento() != getId_docCassa() && getFlgStato() != getFlgStatoPrecedente() && getFlgStato() == 1L) { Documento documento = new Documento(getApFull()); documento.setId_tipoDocumento(getId_tipoDocumento()); documento.findUltimoDocumentoEmesso(); setDataDocumento(documento.getDataDocumento()); } } if (getId_tipoDocumento() == getId_docRiparazione() && getId_usersChiusura() != 0L && getDataChiusura() == null) setDataChiusura(getToday()); if (getId_tipoDocumento() == getId_docRiparazione() && getId_usersChiusura() != 0L && getFlgStatoRiparazione() != 99L) setFlgStatoRiparazione(99L); if (getFlgStatoRiparazione() != getFlgStatoRiparazionePrecedente()) { String noteTemp = " \n" + getStatoRiparazione() + " in data " + String.valueOf(getToday()); setNote(getNote() + getNote()); } if (getId_tipoDocumento() == 1L) setFlgPagata(1L); if (getDataPagamento() != null) setFlgPagata(1L); if (getFlgPagata() == 1L && getDataPagamento() == null) setDataPagamento(getToday()); long resHasUsato = hasRigheConUsato(); if (resHasUsato > 0L) { RigaDocumento rf = new RigaDocumento(getApFull()); Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { rf = (RigaDocumento)vec.nextElement(); if (rf.getId_articolo() > 0L) { ArticoloUsato au = new ArticoloUsato(getApFull()); Vectumerator vecAu = au.findByRigaDocumento(rf.getId_rigaDocumento()); while (vecAu.hasMoreElements()) { au = (ArticoloUsato)vecAu.nextElement(); au.setNumeroDocumento(getNumeroDocumento()); au.setDataDocumento(getDataDocumento()); au.save(); } } } } if (getFlgBartolini() >= 1L && getDataSpedizione() == null) setDataSpedizione(getToday()); if (getDataSpedizione() != null || getTmstInvioMail() != null) { Documento forseOrdine = getDocumentoPadreUno(); if (forseOrdine.getId_tipoDocumento() == getId_docOrdineWWW()) if (getTmstInvioMail() != null) { forseOrdine.setFlgStatoOrdineWww(9L); forseOrdine.superSave(); } else if (forseOrdine.getFlgStatoOrdineWww() < 2L && getDataSpedizione() != null) { forseOrdine.setFlgStatoOrdineWww(2L); forseOrdine.superSave(); } } super.prepareSave(ps); } private ResParm calcoloStatoLavorazione() { ResParm rp = new ResParm(true); if (getTipoDocumento().getFlgTipologia() == 220L) if (getFlgStatoLavorazione() == 100L) { DocFiglioPadre dfp = new DocFiglioPadre(getApFull()); Vectumerator vec = dfp.findByPadre(getId_documento()); while (vec.hasMoreElements()) { DocFiglioPadre row = (DocFiglioPadre)vec.nextElement(); row.getDocumentoFiglio().setFlgStatoLavorazione(100L); row.getDocumentoFiglio().superSave(); } } else if (getFlgStatoLavorazione() == 20L) { DocFiglioPadre dfp = new DocFiglioPadre(getApFull()); Vectumerator vec = dfp.findByPadre(getId_documento()); while (vec.hasMoreElements()) { DocFiglioPadre row = (DocFiglioPadre)vec.nextElement(); row.getDocumentoFiglio().setFlgStatoLavorazione(20L); row.getDocumentoFiglio().superSave(); } } else if (getFlgStatoLavorazione() == 30L) { DocFiglioPadre dfp = new DocFiglioPadre(getApFull()); Vectumerator vec = dfp.findByPadre(getId_documento()); while (vec.hasMoreElements()) { DocFiglioPadre row = (DocFiglioPadre)vec.nextElement(); row.getDocumentoFiglio().setFlgStatoLavorazione(30L); row.getDocumentoFiglio().superSave(); } } if (getTipoDocumento().getFlgTipologia() == 200L) { boolean calcoloAutomatico = false; if (!calcoloAutomatico) { RigaDocumento rd = new RigaDocumento(getApFull()); long totalePezze = rd.getTotalePezzeStacchiByDocumento(getId_documento()); Vectumerator vec = rd.findByDocumento(getId_documento(), 0L, "", 0, 0, 0); long l_totaleColpi = 0L; while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); l_totaleColpi += row.getTotColpiRiga(); } setTotaleColpi(l_totaleColpi); if (getFlgStatoLavorazione() != 100L) if (getStacchiTotali() == getPezzeTotali()) { setFlgStatoLavorazione(100L); if (getTsFineLavorazione() == null) setTsFineLavorazione(getTimestamp()); } else if (getPezzeTotali() > 0L) { setFlgStatoLavorazione(20L); setTsFineLavorazione(null); } else if (hasAlmentoUnaRigaTessTelaio()) { setFlgStatoLavorazione(10L); setTsFineLavorazione(null); } else { setFlgStatoLavorazione(0L); setTsFineLavorazione(null); } } else { Vectumerator vec = new RigaDocumento(getApFull()).findByDocumento(getId_documento(), 0L, "", 0, 0, 0); boolean hasAlmenoUnTelaio = false, hasTuttiTelaio = true; boolean hasAlmenoUnIniziale = false, hasTuttiIniziale = true; boolean hasAlmenoUnFinale = false, hasTuttiFinale = true; long l_totaleColpi = 0L; while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); l_totaleColpi += row.getTotColpiRiga(); if (row.getId_telaio() > 0L) { hasAlmenoUnTelaio = true; } else { hasTuttiTelaio = false; } if (row.getColpoInizialeRiga() > 0L) { hasAlmenoUnIniziale = true; } else { hasTuttiIniziale = false; } if (row.getColpoFinaleRiga() > 0L) { hasAlmenoUnFinale = true; continue; } hasTuttiFinale = false; } if (hasTuttiFinale && hasTuttiIniziale && hasTuttiTelaio) { setFlgStatoLavorazione(100L); if (getTsFineLavorazione() == null) setTsFineLavorazione(getTimestamp()); } else if (hasAlmenoUnIniziale) { setFlgStatoLavorazione(20L); if (getTsInizioLavorazione() == null) setTsInizioLavorazione(getTimestamp()); } else if (hasTuttiTelaio) { setFlgStatoLavorazione(10L); } else { setFlgStatoLavorazione(0L); } setTotaleColpi(l_totaleColpi); } } return rp; } public ResParm aggiornaSerialeTessutoDisposizioneTessitura() { ResParm rp = new ResParm(true); Vectumerator vecrd1 = findRigheDocumento(0, 0, 0); while (vecrd1.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecrd1.nextElement(); StringBuilder sb = new StringBuilder(getLavorazione().getAbbreviazione()); sb.append("/"); sb.append(getClifor().getId_clifor()); sb.append("/"); Vectumerator vetrdf = row.findRigheFilatiByRDTessuto(row.getId_rigaDocumento()); while (vetrdf.hasMoreElements()) { RigaDocumento rowF = (RigaDocumento)vetrdf.nextElement(); sb.append(rowF.getSeriale()); if (vetrdf.hasMoreElements()) sb.append("/"); } row.setSeriale(sb.toString()); row.superSave(); } return rp; } public ResParm aggiornaSerialeTessutoLavorazione() { ResParm rp = new ResParm(true); Vectumerator vecrd1 = findRigheDocumento2(0, 0, 0); while (vecrd1.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecrd1.nextElement(); if (row.getSeriale().isEmpty()) { RigaDocumento rowPartenza = row.getRigaDocumentoTessutoA(); StringBuilder sb = new StringBuilder(getLavorazione().getAbbreviazione()); sb.append("/"); sb.append(getClifor().getId_clifor()); sb.append("/"); sb.append(rowPartenza.getSeriale()); row.setSeriale(sb.toString()); row.superSave(); } } return rp; } public ResParm aggiornaStatoLavorazione() { if (getId_documento() > 0L) { calcoloStatoLavorazione(); return super.save(); } return new ResParm(false); } public Vectumerator findPercentualiAgenti(DocumentoCR CR) { String s_Sql_Find = "SELECT A.id_agente, A.percAgente, A.id_respCommerciale, A.percRespCommerciale, SUM(A.imponibileTotale) AS imponibileTotale FROM DOCUMENTO AS A INNER JOIN TIPO_DOCUMENTO AS B ON A.id_tipoDocumento = B.id_tipoDocumento "; String s_Sql_Group = " GROUP BY A.id_agente, A.percAgente, A.id_respCommerciale, A.percRespCommerciale "; String s_Sql_Order = " ORDER BY A.id_agente, A.id_respCommerciale "; WcString wc = new WcString(); wc.addWc(" B.flgTipologia = 1"); if (CR.getDataDocumentoDa() != null) wc.addWc(" A.dataDocumento >= ? "); if (CR.getDataDocumentoA() != null) wc.addWc(" A.dataDocumento <= ? "); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString() + s_Sql_Group); int i = 1; if (CR.getDataDocumentoDa() != null) { stmt.setDate(i, CR.getDataDocumentoDa()); i++; } if (CR.getDataDocumentoA() != null) stmt.setDate(i, CR.getDataDocumentoA()); return findRows(stmt, 0, 0); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public double getProvvigioneAgente() { DoubleOperator dop = new DoubleOperator(); dop.add(getPercAgente()); dop.multiply(getImponibileTotale()); dop.divide(100.0F); return dop.getResult(); } public double getProvvigioneRespCommerciale() { DoubleOperator dop = new DoubleOperator(); dop.add(getPercRespCommerciale()); dop.multiply(getImponibileTotale()); dop.divide(100.0F); return dop.getResult(); } private long calcolaProgDocumento(long anno) { try { String s_sql = "select max(progDocumento) as _max from DOCUMENTO"; WcString wc = new WcString(); wc.addWc("dataDocumento>=? and dataDocumento<=? "); wc.addWc("id_contatore =" + getId_contatore()); if (getFlgStato() == 0L) { wc.addWc("(flgStato is null or flgStato=0)"); } else { wc.addWc("flgStato =" + getFlgStato()); } wc.addWc("id_documento !=" + getId_documento()); PreparedStatement ps = getConn().prepareStatement(s_sql + s_sql); Date firstOfYear = getFirstOfYear((int)anno); Date lastOfYear = getLastOfYear((int)anno); ps.setDate(1, firstOfYear); ps.setDate(2, lastOfYear); return (long)getMax(ps) + 1L; } catch (Exception e) { return 0L; } } private long calcolaProgDocumento() { long anno = getCurrentEsercizio(); if (getDataDocumento() != null) { Calendar cal = Calendar.getInstance(); cal.setTime(getDataDocumento()); anno = (long)cal.get(1); } return calcolaProgDocumento(anno); } public RigheRegistroIva getRigaRegistroIva() { if (this.rigaRegistroIva == null) { Vectumerator vecRighe = findRigheDocumento(0, 0, 0); this.rigaRegistroIva = new RigheRegistroIva(); while (vecRighe.hasMoreElements()) { RigaDocumento rf = (RigaDocumento)vecRighe.nextElement(); this.rigaRegistroIva.addRigaDocumento(rf); } } return this.rigaRegistroIva; } public RigheRegistroIva getRigaRegistroIvaCompleto() { if (this.rigaRegistroIvaCompleto == null) { Vectumerator vecRighe = findRigheDocumento(0, 0, 0); this.rigaRegistroIvaCompleto = new RigheRegistroIva(); while (vecRighe.hasMoreElements()) { RigaDocumento rf = (RigaDocumento)vecRighe.nextElement(); this.rigaRegistroIvaCompleto.addRigaDocumento(rf); } boolean isNotaDiCredito = !(getTipoDocumento().getFlgTipologia() == 1L); boolean isPiva = !getClifor().getPIva().isEmpty(); if (getTipoDocumento().isTipoFatturaProfessionisti()) { double ci = getImportoContIntegrativo(); DoubleOperator ciIva = new DoubleOperator(ci); ciIva.setScale(4, 5); ciIva.multiply(getIvaDoc().getAliquota()); ciIva.divide(100.0F); this.rigaRegistroIvaCompleto.addRigaDocumento(getIvaDoc(), ci, ciIva.getResult(), isNotaDiCredito, isPiva); } else { if (getTotaleAltriCosti() != 0.0D) { DoubleOperator csi = new DoubleOperator(getTotaleAltriCosti()); csi.setScale(4, 5); csi.multiply(getIvaDoc().getAliquota()); csi.divide(100.0F); this.rigaRegistroIvaCompleto.addRigaDocumento(getIvaDoc(), getTotaleAltriCosti(), csi.getResult(), isNotaDiCredito, isPiva); } double totaleScontiAbbuoni = getTotaleScontiAbbuoni(); if (totaleScontiAbbuoni != 0.0D) { DoubleOperator csi = new DoubleOperator(totaleScontiAbbuoni); csi.setScale(4, 5); csi.multiply(getIvaDoc().getAliquota()); csi.divide(100.0F); this.rigaRegistroIvaCompleto.addRigaDocumento(getIvaDoc(), -totaleScontiAbbuoni, -csi.getResult(), isNotaDiCredito, isPiva); } } } return this.rigaRegistroIvaCompleto; } public Vectumerator findRigheDocumento(long l_flgCodiceRiga, String l_search, int pageNumber, int pageRows, int ordinamentoRiga) { return new RigaDocumento(getApFull()).findByDocumento(getId_documento(), l_flgCodiceRiga, l_search, pageNumber, pageRows, ordinamentoRiga); } public Vectumerator findRigheDocumento(String l_search, int pageNumber, int pageRows, int ordinamentoRiga) { return findRigheDocumento(0L, l_search, pageNumber, pageRows, ordinamentoRiga); } public Vectumerator findRigheDocumento(RigaDocumentoCR CR, int pageNumber, int pageRows, boolean ordineInverso) { return new RigaDocumento(getApFull()).findByDocumento(CR, pageNumber, pageRows, 1); } public Vectumerator findRigheDocumentoDisposizioneTaglio(int pageNumber, int pageRows, int ordinamentoRiga) { return findRigheDocumento(100L, pageNumber, pageRows, ordinamentoRiga); } public double getImponibileRighe() { return this.imponibileRighe; } public void setImponibileRighe(double imponibileRighe) { this.imponibileRighe = imponibileRighe; } public double getImportoIvaRighe() { return this.importoIvaRighe; } public void setImportoIvaRighe(double importoIvaRighe) { this.importoIvaRighe = importoIvaRighe; } public double getImportoRMRighe() { return this.importoRMRighe; } public void setImportoRMRighe(double importoRMRighe) { this.importoRMRighe = importoRMRighe; } public String getNumeroDocumento() { if (getProgDocumentoAgg().isEmpty()) return "" + getProgDocumento() + "/" + getProgDocumento(); return "" + getProgDocumento() + "-" + getProgDocumento() + "/" + getProgDocumentoAgg(); } public String getNumeroDocumentoCompleto() { String stato = ""; stato = stato + stato; return stato + stato + " " + getTipoDocumento().getCodice(); } public double getTotaleDocumento() { if (getTipoDocumento().getFlgCorrispettivi() == 0L) { DoubleOperator doubleOperator = new DoubleOperator(getImponibileTotale()); doubleOperator.add(getImportoIvaTotale()); if (getTipoDocumento().isTipoFatturaProfessionisti()) { doubleOperator.add(getRimborsoArt15()); doubleOperator.subtract(getImportoRitenutaAcconto()); } doubleOperator.setScale(2, 5); return doubleOperator.getResult(); } DoubleOperator temp = new DoubleOperator(getImportoTotale()); temp.subtract(getTotaleScontiAbbuoniConIva()); temp.add(getTotaleAltriCostiConIva()); temp.setScale(2, 5); return temp.getResult(); } public double getTotaleDocumentoArrotondato() { if (getTotaleDocumento() > 0.0D) return (double)Math.round(getTotaleDocumento()); return 0.0D; } public double getImportoIvaTotale() { return this.importoIvaTotale; } public double getImponibileTotale() { return this.imponibileTotale; } public String trovaPrimoBuco() { Calendar cal = Calendar.getInstance(); return trovaPrimoBuco((long)cal.get(1)); } public String trovaPrimoBuco(long anno) { String l_progPrimoBuco = trovaProgPrimoBuco(anno); if (l_progPrimoBuco.isEmpty()) return "Progressivi ok"; if (l_progPrimoBuco.toLowerCase().startsWith("err")) return l_progPrimoBuco; return "Primo Progressivo Contatore " + getTipoDocumento().getContatore().getDescrizione() + " Mancante o con data errata anno " + anno + ": " + l_progPrimoBuco; } public String getNote() { return (this.note == null) ? "" : this.note.trim(); } public void setNote(String note) { this.note = note; } public long getFlgStatoPrecedente() { return this.flgStatoPrecedente; } public void setFlgStatoPrecedente(long flgStatoPrecedente) { this.flgStatoPrecedente = flgStatoPrecedente; } protected void fillFields(ResultSet rst) { super.fillFields(rst); setId_cliforPrecedente(getId_clifor()); setFlgStatoPrecedente(getFlgStato()); setFlgStatoRiparazionePrecedente(getFlgStatoRiparazione()); setFlgStatoPrenotazionePrecedene(getFlgStatoPrenotazione()); setFlgDocumentoPrelevatoPrecedente(getFlgDocumentoPrelevato()); setFlgStatoOrdineWwwPrecedente(getFlgStatoOrdineWww()); setFlgStatoLavorazionePrecedente(getFlgStatoLavorazione()); } protected void initFields() { super.initFields(); setId_cliforPrecedente(0L); setFlgStatoPrecedente(0L); setFlgStatoRiparazionePrecedente(0L); setFlgStatoPrenotazionePrecedene(0L); setFlgDocumentoPrelevatoPrecedente(0L); setFlgStatoOrdineWwwPrecedente(0L); setFlgStatoLavorazionePrecedente(-1L); setRigaRegistroIva(null); setFlgInviaAvviso(1L); setRigaRegistroIvaCompleto(null); setFlgHaDocumentoPadre(-1L); setDocumentoFiglioUno(null); setId_tipoDocumentoFiglio(0L); setFlgStatoLavorazione(-1L); } protected boolean useNullFor0() { return true; } public static final synchronized ResParm addSerialeSuRigheDocumento(DocumentoInterface doc, long l_id_articolo, long l_id_articoloVariante, String l_seriale) { ResParm rp = doc.checkEMSTA(); if (!rp.getStatus()) return new ResParm(false, "ATTENZIONE! Tentativo di modificare una riga documento: " + rp.getMsg()); if (doc.getTipoCaricoScarico() == 0L) { RigaDocumentoCR CR = new RigaDocumentoCR(doc.getApFull()); CR.setId_documento(doc.getId_documento()); CR.setId_articolo(l_id_articolo); CR.setId_articoloVariante(l_id_articoloVariante); CR.setFlgTipoRicerca(0L); CR.setSeriale(l_seriale); Vectumerator vec = new RigaDocumento(doc.getApFull()).findByCR(CR, 0, 0); if (vec.getTotNumberOfRecords() > 0) { rp.setMsg("ERRORE! seriale " + l_seriale + " già inserito nel documento."); } else { CR.setSeriale(""); vec = new RigaDocumento(doc.getApFull()).findByCR(CR, 0, 0); boolean rowFound = false; while (vec.hasMoreElements() && !rowFound) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getSeriale().isEmpty()) { if (row.getQuantita() == 1.0D) { row.setSeriale(l_seriale); row.setQtaSlipStampate(0L); row.save(); } else if (row.getQuantita() > 1.0D) { try { row.setQuantita(row.getQuantita() - 1.0D); row.setQuantitaUdm(row.getQuantita() - 1.0D); if (row.getQtaSlipStampate() > 0L) row.setQtaSlipStampate(row.getQtaSlipStampate() - 1L); row.save(); RigaDocumento row1 = (RigaDocumento)row.clone(); row1.setQuantita(1.0D); row1.setQuantitaUdm(1.0D); row1.setId_rigaDocumento(0L); row1.setSeriale(l_seriale); row1.setQtaSlipStampate(0L); addRigaDocumento(doc, row1); } catch (Exception e) {} } rowFound = true; } } if (rowFound) { rp.setMsg("Seriale aggiunto correttamente"); } else { rp.setMsg("Attenzione! Il seriale non corrisponde a nessun articolo del documento"); } } } return rp; } public ResParm delRigaDocumento(RigaDocumento row) { ResParm rp = new ResParm(false); rp = checkEMSTA(); if (rp.getStatus()) { RigaDocumento bean = new RigaDocumento(getApFull()); bean.findByPrimaryKey(row.getId_rigaDocumento()); if (bean.getQuantitaPrelevata() > 0.0D) { rp.setStatus(false); rp.setMsg("ERRORE! Impossibile cancellare righe prelevate!"); } else { Documento doc = bean.getDocumento(); rp = bean.delete(); if (rp.getStatus()) rp.append(doc.save()); } } else { rp.setMsg("ERRORE! Fattura emessa o stampata! Impossibile eliminare."); } return rp; } public void setImportoIvaTotale(double importoIvaTotale) { this.importoIvaTotale = importoIvaTotale; } public void setImponibileTotale(double imponibileTotale) { this.imponibileTotale = imponibileTotale; } public double getTotaleAltriCosti() { DoubleOperator temp = new DoubleOperator(getSpeseTrasporto()); temp.add(getSpeseAltre()); temp.add(getSpeseIncasso()); temp.setScale(2, 5); return temp.getResult(); } public double getTotaleScontiAbbuoni() { DoubleOperator temp = new DoubleOperator(getScontoIncondizionato()); temp.add(getAbbuono()); temp.setScale(2, 5); return temp.getResult(); } public double getTotaleScontiAbbuoniConIva() { return conIva(getTotaleScontiAbbuoni(), (double)getIvaDoc().getAliquota()); } public double getTotaleAltriCostiConIva() { return conIva(getTotaleAltriCosti(), (double)getIvaDoc().getAliquota()); } public long getFlgAutoAdd() { return getTipoDocumento().getFlgAutoAdd(); } public void setFlgAutoAdd(long flgAutoAdd) { this.flgAutoAdd = flgAutoAdd; } public long getFlgSingleLineArt() { return getTipoDocumento().getFlgSingleLineArt(); } public void setFlgSingleLineArt(long flgSingleLineArt) { this.flgSingleLineArt = flgSingleLineArt; } public ByteArrayOutputStream creaLabelDispoTessitura4x2(DocumentoCR CR) { long pHMarg = 2L; long l_indent = 4L; long totLen = 40L; String l_descrizioneTipo = ""; int nCol = 2; int nRow = 4; float labelHeight = (PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow; int altezzaCod = 60; int larghezzaCod = 520; ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { this.document = new Document(PageSize.A4, 0.0F, 0.0F, 0.0F, 0.0F); this.writer = PdfWriter.getInstance(this.document, ba); String titoloReport = getNumeroDocumentoCompleto(); SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.document.open(); long labelNumber = 0L; this.pdfPcorpo = new PdfPTable(nCol); this.pdfPcorpo.setWidthPercentage(100.0F); Documento doc = new Documento(getApFull()); doc.findByPrimaryKey(CR.getId_documentoS()); if (doc.getTipoDocumento().getFlgTipologia() == 200L) { if (CR.getBlankLabels() > 0L) { PdfPCell pdfPCell = new PdfPCell(); pdfPCell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); pdfPCell.setHorizontalAlignment(1); pdfPCell.setBorder(0); for (int i = 0; (long)i < CR.getBlankLabels(); i++) { labelNumber++; this.pdfPcorpo.addCell(pdfPCell); } } Vectumerator vec = findByCR(CR, 0, 0); long numbOfLabels = 1L; while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vecRighe = row.findRigheDocumento(0, 0, ordineInverso); while (vecRighe.hasMoreElements()) { RigaDocumento rowRD = (RigaDocumento)vecRighe.nextElement(); numbOfLabels = rowRD.getStacchi(); String descLabel = rowRD.getDescrizioneRigaCompleta(); PdfContentByte cb = this.writer.getDirectContent(); Barcode128 codeBar = new Barcode128(); codeBar.setCodeType(9); for (int i = 0; (long)i < numbOfLabels; i++) { PdfPCell cellLabel = new PdfPCell(); cellLabel.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); PdfPTable pdfPtableLabel = new PdfPTable(2); pdfPtableLabel.setWidthPercentage(100.0F); PdfPCell pdfPCell1 = new PdfPCell(); String ditta = getHeaderDoocumento(1).substring(0, getHeaderDoocumento(1).indexOf("\n")); Paragraph paragraph = creaParagrafoConGrassetto(ditta + "\n" + ditta, PDF_fPiccolo, PDF_fPiccoloB); paragraph.setLeading(10.0F); pdfPCell1.addElement((Element)paragraph); pdfPCell1.setHorizontalAlignment(1); pdfPCell1.setColspan(2); pdfPtableLabel.addCell(pdfPCell1); pdfPCell1 = new PdfPCell(); pdfPCell1.addElement(new Chunk("TELA: " + row.getRiferimento() + " - " + rowRD.getCodiceCartellinoIdx((long)i), PdfFontFactory.PDF_H_GrandissimoB)); pdfPCell1.addElement(new Chunk("ARTICOLO: " + descLabel, PdfFontFactory.PDF_H_GrandeB)); pdfPCell1.setColspan(2); pdfPtableLabel.addCell(pdfPCell1); pdfPCell1 = new PdfPCell(); pdfPCell1.addElement(new Chunk("MT: \n ", PdfFontFactory.PDF_H_GrandissimoB)); pdfPCell1.setColspan(1); pdfPtableLabel.addCell(pdfPCell1); pdfPCell1 = new PdfPCell(); pdfPCell1.addElement(new Chunk("KG: ", PdfFontFactory.PDF_H_GrandissimoB)); pdfPCell1.setColspan(1); pdfPtableLabel.addCell(pdfPCell1); pdfPCell1 = new PdfPCell(); codeBar.setCode(rowRD.getCodiceCartellinoIdx((long)i)); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); pdfPCell1.addElement(new Chunk(imgBarcode, 10.0F, (float)(-altezzaCod + 15))); pdfPCell1.setColspan(2); pdfPCell1.setBorder(0); pdfPtableLabel.addCell(pdfPCell1); cellLabel.addElement((Element)pdfPtableLabel); this.pdfPcorpo.addCell(cellLabel); labelNumber++; } } } long numberBlankCell = (long)nCol - labelNumber % (long)nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorderColor(Color.MAGENTA); if (numberBlankCell != (long)nCol) for (int i = 0; (long)i < numberBlankCell; i++) this.pdfPcorpo.addCell(cell); } else { Phrase ph = new Phrase("Attenzione! Non ci sono etichette da stampare!"); PdfPCell cell = new PdfPCell(ph); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); cell.setColspan(nCol); this.pdfPcorpo.addCell(cell); } this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } @Deprecated public Documento getDocumentoFiglio() { this.documentoFiglio = (Documento)getSecondaryObject(this.documentoFiglio, Documento.class, getId_documentoFiglio()); return this.documentoFiglio; } public void setDocumentoFiglio(Documento documentoFiglio) { this.documentoFiglio = documentoFiglio; } public long getId_documentoFiglio() { return this.id_documentoFiglio; } public void setId_documentoFiglio(long id_documentoFiglio) { this.id_documentoFiglio = id_documentoFiglio; setDocumentoFiglio(null); } public long getFlgEmettiFatturaScontrino() { return this.flgEmettiFatturaScontrino; } public void setFlgEmettiFatturaScontrino(long flgEmettiFatturaScontrino) { this.flgEmettiFatturaScontrino = flgEmettiFatturaScontrino; } public ResParm generaScontrino() { ResParm rp = new ResParm(true); return rp; } private String getCashStringSiemens() { StringBuffer temp = new StringBuffer(); String sep = "|"; temp.append("KXCL"); temp.append(sep); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); String rowString = row.getCashStringSiemens(); if (!rowString.isEmpty()) { temp.append(rowString); temp.append(sep); } } String leNote = ""; if (!getCliforListino().getCodiceCartaFidelity().isEmpty()) leNote = "Fidelity Card: " + getCliforListino().getCodiceCartaFidelity() + " - " + getCliforListino().getListino().getDescrizione(); if (!getNote().isEmpty()) leNote = leNote + " " + leNote; if (!leNote.trim().isEmpty()) { leNote = leNote.trim().replace('\r', ' '); StringBuffer sbNote = new StringBuffer(); for (int i = 0; i < leNote.length(); i++) { if ((leNote.charAt(i) == ' ' && sbNote.length() > 23) || leNote.charAt(i) == '\n' || leNote.charAt(i) == '\r') { temp.append("KXSE" + sbNote.toString()); temp.append(sep); sbNote = new StringBuffer(); } if (leNote.charAt(i) != '\n' && leNote.charAt(i) != '\r') sbNote.append(leNote.charAt(i)); } if (sbNote.length() > 0) { temp.append("KXSE" + sbNote.toString()); temp.append(sep); } } TipoPagamento tp = getTipoPagamento(); if (tp.getDBState() == 1) { temp.append("KX" + tp.getCodiceTenderCassa() + tp.getDescrizione()); } else { temp.append("KXT1"); } temp.append(sep); temp.append("KXAC"); temp.append(sep); return temp.toString(); } public boolean isScontrinoEmesso() { return !getEchoScontrino().isEmpty(); } public void setEchoScontrino(String l_echo) { this.echoScontrino = l_echo; } public ResParm stampaScontrino(boolean isFiscale, RegCassa l_regCassa) { boolean test = false; if (test) { ResParm rp = aggiornaEchoScontrino(" test cassa siemens "); return rp; } if (l_regCassa.getFlgTipoCassa() == 0L) return stampaScontrinoSiemens(isFiscale, l_regCassa); return stampaScontrinoEpson(isFiscale, l_regCassa); } public ResParm aggiornaEchoScontrino(String theMsg) { setEchoScontrino(theMsg); return super.save(); } public ResParm associaOrdineTaglioADosposizioneTaglio(long l_id_documentoOrdineTaglio) { if (getTipoDocumento().getFlgObbligoPrelievo() == 1L) return new ResParm(false, "ERRORE! Figlio non generabile. Documento con obbligo di prelievo"); long righeCreate = 0L; ResParm rp = new ResParm(); ResParm rpRow = new ResParm(); DocFiglioPadre dfp = new DocFiglioPadre(getApFull()); Vectumerator rowDfp = dfp.findByFiglio(l_id_documentoOrdineTaglio); if (rowDfp.getTotNumberOfRecords() == 0) { dfp.setId_documentoPadre(getId_documento()); dfp.setId_documentoFiglio(l_id_documentoOrdineTaglio); rp = dfp.save(); dfp.getDocumentoFiglio().setFlgStatoLavorazione(20L); dfp.getDocumentoFiglio().superSave(); Documento documentoFiglio = dfp.getDocumentoFiglio(); Vectumerator rowRdf = documentoFiglio.findRigheDocumento(0, 0, 0); while (rowRdf.hasMoreElements()) { RigaDocumento rd = (RigaDocumento)rowRdf.nextElement(); rd.setId_documento(getId_documento()); rd.setId_rigaDocumento(0L); rd.setDBState(0); rd.setFlgSingleLineArt(1L); rp = addRigaDocumento(this, rd); if (!rp.getStatus()) break; rd.setNrOriginale(rd.getNr()); rd.superSave(); } } else { rp.setStatus(false); DocFiglioPadre currentDfp = (DocFiglioPadre)rowDfp.nextElement(); if (currentDfp.getId_documentoPadre() == getId_documento()) { rp.setMsg("Errore! Ordine taglio gia' legato alla disposizione corrente"); } else { rp.setMsg("Errore! Ordine taglio legato ad un altra disposizione"); } } findByPrimaryKey(getId_documento()); return rp; } public String getEchoScontrino() { return (this.echoScontrino == null) ? "" : this.echoScontrino.trim(); } public long getTipoRigaDocumento() { if (getTipoDocumento().getFlgClienteFornitore().equals("F")); return 0L; } public ByteArrayOutputStream creaDocumentoPdf(DocumentoCR CR, boolean soloFile) { if (CR.getId_documentoS() > 0L) { CR.setFilePdf(getPathStampaDocumentoFull()); if (new File(CR.getFilePdf()).exists()) { if (soloFile) return null; return getByteArrayFromFile(CR.getFilePdf()); } } else { CR.setFilePdf(getPathTmpFull() + "docs_" + getPathTmpFull() + ".pdf"); } boolean creaFile = true; ByteArrayOutputStream ba = new ByteArrayOutputStream(); int pageNumber = 1; try { if (CR.getId_documentoS() > 0L) { Documento bean = null; bean = new Documento(getApFull()); bean.findByPrimaryKey(CR.getId_documentoS()); bean.setCurrentLang(getCurrentLang()); if (bean.getTipoDocumento().getTipologiaDocumento().getCodice() == 220L) { this.document = new Document(PageSize.A5, 20.0F, 20.0F, 20.0F, 10.0F); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 12L) { this.document = new Document(PageSize.A4.rotate(), 20.0F, 20.0F, 20.0F, 10.0F); } else { this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 10.0F); } this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); this.document = creaDocumentoUno(bean, this.document, pageNumber); CR.setFilePdf(bean.getPathStampaDocumentoFull()); bean.superSave(); setDescDocumenti(bean.getDescDocumenti()); if (bean.getTmstStampato() == null) bean.saveTmstStampato(); } else { String temp = ""; Vectumerator vec = new Documento(getApFull()).findByCR(CR, 0, 0); boolean firstrecord = true; while (vec.hasMoreElements()) { pageNumber = 1; Documento row = (Documento)vec.nextElement(); if (firstrecord) { if (row.getTipoDocumento().getTipologiaDocumento().getCodice() == 220L) { this.document = new Document(PageSize.A5, 20.0F, 20.0F, 20.0F, 10.0F); } else { this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 10.0F); } this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); firstrecord = false; } this.document = creaDocumentoUno(row, this.document, pageNumber); temp = temp + temp; if (vec.hasMoreElements()) { this.document.newPage(); temp = temp + " \n"; } if (row.getTmstStampato() == null) row.saveTmstStampato(); } setDescDocumenti(temp); CR.setFilePdf(getDocBase() + getDocBase() + "_" + getPathStampeDocumenti() + "docs.pdf"); } if (this.document != null) { this.document.close(); this.document = null; } if (creaFile) { ResParm rp = createFileFromByteArray(ba, CR.getFilePdf()); if (rp.getStatus()) { DBAdapter.printDebug(true, "Creato file documento " + CR.getFilePdf()); } else { DBAdapter.printDebug(true, "ATTENZIONE! IMPOSSIBILE CREARE DOCUMENTO! ID: " + CR.getId_documentoS() + " filepdf: " + CR.getFilePdf() + "\n rp.getmsg:" + rp.getMsg()); } } } catch (Exception e) { e.printStackTrace(); } return ba; } protected void creaDocumentoIntestazione(Table l_pdfCorpo) { try { String descCliente, descDestinazione; int cellLeading = 8; SimpleDateFormat df = getDataFormat(); float imgLogoWidth = getDocLogoWidth(); Cell cell = new Cell(); try { Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); if (imgLogoWidth > 0.0F) imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); cell.addElement(new Chunk(imgLogo, 0.0F, 0.0F)); } catch (Exception e) { cell.addElement(new Chunk("\n\n", PdfFontFactory.PDF_fPiccolo)); } Paragraph paragraph = creaParagrafoConGrassetto("\n" + getHeaderDoocumento(1) + "\n" + getHeaderDoocumento(2), PDF_fPiccolo, PDF_fPiccoloB); paragraph.setLeading(10.0F); cell.addElement((Element)paragraph); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); l_pdfCorpo.addCell(cell); if (getId_clifor() > 0L) { descCliente = ""; if (getClifor().getpIva().isEmpty() && getClifor().getCodFisc().isEmpty() && getClifor().getCognome().isEmpty()) { descCliente = "AUTOFATTURA\n"; descCliente = descCliente + descCliente; } else { descCliente = descCliente + descCliente + "\n"; descCliente = descCliente + descCliente; String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); if (!getClifor().getNumeroCivico().isEmpty()) descCliente = descCliente + " n." + descCliente; descCliente = descCliente + "\n" + descCliente + " " + capComune; if (!getClifor().getProvinciaComune().isEmpty()) descCliente = descCliente + " (" + descCliente + ")"; if (!getClifor().getId_nazione().isEmpty()) descCliente = descCliente + " " + descCliente; } } else { descCliente = getNominativoDocumento(); } if (!getIndirizzoSped().isEmpty() && !getPresso().isEmpty()) { descDestinazione = ""; descDestinazione = descDestinazione + "c/o " + descDestinazione + "\n"; descDestinazione = descDestinazione + descDestinazione + " n." + getIndirizzoSped() + "\n" + getNumeroCivicoSped() + " " + getCapSped() + " (" + getCittaSped() + ")"; if (!getId_nazioneSped().isEmpty()) descDestinazione = descDestinazione + " " + descDestinazione; } else if (getId_destinazioneDiversa() == 0L) { if (getParm("DESTINAZIONE").getNumeroLong() == 1L) { descDestinazione = "IDEM\n\n"; } else { descDestinazione = ""; } } else { descDestinazione = ""; if (!getDestinazioneDiversa().getPressoDD().isEmpty()) descDestinazione = descDestinazione + "c/o " + descDestinazione + "\n"; descDestinazione = descDestinazione + descDestinazione + " n." + getDestinazioneDiversa().getIndirizzoDD() + "\n" + getDestinazioneDiversa().getNumeroCivicoDD() + " " + getDestinazioneDiversa().getCapComuneDD() + " (" + getDestinazioneDiversa().getDescrizioneComuneDD() + ")"; if (!getDestinazioneDiversa().getId_nazioneDD().isEmpty()) descDestinazione = descDestinazione + " " + descDestinazione; } cell = new Cell(); cell.addElement(new Chunk("\n\nSPETT.LE\n\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(descCliente, PdfFontFactory.PDF_fGrande)); if (!descDestinazione.isEmpty()) { cell.addElement(new Chunk("\nDESTINAZIONE\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(descDestinazione, PdfFontFactory.PDF_fGrande)); } cell.setVerticalAlignment(4); cell.setLeading(12.0F); cell.setBorder(0); cell.setRowspan(3); cell.setColspan(18); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("TIPO DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk("\n", PdfFontFactory.PDF_fMedio)); if (getFlgStato() == 0L) cell.addElement(new Chunk("(B) ", PdfFontFactory.PDF_fMedioB)); if (getFlgStato() == 2L) { cell.addElement(new Chunk("FATTURA PROFORMA\n", PdfFontFactory.PDF_fGrandeB)); } else { cell.addElement(new Chunk(getTipoDocumento().getDescrizioneStampa() + "\n", PdfFontFactory.PDF_fGrandeB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("N. DOC.\n\n", PdfFontFactory.PDF_fPiccolissimo)); if (getProgOrdineWww() > 0L) { cell.addElement(new Chunk(String.valueOf(getProgOrdineWww()), PdfFontFactory.PDF_fMedioB)); } else { cell.addElement(new Chunk(String.valueOf(getNumeroDocumento()), PdfFontFactory.PDF_fMedioB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("DATA\n\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(df.format(getDataDocumento()), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Pag.\n\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(getNf0().format(getNumPagDocumento()), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("xx", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); cell.setRowspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("RIF. INTERNO \n", PdfFontFactory.PDF_fPiccolissimo)); if (!getDescrizioneDocumentiPadre().isEmpty()) { if (getParm("ORDINI_WWW_USA_PROG_WWW").isTrue()) { cell.addElement(new Chunk(getNf0().format(getDocumentoPadreUno().getProgOrdineWww()), PdfFontFactory.PDF_fMedioB)); } else { cell.addElement(new Chunk(getDescrizioneDocumentiPadre(), PdfFontFactory.PDF_fPiccolissimo4)); } } else { cell.addElement(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimoB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setMaxLines(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("COD. C/F\t\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(String.valueOf(getClifor().getId_clifor()), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("PARTITA IVA/CF\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(getClifor().getPIva() + " / " + getClifor().getPIva(), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(11); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("RIF. CLIENTE/FORNITORE \n", PdfFontFactory.PDF_fPiccolissimo)); if (!getRiferimento().isEmpty()) { cell.addElement(new Chunk(getRiferimento(), PdfFontFactory.PDF_fPiccolissimoB)); if (getDataRiferimento() != null) cell.addElement(new Chunk(" del " + df.format(getDataRiferimento()), PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.addElement(new Chunk(".", PdfFontFactory.PDF_fPiccoloBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("CONDIZIONI DI PAGAMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (getFlgPagamentoDataFissa() > 0L) { if (getDataScadenzaPagamento() != null) cell.addElement(new Chunk(getPagamentoDataFissa() + " al " + getPagamentoDataFissa(), PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.addElement(new Chunk(getTipoPagamento().getDescrizione(), PdfFontFactory.PDF_fPiccolissimoB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(12); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("BANCA D'APPOGGIO\n", PdfFontFactory.PDF_fPiccolissimo)); if (getTipoPagamento().getFlgTipoPagamento() == 1L && !getBancaCFDesc().isEmpty()) if (getIbanCF().isEmpty()) { cell.addElement(new Chunk(getBancaCFDesc(), PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.addElement(new Chunk( getBancaCFDesc() + " Abi: " + getBancaCFDesc() + " Cab: " + getAbiCF(), PdfFontFactory.PDF_fPiccolissimoB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(20); l_pdfCorpo.addCell(cell); if (getTipoDocumento().getFlgTipoStampa() == 2L) { creaDocumentoIntestazioneCorpoDDT(l_pdfCorpo); } else if (getTipoDocumento().getFlgTipoStampa() == 3L) { creaDocumentoIntestazioneCorpoFtPro(l_pdfCorpo); } else if (getTipoDocumento().getFlgTipoStampa() == 6L) { creaDocumentoIntestazioneCorpoFtSemplice(l_pdfCorpo); } else if (getTipoDocumento().getFlgTipoStampa() == 12L) { creaDocumentoIntestazioneCorpoFtAcquisto(l_pdfCorpo); } else if (getTipoDocumento().getFlgTipoStampa() == 11L) { creaDocumentoIntestazioneCorpoRicevuta(l_pdfCorpo); } else { creaDocumentoIntestazioneCorpoFt(l_pdfCorpo); } } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoDisposizioneTaglioXLavorazione(Table l_pdfCorpo) { String prtLang = getLangPrimary(); try { int cellLeading = 10; SimpleDateFormat df = getDataFormat(); float imgLogoWidth = getDocLogoWidth() / 4.0F; Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); if (imgLogoWidth > 0.0F) imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); Cell cell = new Cell(); String desc = getArticolo().getDescrizioneCompleta(prtLang); cell.addElement(new Chunk(desc, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrandissimoXB, prtLang))); if (getId_taglia() > 0L) { desc = desc + desc + ": " + translate("taglia", prtLang); cell.addElement(new Chunk(desc, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fMedio, prtLang))); } if (!getArticolo().getNotaArticolo().isEmpty()) cell.addElement(new Chunk("\n" + DBAdapter.convertHtmlToString(getArticolo().getNotaArticolo()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, prtLang))); if (!getArticolo().getNoteTessutiBaseHtml(prtLang).isEmpty()) cell.addElement(new Chunk("\n" + getArticolo().getNoteTessutiBase(prtLang), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, prtLang))); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); l_pdfCorpo.addCell(cell); String imgFileName = getDocBase() + getDocBase() + getArticolo().getPathImg(); if (new File(imgFileName).exists()) { imgLogoWidth = 60.0F; Image imgArt = Image.getInstance(imgFileName); if (imgLogoWidth > 0.0F) imgArt.scaleToFit(imgLogoWidth, imgLogoWidth); cell = new Cell(); cell.addElement(new Chunk(imgArt, 0.0F, 0.0F)); } else { cell = new Cell(); } cell.setBorder(0); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getNumeroDocumentoCompleto(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, prtLang))); cell.addElement(new Chunk(" " + getDataFormat().format(getDataDocumento()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, prtLang))); if (!getRiferimento().isEmpty()) { cell.addElement(new Chunk("\nRIF. ", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, prtLang))); cell.addElement(new Chunk(getRiferimento() + " " + getRiferimento(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, prtLang))); } cell.addElement(new Chunk("\n", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, prtLang))); cell.addElement(new Chunk(getClifor().getDescrizioneCompleta(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, prtLang))); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("N. CAPI", prtLang) + "\n\n" + translate("N. CAPI", prtLang), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrandeB, prtLang))); cell.addElement(new Chunk("\n", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fMedio, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(10); l_pdfCorpo.addCell(cell); Vectumerator vecTessuti = findRigheDocumentoDisposizioneTaglio(0, 0, 0); long totTessuti = (long)vecTessuti.getTotNumberOfRecords(); int colSpan = (int)(15L / totTessuti); int totColSpan = 0; while (vecTessuti.hasMoreElements()) { RigaDocumento rowTessuto = (RigaDocumento)vecTessuti.nextElement(); cell = new Cell(); cell.addElement(new Chunk(rowTessuto.getDescrizioneRiga(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, prtLang))); if (rowTessuto.getId_articoloTessutoColore() == 0L) { cell.addElement(new Chunk("\n" + rowTessuto.getMtTessutoXTaglio() + " " + translate("Mt.", prtLang), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccoloB, prtLang))); cell.addElement(new Chunk("\n" + rowTessuto.getNumTeli() + " " + translate("Teli", prtLang), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccoloB, prtLang))); } else { cell.addElement(new Chunk("\n" + rowTessuto.getMtTessutoXTaglio() + " " + translate("Mt.", prtLang), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrandeBlu, prtLang))); cell.addElement(new Chunk("\n" + rowTessuto.getNumTeli() + " " + translate("Teli", prtLang), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrandeBlu, prtLang))); } cell.addElement(new Chunk("\n" + rowTessuto.getCapiPerTelo() + " " + translate("C./telo", prtLang), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccoloB, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(colSpan * 2); totColSpan += colSpan * 2; l_pdfCorpo.addCell(cell); } if (totColSpan < 30) { cell = new Cell(); cell.addElement(new Chunk("", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBorder(0); cell.setColspan(30 - totColSpan); l_pdfCorpo.addCell(cell); } cell = new Cell(); cell.addElement(new Chunk(translate("QTA'", prtLang), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccoloB, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(3); cell.setBackgroundColor(Color.LIGHT_GRAY); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("COLORE", prtLang) + "\n", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccoloB, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); cell.setBackgroundColor(Color.LIGHT_GRAY); l_pdfCorpo.addCell(cell); Vectumerator vecArticoli = findRigheDocumento(0, 0, 0); while (vecArticoli.hasMoreElements()) { RigaDocumento rowArticolo = (RigaDocumento)vecArticoli.nextElement(); totColSpan = 0; cell = new Cell(); cell.addElement(new Chunk(getNf0().format(rowArticolo.getQuantita()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(); desc = rowArticolo.getArticoloVariante().getColore().getDescrizione(prtLang); if (prtLang.equals("cn")) { cell.addElement(new Chunk(rowArticolo.getArticoloVariante().getColore().getDescrizione("it") + "\n", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, prtLang))); cell.addElement(new Chunk(desc, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fMedio, prtLang))); } else { cell.addElement(new Chunk(desc, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccoloB, prtLang))); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); vecTessuti.moveFirst(); while (vecTessuti.hasMoreElements()) { RigaDocumento rowTessuto = (RigaDocumento)vecTessuti.nextElement(); cell = new Cell(); cell.addElement(new Chunk( getNf0().format(rowTessuto.getNumeroTeliRigaByArticolo(rowArticolo.getId_rigaDocumento()).getNumTeliRiga()) + " " + getNf0().format(rowTessuto.getNumeroTeliRigaByArticolo(rowArticolo.getId_rigaDocumento()).getNumTeliRiga()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, prtLang))); cell.addElement(new Chunk("\n" + getNf0().format(rowTessuto.getNumeroTeliRigaByArticolo(rowArticolo.getId_rigaDocumento()).getMtTessutoRiga()) + " " + translate("mt.", prtLang), PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(colSpan); totColSpan += colSpan; l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setColspan(colSpan); totColSpan += colSpan; l_pdfCorpo.addCell(cell); } if (totColSpan < 30) { cell = new Cell(); cell.addElement(new Chunk("", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(30 - totColSpan); l_pdfCorpo.addCell(cell); } } } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoDisposizioneTaglioXDispositore(Table l_pdfCorpo) { try { int cellLeading = 10; SimpleDateFormat df = getDataFormat(); Cell blankRow = new Cell(); blankRow.setVerticalAlignment(4); blankRow.setHorizontalAlignment(0); blankRow.setLeading((float)cellLeading); blankRow.setBorder(0); blankRow.setColspan(40); float imgLogoWidth = getDocLogoWidth() / 4.0F; Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); if (imgLogoWidth > 0.0F) imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); Cell cell = new Cell(); String desc = getArticolo().getDescrizioneCompleta(getCurrentLang()); cell.addElement(new Chunk(desc, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrandissimoXB, getCurrentLang()))); if (getId_taglia() > 0L) { desc = desc + desc + ": " + translate("taglia", getCurrentLang()); cell.addElement(new Chunk(desc, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fMedio, getCurrentLang()))); } if (!getArticolo().getNotaArticolo().isEmpty()) cell.addElement(new Chunk("\n" + DBAdapter.convertHtmlToString(getArticolo().getNotaArticolo()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); if (!getArticolo().getNoteTessutiBaseHtml(getCurrentLang()).isEmpty()) cell.addElement(new Chunk("\n" + getArticolo().getNoteTessutiBase(getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); l_pdfCorpo.addCell(cell); String imgFileName = getDocBase() + getDocBase() + getArticolo().getPathImg(); if (new File(imgFileName).exists()) { imgLogoWidth = 60.0F; Image imgArt = Image.getInstance(imgFileName); if (imgLogoWidth > 0.0F) imgArt.scaleToFit(imgLogoWidth, imgLogoWidth); cell = new Cell(); cell.addElement(new Chunk(imgArt, 0.0F, 0.0F)); } else { cell = new Cell(); } cell.setBorder(0); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getNumeroDocumentoCompleto(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, getCurrentLang()))); cell.addElement(new Chunk(" " + getDataFormat().format(getDataDocumento()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, getCurrentLang()))); if (!getRiferimento().isEmpty()) { cell.addElement(new Chunk("\nRIF. ", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, getCurrentLang()))); cell.addElement(new Chunk(getRiferimento() + " " + getRiferimento(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, getCurrentLang()))); } cell.addElement(new Chunk("\n", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, getCurrentLang()))); cell.addElement(new Chunk(getClifor().getDescrizioneCompleta(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("N. CAPI", getCurrentLang()) + "\n\n" + translate("N. CAPI", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrandeB, getCurrentLang()))); cell.addElement(new Chunk("\n", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fMedio, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Rif. Ordini", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.addElement(new Chunk("\n" + getDescDocFiglioPadreByPadre(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(30); l_pdfCorpo.addCell(cell); l_pdfCorpo.addCell(blankRow); Vectumerator vecDispo = findRigheDocumento(0, 0, 0); cell = new Cell(); cell.addElement(new Chunk(translate("Disposizione Globale", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Descrizione", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Q.tà Orig", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Q.tà", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(10); l_pdfCorpo.addCell(cell); while (vecDispo.hasMoreElements()) { RigaDocumento rowDispo = (RigaDocumento)vecDispo.nextElement(); cell = new Cell(); cell.addElement(new Chunk(rowDispo.getDescrizioneRigaCompleta(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getNf().format(rowDispo.getNrOriginale()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getNf().format(rowDispo.getNr()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setColspan(10); l_pdfCorpo.addCell(cell); } l_pdfCorpo.addCell(blankRow); Vectumerator vecTessuti = findRigheDocumento2("", 0, 0, 2); cell = new Cell(); cell.addElement(new Chunk(translate("Elenco Tessuti Necessari", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Descrizione", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Q.tà", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Disponibilità", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(10); l_pdfCorpo.addCell(cell); while (vecTessuti.hasMoreElements()) { RigaDocumento rowTessuti = (RigaDocumento)vecTessuti.nextElement(); cell = new Cell(); cell.addElement(new Chunk(rowTessuti.getDescrizioneRiga(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getNf().format(rowTessuti.getQuantita()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getNf().format(rowTessuti.getQuantitaEffettiva()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setColspan(10); l_pdfCorpo.addCell(cell); } } catch (Exception e) { handleDebug(e); } } private Document creaDocumentoUno(Documento bean, Document l_document, int pageNumber) { try { Table l_pdfCorpo = getNewPdfCorpoDocument(); bean.setNumPagDocumento(1L); if (bean.getTipoDocumento().getTipologiaDocumento().getCodice() == 220L) { if (getPrtCommand() == 1L) { bean.creaDocumentoDisposizioneTaglioXLavorazione(l_pdfCorpo); } else { bean.creaDocumentoDisposizioneTaglioXDispositore(l_pdfCorpo); this.document.add((Element)l_pdfCorpo); this.document.newPage(); l_pdfCorpo = getNewPdfCorpoDocument(); bean.creaDocumentoDisposizioneTaglioXDispositoreElencoOrdini(l_pdfCorpo); } } else if (bean.getTipoDocumento().getFlgTipoStampa() == 2L) { bean.creaDocumentoIntestazione(l_pdfCorpo); bean.creaDocumentoCorpoDDT(l_document, l_pdfCorpo); bean.creaDocumentoFooterDDT(l_pdfCorpo, true); bean.creaDocumentoFooterDDTFirme(l_pdfCorpo, true); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 1L) { bean.creaDocumentoIntestazione(l_pdfCorpo); bean.creaDocumentoCorpoFt(l_document, l_pdfCorpo); bean.creaDocumentoFooterDDT(l_pdfCorpo, true); bean.creaDocumentoFooterFatture(l_pdfCorpo, true); bean.creaDocumentoFooterDDTFirme(l_pdfCorpo, true); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 0L) { bean.creaDocumentoIntestazione(l_pdfCorpo); bean.creaDocumentoCorpoFt(l_document, l_pdfCorpo); bean.creaDocumentoFooterFatture(l_pdfCorpo, true); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 12L) { bean.creaDocumentoIntestazione(l_pdfCorpo); bean.creaDocumentoCorpoFtAcquistoBollaCarico(l_document, l_pdfCorpo); bean.creaDocumentoFooterFatture(l_pdfCorpo, true); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 7L) { bean.creaDocumentoIntestazione(l_pdfCorpo); bean.creaDocumentoCorpoFt(l_document, l_pdfCorpo); bean.creaDocumentoFooterFattureConPesiEColli(l_pdfCorpo, true); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 6L) { bean.creaDocumentoIntestazione(l_pdfCorpo); bean.creaDocumentoCorpoFtSemplice(l_document, l_pdfCorpo); creaDocumentoFooterFattureSemplici(l_pdfCorpo, true); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 3L) { bean.creaDocumentoIntestazione(l_pdfCorpo); bean.creaDocumentoCorpoFtPro(l_document, l_pdfCorpo); bean.creaDocumentoFooterFatturePro(l_pdfCorpo, true); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 4L) { bean.creaDocumentoIntestazioneS(l_pdfCorpo); bean.creaDocumentoCorpoFtProS(l_document, l_pdfCorpo); bean.creaDocumentoFooterFattureProS(l_pdfCorpo, true); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 5L) { bean.creaDocumentoSchedaRiparazione(l_pdfCorpo); } else if (bean.getTipoDocumento().getFlgTipoStampa() == 11L) { bean.creaDocumentoIntestazione(l_pdfCorpo); bean.creaDocumentoCorpoRicevuta(l_document, l_pdfCorpo); bean.creaDocumentoFooterRicevute(l_pdfCorpo, true); } bean.setDescDocumenti(bean.getNumeroDocumentoCompleto()); this.document.add((Element)l_pdfCorpo); } catch (Exception e) { e.printStackTrace(); } return this.document; } protected int incrementaNumRighe(int riga, int righePerPagina, Document l_document, Table l_pdfCorpo, boolean hasMoreRow) { riga++; int rpp = righePerPagina; if (hasMoreRow) rpp += 5; if (riga >= righePerPagina && hasMoreRow) { if (getTipoDocumento().getFlgTipoStampa() == 2L) { creaDocumentoFooterDDTTotale(l_pdfCorpo, false); creaDocumentoFooterDDT(l_pdfCorpo, false); creaDocumentoFooterDDTFirme(l_pdfCorpo, false); } else if (getTipoDocumento().getFlgTipoStampa() == 1L) { creaDocumentoFooterDDT(l_pdfCorpo, false); creaDocumentoFooterFatture(l_pdfCorpo, false); creaDocumentoFooterDDTFirme(l_pdfCorpo, false); } else if (getTipoDocumento().getFlgTipoStampa() == 0L) { creaDocumentoFooterFattureConPesiEColli(l_pdfCorpo, false); } else if (getTipoDocumento().getFlgTipoStampa() == 6L) { creaDocumentoFooterFattureSemplici(l_pdfCorpo, false); } else if (getTipoDocumento().getFlgTipoStampa() == 3L) { creaDocumentoIntestazione(l_pdfCorpo); creaDocumentoCorpoFtPro(l_document, l_pdfCorpo); creaDocumentoFooterFatturePro(l_pdfCorpo, false); } else if (getTipoDocumento().getFlgTipoStampa() == 4L) { creaDocumentoIntestazioneS(l_pdfCorpo); creaDocumentoCorpoFtProS(l_document, l_pdfCorpo); creaDocumentoFooterFattureProS(l_pdfCorpo, false); } else if (getTipoDocumento().getFlgTipoStampa() == 11L) { creaDocumentoIntestazione(l_pdfCorpo); creaDocumentoCorpoRicevuta(l_document, l_pdfCorpo); creaDocumentoFooterRicevute(l_pdfCorpo, false); } else if (getTipoDocumento().getFlgTipoStampa() == 7L) { creaDocumentoFooterFattureConPesiEColli(l_pdfCorpo, false); } try { l_document.add((Element)l_pdfCorpo); l_document.newPage(); l_pdfCorpo.deleteAllRows(); setNumPagDocumento(getNumPagDocumento() + 1L); creaDocumentoIntestazione(l_pdfCorpo); } catch (Exception e) { handleDebug(e, 2); } riga = 0; } return riga; } public String getNumeroDocumentoPdf() { String sep = "-"; StringBuilder sb = new StringBuilder(getTipoDocumento().getCodice()); sb.append("-"); sb.append(getProgDocumento()); sb.append("-"); if (!getProgDocumentoAgg().isEmpty()) { sb.append(getProgDocumentoAgg()); sb.append("-"); } sb.append(getId_esercizio()); sb.append("-"); sb.append(getParm("STAMPA_NOME_DOCUMENTO").getTesto()); return sb.toString(); } public Comune getComuneSped() { this.comuneSped = (Comune)getSecondaryObject(this.comuneSped, Comune.class, getId_comuneSped()); return this.comuneSped; } public long getId_comuneSped() { return this.id_comuneSped; } public String getIndirizzoSped() { return (this.indirizzoSped == null) ? "" : this.indirizzoSped.trim(); } public String getPresso() { return (this.presso == null) ? "" : this.presso.trim(); } public void setId_comuneSped(long newId_comuneSped) { this.id_comuneSped = newId_comuneSped; setComuneSped(null); } public void setIndirizzoSped(String indirizzoSped) { this.indirizzoSped = indirizzoSped; } public void setPresso(String presso) { this.presso = presso; } public void setComuneSped(Comune comuneSped) { this.comuneSped = comuneSped; } public String getDescrizioneDocumentiPadre() { Vectumerator vec = findDocumentiPadre(); StringBuffer temp = new StringBuffer(); while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); temp.append(row.getNumeroDocumentoCompleto()); if (vec.hasMoreElements()) temp.append(", "); } return temp.toString(); } public String getDescrizioneDocumentiPadreId() { Vectumerator vec = findDocumentiPadre(); StringBuffer temp = new StringBuffer(); while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); temp.append(row.getId_documento()); if (vec.hasMoreElements()) temp.append(", "); } return temp.toString(); } public boolean hasLabelDaStampare() { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getArticolo().getFlgStampaEtichetteT() == 1L) return true; } return false; } private String getCashStringSiemensNonFiscale() { StringBuffer temp = new StringBuffer(); String sep = "|"; temp.append("KXCL"); temp.append(sep); temp.append("KXSE" + getNumeroDocumentoCompleto()); temp.append(sep); temp.append("KXSESig. " + getNominativoDocumento()); temp.append(sep); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); temp.append(row.getCashStringNonFiscale()); } if (getAcconto() > 0.0D) { temp.append("KXSEAcconto: " + getNf().format(getAcconto())); temp.append(sep); } temp.append("KXSEArrivederci e Grazie"); temp.append(sep); temp.append("KXCE"); return temp.toString(); } public String getStato() { return getStato(getFlgStato()); } public Vectumerator findRigheDocumentoPrelevabili(int pageNumber, int pageRows) { return new RigaDocumento(getApFull()).findRighePrelevabiliByDocumento(this, pageNumber, pageRows); } public ResParm addRigaDocumentoDaPrelevareM(RigaDocumento rddp, double l_qtaDaPrelevare) { ResParm rp = new ResParm(false); rp = checkEMSTA(); if (rp.getStatus()) { DoubleOperator dop = new DoubleOperator(l_qtaDaPrelevare); Vectumerator vec = findRigheDocumentoByArticoloArticoloVariante(rddp.getId_articolo(), rddp.getId_articoloVariante()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_articolo() == rddp.getId_articolo() && row.getId_articoloVariante() == rddp.getId_articoloVariante()) if (row.getQuantita() != 0.0D) { RigaDocumentoP rdp = new RigaDocumentoP(getApFull()); rdp.setId_rigaDocumento(row.getId_rigaDocumento()); rdp.setId_documento(row.getId_documento()); rdp.setId_rigaDocumentoPrelevata(rddp.getId_rigaDocumento()); if (row.getQuantita() <= dop.getResult()) { rdp.setQuantitaPrelevata(row.getQuantita()); } else { rdp.setQuantitaPrelevata(dop.getResult()); } rp = row.addRigaDocumentoP(rdp); if (rp.getStatus()) { Movimento mov = new Movimento(getApFull()); mov.setId_articolo(row.getId_articolo()); mov.setId_articoloVariante(row.getId_articoloVariante()); mov.setId_articoloTaglia(row.getId_articoloTaglia()); mov.setId_clifor(getId_clifor()); mov.setId_causaleMagazzino(getTipoDocumento().getId_causaleMagazzino()); long l_id_magazzinoFisicoDocumentoDaPrelevare = rddp.getDocumento().getTipoDocumento().getCausaleMagazzino() .getId_magFisicoArrivo(); mov.setId_magFisico(l_id_magazzinoFisicoDocumentoDaPrelevare); mov.setId_rigaDocumento(row.getId_rigaDocumento()); if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 1L) { mov.setNr(-1.0D * rdp.getQuantitaPrelevata()); } else if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 2L) { mov.setKg(-1.0D * rdp.getQuantitaPrelevata()); } else if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 3L) { mov.setMt(-1.0D * rdp.getQuantitaPrelevata()); } rp = mov.save(); dop.subtract(rdp.getQuantitaPrelevata()); } if (dop.getResult() <= 0.0D) break; } } boolean checkPrelievo = true; Documento ordine = rddp.getDocumento(); Vectumerator vecRows = ordine.findRigheDocumento(0, 0, 0); while (vecRows.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRows.nextElement(); if (row.getFlgRigaPrelevata() == 0L) { checkPrelievo = false; break; } } if (checkPrelievo) { ordine.setFlgDocumentoPrelevato(1L); ordine.superSave(); } } else { rp.setMsg("ERRORE! Fattura emessa o stampata! Impossibile salvare."); } return rp; } public ResParm addRigaDocumentoDaPrelevare(RigaDocumento rddp, double l_qtaDaPrelevare) { ResParm rp = new ResParm(false); rp = checkEMSTA(); if (rp.getStatus()) { DoubleOperator dop = new DoubleOperator(l_qtaDaPrelevare); Vectumerator vec = findRigheDocumentoByArticoloArticoloVariante(rddp.getId_articolo(), rddp.getId_articoloVariante()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_articolo() == rddp.getId_articolo() && row.getId_articoloVariante() == rddp.getId_articoloVariante()) if (row.getQuantita() != 0.0D) { try { double qtaPrelevata; RigaDocumento rd = (RigaDocumento)row.clone(); rd.setId_rigaDocumento(0L); rd.setDBState(0); rd.setId_rigaDocumentoMov(row.getId_rigaDocumento()); rd.setId_rigaDocumentoPrelevata(rddp.getId_rigaDocumento()); rd.setId_magFisico(rddp.getDocumento().getTipoDocumento().getCausaleMagazzino().getId_magFisicoArrivo()); rd.setSegnoMov(-1L); if (row.getQuantita() <= dop.getResult()) { qtaPrelevata = row.getQuantita(); } else { qtaPrelevata = dop.getResult(); } if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 1L) { rd.setNr(qtaPrelevata); } else if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 2L) { rd.setKg(qtaPrelevata); } else if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 3L) { rd.setMt(qtaPrelevata); } rp = rd.saveMov(); } catch (Exception e) { e.printStackTrace(); } if (dop.getResult() <= 0.0D) break; } } boolean checkPrelievo = true; Documento ordine = rddp.getDocumento(); Vectumerator vecRows = ordine.findRigheDocumento(0, 0, 0); while (vecRows.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRows.nextElement(); if (row.getFlgRigaPrelevata() == 0L) { checkPrelievo = false; break; } } if (checkPrelievo) { ordine.setFlgDocumentoPrelevato(1L); ordine.superSave(); } } else { rp.setMsg("ERRORE! Fattura emessa o stampata! Impossibile salvare."); } return rp; } public ResParm delRigaDocumentoDaPrelevare(long id_rigaDocumento, long id_rigaDocumentoPrelevata) { ResParm rp = new ResParm(false); return rp; } public Vectumerator findRigheDocumentoPrelevateAssociate(int pageNumber, int pageRows) { return new RigaDocumentoP(getApFull()).findByDocumento(getId_documento(), pageNumber, pageRows); } public String getNumeroCivicoSped() { return (this.numeroCivicoSped == null) ? "" : this.numeroCivicoSped.trim(); } public void setNumeroCivicoSped(String numeroCivicoSped) { this.numeroCivicoSped = numeroCivicoSped; } public String getDocumentoPrelevato() { return (this.flgDocumentoPrelevato == 0L) ? "Aperto" : "Chiuso"; } public void setFlgDocumentoPrelevato(long flgDocumentoPrelevato) { this.flgDocumentoPrelevato = flgDocumentoPrelevato; } public void aggiornaFlgDocumentoPrelevato(long l_flgDocumentoPrelevato) { if (l_flgDocumentoPrelevato != getFlgDocumentoPrelevato()) { setFlgDocumentoPrelevato(l_flgDocumentoPrelevato); save(); } } public void verificaEAggiornaFlgDocumentoPrelevato() { if (new RigaDocumento(getApFull()).isAllRighePrelevateByDocumento(getId_documento())) { aggiornaFlgDocumentoPrelevato(1L); } else { aggiornaFlgDocumentoPrelevato(0L); } } protected long getId_docRiparazione() { return getParm("ID_DOC_RIPARAZIONE").getNumeroLong(); } public boolean isPrelevataNoObbligo() { if (getTipoDocumento().getFlgTipoDocumentoPrelevabile() == 0L || getId_tipoDocumento() == getId_docCassa()) return true; return !(getFlgDocumentoPrelevato() == 0L); } public long getTipoCaricoScarico() { if (getTipoDocumento().getFlgNoAnag() == 1L) return -1L; if (getId_magFisicoPartenza() != 0L) return 1L; if (getTipoDocumento().getCausaleMagazzino().getId_magFisicoPartenza() != 0L) return 1L; return 0L; } public ByteArrayOutputStream creaReportPdf(int flgTipo, DocumentoCR CR) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); String titoloReport = ""; try { long numGiorni; switch (flgTipo) { case 7: case 9: this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 20.0F); break; case 0: this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 20.0F); break; case 8: case 10: this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 20.0F); break; case 3: this.document = new Document(PageSize.A4.rotate(), 20.0F, 20.0F, 20.0F, 20.0F); break; case 1: this.document = new Document(PageSize.A4.rotate(), 20.0F, 20.0F, 20.0F, 20.0F); break; case 2: this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 20.0F); case 4: this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 20.0F); break; case 6: this.document = new Document(PageSize.A4.rotate(), 20.0F, 20.0F, 20.0F, 20.0F); break; default: this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 20.0F); break; } switch (flgTipo) { case 7: titoloReport = "Report Vendite Giornaliere"; break; case 9: titoloReport = "Report Vendite Giornaliere x Nazione"; break; case 0: titoloReport = "Report Vendite Giornaliere"; break; case 8: titoloReport = "Report Documenti"; break; case 10: titoloReport = "Report Documenti con DDT"; break; case 3: titoloReport = "Report Vendite Giornaliere"; break; case 1: titoloReport = "Report Vendite Completo"; break; case 2: titoloReport = "Report Vendite Compatto"; break; case 4: titoloReport = "Report Ordini Inevasi"; break; case 6: titoloReport = "Vendite servizi"; break; default: titoloReport = "Report ???"; break; } SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.writer = PdfWriter.getInstance(this.document, ba); if (flgTipo != 99) { Phrase pH = new Phrase(new Chunk(titoloReport + " - Pag. n. ", PDF_A_Piccolo)); HeaderFooter header = new HeaderFooter(pH, true); header.setAlignment(2); header.setBorder(0); this.document.setFooter(header); } this.document.open(); prepareNewPdfCorpoDocument(); switch (flgTipo) { case 7: creaReportUnoGiornaliero(CR, false); break; case 9: creaReportUnoGiornalieroXNazione(CR, false); break; case 0: if (CR.getDataDocumentoDa() == null) CR.setDataDocumentoDa(getToday()); CR.setDataDocumentoA(CR.getDataDocumentoDa()); creaReportUnaVendite(CR, false); break; case 8: if (CR.getDataDocumentoDa() == null) CR.setDataDocumentoDa(getToday()); creaReportDettagliDocumenti(CR, false); break; case 10: if (CR.getDataDocumentoDa() == null) CR.setDataDocumentoDa(getToday()); creaReportDettagliDocumenti(CR, true); break; case 3: if (CR.getDataDocumentoDa() == null) CR.setDataDocumentoDa(getToday()); if (CR.getDataDocumentoA() == null) CR.setDataDocumentoA(getToday()); numGiorni = getDateDiff(CR.getDataDocumentoDa(), CR.getDataDocumentoA()); if (numGiorni >= 0L) { Calendar cal = Calendar.getInstance(); cal.setTime(CR.getDataDocumentoDa()); for (int i = 0; (long)i <= numGiorni; i++) { CR.setDataDocumentoDa(new Date(cal.getTimeInMillis())); CR.setDataDocumentoA(new Date(cal.getTimeInMillis())); creaReportUnaVendite(CR, false); if ((long)i < numGiorni) { this.document.newPage(); cal.add(6, 1); } } } break; case 1: if (CR.getDataDocumentoDa() == null) CR.setDataDocumentoDa(getToday()); if (CR.getDataDocumentoA() == null) CR.setDataDocumentoA(getToday()); creaReportUnaVendite(CR, false); break; case 2: if (CR.getDataDocumentoDa() == null) CR.setDataDocumentoDa(getToday()); creaReportUnaVendite(CR, true); break; case 4: CR.setId_tipoDocumento(getId_docOrdine()); CR.setFlgDocumentoPrelevato(1L); creaReportUnaOrdiniInevasi(CR, true); break; case 6: creaReportUnaVenditeServizi(CR, true); break; } this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } private Document creaReportUnaVenditeServizi(DocumentoCR CR, boolean soloCompatto) { int rowCellLeading = 6; NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col_1 = 2, col_2 = 3, col_3 = 6, col_4 = 3, col_5 = 3, col_6 = 3, col_7 = 3, col_8 = 6, col_9 = 4, col_10 = 3, col_11 = 2; int col_12 = 2; int cellLeading = 12; long id_articolo = 0L; DoubleOperator totQta = new DoubleOperator(); DoubleOperator totImporti = new DoubleOperator(); DoubleOperator totQtaArt = new DoubleOperator(); DoubleOperator totImportiArt = new DoubleOperator(); SimpleDateFormat df = getDataFormat(); try { Cell rigaVuota = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); String intestazioneReport = "Data: dal " + df.format(CR.getDataDocumentoDa()) + " al " + df.format(CR.getDataDocumentoA()); if (CR.getId_tipo() != 0L) intestazioneReport = intestazioneReport + " - Tipo: " + intestazioneReport; if (CR.getId_articolo() != 0L) intestazioneReport = intestazioneReport + " - Articolo: " + intestazioneReport; creaIntestazioneReport(CR.getTipoReport(), intestazioneReport); Cell cell = new Cell(new Chunk("ID", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Tipo art.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Articolo", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Operatore", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Tipo doc.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Documento", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Data doc.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Cliente/Fornitore", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Nota riga", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_9); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Seriale", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_10); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Q.tà", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_11); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Importo", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_12); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); Vectumerator vec = new RigaDocumento(getApFull()).findVenditeServizi(CR); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (id_articolo > 0L && id_articolo != row.getId_articolo()) { cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); cell.setBackgroundColor(Color.yellow); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Totale articolo", PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); cell.setBackgroundColor(Color.yellow); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3 + col_4 + col_5 + col_6 + col_7 + col_8 + col_9 + col_10); cell.setRowspan(1); cell.setBackgroundColor(Color.yellow); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totQtaArt.getResult()), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_11); cell.setRowspan(1); cell.setBackgroundColor(Color.yellow); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totImportiArt.getResult()), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_12); cell.setBackgroundColor(Color.yellow); cell.setRowspan(1); this.pdfcorpo.addCell(cell); totQtaArt = new DoubleOperator(); totImportiArt = new DoubleOperator(); } cell = new Cell(new Chunk(String.valueOf(row.getId_documento()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getArticolo().getTipo().getDescrizione(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(convertHtmlToString(row.getArticolo().getDescrizioneCompleta()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getDocumento().getUsers().getCognomeNome(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getDocumento().getTipoDocumento().getDescrizione(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getDocumento().getNumeroDocumento(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(df.format(row.getDocumento().getDataDocumento()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getDocumento().getClifor().getDescrizioneCliente(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getNotaRigaDocumento(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_9); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getSeriale(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_10); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getQuantita()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_11); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getImporto()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_12); cell.setRowspan(1); this.pdfcorpo.addCell(cell); totQtaArt.add(row.getQuantita()); totImportiArt.add(row.getImporto()); totQta.add(row.getQuantita()); totImporti.add(row.getImporto()); id_articolo = row.getId_articolo(); } cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); cell.setBackgroundColor(Color.yellow); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Totale articolo", PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); cell.setBackgroundColor(Color.yellow); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3 + col_4 + col_5 + col_6 + col_7 + col_8 + col_9 + col_10); cell.setRowspan(1); cell.setBackgroundColor(Color.yellow); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totQtaArt.getResult()), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_11); cell.setRowspan(1); cell.setBackgroundColor(Color.yellow); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totImportiArt.getResult()), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_12); cell.setBackgroundColor(Color.yellow); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Totale", PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3 + col_4 + col_5 + col_6 + col_7 + col_8 + col_9 + col_10); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totQta.getResult()), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_11); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totImporti.getResult()), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_12); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); } catch (Exception e) { handleDebug(e); } return this.document; } protected Document creaIntestazioneReport(String titolo, String sottoTitolo) { int cellLeading = 12; int corpoPadding = 2; try { Cell rigaVuota = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); float imgLogoWidth = getDocLogoWidth(); File imgLogoFile = new File(getDocBase() + getDocBase()); if (imgLogoFile.exists()) { Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); imgLogo.setAlignment(5); this.pdfcorpo = new Table(40); this.pdfcorpo.setWidth(100.0F); this.pdfcorpo.setPadding((float)corpoPadding); this.pdfcorpo.setSpacing(0.0F); this.pdfcorpo.setWidths(colWidthsRighe40); this.pdfcorpo.setBorder(0); Cell cell1 = new Cell(); cell1.add(new Chunk(imgLogo, 10.0F, 0.0F)); cell1.setLeading(12.0F); cell1.setBorder(0); cell1.setColspan(16); cell1.setRowspan(1); this.pdfcorpo.addCell(cell1); } Cell cell = new Cell(new Chunk("Report: " + titolo, PdfFontFactory.PDF_fGrandeB)); cell.add(new Chunk("\n\n" + sottoTitolo, PdfFontFactory.PDF_fMedio)); cell.setLeading(12.0F); cell.setBorder(0); cell.setVerticalAlignment(4); cell.setColspan(18); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(" ", PdfFontFactory.PDF_fGrandeB)); cell.setLeading(12.0F); cell.setBorder(0); cell.setVerticalAlignment(6); cell.setColspan(6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.addCell(rigaVuota); this.document.add((Element)this.pdfcorpo); this.pdfcorpo = new Table(40); this.pdfcorpo.setWidth(100.0F); this.pdfcorpo.setPadding((float)corpoPadding); this.pdfcorpo.setSpacing(0.0F); this.pdfcorpo.setWidths(colWidthsRighe40); this.pdfcorpo.setBorder(0); } catch (Exception e) { handleDebug(e); } return this.document; } public String getLinkOrdineWww() { try { return getWwwAddressParm() + "ShowOrdine.abl?idcrypt=" + getWwwAddressParm(); } catch (Exception e) { return "link unavailable!!"; } } public String getLinkOrdineWwwNoReg(Users l_user) { try { return getWwwAddressParm() + "ShowOrdine.abl?idcrypt=" + getWwwAddressParm() + "&uc=" + URLEncoder.encode(getId_documentoCript(), "utf-8"); } catch (Exception e) { return "link unavailable!!"; } } public String getLinkOrdineWwwAuto() { if (getClifor().getUserWww().getId_userProfile() == getClifor().getUserWww().getIdUserProfileNoReg()) return getLinkOrdineWwwNoReg(getClifor().getUserWww()); return getLinkOrdineWww(); } public double getImportoTotaleRigheCorrispettivi() { Vectumerator vec = findRigheDocumento(0, 0, 0); DoubleOperator dop = new DoubleOperator(); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); dop.add(row.getTotImportoRigaConSconto()); } return dop.getResult(); } public static final double scorporaIva(double importo, Iva iva) { DoubleOperator dop = new DoubleOperator((float)iva.getAliquota()); dop.setScale(4, 5); dop.divide(100.0F); dop.add(1); DoubleOperator dop2 = new DoubleOperator(importo); dop2.setScale(4, 5); dop2.divide(dop); dop2.setScale(2, 5); return dop2.getResult(); } public static final String getTipoReport(long l_flgTipoReport) { if (l_flgTipoReport == 0L) return "Vendite del Giorno"; if (l_flgTipoReport == 3L) return "Vendite Giornaliere"; if (l_flgTipoReport == 1L) return "Vendite Completo"; if (l_flgTipoReport == 2L) return "Vendite Compatto"; if (l_flgTipoReport == 4L) return "Ordini Invevasi"; if (l_flgTipoReport == 5L) return "Fatturato"; if (l_flgTipoReport == 6L) return "Vendite servizi"; if (l_flgTipoReport == 7L) return "Giornaliero"; if (l_flgTipoReport == 9L) return "Giornaliero x Nazione"; if (l_flgTipoReport == 8L) return "Dettaglio Documenti"; if (l_flgTipoReport == 10L) return "Dettaglio Documenti con DDT"; return ""; } public static final String getTipoDotocumentoUsato(long l_flg) { if (l_flg == 0L) return "0- No Usato"; if (l_flg == 3L) return "3- Usato Iva"; if (l_flg == 1L) return "1- Usato RM"; if (l_flg == 4L) return "4- Usato iva e Std"; if (l_flg == 2L) return "2- Usato RM e std"; if (l_flg == 5L) return "5- Usato RM e Usato IVA"; if (l_flg == 6L) return "6- Usato RM, Usato IVA e std"; return "??"; } public double getImportoTotale() { return this.importoTotale; } public void setImportoTotale(double importoTotale) { this.importoTotale = importoTotale; } public boolean isDataOkOld() { if (getDBState() == 1 && getFlgStato() == 1L) { Documento bean = new Documento(getApFull()); bean.findByProgressivoEsercizioContatore(getProgDocumento() - 1L, getId_esercizio(), getId_contatore()); if (bean != null && bean.getDBState() == 1) { if (getDateDiff(bean.getDataDocumento(), getDataDocumento()) >= 0L) return true; return false; } return true; } return true; } public void findByProgressivoEsercizioContatore(long l_progDocumento, long l_id_esercizio, long l_id_contatore) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.dataDocumento desc, A.id_esercizio desc, A.progDocumento desc"; WcString wc = new WcString(); wc.addWc("A.flgStato=1"); wc.addWc("A.progDocumento=" + l_progDocumento); wc.addWc("A.id_esercizio=" + l_id_esercizio); wc.addWc("A.id_contatore=" + l_id_contatore); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public static ResParm aggiornaCostoUltimoFornitore(ApplParmFull ap, long l_id_articolo) { ResParm rp = new ResParm(true); int i = 0; int se1 = 10; int se2 = 100; String currentDoc = ""; long l_id_documento = 0L; System.out.println("Ricerca righe documento......."); Vectumerator vec = new RigaDocumento(ap).findAllPerRiordinoMagazzino(l_id_articolo, 0, 0); System.out.println("Num righe documento trovate: " + vec.getTotNumberOfRecords()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (l_id_documento != row.getId_documento()) { currentDoc = row.getDocumento().getNumeroDocumentoCompleto(); l_id_documento = row.getId_documento(); System.out.println("\n" + currentDoc); } if (row.getId_documento() == 0L) { row.delete(); } else { rp = row.savexAggiornaCostoUltimoFornitore(); } i++; if (se1 > 0 && i % se1 == 0) System.out.print("."); if (se2 > 0 && i % se2 == 0) System.out.println(i); if (!rp.getStatus()) { rp.setMsg("ERRORE DOCUMENTO " + row.getDocumento().getNumeroDocumentoCompleto() + "\n" + rp.getMsg()); return rp; } } rp.setMsg("Ripristino magazzino ok"); return rp; } public long getFlgMantieniArticoloRiga() { return this.flgMantieniArticoloRiga; } public void setFlgMantieniArticoloRiga(long flgUltimoArticoloRiga) { this.flgMantieniArticoloRiga = flgUltimoArticoloRiga; } public double getAcconto() { return this.acconto; } public void setAcconto(double acconto) { this.acconto = acconto; } public static String getStatoPrenotazione(long l_flgStatoPrenotazione) { switch ((int)l_flgStatoPrenotazione) { case 10: return "Ordinati"; case 0: return "Accettati"; case 20: return "Arrivati"; case 30: return "Spediti"; case 90: return "Chiusi"; case 100: return "Annullati"; case 200: return "Aperte"; } return "????"; } public static String getStatoPrenotazioneArt(long l_flgStatoPrenotazioneArt) { switch ((int)l_flgStatoPrenotazioneArt) { case 0: return "Da ordinare"; case 20: return "Arrivato parziale"; case 30: return "Arrivato totale"; case 15: return "Ordinato parziale"; case 10: return "Ordinato totale"; } return "????"; } public long getFlgStatoPrenotazione() { return this.flgStatoPrenotazione; } public void setFlgStatoPrenotazione(long flgStatoPrenotazione) { this.flgStatoPrenotazione = flgStatoPrenotazione; } public boolean isDocumentoFiglioCreabile() { if (getTipoDocumento().getTipologiaDocumento().getFlgGestioneSeparata() == 0L) { if (getTipoDocumento().getTipologiaDocumento().getCodice() == 200L) { if (getPrezzo1000Colpi() != 0.0D) { long pezzeFatturate = getPezzeTotaliFatturate(); long pezzeInviate = getPezzeTotaliInviate(); if (pezzeInviate > pezzeFatturate) return true; return false; } return false; } if (getTipoDocumento().findDocGen(0L, 0L, 1, 1).hasMoreElements()) { RigaDocumento rd = new RigaDocumento(getApFull()); return !rd.isAllRighePrelevateByDocumento(getId_documento()); } return false; } return false; } public boolean isDocumentoWwwNonPagato() { if (getFlgStatoOrdineWww() == 99L || getFlgPagata() == 1L) return false; return true; } public boolean isOrdineWww() { if (getId_tipoDocumento() == getParm("ID_DOC_ORDINE_WWW").getNumeroLong()) return true; return false; } public boolean hasRigheDocumento() { Vectumerator vec = findRigheDocumento(1, 1, 0); if (vec.hasMoreElements()) return true; return false; } protected void creaDocumentoCorpoDDT(Document l_document, Table l_pdfCorpo) { int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); if (righePerPagina <= 0) righePerPagina = 10; int maxCarDesc = (int)getTipoDocumento().getMaxCarDesc(); if (maxCarDesc == 0) maxCarDesc = 35; int riga = 0; int cellLeadingRow = getDocLeadRow(); if (cellLeadingRow == 0) cellLeadingRow = 12; Font PDF_frow = getTipoDocumento().getPdfFontRow(); NumberFormat nf = getNf(); int ordinamentoRighe = (int)getTipoDocumento().getFlgOrdinamentoRigheStampa(); Vectumerator vec = findRigheDocumento(0, 0, ordinamentoRighe); try { String str1; String currentDescRigaRagg = ""; if (!getPudoId().isEmpty()) { str1 = "Fermo Point BRT\n" + getPudoDesc() + "\n" + getNote(); } else { str1 = getNote(); } if (!getPudoId().isEmpty()) { str1 = "Fermo Point BRT\n" + getPudoDesc() + "\n" + getNote(); } else { str1 = getNote(); } ArrayList alNote = RigaDocumentoItemPdf.getArrayListNota(str1, 0, cols_DDT_, PDF_frow); if (getDocPosizioneNota() == 0L) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_rigaDocumento() == 18463L) System.out.println("creaDocumentoCorpoDDT: " + row.getId_rigaDocumento()); double quantita = row.getQuantita(); if (ordinamentoRighe == 3 && !row.getDescrizioneRigaRaggruppamento().isEmpty()) { if (!currentDescRigaRagg.equals(row.getDescrizioneRigaRaggruppamento())) { currentDescRigaRagg = row.getDescrizioneRigaRaggruppamento(); ArrayList arrayList1 = new ArrayList<>(); arrayList1.add(new RigaDocumentoItemPdf(30, currentDescRigaRagg, PDF_frow)); arrayList1.add(new RigaDocumentoItemPdf(10, " ", PDF_frow, 2)); riga = inserisciRigaDocumento(arrayList1, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); } String str = row.getDescrizioneRigaDettaglio(); if (!row.getNotaRigaDocumento().isEmpty()) str = str + " " + str; ArrayList arrayList = new ArrayList<>(); arrayList.add(new RigaDocumentoItemPdf(30, str, PDF_frow)); arrayList.add(new RigaDocumentoItemPdf(10, nf.format(quantita), PDF_frow, 2)); riga = inserisciRigaDocumento(arrayList, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); continue; } String desc = row.getDescrizioneRigaCompleta(); if (!row.getNotaRigaDocumento().isEmpty()) desc = desc + " " + desc; ArrayList dati = new ArrayList<>(); dati.add(new RigaDocumentoItemPdf(cols_DDT_[0], desc, PDF_frow)); dati.add(new RigaDocumentoItemPdf(cols_DDT_[1], nf.format(quantita), PDF_frow, 2)); riga = inserisciRigaDocumento(dati, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); } if (getDocPosizioneNota() == 1L && !str1.isEmpty()) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); if (righePerPagina - riga > 0) riga = inserisciRigheVuote(righePerPagina - riga, cols_DDT_, riga, l_document, l_pdfCorpo, cellLeadingRow); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoIntestazioneCorpoDDT(Table l_pdfCorpo) { int cellLeading = 8; try { Cell cell = new Cell(); cell.addElement(new Chunk("DESCRIZIONE", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_DDT_[0]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("QUAN.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_DDT_[1]); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoIntestazioneCorpoFtSemplice(Table l_pdfCorpo) { int cellLeading = 8; try { Cell cell = new Cell(); cell.addElement(new Chunk("DESCRIZIONE", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[0] + cols_FT_STD_[1] + cols_FT_STD_[2] + cols_FT_STD_[3]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPORTO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[4]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IVA", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[5]); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoFooterDDTFirme(Table l_pdfCorpo, boolean isUltimaPagina) { try { int cellLeading = 8; NumberFormat nf = getNf(); Cell cell = new Cell(); if (isUltimaPagina) { cell.add(new Chunk("Pregasi controllare bene l'esatta intestazione del documento e della partita iva. In caso di errata intestazione non ci terremo responsabili in solido come previsto dall'art. 41 DPR 28/10/72 rif 833", PdfFontFactory.PDF_fPiccolissimo)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(20); cell.setRowspan(1); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("DATA E ORA TRASP.\n", PdfFontFactory.PDF_fPiccolissimo)); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(1); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("FIRMA CONDUCENTE\n", PdfFontFactory.PDF_fPiccolissimo)); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); cell.setRowspan(1); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("FIRMA DESTINATARIO\n", PdfFontFactory.PDF_fPiccolissimo)); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); cell.setRowspan(1); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } protected void creaDocumentoFooterFattureSemplici(Table l_pdfCorpo, boolean isUltimaPagina) { int cellLeading = 8; NumberFormat nf = getNf(); RigheRegistroIva rri = getRigaRegistroIvaCompleto(); String codIva = "", imponibile = "", aliquota = "", imposta = ""; if (rri != null) { Enumeration enuRrri = rri.elementsFatt(); while (enuRrri.hasMoreElements()) { RigaRegistroIvaItem rrii = enuRrri.nextElement(); if (rrii.getImponibile() != 0.0D) { if (getFlgArt8() == 1L) { imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n0"; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; continue; } imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n" + imposta; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; } } } try { Cell cell = new Cell(new Chunk("ALIQ.", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(codIva, PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPONIBILE", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imponibile, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPOSTA\t", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imposta, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); cell.setRowspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(16); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE NETTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImponibileTotale() != 0.0D) { cell.add(new Chunk(nf.format(getImponibileTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SCADENZE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && !getNotePagamento().isEmpty()) { cell.add(new Chunk(getNotePagamento(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(23); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("\n", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPONIBILE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getImponibileTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPOSTA\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getImportoIvaTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("\n", PdfFontFactory.PDF_fPiccolissimo)); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(16); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } protected void creaDocumentoFooterDDT(Table l_pdfCorpo, boolean isUltimaPagina) { try { int cellLeading = 8; NumberFormat nf = getNf(); Cell cell = new Cell(new Chunk("TRASPORTO A CURA\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && !getTrasporto().isEmpty()) { cell.add(new Chunk(getTrasporto(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("CAUSALE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getId_causaleTrasporto() != 0L) { cell.add(new Chunk(getCausaleTrasporto().getDescrizione(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PESO LORDO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getKgLordo() != 0.0D) { cell.add(new Chunk(nf.format(getKgLordo()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PESO NETTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getKgNetto() != 0.0D) { cell.add(new Chunk(nf.format(getKgNetto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PORTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getId_porto() != 0L) { cell.add(new Chunk(getPorto().getDescrizione(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("ASPETTO ESTERIORE BENI\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getId_aspetto() != 0L) { cell.add(new Chunk(getAspetto().getDescrizione(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("VOLUME\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getVolume() != 0.0D) { cell.add(new Chunk(nf.format(getVolume()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("COLLI\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getNColli() != 0L) { cell.add(new Chunk(nf.format(getNColli()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("Q.tà Articoli\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getQuantitaTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getQuantitaTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("VETTORE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getId_vettore() != 0L) { StringBuilder vett = new StringBuilder(); vett.append(getVettore().getDescrizione()); if (!getVettore().getIndirizzo().isEmpty()) { vett.append(" "); vett.append(getVettore().getIndirizzo()); } if (!getVettore().getCodFiscale().isEmpty()) { vett.append(" C.F. "); vett.append(getVettore().getCodFiscale()); } if (!getVettore().getPIva().isEmpty()) { vett.append(" P.I. "); vett.append(getVettore().getPIva()); } vett.append("\n"); if (!getVettore().getIscrizioneAlbo().isEmpty()) { vett.append("Iscr. Albo "); vett.append(getVettore().getIscrizioneAlbo()); } if (!getNotaSpedizione().isEmpty()) vett.append(getNotaSpedizione()); cell.add(new Chunk(vett.toString(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(28); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("DATA RITIRO\n", PdfFontFactory.PDF_fPiccolissimo)); cell.add(new Chunk("xx", PdfFontFactory.PDF_fPiccoloBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("FIRMA VETTORE\n", PdfFontFactory.PDF_fPiccolissimo)); cell.add(new Chunk("xx", PdfFontFactory.PDF_fPiccoloBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } public long getNumPagDocumento() { return this.numPagDocumento; } public void setNumPagDocumento(long numPagDocumento) { this.numPagDocumento = numPagDocumento; } public String getDescrizioneRigheHtmlOld() { StringBuffer temp = new StringBuffer(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); temp.append(""); temp.append(getNf().format(row.getQuantita())); temp.append(" "); temp.append(row.getDescrizioneRigaCompleta()); temp.append(""); if (row.getId_articolo() != 0L) { temp.append(" nr."); temp.append(getNf().format(row.getArticolo().getQuantitaEffettiva())); temp.append(" ("); temp.append(getNf().format(row.getArticolo().getQuantita())); temp.append(")"); } if (vec.hasMoreElements()) temp.append("
"); } return temp.toString(); } public void setAbbuono(double abbuono) { this.abbuono = abbuono; } public double getKgNetto() { return this.kgNetto; } public void setKgNetto(double kgNetto) { this.kgNetto = kgNetto; } public double getVolume() { return this.volume; } public double getVolumeM3() { return (getId_documento() == 0L) ? 0.0D : new RigaDocumento(getApFull()).getVolumeM3ByDocumento(getId_documento()); } public long getVolumeCm3() { return (getId_documento() == 0L) ? 0L : new RigaDocumento(getApFull()).getVolumeCm3ByDocumento(getId_documento()); } public void setVolume(double volume) { this.volume = volume; } public CausaleTrasporto getCausaleTrasporto() { this.causaleTrasporto = (CausaleTrasporto)getSecondaryObject(this.causaleTrasporto, CausaleTrasporto.class, getId_causaleTrasporto()); return this.causaleTrasporto; } public void setCausaleTrasporto(CausaleTrasporto causaleTrasporto) { this.causaleTrasporto = causaleTrasporto; } public long getId_causaleTrasporto() { return this.id_causaleTrasporto; } public void setId_causaleTrasporto(long id_causaleTrasporto) { this.id_causaleTrasporto = id_causaleTrasporto; setCausaleTrasporto(null); } public double getSpeseIncasso() { return this.speseIncasso; } public void setSpeseIncasso(double speseIncasso) { this.speseIncasso = speseIncasso; } public double getTotaleDaPagare() { DoubleOperator temp = new DoubleOperator(getTotaleDocumento()); temp.subtract(getAcconto()); temp.setScale(2, 5); return temp.getResult(); } public String getBancaDesc() { return (this.bancaDesc == null) ? "" : this.bancaDesc.trim(); } public String getEMailDocumento() { return (this.eMailDocumento == null) ? "" : this.eMailDocumento.trim(); } public void setBancaDesc(String banca) { this.bancaDesc = banca; } public void setEMailDocumento(String cellulare) { this.eMailDocumento = cellulare; } public Vectumerator findRigheDocumento(long l_flgCodiceRiga, int pageNumber, int pageRows, int ordinamentoRiga) { return new RigaDocumento(getApFull()).findByDocumento(getId_documento(), l_flgCodiceRiga, "", pageNumber, pageRows, ordinamentoRiga); } public Vectumerator findRigheDocumentoOBRiferimento(int pageNumber, int pageRows) { return new RigaDocumento(getApFull()).findByDocumento(getId_documento(), 0L, "", pageNumber, pageRows, 10); } public Vectumerator findRigheDocumento(int pageNumber, int pageRows, int ordinamentoRiga) { return findRigheDocumento(0L, pageNumber, pageRows, ordinamentoRiga); } public Vectumerator findRigheDocumento2(int pageNumber, int pageRows, int ordinamentoRiga) { return findRigheDocumento(1L, pageNumber, pageRows, ordinamentoRiga); } public Vectumerator findRigheDocumentoByArticoloArticoloVariante(long l_id_articolo, long l_id_articoloVariante) { return new RigaDocumento(getApFull()).findByDocumentoArticoloArticoloVariante(getId_documento(), l_id_articolo, l_id_articoloVariante); } public void setId_contatore(long id_contatore) { this.id_contatore = id_contatore; } public String getStatoPrenotazione() { return getStatoPrenotazione(getFlgStatoPrenotazione()); } public String getStatoCompleto() { StringBuffer res = new StringBuffer(); if (getTipoDocumento().getFlgTipologia() == 210L || getTipoDocumento().getFlgTipologia() == 220L || getTipoDocumento().getFlgTipologia() == 200L) { res.append(getStatoLavorazione()); res.append(" - "); } if (getTipoDocumento().getFlgTipologia() == 4L) { res.append(getStatoPrenotazione()); res.append(" - "); } if (getTipoDocumento().getFlgTipoDocumentoPrelevabile() == 1L && getTipoDocumento().getFlgObbligoPrelievo() == 1L) { if (getFlgDocumentoPrelevato() == 1L) { res.append("Chiuso"); } else { res.append("Aperto"); } res.append(" - "); } if (getId_tipoDocumento() == 1L) { if (getEchoScontrino().isEmpty() && getFlgEmettiFatturaScontrino() == 0L) { res.append("Scontrino non emesso"); res.append(" - "); } } else if (getTipoDocumento().getFlgTipologia() == 1L || getTipoDocumento().getFlgTipologia() == 2L) { if (getFlgPagata() == 1L) { res.append("Pagata"); if (getDataPagamento() != null) res.append(" " + getDataFormat().format(getDataPagamento())); } else { res.append("NON Pagata"); } } else if (getTipoDocumento().getFlgTipologia() == 0L) { res.append(getStato()); } if (getId_tipoDocumento() == getId_docOrdine()) { res.append(getDocumentoPrelevato()); res.append(" - "); } if (isOrdineWww()) { res.append(getStatoOrdineWww()); res.append(" - "); if (getFlgPagata() == 1L) { res.append("Pagata"); if (getDataPagamento() != null) res.append(" " + getDataFormat().format(getDataPagamento())); } else { res.append("NON Pagata"); } } else if (getTipoDocumento().getFlgTipologia() == 3L) { res.append(getStatoOrdineWww()); res.append(" - "); if (getFlgPagata() == 1L) { res.append("Pagata"); if (getDataPagamento() != null) res.append(" " + getDataFormat().format(getDataPagamento())); } else { res.append("NON Pagata"); } } return res.toString(); } public String getIban() { return (this.iban == null) ? "" : this.iban.trim(); } public void setIban(String iban) { this.iban = iban; } public String getAbiCF() { if (getIbanCF().length() < 11) return "??"; return getIbanCF().substring(5, 10); } public String getCab() { if (getIban().length() < 16) return "??"; return getIban().substring(10, 15); } public String getConto() { if (getIban().length() < 27) return "??"; return getIban().substring(15); } public void findPrimoScontrinoAperto(long l_id_user) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.dataDocumento desc, A.id_esercizio desc, A.progDocumento desc"; WcString wc = new WcString(); wc.addWc("A.id_tipoDocumento=1"); if (l_id_user != 0L) wc.addWc("A.lastUpdId_user=" + l_id_user); wc.addWc("(A.echoScontrino is null or A.echoScontrino ='')"); wc.addWc("(A.flgEmettiFatturaScontrino is null or A.flgEmettiFatturaScontrino =0)"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public String getNotePagamento() { return (this.notePagamento == null) ? "" : this.notePagamento.trim(); } public void setNotePagamento(String notePagamento) { this.notePagamento = notePagamento; } public long getId_destinazioneDiversa() { return this.id_destinazioneDiversa; } public void setId_destinazioneDiversa(long id_destinazioneDiversa) { this.id_destinazioneDiversa = id_destinazioneDiversa; setDestinazioneDiversa(null); } public DestinazioneDiversa getDestinazioneDiversa() { this.destinazioneDiversa = (DestinazioneDiversa)getSecondaryObject(this.destinazioneDiversa, DestinazioneDiversa.class, getId_destinazioneDiversa()); return this.destinazioneDiversa; } public void setDestinazioneDiversa(DestinazioneDiversa destinazioneDiversa) { this.destinazioneDiversa = destinazioneDiversa; } public ResParm impostaFlgPagata(long l_flgPagata) { if (getDBState() == 1) { setFlgPagata(l_flgPagata); return super.save(); } return new ResParm(false, "Errore. Documento non valido."); } public String getDescDocumenti() { return (this.descDocumenti == null) ? "" : this.descDocumenti.trim(); } public void setDescDocumenti(String descDocumenti) { this.descDocumenti = descDocumenti; } public String getProgDocumentoAgg() { return (this.progDocumentoAgg == null) ? "" : this.progDocumentoAgg; } public void setProgDocumentoAgg(String progDocumentoAgg) { this.progDocumentoAgg = progDocumentoAgg; } protected boolean useNullForString() { return false; } public ByteArrayOutputStream creaLabelDocumentoArticoliAccA4Pdf(DocumentoCR CR) { long pHMarg = getParm("LABEL_ART_A4_MARGINE").getNumeroLong(); ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { this.document = new Document(PageSize.A4, 0.0F, 0.0F, 10.0F, -20.0F); this.writer = PdfWriter.getInstance(this.document, ba); String titoloReport = getNumeroDocumentoCompleto(); SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.document.open(); long labelNumber = 0L; String dim = getParm("LABEL_ART_A4_COL_ROW").getTesto(); int nCol = Integer.parseInt(dim.substring(0, dim.indexOf(','))); int nRow = Integer.parseInt(dim.substring(dim.indexOf(',') + 1)); this.pdfPcorpo = new PdfPTable(nCol); this.pdfPcorpo.setWidthPercentage(100.0F); Documento doc = new Documento(getApFull()); doc.findByPrimaryKey(CR.getId_documentoS()); if (doc.hasLabelAccessoriDaStampare()) { if (CR.getBlankLabels() > 0L) { PdfPCell pdfPCell = new PdfPCell(); pdfPCell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); pdfPCell.setBorder(0); for (int i = 0; (long)i < CR.getBlankLabels(); i++) { labelNumber++; this.pdfPcorpo.addCell(pdfPCell); } } Vectumerator vec = findByCR(CR, 0, 0); long numbOfLabels = 1L; while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vecRighe = row.findRigheDocumento(0, 0, ordineInverso); while (vecRighe.hasMoreElements()) { RigaDocumento rowRD = (RigaDocumento)vecRighe.nextElement(); if (rowRD.getFlgUdm() == 1L) { numbOfLabels = (long)rowRD.getQuantita(); } else { numbOfLabels = 1L; } rowRD.getArticolo().setWriter(getWriter()); rowRD.getArticolo().setPdfPcorpo(getPdfPcorpo()); String descLabel = rowRD.getDescrizioneRigaCompleta(); numbOfLabels = (long)rowRD.getArticolo().addLabelUnArticoloAccA4Pdf(nRow, numbOfLabels, labelNumber, descLabel); labelNumber += numbOfLabels; } } long numberBlankCell = (long)nCol - labelNumber % (long)nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); if (numberBlankCell != (long)nCol) for (int i = 0; (long)i < numberBlankCell; i++) this.pdfPcorpo.addCell(cell); } else { Phrase ph = new Phrase("Attenzione! Non ci sono etichette da stampare!"); PdfPCell cell = new PdfPCell(ph); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); cell.setColspan(nCol); this.pdfPcorpo.addCell(cell); } this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public boolean hasLabelAccessoriDaStampare() { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getArticolo().getFlgStampaAccessoriT() == 1L) return true; } return false; } public Date getDataAvviso() { return this.dataAvviso; } public void setDataAvviso(Date dataAvviso) { this.dataAvviso = dataAvviso; } public Date getDataChiusura() { return this.dataChiusura; } public void setDataChiusura(Date dataChiusura) { this.dataChiusura = dataChiusura; } public long getId_users() { return this.id_users; } public Users getUsers() { this.users = (Users)getSecondaryObject((DBAdapter)this.users, Users.class, getId_users()); return this.users; } public void setId_users(long newId_users) { this.id_users = newId_users; setUsers(null); } public void setUsers(Users users) { this.users = users; } public String getNominativoDocumento() { return (this.nominativoDocumento == null) ? "" : this.nominativoDocumento; } public ResParm sendAvvisoRiparazione() { ResParm rp = new ResParm(true); String msg = ""; if (getId_documento() == 0L || getFlgInviaAvviso() == 0L) { rp.setMsg("Errore! Impossibile inviare avviso."); rp.setStatus(false); } else { msg = ""; } if (!getEMailDocumento().isEmpty()) { MailMessage mm = new MailMessage(getApFull()); if (getId_tipoDocumento() == getId_docRiparazione()) { mm.setTextMessage(getMessaggioAvvisoRiparazioneEmail()); } else { mm.setTextMessage(getMessaggioAvvisoPrenotazioneEmail()); } mm.setString("cliente", getNominativoDocumento()); mm.setString("ndocumento", getNumeroDocumentoCompleto()); MailProperties mp = new MailProperties(); mp.setProperty("TO", getEMailDocumento()); if (getId_tipoDocumento() == getId_docRiparazione()) { mp.setProperty("SUBJECT", getMailSubject() + " - Avviso riparazione"); } else { mp.setProperty("SUBJECT", getMailSubject() + " - Avviso arrivo prenotazione"); } mp.setProperty("MSG", mm.getMessage()); rp = mm.sendMailMessage(mp, true); if (rp.getStatus()) rp.append(aggiornaDataAvviso(getToday())); } if (!getCellDocumento().isEmpty()) { MailMessage mm = new MailMessage(getApFull()); if (getId_tipoDocumento() == getId_docRiparazione()) { mm.setTextMessage(getMessaggioAvvisoRiparazioneSms()); } else { mm.setTextMessage(getMessaggioAvvisoPrenotazioneSms()); } mm.setString("cliente", getNominativoDocumento()); mm.setString("ndocumento", getNumeroDocumentoCompleto()); CodaMessaggi cm = new CodaMessaggi(getApFull()); cm.setDataCreazione(getToday()); cm.setCellulare(getCellDocumento()); cm.setTestoMessaggio(mm.getMessage()); cm.setFlgTipo(2L); cm.setFlgStatoInvio(0L); rp = cm.save(); if (rp.getStatus()) rp.append(aggiornaDataAvviso(getToday())); } return rp; } public double getAbbuono() { return this.abbuono; } public static final Hashtable getTipoDocumentoHT(ApplParmFull ap) { if (tipoDocumentoHT == null) { tipoDocumentoHT = new Hashtable(); Vectumerator vec = new TipoDocumento(ap).findAll(); while (vec.hasMoreElements()) { TipoDocumento row = (TipoDocumento)vec.nextElement(); row.getCausaleMagazzino(); tipoDocumentoHT.put(new Long(row.getId_tipoDocumento()), row); } } return tipoDocumentoHT; } public String getCellDocumento() { return (this.cellDocumento == null) ? "" : this.cellDocumento.trim(); } public void setCellDocumento(String telDocumento) { this.cellDocumento = telDocumento; } public long getFlgInviaAvviso() { return this.flgInviaAvviso; } public void setFlgInviaAvviso(long flgInviaAvviso) { this.flgInviaAvviso = flgInviaAvviso; } public static final String getInviaAvviso(long l_flgInviaAvviso) { switch ((int)l_flgInviaAvviso) { case 1: return "Email"; case 2: return "Sms"; } return "No"; } public String getInviaAvviso() { return getInviaAvviso(getFlgInviaAvviso()); } public ResParm aggiornaStatoPrenotazione(long l_flgStatoPrenotazionePrecedente, long l_flgStatoPrenotazione) { if (getId_tipoDocumento() == getId_docPrenotazione()) { if (l_flgStatoPrenotazionePrecedente != l_flgStatoPrenotazione) { String noteTemp = " \n" + getStatoPrenotazione(l_flgStatoPrenotazione) + " in data " + String.valueOf(getToday()); setNote(getNote() + getNote()); } setFlgStatoPrenotazione(l_flgStatoPrenotazione); if (l_flgStatoPrenotazione == 90L || l_flgStatoPrenotazione == 100L) { setDataChiusura(getToday()); } else { setDataChiusura(null); setDataRestituzioneAcconto(null); } } ResParm rp = super.save(); if (rp.getStatus()) { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_articolo() > 0L) { row.getArticolo().resetCalcoloQuantita(); row.resetStatoPrenotazioneByArticolo(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia()); } } } return rp; } public double getPercContIntegrativo() { return this.percContIntegrativo; } public void setPercContIntegrativo(double percContIntegrativo) { this.percContIntegrativo = percContIntegrativo; } public double getPercRitenutaAcconto() { return this.percRitenutaAcconto; } public void setPercRitenutaAcconto(double percRitenutaAcconto) { this.percRitenutaAcconto = percRitenutaAcconto; } public double getRimborsoArt15() { return this.rimborsoArt15; } public void setRimborsoArt15(double rimborsoArt15) { this.rimborsoArt15 = rimborsoArt15; } protected void creaDocumentoIntestazioneCorpoFtPro(Table l_pdfCorpo) { int cellLeading = 8; try { Cell cell = new Cell(); cell.addElement(new Chunk("DESCRIZIONE", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[0]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("QUAN.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[1]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PREZZO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[2]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SC.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[3]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPORTO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[4]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IVA", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[5]); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoFooterFatturePro(Table l_pdfCorpo, boolean isUltimaPagina) { int cellLeading = 8; NumberFormat nf = getNf(); RigheRegistroIva rri = getRigaRegistroIvaCompleto(); String codIva = "", imponibile = "", aliquota = "", imposta = ""; if (rri != null) { Enumeration enuRrri = rri.elementsFatt(); while (enuRrri.hasMoreElements()) { RigaRegistroIvaItem rrii = enuRrri.nextElement(); if (rrii.getImponibile() != 0.0D) { if (getFlgArt8() == 1L) { imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n0"; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; continue; } imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n" + imposta; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; } } } try { Cell cell = new Cell(new Chunk("ALIQ.", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(codIva, PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPONIBILE", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imponibile, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPOSTA\t", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imposta, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); cell.setRowspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE FATTURA\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImponibileRighe() != 0.0D) { cell.add(new Chunk(nf.format(getImponibileRighe()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("CONTRIBUTO INTEGRATIVO " + getPercContIntegrativo() + "%\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImportoContIntegrativo() != 0.0D) { cell.add(new Chunk(nf.format(getImportoContIntegrativo()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(16); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE IMP. FATTURA\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImponibileTotale() != 0.0D) { cell.add(new Chunk(nf.format(getImponibileTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(23); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IVA TOTALE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImportoIvaTotale() != 0.0D) { cell.add(new Chunk(nf.format(getImportoIvaTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("RIMBORSI SPESE ART. 15\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getRimborsoArt15() != 0.0D) { cell.add(new Chunk(nf.format(getRimborsoArt15()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE COMPLESSIVO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleDocumentoSenzaRitenuta() != 0.0D) { cell.add(new Chunk(nf.format(getTotaleDocumentoSenzaRitenuta()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("\n", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPONIBILE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getImponibileTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPOSTA\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getImportoIvaTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("RITENUTA D'ACCONTO " + getPercRitenutaAcconto() + "%\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImportoRitenutaAcconto() != 0.0D) { cell.add(new Chunk(nf.format(getImportoRitenutaAcconto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(16); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } public double getImportoContIntegrativo() { if (getPercContIntegrativo() == 0.0D) return 0.0D; DoubleOperator ci = new DoubleOperator(getRigaRegistroIva().getTotImponibile()); ci.setScale(4, 5); ci.multiply(getPercContIntegrativo()); ci.divide(100.0F); ci.setScale(2, 1); return ci.getResult(); } public void setRigaRegistroIva(RigheRegistroIva rigaRegistroIva) { this.rigaRegistroIva = rigaRegistroIva; } public void setRigaRegistroIvaCompleto(RigheRegistroIva rigaRegistroIvaCompleto) { this.rigaRegistroIvaCompleto = rigaRegistroIvaCompleto; } public double getTotaleDocumentoSenzaRitenuta() { if (getTipoDocumento().getFlgCorrispettivi() == 0L) { DoubleOperator temp = new DoubleOperator(getImponibileTotale()); temp.add(getImportoIvaTotale()); if (getTipoDocumento().isTipoFatturaProfessionisti()) temp.add(getRimborsoArt15()); temp.setScale(2, 5); return temp.getResult(); } return getImportoTotale(); } public double getImportoRitenutaAcconto() { if (getPercRitenutaAcconto() == 0.0D) return 0.0D; DoubleOperator ci = new DoubleOperator(getImponibileRighe()); ci.setScale(4, 5); ci.multiply(getPercRitenutaAcconto()); ci.divide(100.0F); ci.setScale(2, 1); return ci.getResult(); } protected void creaDocumentoIntestazioneS(Table l_pdfCorpo) { Font pdfFont = getTipoDocumento().getPdfFont(); Font pdfFontMedio = getTipoDocumento().getPdfFont(2); Font pdfFontPiccolo = getTipoDocumento().getPdfFont(-2); Font pdfFontGrande = getTipoDocumento().getPdfFont(4); Font pdfFontHF = getTipoDocumento().getPdfFontHeaderFooter(); try { String descDestinazione; int cellLeading = 8; SimpleDateFormat df = getDataFormat(); float imgLogoWidth = getDocLogoWidth(); Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); if (imgLogoWidth > 0.0F) imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); Cell cell = new Cell(); cell.addElement(new Chunk(imgLogo, 0.0F, 0.0F)); Paragraph paragraph = creaParagrafoConGrassetto("\n" + getHeaderDoocumento(1) + "\n" + getHeaderDoocumento(2), PDF_fPiccolo, PDF_fPiccoloB); paragraph.setLeading(10.0F); cell.addElement((Element)paragraph); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); l_pdfCorpo.addCell(cell); String descCliente = getClifor().getCognomeNome() + "\n"; String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); descCliente = descCliente + descCliente + " n." + getClifor().getIndirizzo() + "\n" + getClifor().getNumeroCivico() + " " + capComune + " (" + getClifor().getDescrizioneComune() + ")\nP.Iva/Cod. Fisc " + getClifor().getProvinciaComune() + " / " + getClifor().getPIva(); if (getId_destinazioneDiversa() == 0L) { if (getParm("DESTINAZIONE").getNumeroLong() == 1L) { descDestinazione = "IDEM\n\n"; } else { descDestinazione = ""; } } else { descDestinazione = getClifor().getCognomeNome() + "\n"; if (!getDestinazioneDiversa().getPressoDD().isEmpty()) descDestinazione = descDestinazione + "c/o " + descDestinazione + "\n"; descDestinazione = descDestinazione + descDestinazione + " n." + getDestinazioneDiversa().getIndirizzoDD() + "\n" + getDestinazioneDiversa().getNumeroCivicoDD() + " " + getDestinazioneDiversa().getCapComuneDD() + " (" + getDestinazioneDiversa().getComuneDD().getDescrizione() + ")\n "; } cell = new Cell(); cell.addElement(new Chunk("\n\nSPETT.LE\n\n", pdfFont)); cell.addElement(new Chunk(descCliente, pdfFontGrande)); cell.addElement(new Chunk("\nDESTINAZIONE\n", pdfFont)); cell.addElement(new Chunk(descDestinazione, pdfFontGrande)); cell.setVerticalAlignment(4); cell.setLeading(12.0F); cell.setBorder(0); cell.setRowspan(3); cell.setColspan(18); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("\n\nDATA", pdfFontMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("\n\n" + df.format(getDataDocumento()), pdfFontMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(17); l_pdfCorpo.addCell(cell); cell = new Cell(); if (getFlgStato() == 0L) { cell.addElement(new Chunk("BOZZA", pdfFontMedio)); } else if (getFlgStato() == 2L) { cell.addElement(new Chunk("PROFORMA", pdfFontMedio)); } else { cell.addElement(new Chunk(getTipoDocumento().getDescrizioneStampa(), pdfFontMedio)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("N. " + String.valueOf(getNumeroDocumento()), pdfFontMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(11); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Pag. ", pdfFontPiccolo)); cell.addElement(new Chunk(getNf0().format(getNumPagDocumento()), pdfFontPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("xx", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); cell.setRowspan(1); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("xx", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); cell.setRowspan(1); l_pdfCorpo.addCell(cell); creaDocumentoIntestazioneCorpoFtProS(l_pdfCorpo); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoFooterFattureProS(Table l_pdfCorpo, boolean isUltimaPagina) { Font PDF_font = getTipoDocumento().getPdfFont(); Font PDF_fontGrande = getTipoDocumento().getPdfFont(2); int cellLeading = 14; NumberFormat nf = getNf(); RigheRegistroIva rri = getRigaRegistroIvaCompleto(); String codIva = "", imponibile = "", aliquota = "", imposta = ""; if (rri != null) { Enumeration enuRrri = rri.elementsFatt(); while (enuRrri.hasMoreElements()) { RigaRegistroIvaItem rrii = enuRrri.nextElement(); if (rrii.getImponibile() != 0.0D) { if (getFlgArt8() == 1L) { imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n0"; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; continue; } imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n" + imposta; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; } } } try { Cell cell = new Cell(); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorderWidthBottom(2.0F); cell.setBorderColorLeft(Color.white); cell.setBorderColorTop(Color.white); cell.setBorderColorRight(Color.white); cell.setBorderColorBottom(Color.gray); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(15); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE FATTURA", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("€", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(nf.format(getImponibileRighe()), PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(15); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("CONTRIBUTO INTEGRATIVO " + nf.format(getPercContIntegrativo()) + "%", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("€", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(nf.format(getImportoContIntegrativo()), PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(15); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPONIBILE", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("€", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(nf.format(getImponibileTotale()), PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(15); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IVA", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("€", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(nf.format(getImportoIvaTotale()), PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(15); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("RIMBORSI SPESE ART. 15", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("€", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(nf.format(getRimborsoArt15()), PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(15); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE COMPLESSIVO", PDF_fontGrande)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("€", PDF_fontGrande)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(nf.format(getTotaleDocumentoSenzaRitenuta()), PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(15); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("RITENUTA D'ACCONTO " + nf.format(getPercRitenutaAcconto()) + "%", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("€", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(nf.format(getImportoRitenutaAcconto()), PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(15); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("NETTO DA PAGARE", PDF_fontGrande)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorderWidthTop(2.0F); cell.setBorderColorLeft(Color.white); cell.setBorderColorTop(Color.gray); cell.setBorderColorRight(Color.white); cell.setBorderColorBottom(Color.gray); cell.setColspan(14); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk("€", PDF_font)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorderWidthTop(2.0F); cell.setBorderColorLeft(Color.white); cell.setBorderColorTop(Color.gray); cell.setBorderColorRight(Color.white); cell.setBorderColorBottom(Color.gray); cell.setColspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.add(new Chunk(nf.format(getTotaleDocumento()), PDF_fontGrande)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorderWidthTop(2.0F); cell.setBorderColorLeft(Color.white); cell.setBorderColorTop(Color.gray); cell.setBorderColorRight(Color.white); cell.setBorderColorBottom(Color.gray); cell.setColspan(9); l_pdfCorpo.addCell(cell); if (!getFooterDocumento(1).isEmpty()) { String temp; cell = new Cell(); if (!getFooterDocumento(2).isEmpty()) { temp = getFooterDocumento(1) + "\n" + getFooterDocumento(1); } else { temp = getFooterDocumento(1); } cell.add(new Chunk("\n\n\n\n\n\n\n\n\n" + temp, getTipoDocumento().getPdfFontHeaderFooter())); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); } } catch (Exception e) { handleDebug(e, 2); } } protected void creaDocumentoIntestazioneCorpoFtProS(Table l_pdfCorpo) { int cellLeading = 8; Font pdfFont = getTipoDocumento().getPdfFont(); try { Cell cell = new Cell(); cell.addElement(new Chunk("DESCRIZIONE", pdfFont)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(30); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("ONORARI", pdfFont)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(10); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoFooterDDTTotale(Table l_pdfCorpo, boolean isUltimaPagina) { try { int cellLeading = 8; NumberFormat nf = getNf(); Cell cell = new Cell(); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(28); cell.setRowspan(1); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setColspan(12); cell.setRowspan(1); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } public Date getDataScadenzaPagamento() { return this.dataScadenzaPagamento; } public void setDataScadenzaPagamento(Date dataScadenzaPagamento) { this.dataScadenzaPagamento = dataScadenzaPagamento; } public long getFlgPagamentoDataFissa() { return this.flgPagamentoDataFissa; } public void setFlgPagamentoDataFissa(long flgPagamentoDataFissa) { this.flgPagamentoDataFissa = flgPagamentoDataFissa; } public String getPagamentoDataFissa() { return TipoPagamento.getTipoPagamento(getFlgPagamentoDataFissa()); } public static final String getPagamentoDataFissa(long l_flg) { return TipoPagamento.getTipoPagamento(l_flg); } public long getFlgHaDocumentoPadre() { return this.flgHaDocumentoPadre; } public void setFlgHaDocumentoPadre(long flgHaDocumentiPadre) { this.flgHaDocumentoPadre = flgHaDocumentiPadre; } public boolean hasDocumentiFiglio() { Vectumerator vec = findDocumentiFiglio(1, 1); if (vec.hasMoreElements()) return true; return false; } public void findOrdineBozza(long l_id_clifor) { String s_Sql_Find = "select A.* from DOCUMENTO AS A, TIPO_DOCUMENTO AS B"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_tipoDocumento=B.id_tipoDocumento"); wc.addWc("(A.flgStato is null or A.flgStato=0)"); wc.addWc("A.id_clifor=" + l_id_clifor); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public ByteArrayOutputStream creaSlip(DocumentoCR CR) { CR.setFlgSlip(1L); int numeroSlipXPagina = 4; ByteArrayOutputStream ba = new ByteArrayOutputStream(); long totSlipStampate = 0L; try { this.document = new Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 10.0F); this.writer = PdfWriter.getInstance(this.document, ba); String titoloReport = "Slip"; SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.document.open(); CR.setFlgSlip(1L); CR.setId_tipoDocumento(getParm("ID_DOC_PRENOTAZIONE").getNumeroLong()); CR.setFlgStatoPrenotazione(200L); Vectumerator vec = findByCR(CR, 0, 0); if (vec.hasMoreElements()) { System.out.println(" TOT RIGHE: " + vec.size()); while (vec.hasMoreElements()) { Documento rowDoc = (Documento)vec.nextElement(); Vectumerator vecR = rowDoc.findRigheDocumentoPerSlip(); while (vecR.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecR.nextElement(); double[] stati = { 0.0D, 0.0D }; row.checkStatoRigaQta(stati); if (stati[0] == 30.0D || stati[0] == 20.0D) { long totSlipDaStampare = 0L; if (stati[0] != 30.0D) { totSlipDaStampare = (long)stati[1]; } else { totSlipDaStampare = (long)row.getQuantita(); } if (row.getQtaSlipStampate() > 0L) if (totSlipDaStampare > row.getQtaSlipStampate() && (double)totSlipDaStampare >= row.getQuantita()) { totSlipDaStampare = (long)(row.getQuantita() - (double)row.getQtaSlipStampate()); } else if (totSlipDaStampare > row.getQtaSlipStampate()) { totSlipDaStampare -= row.getQtaSlipStampate(); } else if (totSlipDaStampare < row.getQtaSlipStampate()) { totSlipDaStampare = 0L; } for (int num = 0; (long)num < totSlipDaStampare; num++) { totSlipStampate++; this.pdfcorpo = new Table(40); this.pdfcorpo.setWidth(100.0F); this.pdfcorpo.setBorderWidth(1.0F); this.pdfcorpo.setBorderColor(Color.gray); this.pdfcorpo.setPadding(2.0F); this.pdfcorpo.setSpacing(0.0F); this.pdfcorpo.setOffset(10.0F); this.pdfcorpo.setWidths(colWidthsRighe40); Cell cell = new Cell(); cell.addElement(new Chunk(getParm("HEAD_SLIP").getTesto(), PdfFontFactory.PDF_fGrandeB)); cell.setBorder(0); cell.setLeading(12.0F); cell.setRowspan(1); cell.setColspan(40); cell.setHorizontalAlignment(1); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Prenotazione n.", PdfFontFactory.PDF_fMedioB)); cell.addElement(new Chunk(" " + rowDoc.getNumeroDocumentoCompleto(), PdfFontFactory.PDF_fMedio)); cell.setBorder(0); cell.setLeading(12.0F); cell.setRowspan(1); cell.setColspan(10); cell.setHorizontalAlignment(0); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("del ", PdfFontFactory.PDF_fMedioB)); cell.addElement(new Chunk(getDataFormat().format(rowDoc.getDataDocumento()), PdfFontFactory.PDF_fMedio)); cell.setBorder(0); cell.setLeading(12.0F); cell.setRowspan(1); cell.setColspan(10); cell.setHorizontalAlignment(0); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Cliente: ", PdfFontFactory.PDF_fMedioB)); cell.addElement(new Chunk(rowDoc.getNominativoDocumento(), PdfFontFactory.PDF_fMedio)); cell.setBorder(0); cell.setLeading(12.0F); cell.setRowspan(1); cell.setColspan(20); cell.setHorizontalAlignment(0); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Articolo: ", PdfFontFactory.PDF_fMedioB)); cell.addElement(new Chunk(row.getDescrizioneRigaCompleta(), PdfFontFactory.PDF_fMedio)); cell.setBorder(0); cell.setLeading(12.0F); cell.setRowspan(1); cell.setColspan(20); cell.setHorizontalAlignment(0); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(rowDoc.getClifor().getIndirizzoCompleto(), PdfFontFactory.PDF_fMedio)); cell.setBorder(0); cell.setLeading(12.0F); cell.setRowspan(1); cell.setColspan(20); cell.setHorizontalAlignment(0); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Note: ", PdfFontFactory.PDF_fMedioB)); cell.addElement(new Chunk( String.valueOf(formattaNoteDocumento(rowDoc.getNote(), 0, 8, true)) + " " + String.valueOf(formattaNoteDocumento(rowDoc.getNote(), 0, 8, true)), PdfFontFactory.PDF_fMedio)); cell.setBorder(0); cell.setLeading(12.0F); cell.setRowspan(1); cell.setColspan(20); cell.setHorizontalAlignment(0); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Cell. " + rowDoc.getCellDocumento() + ( !rowDoc.getTelDocumento().isEmpty() ? (" - Tel. " + rowDoc.getTelDocumento()) : ""), PdfFontFactory.PDF_fMedio)); cell.setBorder(0); cell.setLeading(12.0F); cell.setRowspan(1); cell.setColspan(20); cell.setHorizontalAlignment(0); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); if (totSlipStampate % (long)numeroSlipXPagina == 0L) this.document.newPage(); } if (CR.getFlgSimulazione() == 0L && totSlipDaStampare > 0L) { row.setQtaSlipStampate(row.getQtaSlipStampate() + totSlipDaStampare); row.superSave(); } } } } if (totSlipStampate == 0L) { Phrase ph = new Phrase("Attenzione! Non ci sono slip da stampare!"); this.document.add((Element)ph); } System.out.println(" Fine "); } else { Phrase ph = new Phrase("Attenzione! Non ci sono slip da stampare!"); this.document.add((Element)ph); } this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public long getFlgInserisciReso() { return this.flgInserisciReso; } public void setFlgInserisciReso(long flgInserisciReso) { this.flgInserisciReso = flgInserisciReso; } public String getDescrizioneRigheHtml() { StringBuffer temp = new StringBuffer(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); if (vec.hasMoreElements()) { temp.append(""); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); temp.append(""); } temp.append("
"); temp.append(""); temp.append(getNf().format(row.getQuantita())); temp.append(" "); temp.append(row.getDescrizioneRigaCompleta()); temp.append(""); temp.append("
"); } return temp.toString(); } public String getDescrizioneRighe() { StringBuffer temp = new StringBuffer(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); if (vec.hasMoreElements()) while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); temp.append(getNf().format(row.getQuantita())); temp.append(" "); temp.append(row.getDescrizioneRigaCompleta()); if (vec.hasMoreElements()) temp.append("\n"); } return temp.toString(); } public long getTipoAvviso() { if (getFlgInviaAvviso() == 1L) { if (!getEMailDocumento().isEmpty() && getCellDocumento().isEmpty()) return 1L; if (getEMailDocumento().isEmpty() && !getCellDocumento().isEmpty()) return 2L; if (!getEMailDocumento().isEmpty() && !getCellDocumento().isEmpty()) return 3L; return 9L; } return 0L; } public String getTipoAvvisoDesc() { switch ((int)getTipoAvviso()) { case 2: return "SMS"; case 1: return "Email"; case 3: return "Email + SMS"; } return "!! PARAMETRI NON IMPOSTATI"; } public static String getStatoRiparazione(long l_flgStatoRiparazione) { switch ((int)l_flgStatoRiparazione) { case 0: return "Non Visionato"; case 1: return "Riparazione Esterna"; case 2: return "Preventivo"; case 3: return "Prev.Accettato"; case 4: return "Prev. NON Accettato"; case 10: return "Riparato"; case 11: return "Non Riparato"; case 99: return "Riconsegnato"; } return "????"; } public long getFlgInGaranzia() { return this.flgInGaranzia; } public void setFlgInGaranzia(long flgInGaranzia) { this.flgInGaranzia = flgInGaranzia; } public long getFlgStatoRiparazione() { return this.flgStatoRiparazione; } public void setFlgStatoRiparazione(long flgStatoRiparazione) { this.flgStatoRiparazione = flgStatoRiparazione; } public double getCauzione() { return this.cauzione; } public void setCauzione(double cauzione) { this.cauzione = cauzione; } public String getStatoRiparazione() { return getStatoRiparazione(getFlgStatoRiparazione()); } private boolean hasDocumentiPrelevabili() { if (getDBState() == 1) { if (getTipoDocumento().hasDocPrel()) { Vectumerator vec = findRigheDocumentoPrelevabili(0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getQtaPrelevabileByDocumento(getId_documento()) > 0.0D) return true; } return false; } return false; } return false; } public long getFlgHasDocumentiPrelevabili() { if (this.flgHasDocumentiPrelevabili == -1L) if (hasDocumentiPrelevabili()) { this.flgHasDocumentiPrelevabili = 1L; } else { this.flgHasDocumentiPrelevabili = 0L; } return this.flgHasDocumentiPrelevabili; } public void setFlgHasDocumentiPrelevabili(long flgHasDocumentiPrelevabili) { this.flgHasDocumentiPrelevabili = flgHasDocumentiPrelevabili; } protected void creaDocumentoSchedaRiparazione(Table l_pdfCorpo) { try { String descCliente; int cellLeading = 10; SimpleDateFormat df = getDataFormat(); float imgLogoWidth = getDocLogoWidth(); Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); Cell cell = new Cell(); cell.addElement(new Chunk(imgLogo, 0.0F, 0.0F)); Paragraph paragraph = creaParagrafoConGrassetto("\n" + getHeaderDoocumento(1) + "\n" + getHeaderDoocumento(2), PDF_fPiccolo, PDF_fPiccoloB); paragraph.setLeading(10.0F); cell.addElement((Element)paragraph); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); l_pdfCorpo.addCell(cell); if (getId_clifor() > 1L) { descCliente = getClifor().getCognomeNome() + "\n"; String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); descCliente = descCliente + descCliente + " n." + getClifor().getIndirizzo() + "\n" + getClifor().getNumeroCivico() + " " + capComune + " (" + getClifor().getDescrizioneComune() + ")"; } else { descCliente = getNominativoDocumento(); } if (getId_destinazioneDiversa() == 0L) { if (getParm("DESTINAZIONE").getNumeroLong() == 1L) { String descDestinazione = "IDEM\n\n"; } else { String descDestinazione = ""; } } else { String descDestinazione = getClifor().getCognomeNome() + "\n"; if (!getDestinazioneDiversa().getPressoDD().isEmpty()) descDestinazione = descDestinazione + "c/o " + descDestinazione + "\n"; descDestinazione = descDestinazione + descDestinazione + " n." + getDestinazioneDiversa().getIndirizzoDD() + "\n" + getDestinazioneDiversa().getNumeroCivicoDD() + " " + getDestinazioneDiversa().getComuneDD().getCap() + " (" + getDestinazioneDiversa().getComuneDD().getDescrizione() + ")\n "; } cell = new Cell(); cell.addElement(new Chunk("\n\nSPETT.LE\n\n", PdfFontFactory.PDF_fPiccolissimoB)); cell.addElement(new Chunk(descCliente, PdfFontFactory.PDF_fGrande)); cell.setVerticalAlignment(4); cell.setLeading(12.0F); cell.setBorder(0); cell.setRowspan(3); cell.setColspan(18); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("TIPO DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (getFlgStato() == 0L) { cell.addElement(new Chunk("(B) ", PdfFontFactory.PDF_fMedioB)); } else if (getFlgStato() == 2L) { cell.addElement(new Chunk("PROFORMA\n", PdfFontFactory.PDF_fMedioB)); } else { cell.addElement(new Chunk(getTipoDocumento().getDescrizioneStampa() + "\n", PdfFontFactory.PDF_fPiccoloB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("N. DOC.\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(String.valueOf(getNumeroDocumento()), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("DATA\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(df.format(getDataDocumento()), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Operatore\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(getUsers().getCognomeNome(), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("xx", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); cell.setRowspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Recapiti: ", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk("Cell: " + getCellDocumento() + " Tel:" + getTelDocumento() + " Fax:" + getFaxDocumento() + " - " + getEMailDocumento(), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(20); l_pdfCorpo.addCell(cell); Vectumerator vec = findRigheDocumento(1, 1, 0); RigaDocumento row = new RigaDocumento(getApFull()); if (vec.hasMoreElements()) row = (RigaDocumento)vec.nextElement(); cell = new Cell(); cell.addElement(new Chunk("APPARATO: ", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(row.getDescrizioneRigaCompleta(), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(32); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("GARANZIA: ", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getInGaranzia(), PdfFontFactory.PDF_fMedioB)); cell.addElement(new Chunk(" - Doc. n. " + getRiferimento(), PdfFontFactory.PDF_fMedioB)); cell.addElement(new Chunk(" del " + df.format(getDataRiferimento()), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(32); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("ACCESSORI: ", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(row.getNotaRigaDocumento(), PdfFontFactory.PDF_fMedioB)); if (getFlgPagamentoDataFissa() > 0L) { if (getDataScadenzaPagamento() != null) cell.addElement(new Chunk(getPagamentoDataFissa() + " al " + getPagamentoDataFissa(), PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.addElement(new Chunk(getTipoPagamento().getDescrizione(), PdfFontFactory.PDF_fPiccolissimoB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(32); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); if (!getDescrizioneDifetto().isEmpty()) { cell = new Cell(); cell.addElement(new Chunk("DESCRIZIONE DIFETTO\n", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.gray); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getDescrizioneDifetto() + "\n\n.", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); } if (getFlgStatoRiparazione() < 2L) { cell = new Cell(); cell.addElement(new Chunk("INFORMIAMO LA GENTILE CLIENTELA CHE\n", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.gray); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getParm("RIP_NOTA_SCHEDA_RIPARAZIONE").getTesto() + "\n\n.", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); l_pdfCorpo.setComplete(true); cell = new Cell(); cell.addElement(new Chunk("x", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("\n\n\n\n\n\n\n\nFirma per accettazione\n\n\n\n______________________", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(20); l_pdfCorpo.addCell(cell); } if (getFlgStatoRiparazione() == 2L) { cell = new Cell(); cell.addElement(new Chunk("IL PREVENTIVO PREVEDE \n", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.gray); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getDescrizionePreventivo() + "\n\n.", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getParm("RIP_NOTA_ACCETTAZIONE_PREVENTIVO").getTesto() + "\n\n.", PdfFontFactory.PDF_fGrande)); cell.addElement(new Chunk("\n\nTOTALE PREVENTIVO: ", PdfFontFactory.PDF_fGrandeRouge)); cell.addElement(new Chunk(getNf().format(getImportoPreventivo()) + " + IVA", PdfFontFactory.PDF_fGrandeRouge)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("\n\n\n\n\\n.", PdfFontFactory.PDF_fPiccoloBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); l_pdfCorpo.setComplete(true); Image imgSquare = Image.getInstance(getDocBase() + "admin/_V3/_img/Icons/48x48/shadow/bullet_square_grey.gif"); imgSquare.scaleToFit(16.0F, 16.0F); cell = new Cell(); cell.addElement(new Chunk(imgSquare, -6.0F, 0.0F)); cell.addElement(new Chunk("PREVENTIVO ACCETTATO\n\n", PdfFontFactory.PDF_fMedioB)); cell.addElement(new Chunk(imgSquare, -6.0F, 0.0F)); cell.addElement(new Chunk("PREVENTIVO NON ACCETTATO", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Timbro e firma\n\n\n\n______________________", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(20); l_pdfCorpo.addCell(cell); } if (getFlgStatoRiparazione() >= 10L) { cell = new Cell(); cell.addElement(new Chunk("INTERVENTO EFFETTUATO\n", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.gray); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getInterventoEffettuato() + "\n\n.", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); if (!row.getSerialeSost().isEmpty()) { cell = new Cell(); cell.addElement(new Chunk("Nuovo S/N: " + row.getSerialeSost(), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); } cell = new Cell(); cell.addElement(new Chunk(getNotaAggiuntiva() + "\n\n.", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); l_pdfCorpo.addCell(cell); l_pdfCorpo.setComplete(true); cell = new Cell(); cell.addElement(new Chunk("x", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("\n\n\n\n\n\n\nFirma per ritiro\n\n\n\n______________________", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(20); l_pdfCorpo.addCell(cell); } } catch (Exception e) { handleDebug(e); } } public ResParm aggiornaStatoRiparazione(long l_flgStatoRiparazione) { setFlgStatoRiparazione(l_flgStatoRiparazione); if (getId_tipoDocumento() == getId_docPrenotazione()) { if (l_flgStatoRiparazione == 99L) setDataChiusura(getToday()); String noteTemp = " \n" + getStatoRiparazione(l_flgStatoRiparazione) + " in data " + String.valueOf(getToday()); setNote(getNote() + getNote()); return super.save(); } return new ResParm(true); } public String getDescrizioneDifetto() { return (this.descrizioneDifetto == null) ? "" : this.descrizioneDifetto.trim(); } public void setDescrizioneDifetto(String descrizioneDifetto) { this.descrizioneDifetto = descrizioneDifetto; } public String getIntestazioneDocumento() { if (getId_clifor() > 1L) return getClifor().getDescrizioneCompleta(); return getNominativoDocumento(); } public void setInterventoEffettuato(String interventoEffettuato) { this.interventoEffettuato = interventoEffettuato; } public long getFlgPreventivo() { return this.flgPreventivo; } public void setFlgPreventivo(long flgPreventivo) { this.flgPreventivo = flgPreventivo; } public double getImportoPreventivo() { return this.importoPreventivo; } public void setImportoPreventivo(double importoPreventivo) { this.importoPreventivo = importoPreventivo; } protected int getStringValueCase(String l_colomnName) { if (l_colomnName != null && l_colomnName.startsWith("eMailDocumento")) return 0; return super.getStringValueCase(l_colomnName); } public String getNotaAggiuntiva() { return (this.notaAggiuntiva == null) ? "" : this.notaAggiuntiva.trim(); } public void setNotaAggiuntiva(String notaAggiuntiva) { this.notaAggiuntiva = notaAggiuntiva; } public String getDescrizionePreventivo() { return (this.descrizionePreventivo == null) ? "" : this.descrizionePreventivo; } public void setDescrizionePreventivo(String descrizionePreventivo) { this.descrizionePreventivo = descrizionePreventivo; } public ResParm aggiornaDataAvviso(Date l_dataAvviso) { setDataAvviso(l_dataAvviso); String noteTemp = " \nAvvisato in data " + String.valueOf(getToday()); setNote(getNote() + getNote()); return super.save(); } protected long getId_docOrdine() { return getParm("ID_DOC_ORDINE").getNumeroLong(); } protected long getId_docPrenotazione() { return getParm("ID_DOC_PRENOTAZIONE").getNumeroLong(); } private Document creaReportUnaOrdiniInevasi(DocumentoCR CR, boolean soloCompatto) { int rowCellLeading = 6; NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col_1 = 4, col_2 = 16, col_3 = 3, col_4 = 3, col_5 = 14; int cellLeading = 12; SimpleDateFormat df = getDataFormat(); try { Cell rigaVuota = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); String intestazioneReport = "Data: dal " + df.format(CR.getDataDocumentoDa()) + " al " + df.format(CR.getDataDocumentoA()); if (CR.getId_tipo() != 0L) intestazioneReport = intestazioneReport + " - Tipo: " + intestazioneReport; creaIntestazioneReport(CR.getTipoReport(), intestazioneReport); Cell cell = new Cell(new Chunk("Doc.", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Articolo", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Q.ta ord.", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Q.ta prel.", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Fornitore", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); Vectumerator vec = new RigaDocumento(getApFull()).findOrdini(CR); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); cell = new Cell(new Chunk(row.getDocumento().getNumeroDocumentoCompleto(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getDescrizioneRigaCompleta(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(nf0.format(row.getQuantita()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(nf0.format(row.getQuantitaPrelevata()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getDocumento().getClifor().getDescrizioneCompleta(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("TOTALE RECORD: ", PdfFontFactory.PDF_fGrande)); cell.add(new Chunk(String.valueOf(vec.getTotNumberOfRecords()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); } catch (Exception e) { handleDebug(e); } return this.document; } public void findDocumentoBozza(long l_id_tipoDocumento, long l_id_clifor) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_tipoDocumento=" + l_id_tipoDocumento); wc.addWc("(A.flgStato is null or A.flgStato=0)"); wc.addWc("A.id_clifor=" + l_id_clifor); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public String getFaxDocumento() { return (this.faxDocumento == null) ? "" : this.faxDocumento; } public void setFaxDocumento(String faxDocumento) { this.faxDocumento = faxDocumento; } public String getTelDocumento() { return (this.telDocumento == null) ? "" : this.telDocumento; } public void setTelDocumento(String telDocumento) { this.telDocumento = telDocumento; } public long getId_usersIntervento() { return this.id_usersIntervento; } public void setId_usersIntervento(long id_usersIntervento) { this.id_usersIntervento = id_usersIntervento; setUsersIntervento(this.usersIntervento); } public long getId_usersChiusura() { return this.id_usersChiusura; } public void setId_usersChiusura(long id_usersChiusura) { this.id_usersChiusura = id_usersChiusura; setUsersChiusura(null); } public Users getUsersIntervento() { this.usersIntervento = (Users)getSecondaryObject((DBAdapter)this.usersIntervento, Users.class, getId_usersIntervento()); return this.usersIntervento; } public void setUsersIntervento(Users usersIntervento) { this.usersIntervento = usersIntervento; } public Users getUsersChiusura() { this.usersChiusura = (Users)getSecondaryObject((DBAdapter)this.usersChiusura, Users.class, getId_usersChiusura()); return this.usersChiusura; } public void setUsersChiusura(Users usersChiusura) { this.usersChiusura = usersChiusura; } public long getFlgStatoRiparazionePrecedente() { return this.flgStatoRiparazionePrecedente; } public void setFlgStatoRiparazionePrecedente(long flgStatoRiparazionePrecedente) { this.flgStatoRiparazionePrecedente = flgStatoRiparazionePrecedente; } public String getInGaranzia() { return getInGaranzia(getFlgInGaranzia()); } public Vectumerator findDocumentiFiglio() { return findDocumentiFiglio(0, 0); } public Vectumerator findDocumentiPadre() { if (getId_documento() == 0L) return AB_EMPTY_VECTUMERATOR; StringBuffer s_Sql_Find = new StringBuffer("select D.* from DOCUMENTO AS D where id_documento in (select B.id_documentoPadre from DOCUMENTO AS A, RIGA_DOCUMENTO AS B "); WcString wc = new WcString(); wc.addWc("A.id_documento=B.id_documento"); wc.addWc("B.id_documento=" + getId_documento()); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + ")"); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public String getDocumentiPadreDesc(String javascript) { Vectumerator vec = findDocumentiPadre(); if (!vec.hasMoreElements()) return ""; StringBuilder sb = new StringBuilder(); while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); if (javascript != null) { sb.append(""); } else { sb.append(row.getNumeroDocumentoCompleto()); } if (vec.hasMoreElements()) sb.append(", "); } return sb.toString(); } public String getDocumentiPadreDesc() { return getDocumentiPadreDesc(null); } public String getDocumentiFiglioDesc(String javascript) { Vectumerator vec = findDocumentiFiglio(); if (!vec.hasMoreElements()) return ""; StringBuilder sb = new StringBuilder(); while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); if (javascript != null) { sb.append(""); } else { sb.append(row.getNumeroDocumentoCompleto()); } if (vec.hasMoreElements()) sb.append(", "); } return sb.toString(); } public String getDocumentiFiglioDesc() { return getDocumentiFiglioDesc(null); } public String getDescrizioneRigheHtmlCompleta() { StringBuffer temp = new StringBuffer(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); if (vec.hasMoreElements()) { temp.append(""); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); temp.append(""); } temp.append("
"); temp.append(""); temp.append(getNf().format(row.getQuantita())); temp.append(" "); temp.append(row.getDescrizioneRigaCompleta()); temp.append(""); temp.append(""); if (row.getId_articolo() != 0L) { temp.append(getNf().format(row.getArticolo().getQuantitaEffettiva())); temp.append(""); temp.append(getNf().format(row.getArticolo().getQuantita())); temp.append(""); } temp.append("
"); } return temp.toString(); } public String getDescrizioneRigheCompleta() { if (!getDescrizioneRighePrenotazione().isEmpty()) return getDescrizioneRighePrenotazione(); StringBuffer temp = new StringBuffer(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); if (vec.hasMoreElements()) while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); temp.append(getNf().format(row.getQuantita())); temp.append(" "); temp.append(row.getDescrizioneRigaCompleta()); temp.append(" "); if (row.getId_articolo() != 0L) { temp.append(getNf().format(row.getArticolo().getQuantitaEffettiva())); temp.append(" "); temp.append(getNf().format(row.getArticolo().getQuantita())); temp.append(" "); } temp.append(" - "); } return temp.toString(); } public boolean isUnDocumentoFiglioCreato() { StringBuffer s_Sql_Find = new StringBuffer("select B.id_documento from DOCUMENTO AS A, RIGA_DOCUMENTO AS B "); WcString wc = new WcString(); wc.addWc("A.id_documento=B.id_documento"); wc.addWc("B.id_documentoPadre=" + getId_documento()); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + " limit 1"); Vectumerator vec = findRows(stmt); if (vec.hasMoreElements()) return true; return false; } catch (SQLException e) { handleDebug(e); return false; } } public String getDocumentiFigliDesc() { Vectumerator vec = findDocumentiFiglio(); StringBuffer sb = new StringBuffer(); if (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); sb.append(row.getNumeroDocumentoCompleto()); if (vec.hasMoreElements()) sb.append(" - "); } return sb.toString(); } public Documento getDocumentoFiglioUno() { if (this.documentoFiglioUno == null) { Vectumerator vec = findDocumentiFiglio(); if (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); this.documentoFiglioUno = row; } } return (this.documentoFiglioUno == null) ? new Documento(getApFull()) : this.documentoFiglioUno; } public void setDocumentoFiglioUno(Documento documentoFiglioUno) { this.documentoFiglioUno = documentoFiglioUno; } public long getId_porto() { return this.id_porto; } public void setId_porto(long id_porto) { this.id_porto = id_porto; setPorto(null); } public Porto getPorto() { this.porto = (Porto)getSecondaryObject(this.porto, Porto.class, getId_porto()); return this.porto; } public void setPorto(Porto porto) { this.porto = porto; } public boolean isFatturaONotaDiCredito() { if (getDBState() == 1 && getFlgStato() == 1L) { if (getTipoDocumento().getFlgTipologia() == 1L || getTipoDocumento().getFlgTipologia() == 2L) return true; return false; } return false; } public void findPrecedente(long l_progDocumento, long l_annoDocumento, long l_id_contatore) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.progDocumento desc limit 1"; WcString wc = new WcString(); wc.addWc("A.flgStato=1"); wc.addWc("A.progDocumento<" + l_progDocumento); wc.addWc("A.id_esercizio=" + l_annoDocumento); wc.addWc("A.id_contatore=" + l_id_contatore); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findSuccessiva(long l_progDocumento, long l_id_esercizio, long l_id_contatore) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.progDocumento asc limit 1"; WcString wc = new WcString(); wc.addWc("A.flgStato=1"); wc.addWc("A.progDocumento>" + l_progDocumento); wc.addWc("A.id_esercizio=" + l_id_esercizio); wc.addWc("A.id_contatore=" + l_id_contatore); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public long getId_tipoDocumentoFiglio() { return this.id_tipoDocumentoFiglio; } public void setId_tipoDocumentoFiglio(long idTipoDocumentoFiglio) { this.id_tipoDocumentoFiglio = idTipoDocumentoFiglio; } public long getId_esercizioB() { return this.id_esercizioB; } public void setId_esercizioB(long idEsercizioB) { this.id_esercizioB = idEsercizioB; } public long getProgDocumentoB() { return this.progDocumentoB; } public void setProgDocumentoB(long progDocumentoB) { this.progDocumentoB = progDocumentoB; } public String getProgDocumentoAggB() { return this.progDocumentoAggB; } public void setProgDocumentoAggB(String progDocumentoAggB) { this.progDocumentoAggB = progDocumentoAggB; } private int findByCRTotRecord(DocumentoCR CR) { StringBuffer s_Sql_Find = new StringBuffer("select count(*) as tot from DOCUMENTO AS A "); WcString wc = new WcString(); findByCRCreateWC(CR, s_Sql_Find, wc); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); findByCRCreateStmtDate(CR, stmt); return (int)getTots(stmt); } catch (Exception e) { handleDebug(e); return 0; } } public void findByCRCreateWC(DocumentoCR CR, StringBuffer s_Sql_Find, WcString wc) { if (CR.getFlgRicercaPerTaglio() == 1L || !CR.getSeriale().isEmpty() || CR.getId_articoloTessuto() != 0L || CR.getId_iva() != 0L || CR.getId_articoloVariante() != 0L || CR.getId_telaio() != 0L || CR.getId_articolo() != 0L || !CR.getDescrizioneCompletaArticolo().isEmpty() || CR.getFlgSlip() > 0L || CR.getId_tipo() != 0L || CR.getId_marca() != 0L || !CR.getNotaBarcode().isEmpty() || !CR.getRiferimentoAzienda().isEmpty() || CR.getFlgReport().equals("S") || !CR.getNMatricola().isEmpty() || !CR.getSearchArticolo().isEmpty()) { s_Sql_Find.append(" inner join RIGA_DOCUMENTO AS B ON A.id_documento=B.id_documento"); s_Sql_Find.replace(0, 11, "select DISTINCT A.*"); if (CR.getFlgRicercaPerTaglio() == 1L || CR.getId_tipo() != 0L || CR.getId_marca() != 0L) { s_Sql_Find.append(" inner join ARTICOLO as D ON B.id_articolo=D.id_articolo"); } else if (!CR.getNMatricola().isEmpty()) { s_Sql_Find.append(" left join ARTICOLO as D ON B.id_articolo=D.id_articolo"); } if (CR.getId_tipo() != 0L) s_Sql_Find.append(" inner join TIPO as E on D.id_tipo=E.id_tipo "); } if (CR.getFlgOrderBy() == 9L || CR.getId_contatore() != 0L || CR.getFlgSoloFattureElettroniche() == 1L || CR.getFlgTipologia() >= 0L || !CR.getFlgClienteFornitore().isEmpty() || !CR.getRiferimentoAzienda().isEmpty() || CR.getFlgXmlGenerato() >= 0L || CR.getFlgOss() > 0L) { s_Sql_Find.append(" inner join TIPO_DOCUMENTO AS C ON A.id_tipoDocumento= C.id_tipoDocumento"); if (CR.getFlgTipologia() >= 0L || CR.getFlgSoloFattureElettroniche() == 1L || CR.getFlgXmlGenerato() >= 0L) s_Sql_Find.append(" inner join TIPOLOGIA_DOCUMENTO AS TD ON TD.id_tipologiaDocumento=C.id_tipologiaDocumento"); } if (CR.getFlgPA() >= 0L || CR.getFlgSplitPayment() >= 0L || !CR.getId_nazione().isEmpty() || CR.getFlgMl() >= 0L || CR.getFlgOrderBy() == 2L) s_Sql_Find.append(" inner join CLIFOR AS CF ON CF.id_clifor=A.id_clifor"); if (CR.getId_marca() != 0L) wc.addWc("D.id_marca=" + CR.getId_marca()); if (!CR.getNotaBarcode().isEmpty()) wc.addWc("B.notaBarcode LIKE '%" + CR.getNotaBarcode() + "%'"); if (CR.getFlgXmlGenerato() == 0L) { wc.addWc("A.tmstFileXml is null"); wc.addWc("A.id_esercizio >=2019"); wc.addWc("(TD.codice=1 or TD.codice=2)"); wc.addWc("A.flgStato='1'"); } else if (CR.getFlgXmlGenerato() > 0L) { wc.addWc("A.tmstFileXml is not null"); wc.addWc("A.id_esercizio >=2019"); wc.addWc("A.flgStato='1'"); } if (CR.getProgOrdineWww() != 0L) wc.addWc("A.progOrdineWww=" + CR.getProgOrdineWww()); if (CR.getId_documentoS() != 0L) wc.addWc("A.id_documento=" + CR.getId_documentoS()); if (CR.getId_documentoNo() != 0L) wc.addWc("A.id_documento!=" + CR.getId_documentoNo()); if (CR.getId_clifor() != 0L) wc.addWc("A.id_clifor=" + CR.getId_clifor()); if (CR.getId_users() > 0L) wc.addWc("A.id_users=" + CR.getId_users()); if (CR.getId_contatore() != 0L) { wc.addWc("C.id_contatore=" + CR.getId_contatore()); } else if (CR.getId_clifor() == 0L && !CR.getNominativoDocumento().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getNominativoDocumento().trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = prepareSqlString(st.nextToken()); txt.append("(A.nominativoDocumento like '%" + token + "%' )"); if (st.hasMoreTokens()) txt.append(" and "); } txt.append(")"); wc.addWc(txt.toString()); } if (CR.getFlgMl() == 0L) { wc.addWc("(CF.flgMl is null or CF.flgMl=0)"); } else if (CR.getFlgMl() > 0L) { wc.addWc("CF.flgMl=" + CR.getFlgMl()); } if (CR.getId_telaio() != 0L) wc.addWc("B.id_telaio=" + CR.getId_telaio()); if (CR.getId_articoloDocumento() != 0L) wc.addWc("A.id_articolo=" + CR.getId_articoloDocumento()); if (CR.getId_articoloVariante() != 0L) { wc.addWc("B.id_articoloVariante=" + CR.getId_articoloVariante()); } else if (CR.getId_articolo() != 0L) { wc.addWc("B.id_articolo=" + CR.getId_articolo()); } else if (!CR.getSearchArticolo().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getSearchArticolo().trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = prepareSqlString(st.nextToken()); txt.append("(B.descrizioneRiga like '%" + token + "%' )"); if (st.hasMoreTokens()) txt.append(" and "); } txt.append(")"); wc.addWc(txt.toString()); } if (CR.getId_iva() != 0L) wc.addWc("B.id_iva=" + CR.getId_iva()); if (CR.getId_articoloTessuto() != 0L) wc.addWc("B.id_articoloTessuto=" + CR.getId_articoloTessuto()); if (CR.getId_tipo() != 0L) wc.addWc("(E.id_tipo=" + CR.getId_tipo() + " or E.indici like'%:" + CR.getId_tipo() + ":%')"); if (CR.getFlgTipologia() >= 0L) if (CR.getFlgTipologia() == 100L) { wc.addWc("A.id_tipoDocumento=1"); } else if (CR.getFlgTipologia() == 20L) { wc.addWc("(TD.codice=1 OR TD.codice=2)"); wc.addWc("A.id_tipoDocumento<>1"); } else if (CR.getFlgTipologia() == 1L) { wc.addWc("TD.codice=" + CR.getFlgTipologia()); wc.addWc("A.id_tipoDocumento<>1"); } else if (CR.getFlgTipologia() == 0L) { wc.addWc("(TD.codice is null or TD.codice=" + CR.getFlgTipologia() + ")"); } else { wc.addWc("TD.codice=" + CR.getFlgTipologia()); } if (CR.getFlgStatoLavorazione() == 0L) { wc.addWc("(A.flgStatoLavorazione is null or A.flgStatoLavorazione=0)"); } else if (CR.getFlgStatoLavorazione() > 0L) { wc.addWc("A.flgStatoLavorazione=" + CR.getFlgStatoLavorazione()); } else if (CR.getFlgStatoLavorazione() == -1L) { wc.addWc("(A.flgStatoLavorazione=0 is null or A.flgStatoLavorazione=0 or A.flgStatoLavorazione=20 or A.flgStatoLavorazione=10 ) "); } if (!CR.getSeriale().isEmpty()) { String temp = CR.getSeriale(); temp = temp.replace("%", "\\%"); temp = temp.replace("_", "\\_"); temp = temp.replace("*", "%"); wc.addWc("B.seriale like '" + CR.getSeriale() + "'"); } if (!CR.getNMatricola().isEmpty()) wc.addWc("(D.nMatricola like'%" + CR.getNMatricola() + "%' or B.seriale like'%" + CR.getNMatricola() + "%')"); if (CR.getProgDocumento() != 0L && CR.getProgDocumentoA() == 0L) { wc.addWc("A.progDocumento =" + CR.getProgDocumento()); } else if (CR.getProgDocumento() != 0L && CR.getProgDocumentoA() != 0L) { wc.addWc("A.progDocumento >=" + CR.getProgDocumento()); wc.addWc("A.progDocumento <=" + CR.getProgDocumentoA()); } if (CR.getId_esercizio() != 0L) wc.addWc("A.id_esercizio =" + CR.getId_esercizio()); if (CR.getFlgInvioMail() == 0L) wc.addWc("A.tmstInvioMail is null"); if (CR.getFlgSoloFattureElettroniche() == 1L) { wc.addWc("(TD.codice=1 OR TD.codice=2)"); wc.addWc("A.flgStato=1"); } if (CR.getTotaleDocumentoDa() > 0.0D) wc.addWc("A.totaleDocumento >=" + CR.getTotaleDocumentoDa()); if (CR.getTotaleDocumentoA() > 0.0D) wc.addWc("A.totaleDocumento <=" + CR.getTotaleDocumentoA()); if (CR.getId_tipoPagamento() != 0L) wc.addWc("A.id_tipoPagamento =" + CR.getId_tipoPagamento()); if (CR.getNumScontrino() != 0L) wc.addWc("A.echoScontrino like'%" + CR.getNumScontrino() + " %'"); if (!CR.getRiferimento().isEmpty()) wc.addWc("A.riferimento like'%" + CR.getRiferimento() + "%'"); if (CR.getFlgBartolini() == 0L) { wc.addWc("(A.flgBartolini is null or flgBartolini=0)"); } else if (CR.getFlgBartolini() > 0L) { wc.addWc("A.flgBartolini =" + CR.getFlgBartolini()); } if (CR.getFlgStato() == 0L) { wc.addWc("(A.flgStato is null or flgStato=0)"); } else if (CR.getFlgStato() > 0L) { wc.addWc("A.flgStato =" + CR.getFlgStato()); } if (CR.getFlgInviatoAvviso() == 0L) { wc.addWc("A.dataAvviso is null"); } else if (CR.getFlgInviatoAvviso() > 0L) { wc.addWc("A.dataAvviso is not null"); } if (CR.getFlgStatoRiparazione() == 0L) { wc.addWc("(A.flgStatoRiparazione is null or flgStatoRiparazione=0)"); } else if (CR.getFlgStatoRiparazione() > 0L) { wc.addWc("A.flgStatoRiparazione =" + CR.getFlgStatoRiparazione()); } if (CR.getFlgSlip() > 0L) { wc.addWc("B.quantita>COALESCE(B.qtaSlipStampate, 0)"); wc.addWc("B.quantita>0"); } if (CR.getFlgSplitPayment() == 0L) { wc.addWc("(CF.flgSplitPayment is null or CF.flgSplitPayment=0)"); } else if (CR.getFlgSplitPayment() > 0L) { wc.addWc("CF.flgSplitPayment =" + CR.getFlgSplitPayment()); } if (!CR.getId_nazione().isEmpty()) wc.addWc("CF.id_nazione ='" + CR.getId_nazione() + "'"); if (CR.getFlgPA() == 0L) { wc.addWc("(CF.flgPA is null or CF.flgPA=0)"); } else if (CR.getFlgPA() > 0L) { wc.addWc("CF.flgPA =" + CR.getFlgPA()); } if (CR.getFlgPagata() == 0L) { wc.addWc("(A.flgPagata is null or flgPagata=0)"); } else if (CR.getFlgPagata() > 0L) { wc.addWc("A.flgPagata =" + CR.getFlgPagata()); } if (CR.getFlgStatoPrenotazione() == 0L) { wc.addWc("(A.flgStatoPrenotazione is null or flgStatoPrenotazione=0)"); } else if (CR.getFlgStatoPrenotazione() == 200L) { wc.addWc("(A.flgStatoPrenotazione is null or flgStatoPrenotazione=0 or A.flgStatoPrenotazione <90)"); } else if (CR.getFlgStatoPrenotazione() > 0L) { wc.addWc("A.flgStatoPrenotazione =" + CR.getFlgStatoPrenotazione()); } if (CR.getFlgDocumentoPrelevato() == 0L) { wc.addWc("(A.flgDocumentoPrelevato is null or A.flgDocumentoPrelevato=0)"); } else if (CR.getFlgDocumentoPrelevato() > 0L) { wc.addWc("A.flgDocumentoPrelevato =" + CR.getFlgDocumentoPrelevato()); } if (CR.getFlgHasDocumentiPrelevabili() == 0L) { wc.addWc("(A.flgHasDocumentiPrelevabili is null or A.flgHasDocumentiPrelevabili=0)"); } else if (CR.getFlgHasDocumentiPrelevabili() > 0L) { wc.addWc("A.flgHasDocumentiPrelevabili =" + CR.getFlgHasDocumentiPrelevabili()); } if (CR.getId_tipoDocumento() != 0L) wc.addWc("A.id_tipoDocumento=" + CR.getId_tipoDocumento()); if (CR.getDataScontrino() != null) wc.addWc("A.echoScontrino like'% " + CR.getDataScontrinoF() + " %'"); if (CR.getId_bancaAnticipo() == 0L) { wc.addWc("A.id_bancaAnticipo >0"); } else if (CR.getId_bancaAnticipo() > 0L) { wc.addWc("A.id_bancaAnticipo =" + CR.getId_bancaAnticipo()); } if (CR.getFlgStatoOrdineWww() == 0L) { wc.addWc("(A.flgStatoOrdineWww is null or A.flgStatoOrdineWww=0)"); } else if (CR.getFlgStatoOrdineWww() == 10L) { wc.addWc("(A.flgStatoOrdineWww is null or A.flgStatoOrdineWww <9)"); } else if (CR.getFlgStatoOrdineWww() == 11L) { wc.addWc("(A.flgStatoOrdineWww =9 or A.flgStatoOrdineWww =99 )"); } else if (CR.getFlgStatoOrdineWww() > 0L) { wc.addWc("A.flgStatoOrdineWww =" + CR.getFlgStatoOrdineWww()); } if (CR.getDataDocumentoDa() != null) wc.addWc("A.dataDocumento>=?"); if (CR.getDataDocumentoA() != null) wc.addWc("A.dataDocumento<=?"); if (CR.getDataChiusuraDa() != null) wc.addWc("A.dataChiusura>=?"); if (CR.getDataChiusuraA() != null) wc.addWc("A.dataChiusura<=?"); if (CR.getDataRiferimentoDa() != null) wc.addWc("A.dataRiferimento>=?"); if (CR.getDataRiferimentoA() != null) wc.addWc("A.dataRiferimento<=?"); if (CR.getFlgSuperR() == 0L) { wc.addWc("(A.flgSuper=0 OR A.flgSuper IS NULL)"); } else if (CR.getFlgSuperR() > 0L) { wc.addWc(" A.flgSuper= " + CR.getFlgSuperR()); } else if (CR.getFlgSuper() == 0L) { wc.addWc("(A.flgSuper=0 OR A.flgSuper IS NULL)"); } if (!CR.getFlgClienteFornitore().isEmpty() || !CR.getRiferimentoAzienda().isEmpty()) { if (!CR.getRiferimentoAzienda().isEmpty()) wc.addWc(" C.riferimento = '" + CR.getRiferimentoAzienda() + "'"); if (!CR.getFlgClienteFornitore().isEmpty()) wc.addWc(" C.flgClienteFornitore = '" + CR.getFlgClienteFornitore() + "'"); } if (CR.getFlgOss() > 0L) wc.addWc("( C.flgOss =0 or C.flgOss is null or C.flgOss = " + CR.getFlgOss() + ")"); if (CR.getCreateTmst() != null) wc.addWc("A.createTmst 0L) { wc.addWc("A.flgGRS =" + CR.getFlgGRS()); } } public Vectumerator findCliforByCR(DocumentoCR CR) { StringBuffer s_Sql_Find = new StringBuffer("select A.id_clifor from DOCUMENTO AS A "); WcString wc = new WcString(); findByCRCreateWC(CR, s_Sql_Find, wc); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); findByCRCreateStmtDate(CR, stmt); Vectumerator vec = findRows(stmt); Vectumerator vecRes = new Vectumerator(); while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); vecRes.add(row.getClifor()); } return vecRes; } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findByCR(DocumentoCR CR, int pageNumber, int pageRows) { String s_Sql_Order; StringBuffer s_Sql_Find = new StringBuffer("select A.* from DOCUMENTO AS A "); if (CR.getTipoDocumento().getFlgClienteFornitore().equals("F") && ( CR.getTipoDocumento().getFlgTipologia() == 1L || CR.getTipoDocumento().getFlgTipologia() == 2L)) { if (CR.getFlgOrderBy() == 1L) { s_Sql_Order = " order by A.dataRiferimento asc, A.id_esercizio asc, A.progDocumento asc"; } else { s_Sql_Order = " order by A.dataRiferimento desc, A.id_esercizio desc, A.progDocumento desc"; } } else if (CR.getFlgOrderBy() == 1L) { s_Sql_Order = " order by A.dataDocumento asc, A.id_esercizio asc, A.progDocumento asc"; } else if (CR.getFlgOrderBy() == 9L) { s_Sql_Order = " order by C.flgUsato desc, A.dataDocumento asc, A.id_esercizio asc, A.progDocumento asc"; } else if (CR.getFlgOrderBy() == 2L) { s_Sql_Order = " order by CF.cognome, CF.nome, A.dataDocumento asc, A.id_esercizio asc, A.progDocumento asc"; } else { s_Sql_Order = " order by A.dataDocumento desc, A.id_esercizio desc, A.progDocumento desc "; } WcString wc = new WcString(); findByCRCreateWC(CR, s_Sql_Find, wc); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); findByCRCreateStmtDate(CR, stmt); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public void findByCRCreateStmtDate(DocumentoCR CR, PreparedStatement stmt) { try { int dataCount = 0; if (CR.getDataDocumentoDa() != null) { dataCount++; stmt.setDate(dataCount, CR.getDataDocumentoDa()); } if (CR.getDataDocumentoA() != null) { dataCount++; stmt.setDate(dataCount, CR.getDataDocumentoA()); } if (CR.getDataChiusuraDa() != null) { dataCount++; stmt.setDate(dataCount, CR.getDataChiusuraDa()); } if (CR.getDataChiusuraA() != null) { dataCount++; stmt.setDate(dataCount, CR.getDataChiusuraDa()); } if (CR.getDataRiferimentoDa() != null) { dataCount++; stmt.setDate(dataCount, CR.getDataRiferimentoDa()); } if (CR.getDataRiferimentoA() != null) { dataCount++; stmt.setDate(dataCount, CR.getDataRiferimentoA()); } if (CR.getCreateTmst() != null) { dataCount++; stmt.setTimestamp(dataCount, CR.getCreateTmst()); } } catch (SQLException e) { handleDebug(e); } } public static final String getInGaranzia(long l_flgInviaAvviso) { switch ((int)l_flgInviaAvviso) { case 0: return "NO"; case 1: return "SI"; case 2: return "DOA"; } return "No"; } protected boolean isUseSafeUpdate() { return true; } public long getFlgDocumentoPrelevato() { return this.flgDocumentoPrelevato; } private Vectumerator findRientri(String l_seriale, int pageNumber, int pageRows) { DocumentoCR CR = new DocumentoCR(); CR.setSeriale(l_seriale); CR.setId_tipoDocumento(getId_docRiparazione()); CR.setId_documentoNo(getId_documento()); return findByCR(CR, pageNumber, pageRows); } public boolean isRientro(String l_seriale) { if (getId_documento() == 0L || l_seriale.trim().isEmpty()) return false; Vectumerator vec = findRientri(l_seriale, 1, 1); if (vec.hasMoreElements()) return true; return false; } public Vectumerator findRientri(String l_seriale) { return findRientri(l_seriale, 0, 0); } public boolean hasRigheDocumentoPrenotazioneArrivate() { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getFlgPrenotazioneArrivata() == 0L) return false; } return true; } public static String getTrasporto(long l_flgTrasporto) { switch ((int)l_flgTrasporto) { case 1: return "Mittente"; case 2: return "Destinatario"; case 3: return "Vettore"; } return ""; } public long getFlgTipoMovimento() { long id_p = getTipoDocumento().getCausaleMagazzino().getId_magFisicoPartenza(); long id_a = getTipoDocumento().getCausaleMagazzino().getId_magFisicoArrivo(); if (id_p > 0L && id_a > 0L) return 3L; if (id_p > 0L && id_a == 0L) return 2L; if (id_p == 0L && id_a > 0L) return 1L; return 0L; } public void setFlgTipoMovimento(long flgTipoMovimento) { this.flgTipoMovimento = flgTipoMovimento; } public ResParm delAllegato(AllegatoDocumento row) { AllegatoDocumento bean = new AllegatoDocumento(getApFull()); bean.findByPrimaryKey(row.getId_allegatoDocumento()); return bean.delete(); } public ResParm addAllegato(AllegatoDocumento row) { AllegatoDocumento bean = new AllegatoDocumento(getApFull()); bean.findByDocumentoNomeFile(row.getId_documento(), row.getNomeFile()); if (bean.getDBState() == 1) return new ResParm(false, "Nome File Duplicato"); row.setDBState(0); ResParm rp = row.save(); return rp; } public Vectumerator getAllegati(long l_id_tipoAllegatoDocumento) { return new AllegatoDocumento(getApFull()).findByDocumentoTipo(getId_documento(), l_id_tipoAllegatoDocumento, 0, 0); } public void setNominativoDocumento(String nominativoDocumento) { this.nominativoDocumento = nominativoDocumento; } public long getId_cliforListino() { if (getId_documentoFiglio() == 0L) return this.id_cliforListino; return getDocumentoFiglio().getId_clifor(); } public void setId_cliforListino(long id_cliforListino) { this.id_cliforListino = id_cliforListino; setCliforListino(null); } public Clifor getCliforListino() { if (getId_documentoFiglio() == 0L) { this.cliforListino = (Clifor)getSecondaryObject(this.cliforListino, Clifor.class, getId_cliforListino()); return this.cliforListino; } return getDocumentoFiglio().getClifor(); } public void setCliforListino(Clifor cliforListino) { this.cliforListino = cliforListino; } public void applicaListinoByClifor(Clifor l_clifor) { synchronized (this) { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_articolo() != 0L) { row.setSconto(row.getArticolo().getPrezzoArticolo(l_clifor).getPercSconto()); row.setImponibile(row.getArticolo().getPrezzoArticolo(l_clifor).getPrezzoBase()); row.setPrezzoPubblicoConIva(row.getArticolo().getPrezzoArticoloIva(l_clifor).getPrezzoFinale()); addRigaDocumento(this, row); } } } } protected long getDocumentoAnnoIniziale() { return getTipoDocumento().getContatore().getAnnoIniziale(); } protected long getDocumentoNumeroIniziale() { return getTipoDocumento().getContatore().getProgIniziale(); } private String trovaProgPrimoBuco(long anno) { if (getTipoDocumento().getContatore().getFlgControllo() == 0L) return ""; try { String s_SqlFatt = "select * from DOCUMENTO where dataDocumento>=? and dataDocumento<=? and progDocumentoAgg ='' and id_contatore=" + getTipoDocumento().getId_contatore() + " and flgStato ='1' order by progDocumento, dataDocumento"; PreparedStatement ps = getConn().prepareStatement(s_SqlFatt); Date firstOfYear = getFirstOfYear((int)anno); Date lastOfYear = getLastOfYear((int)anno); ps.setDate(1, firstOfYear); ps.setDate(2, lastOfYear); Vectumerator vec = findRows(ps); long i = 0L; Date lastDate = firstOfYear; if (getDocumentoAnnoIniziale() == anno && getDocumentoNumeroIniziale() > 1L) i = getDocumentoNumeroIniziale() - 1L; while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); if (row.getProgDocumentoAgg().isEmpty()) i++; if (row.getProgDocumento() != i) return row.getNumeroDocumentoCompleto() + " del " + row.getNumeroDocumentoCompleto(); if (getDateDiff(row.getDataDocumento(), lastDate) > 0L) return row.getNumeroDocumentoCompleto() + " del " + row.getNumeroDocumentoCompleto(); lastDate = row.getDataDocumento(); } return ""; } catch (Exception e) { handleDebug(e, 2); return "Errore! " + e.getMessage(); } } public String getDescrizioneAllegato() { return (this.descrizioneAllegato == null) ? "" : this.descrizioneAllegato; } public void setDescrizioneAllegato(String descrizioneAllegato) { this.descrizioneAllegato = descrizioneAllegato; } public long getId_ivaDoc() { return this.id_ivaDoc; } public Iva getIvaDoc() { this.ivaDoc = (Iva)getSecondaryObject(this.ivaDoc, Iva.class, getId_ivaDoc()); return this.ivaDoc; } public void setId_ivaDoc(long newId_iva) { this.id_ivaDoc = newId_iva; setIvaDoc(null); } public void setIvaDoc(Iva newIva) { this.ivaDoc = newIva; } public String getInterventoEffettuato() { return (this.interventoEffettuato == null) ? "" : this.interventoEffettuato.trim(); } public double getImportoConsuntivo() { return this.importoConsuntivo; } public void setImportoConsuntivo(double importoConsuntivo) { this.importoConsuntivo = importoConsuntivo; } protected void creaDocumentoFooterFatture(Table l_pdfCorpo, boolean isUltimaPagina) { double totImponibileMerce, totImponibile, totImposta; int cellLeading = 8; NumberFormat nf = getNf(); RigheRegistroIva rri = getRigaRegistroIvaCompleto(); String codIva = "", imponibile = "", aliquota = "", imposta = ""; DoubleOperator totaleFatturaFromRri = new DoubleOperator(); DoubleOperator totaleIvaFromRri = new DoubleOperator(); if (rri != null) { Enumeration enuRrri = rri.elementsFatt(); while (enuRrri.hasMoreElements()) { RigaRegistroIvaItem rrii = enuRrri.nextElement(); if (rrii.getImponibile() != 0.0D) { if (getFlgArt8() == 1L) { imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n0"; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; continue; } imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n" + imposta; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; totaleFatturaFromRri.add(rrii.getImponibile()); totaleIvaFromRri.add(rrii.getImportoIva()); } } } long resHasUsato = hasRigheConUsato(); if (resHasUsato == 1L) { totImponibileMerce = totaleFatturaFromRri.getResult(); totImponibile = totaleFatturaFromRri.getResult(); totImposta = totaleIvaFromRri.getResult(); } else { totImponibileMerce = getImponibileRighe(); totImponibile = getImponibileTotale(); totImposta = getImportoIvaTotale(); } try { String bancaDesc; Cell cell = new Cell(new Chunk("ALIQ.", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(codIva, PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPONIBILE", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imponibile, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPOSTA\t", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imposta, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); cell.setRowspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SCONTO INC.\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getScontoIncondizionato()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("ABBUONO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getAbbuono() != 0.0D) { cell.add(new Chunk(nf.format(getAbbuono()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE TRASPORTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseTrasporto() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseTrasporto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE MERCE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && totImponibileMerce != 0.0D) { cell.add(new Chunk(nf.format(totImponibileMerce), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE INCASSO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseIncasso() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseIncasso()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE VARIE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseAltre() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseAltre()), PdfFontFactory.PDF_fPiccoloB)); if (!getDescSpeseAltre().isEmpty()) cell.add(new Chunk(" " + getDescSpeseAltre(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(11); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE NETTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && totImponibile != 0.0D) { cell.add(new Chunk(nf.format(totImponibile), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); String temp = getElencoScadenze2Righe(); cell = new Cell(new Chunk("SCADENZE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && !temp.isEmpty()) { cell.add(new Chunk(temp, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(23); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. ESENTE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPONIBILE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(totImponibile), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPOSTA\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(totImposta), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("\n", PdfFontFactory.PDF_fPiccolissimo)); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("ACCONTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getAcconto() != 0.0D) { cell.add(new Chunk(nf.format(getAcconto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleDocumento() != 0.0D) { cell.add(new Chunk("EUR " + nf.format(getTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); if (getIban().isEmpty()) { Banca banca = new Banca(getApFull()); bancaDesc = banca.getBancheDefaultBonificoDesc(); } else { bancaDesc = getBancaDesc() + " " + getBancaDesc(); } cell = new Cell(new Chunk("NS BANCA: " + bancaDesc, PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading(10.0F); cell.setBorder(2); cell.setColspan(40); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } protected void creaDocumentoIntestazioneCorpoFt(Table l_pdfCorpo) { int cellLeading = 8; try { Cell cell = new Cell(); cell.addElement(new Chunk("DESCRIZIONE", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[0]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("QUAN.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[1]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PREZZO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[2]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SC.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[3]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPORTO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[4]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IVA", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_STD_[5]); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e); } } public ByteArrayOutputStream creaLabelDocumentoArticoliAccZebraPdf(DocumentoCR CR) { long pHMarg = 2L; ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { String dim = getParm("LABEL_ART_SIZE").getTesto(); long xx = Long.parseLong(dim.substring(0, dim.indexOf(','))); long yy = Long.parseLong(dim.substring(dim.indexOf(',') + 1)); 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 titoloReport = getNumeroDocumentoCompleto(); SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.document.open(); long labelNumber = 0L; int nCol = 4; int nRow = 10; float[] widths = { 0.25F, 0.25F, 0.25F, 0.25F }; this.pdfPcorpo = new PdfPTable(widths); this.pdfPcorpo.setWidthPercentage(100.0F); Documento doc = new Documento(getApFull()); doc.findByPrimaryKey(CR.getId_documentoS()); if (doc.hasLabelAccessoriDaStampare()) { Vectumerator vec = findByCR(CR, 0, 0); long numbOfLabels = 1L; while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vecRighe = row.findRigheDocumento(0, 0, ordineInverso); while (vecRighe.hasMoreElements()) { RigaDocumento rowRD = (RigaDocumento)vecRighe.nextElement(); if (rowRD.getFlgUdm() == 1L) { numbOfLabels = (long)rowRD.getQuantita(); } else { numbOfLabels = 1L; } rowRD.getArticolo().setWriter(getWriter()); rowRD.getArticolo().setPdfPcorpo(getPdfPcorpo()); rowRD.getArticolo().setDocument(this.document); String descLabel = rowRD.getDescrizioneRigaCompleta(); numbOfLabels = (long)rowRD.getArticolo().addLabelUnArticoloAccZebraPdf(numbOfLabels, labelNumber, descLabel); labelNumber += numbOfLabels; } } long numberBlankCell = (long)nCol - labelNumber % (long)nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); if (numberBlankCell != (long)nCol) for (int i = 0; (long)i < numberBlankCell; i++) this.pdfPcorpo.addCell(cell); } else { Phrase ph = new Phrase("Attenzione! Non ci sono etichette da stampare!"); PdfPCell cell = new PdfPCell(ph); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); cell.setColspan(nCol); this.pdfPcorpo.addCell(cell); } this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public ByteArrayOutputStream creaLabelDocumentoArticoliZebraPdf(DocumentoCR CR) { long pHMarg = 2L; ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { String dim = getParm("LABEL_ART_SIZE").getTesto(); long xx = Long.parseLong(dim.substring(0, dim.indexOf(','))); long yy = Long.parseLong(dim.substring(dim.indexOf(',') + 1)); 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(); this.document.open(); long labelNumber = 0L; int nCol = 4; int nRow = 10; float[] widths = { 0.25F, 0.25F, 0.25F, 0.25F }; this.pdfPcorpo = new PdfPTable(widths); this.pdfPcorpo.setWidthPercentage(100.0F); Documento doc = new Documento(getApFull()); doc.findByPrimaryKey(CR.getId_documentoS()); if (doc.hasLabelDaStampare()) { if (CR.getBlankLabels() > 0L) { PdfPCell pdfPCell = new PdfPCell(); pdfPCell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); pdfPCell.setBorder(0); for (int i = 0; (long)i < CR.getBlankLabels(); i++) { labelNumber++; this.pdfPcorpo.addCell(pdfPCell); } } Vectumerator vec = findByCR(CR, 0, 0); long numbOfLabels = 1L; while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vecRighe = row.findRigheDocumento(0, 0, ordineInverso); while (vecRighe.hasMoreElements()) { RigaDocumento rowRD = (RigaDocumento)vecRighe.nextElement(); if (rowRD.getFlgUdm() == 1L) { numbOfLabels = (long)rowRD.getQuantita(); } else { numbOfLabels = 1L; } rowRD.getArticolo().setWriter(getWriter()); rowRD.getArticolo().setPdfPcorpo(getPdfPcorpo()); rowRD.getArticolo().setDocument(this.document); String descLabel = rowRD.getDescrizioneRigaCompleta(); numbOfLabels = (long)rowRD.getArticolo().addLabelUnArticoloZebraPdf(numbOfLabels, null); labelNumber += numbOfLabels; } } long numberBlankCell = (long)nCol - labelNumber % (long)nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); if (numberBlankCell != (long)nCol) for (int i = 0; (long)i < numberBlankCell; i++) this.pdfPcorpo.addCell(cell); } else { Phrase ph = new Phrase("Attenzione! Non ci sono etichette da stampare!"); PdfPCell cell = new PdfPCell(ph); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); cell.setColspan(nCol); this.pdfPcorpo.addCell(cell); } this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public String getDescTransaction() { return (this.descTransaction == null) ? "" : this.descTransaction; } public void setDescTransaction(String descTransaction) { this.descTransaction = descTransaction; } public Date getDataTransaction() { return this.dataTransaction; } public void setDataTransaction(Date dataTransaction) { this.dataTransaction = dataTransaction; } public long getFlgProcediPagamento() { return this.flgProcediPagamento; } public void setFlgProcediPagamento(long flgProcediPagamento) { this.flgProcediPagamento = flgProcediPagamento; } public long getFlgStatoOrdineWww() { return this.flgStatoOrdineWww; } public void setFlgStatoOrdineWww(long flgStatoOrdineWww) { this.flgStatoOrdineWww = flgStatoOrdineWww; } public static final String getStatoOrdineWww(long l_flgStato) { if (l_flgStato == 0L) return "Confermato"; if (l_flgStato == 1L) return "In Lavorazione"; if (l_flgStato == 2L) return "Spedito"; if (l_flgStato == 9L) return "Chiuso"; if (l_flgStato == 99L) return "Annullato"; if (l_flgStato == 10L) return "Aperti"; if (l_flgStato == 11L) return "Chiusi e Annullati"; if (l_flgStato == -1L) return "-- Tutti --"; return "??"; } public static final String getStatoResoWww(long l_flgStato) { if (l_flgStato == 1L) return "Richiesta Reso"; if (l_flgStato == 2L) return "Reso accettato"; if (l_flgStato == 3L) return "Reso Completato"; if (l_flgStato == 99L) return "Reso Respinto"; if (l_flgStato == 0L) return "Nessuna Richiesta"; return "??"; } public long getId_ordine() { return getId_documento(); } public String getStatoOrdineWww() { if (getFlgStatoOrdineWww() == 2L && !getTrackingSpedizione().isEmpty()) return getVettore().getDescrizione() + " " + getVettore().getDescrizione(); return getStatoOrdineWww(getFlgStatoOrdineWww()); } public long getStatoPagato() { if (getDataPagamento() != null) return 2L; if (getTipoPagamento().getFlgTipoPagamento() == 5L) { if (getDataTransaction() != null && getDataPagamento() == null) return 1L; return 0L; } return 0L; } public ResParm sendResoMailMessage() { ResParm rp = new ResParm(true); return rp; } public void setId_ordine(long l_id_ordine) { setId_documento(l_id_ordine); } public String getCapSped() { return (this.capSped == null) ? "" : this.capSped; } public String getCittaSped() { return (this.cittaSped == null) ? "" : this.cittaSped; } public void setCapSped(String capSped) { this.capSped = capSped; } public void setCittaSped(String cittaSped) { this.cittaSped = cittaSped; } public String getProvinciaSped() { return (this.provinciaSped == null) ? "" : this.provinciaSped.trim(); } public void setProvinciaSped(String provinciaSped) { this.provinciaSped = provinciaSped; } private static final synchronized ResParm addRigaDocumentoMagArticolo(DocumentoInterface doc, RigaDocumento rd) { ResParm rp = doc.checkEMSTA(); if (!rp.getStatus()) return new ResParm(false, "ATTENZIONE! Tentativo di aggiungere una riga documento: " + rp.getMsg()); rd.setId_documento(doc.getId_documento()); double l_qtaDb = 0.0D; long l_statoDb = 0L; long l_statoOrdineWwwDb = -99L; if (rd.getId_rigaDocumento() > 0L) { RigaDocumento rdB = new RigaDocumento(doc.getApFull()); rdB.findByPrimaryKey(rd.getId_rigaDocumento()); if (rdB.getId_articolo() == rd.getId_articolo()) { l_qtaDb = rdB.getNr(); l_statoDb = rdB.getDocumento().getFlgStato(); l_statoOrdineWwwDb = rdB.getDocumento().getFlgStatoOrdineWww(); } else { l_qtaDb = 0.0D; DoubleOperator dop = new DoubleOperator(rdB.getNr()); dop.multiply(-doc.getTipoDocumento().getFlgMovMagazzino()); dop.add(rdB.getArticolo().getQuantita()); rdB.getArticolo().setQuantita(dop.getResult()); rp = rdB.getArticolo().superSave(); } } if (rp.getStatus()) rp = rd.save(); if (rp.getStatus()) if (rd.getArticolo().usaMagazzino() && doc.getTipoDocumento().getFlgMovMagazzino() != 0L) if (doc.getFlgStato() == 1L && doc.getFlgStatoOrdineWww() != 99L) { DoubleOperator dop = new DoubleOperator(rd.getNr()); dop.subtract(l_qtaDb); dop.multiply(doc.getTipoDocumento().getFlgMovMagazzino()); dop.add(rd.getArticolo().getQuantita()); rd.getArticolo().setQuantita(dop.getResult()); if (rd.getArticolo().getQuantita() <= 0.0D && ( rd.getArticolo().getFlgUsato() > 0L || rd.getArticolo().getFlgStockOfferte() == 2L || rd.getArticolo().getFlgStockOfferte() == 3L || rd.getArticolo().getFlgEbay() == 1L)) rd.getArticolo().setFlgEscludiWebArt(1L); rd.getArticolo().handleQuantitaDebugBeforeSave("documento.addRigaDocumentoMagArticolo"); rp.append(rd.getArticolo().superSave()); } rp.append(doc.save()); if (rp.getStatus()) rp.setMsg("Riga aggiunta correttamente"); return rp; } public static final synchronized ResParm addRigaDocumento(DocumentoInterface doc, RigaDocumento row) { ResParm rp = doc.checkEMSTA(); if (!rp.getStatus()) return new ResParm(false, "ATTENZIONE! Tentativo di aggiungere una riga documento: " + rp.getMsg()); if (doc.getParm("USA_MAGAZZINO").isTrue()) return addRigaDocumentoMagArticolo(doc, row); RigaDocumento RD = new RigaDocumento(doc.getApFull()); double l_quantitaDisponibileMagPartenza = 0.0D; double l_quantitaDisponibileTuttiMagazziniInterniEsterni = 0.0D; double l_quantitaDisponibileMagazziniInterni = 0.0D; long l_id_magFisicoPartenza = row.getDocumento().getId_magFisicoPartenza(); long l_id_magFisicoArrivo = row.getDocumento().getId_magFisicoArrivo(); rp = new ResParm(true); RigaDocumento rowOnDb = new RigaDocumento(doc.getApFull()); rowOnDb.findByPrimaryKey(row.getId_rigaDocumento()); if (!row.getSeriale().trim().isEmpty() && row.getArticolo().getFlgSerialiMassivi() == 0L) { row.setQuantita(1.0D); row.setQuantitaUdm(1.0D); } if (rowOnDb.getDBState() == 1 && (rowOnDb.getId_articolo() != row.getId_articolo() || rowOnDb.getId_articoloVariante() != row.getId_articoloVariante() || !rowOnDb.getSeriale().equals(row.getSeriale()))) { rp = rowOnDb.delete(); if (!rp.getStatus()) return rp; row.setId_rigaDocumento(0L); row.setDBState(0); } if (row.getId_articolo() != 0L && l_id_magFisicoPartenza > 0L) { RD.findMagDisponibilitaPuntuale(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), row.getSeriale(), l_id_magFisicoPartenza, 0L, 0L); l_quantitaDisponibileMagPartenza = RD.getQuantita(); if (rowOnDb.getDBState() == 1) l_quantitaDisponibileMagPartenza += rowOnDb.getQuantita(); if (row.getArticolo().getTipo().getFlgTipoMagazzino() > 0L && row.getArticolo().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articolo() != 0L && l_id_magFisicoPartenza != 0L && row.getFlgReso() == 0L && l_quantitaDisponibileMagPartenza < row.getQuantita()) { rp.setStatus(false); rp.setMsg("Attenzione. Tentativo di utilizzare un articolo non disponibile"); return rp; } } if (row.getId_articolo() != 0L && l_id_magFisicoPartenza > 0L && row.getDocumento().getMagFisicoPartenza().getFlgTipo() == 1L && row.getArticolo().getTipo().getFlgTipoMagazzino() > 0L && row.getArticolo().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articolo() != 0L && rowOnDb.getDBState() == 0 && row.getFlgReso() == 0L && row.getFlgIgnoraPrenotazione() == 0L) { double totArticoliEffettivi = 0.0D; if (row.getSeriale().isEmpty()) { RD.findMagDisponibilitaPuntualeMagazziniInterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), null, 0L); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - row.getTotArticoliImpegnati(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia()); } else { RigaDocumento rd = new RigaDocumento(row.getApFull()); rd.findRigaImpegnoBySeriale(row.getId_articolo(), row.getId_articoloVariante(), row.getSeriale()); if (rd.getDBState() == 1) { if (row.getFlgIgnoraPrenotazione() == 1L) { rd.setSeriale(""); rd.save(); totArticoliEffettivi = 1.0D; } else { totArticoliEffettivi = 0.0D; } } else { RD.findMagDisponibilitaPuntualeMagazziniInterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), null, 0L); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - row.getTotArticoliImpegnati(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia()); } if (totArticoliEffettivi <= 0.0D) { rp.setStatus(false); rp.setMsg("Attenzione. L'articolo è in magazzino ma non disponibile perchè risulta impegnato. "); return rp; } } } if (l_id_magFisicoArrivo > 0L && ( row.getDocumento().getMagFisicoArrivo().getFlgTipo() == 1L || row.getDocumento().getMagFisicoArrivo().getFlgTipo() == 2L) && !row.getSeriale().trim().isEmpty() && row.getArticolo().getTipo().getFlgTipoMagazzino() == 2L && rowOnDb.getDBState() == 0) { if (RD.getParm("SERIALI_UNIVOCI").isTrue()) { RD.findMagDisponibilitaGlobaleMagazziniInterniEsterni(row.getId_articolo(), row.getSeriale(), 0L); } else { RD.findMagDisponibilitaPuntualeMagazziniInterniEsterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), row.getSeriale(), 0L); } l_quantitaDisponibileTuttiMagazziniInterniEsterni = RD.getQuantita(); if (l_quantitaDisponibileTuttiMagazziniInterniEsterni >= 1.0D) { rp.setStatus(false); rp.setMsg("Attenzione. Stai inserendo un seriale già caricato in magazzino."); return rp; } } long l_numSeriali = 1L; if (doc.getTipoDocumento().getFlgTipologia() != 3L && row.getArticolo().getFlgSerialiMassivi() == 1L && row.getQuantita() > 1.0D) { l_numSeriali = (long)row.getQuantita(); row.setQuantita(1.0D); row.setQuantitaUdm(1.0D); } for (int i = 0; (long)i < l_numSeriali; i++) { RigaDocumento bean = new RigaDocumento(doc.getApFull()); if (row.getId_rigaDocumento() != 0L) { bean.findByPrimaryKey(row.getId_rigaDocumento()); } else if (row.getId_articolo() != 0L && row.getFlgSingleLineArt() == 1L && ( doc.getTipoDocumento().getFlgTipologia() == 3L || doc.getTipoDocumento().getFlgTipologia() == 4L || row.getArticolo().getTipo().getFlgTipoMagazzino() != 2L)) { if (row.getId_articoloTaglia() != 0L) { bean.findFirstByDocumentoArticoloTaglia(row.getId_documento(), row.getId_articoloTaglia()); } else if (row.getId_articoloVariante() != 0L) { bean.findFirstByDocumentoArticoloVariante(row.getId_documento(), row.getId_articoloVariante()); } else if (row.getId_articolo() != 0L) { bean.findFirstByDocumentoArticolo(row.getId_documento(), row.getId_articolo()); } row.setId_rigaDocumento(bean.getId_rigaDocumento()); row.addQuantita(bean.getQuantita()); } row.setDBState(bean.getDBState()); row.setQuantitaOld(bean.getQuantitaOld()); row.setId_documento(doc.getId_documento()); rp.append(row.save()); if (!rp.getStatus()) return rp; if (l_numSeriali > 1L) try { long currentSeriale = Long.valueOf(row.getSeriale()); currentSeriale++; String newSeriale = zeroLeft(currentSeriale, row.getSeriale().length()); row.setSeriale(newSeriale); row.setId_rigaDocumento(0L); row.setDBState(0); } catch (Exception e) { rp.setStatus(false); rp.setMsg("Errore! seriale non numerico per carico massivo: " + row.getSeriale()); return rp; } } if (rp.getStatus()) rp.setMsg(AbMessages.getMessage("SAVE_OK")); return rp; } public static final synchronized ResParm riordinaRigheDocPerRiferimentoOld(DocumentoInterface doc) { ResParm rp = new ResParm(true); String TAG_THREAD_MSG = "RIORDINO RIGHE"; Vectumerator vecRD = doc.findRigheDocumentoOBRiferimento(0, 0); StatusMsg.updateMsgByTag(doc.getApFull(), "RIORDINO RIGHE", "...inizio ..."); int i = 0; int totRighe = vecRD.getTotNumberOfRecords(); while (vecRD.hasMoreElements() && rp.getStatus()) { i++; RigaDocumento row = (RigaDocumento)vecRD.nextElement(); StatusMsg.updateMsgByTag(doc.getApFull(), "RIORDINO RIGHE", "riga " + i + " su " + totRighe); try { RigaDocumento rowNew = (RigaDocumento)row.clone(); rowNew.setId_rigaDocumento(0L); rowNew.setDBState(0); rp = rowNew.save(); if (rp.getStatus()) rp = row.delete(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } if (rp.getStatus()) rp.setMsg("Riordino righe per riferimento completato"); StatusMsg.deleteMsgByTag(doc.getApFull(), "RIORDINO RIGHE"); return rp; } public static final synchronized Vectumerator findTessutiPerTaglio(Documento bean) { ResParm rp = new ResParm(true); boolean debug = false; String debugIngo = "findTessutiPerTaglio"; HashMap hmTess = new HashMap<>(); Vectumerator vec = bean.findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_articoloVariante() > 0L) { Vectumerator vecAAT = row.getArticoloVariante().findArticoliTessuto(); while (vecAAT.hasMoreElements()) { DoubleOperator dop; ArticoloTessutoColore atc; ArticoloArticoloTessuto rowAAT = (ArticoloArticoloTessuto)vecAAT.nextElement(); logDebug(debug, "" + rowAAT.getId_articoloTessuto() + " " + rowAAT.getId_articoloTessuto() + " " + rowAAT.getId_articoloTessutoColore() + " " + rowAAT.getArticoloTessutoColore().getDescrizioneCompleta()); if (hmTess.containsKey(Long.valueOf(rowAAT.getId_articoloTessutoColore()))) { atc = hmTess.get(Long.valueOf(rowAAT.getId_articoloTessutoColore())); dop = new DoubleOperator(atc.getMtLavorazioneTaglio()); } else { atc = rowAAT.getArticoloTessutoColore(); dop = new DoubleOperator(); } DoubleOperator dopRow = new DoubleOperator(rowAAT.getMtATT()); NumeroTeliRiga ntr = row.getNumeroTeliRigaByTessuto(row.getId_rigaDocumento()); System.out.println("findTessutiPerTaglio num teli riga: " + ntr.getNumTeliRiga() + " capi per telo: " + row.getCapiPerTelo() + " quantita': " + row.getQuantita()); dopRow.multiply(row.getQuantita()); dop.add(dopRow.getResult()); atc.setMtLavorazioneTaglio(dop.getResult()); hmTess.put(Long.valueOf(rowAAT.getId_articoloTessutoColore()), atc); } continue; } if (row.getId_articolo() > 0L) { Vectumerator vecAAT = row.getArticolo().findArticoliTessuto(); while (vecAAT.hasMoreElements()) { DoubleOperator dop; ArticoloTessutoColore atc; ArticoloArticoloTessuto rowAAT = (ArticoloArticoloTessuto)vecAAT.nextElement(); if (hmTess.containsKey(Long.valueOf(rowAAT.getId_articoloTessutoColore()))) { atc = hmTess.get(Long.valueOf(rowAAT.getId_articoloTessutoColore())); dop = new DoubleOperator(atc.getMtLavorazioneTaglio()); } else { atc = rowAAT.getArticoloTessutoColore(); dop = new DoubleOperator(); } DoubleOperator dopRow = new DoubleOperator(rowAAT.getMtATT()); dopRow.multiply(row.getQuantita()); dop.add(dopRow.getResult()); atc.setMtLavorazioneTaglio(dop.getResult()); hmTess.put(Long.valueOf(rowAAT.getId_articoloTessutoColore()), atc); } } } Vectumerator vecRes = new Vectumerator(); Set keySet = hmTess.keySet(); for (Long key : keySet) { ArticoloTessutoColore atc = hmTess.get(key); vecRes.add(atc); logDebug(debug, "art tess:" + atc.getId_articoloTessuto() + " art tess col: " + atc.getId_articoloTessutoColore() + " mt" + atc.getMtLavorazioneTaglio()); } return vecRes; } public static final synchronized Vectumerator findTessutiBasePerTaglio(Documento bean) { ResParm rp = new ResParm(true); boolean debug = false; String debugIngo = "findTessutiBasePerTaglio"; Vectumerator vecRes = new Vectumerator(); Vectumerator vec = bean.getArticolo().findArticoliTessuto(); HashMap hmTess = new HashMap<>(); while (vec.hasMoreElements()) { ArticoloArticoloTessuto rowAAT = (ArticoloArticoloTessuto)vec.nextElement(); if (rowAAT.getId_articoloTessutoColore() == 0L) { System.out.println(rowAAT.getId_articoloTessuto()); if (hmTess.containsKey(Long.valueOf(rowAAT.getId_articoloTessuto()))) { at = hmTess.get(Long.valueOf(rowAAT.getId_articoloTessuto())); continue; } ArticoloTessuto at = rowAAT.getArticoloTessuto(); hmTess.put(Long.valueOf(rowAAT.getId_articoloTessuto()), at); } } Vectumerator vecRD = bean.findRigheDocumento(1L, 0, 0, 0); while (vecRD.hasMoreElements()) { RigaDocumento rowRD = (RigaDocumento)vecRD.nextElement(); System.out.println(rowRD.getId_articoloTessuto()); if (hmTess.containsKey(Long.valueOf(rowRD.getId_articoloTessuto()))) { ArticoloTessuto at = hmTess.get(Long.valueOf(rowRD.getId_articoloTessuto())); DoubleOperator dop = new DoubleOperator(at.getMtLavorazioneTaglio()); dop.add(rowRD.getMt()); at.setMtLavorazioneTaglio(dop.getResult()); hmTess.put(Long.valueOf(rowRD.getId_articoloTessuto()), at); } } Set keySet = hmTess.keySet(); for (Long key : keySet) vecRes.add(hmTess.get(key)); return vecRes; } private String getNuovoProgressivoDocumentoXpay() { return String.valueOf(Calendar.getInstance().getTimeInMillis() + (long)(Math.random() * 1000.0D)); } public String getId_documentoXpay() { if (this.id_documentoXpay != null && this.id_documentoXpay.isEmpty()) return null; return this.id_documentoXpay; } public String getId_documentoCript() { return crypt(String.valueOf(getId_documento())); } public void setId_documentoXpay(String id_ordineIG) { this.id_documentoXpay = id_ordineIG; } public ResParm agiornaNuovoId_documentoXpay() { ResParm rp = new ResParm(); if (getDBState() == 1) { setId_documentoXpay(getNuovoProgressivoDocumentoXpay()); rp = super.save(); } else { rp.setStatus(false); rp.setMsg("agiornaNuovoId_documentoXpay: Documento nullo"); } return rp; } public void findByDocumentoXpay(String l_id_documentoXpay) { String s_Sql_Find = "select A.* from DOCUMENTO as A where id_documentoXpay='" + l_id_documentoXpay + "'"; try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find); findFirstRecord(stmt); } catch (Exception e) { handleDebug(e, 2); } } public ResParm sendOrderMailMessage(String lang, boolean mailAdmin, boolean mailUser, boolean isPagamentoVariato) { ResParm rp = new ResParm(true); if (getId_documento() == 0L) { rp.setStatus(false); rp.setMsg("ERRORE! Codice Documento nullo! contattare l'amministratore del sito"); handleDebug(rp.getMsg(), 0); return rp; } try { int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; String subject = getMailSubject(); NumberFormat nf = getNf(); String notePagamento = "", statoPagamento = "", notaStato = ""; String orderLine = ""; String orderLine2 = ""; DoubleOperator totaleCosto = new DoubleOperator(); double totaleQta = 0.0D; statoPagamento = "Metodo di pagamento scelto: " + getTipoPagamento().getDescrizione(); if (getStatoPagato() == 1L) statoPagamento = statoPagamento + "
Transazione n. " + statoPagamento + " del " + getDescTransaction(); if (getStatoPagato() == 2L) statoPagamento = statoPagamento + "
Data Pagamento: " + statoPagamento; if (getStatoPagato() == 0L) { if (getFlgProcediPagamento() == 1L) { notePagamento = getTipoPagamento().getMsgMailProcedi(lang); if (getTipoPagamento().getFlgTipoPagamento() == 5L) notePagamento = notePagamento + "
Clicca qui"; } else { notePagamento = getTipoPagamento().getMsgMailAspetta(lang); } } else { notePagamento = ""; } if (getFlgStatoOrdineWww() == 2L) notaStato = getParm("MSG_ORDINE_SPEDITO").getTesto(); if (mailUser || isPagamentoVariato) { MailMessage mf = new MailMessage(getApFull(), getCheckOutMailMessage(lang)); mf.setQuestionMark(false); mf.setString("id_ordine", String.valueOf(getId_ordine())); mf.setString("stato", getStato()); mf.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mf.setString("statoPagamento", statoPagamento); mf.setString("notaPagamento", notePagamento); mf.setLong("id_users", getClifor().getId_clifor()); mf.setString("nominativo", getClifor().getCognome()); mf.setString("nome", getClifor().getNome()); mf.setString("cognome", getClifor().getCognome()); mf.setString("indirizzo", getClifor().getIndirizzo()); mf.setString("numero", getClifor().getNumeroCivico()); String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); mf.setString("cap", capComune); mf.setString("citta", getClifor().getDescrizioneComune()); mf.setString("nazione", getClifor().getNazione().getDescrizione(lang)); mf.setString("provincia", getClifor().getProvinciaComune()); mf.setString("codfisc", getClifor().getCodFisc()); mf.setString("piva", getClifor().getPIva()); mf.setString("email", getClifor().getEMail()); if (getIndirizzoSped().trim().equals("")) { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mf.setString("indirizzoSped", getClifor().getIndirizzo() + " c/o " + getClifor().getIndirizzo()); } mf.setString("numeroSped", getClifor().getNumeroCivico()); mf.setString("capSped", getClifor().getCapComune()); mf.setString("cittaSped", getClifor().getDescrizioneComune()); mf.setString("provinciaSped", getClifor().getProvinciaComune()); mf.setString("nazioneSped", getClifor().getNazione().getDescrizione(lang)); } else { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getIndirizzoSped()); } else { mf.setString("indirizzoSped", getIndirizzoSped() + " c/o " + getIndirizzoSped()); } mf.setString("numeroSped", getNumeroCivicoSped()); mf.setString("capSped", getCapSped()); mf.setString("cittaSped", getCittaSped()); mf.setString("provinciaSped", getProvinciaSped()); mf.setString("nazioneSped", getNazioneSped().getDescrizione(lang)); } Vectumerator enu = findRigheDocumento(0, 0, ordineInverso); while (enu.hasMoreElements()) { RigaDocumento row = (RigaDocumento)enu.nextElement(); orderLine = orderLine + " " + orderLine + " " + row.getDescrizioneRigaCompleta() + " " + nf.format(row.getImponibile()) + " " + nf.format(row.getSconto()) + " " + row.getQuantita() + "\n"; totaleQta += row.getQuantita(); } mf.setString("orderline", orderLine); if (getTotaleScontiAbbuoniConIva() > 0.0D) { mf.setString("descSconto", "**** " + translate("SCONTO INCONDIZIONATO", lang) + " *****"); mf.setString("scontoInc", " - " + nf.format(getTotaleScontiAbbuoniConIva())); } mf.setString("qta", nf.format(totaleQta)); mf.setString("totale", nf.format(getImponibileTotale())); mf.setString("totaleOrdine", nf.format(getTotaleDocumento())); mf.setString("iva", nf.format(getImportoIvaTotale())); mf.setString("speseSped", nf.format(getSpeseTrasporto())); mf.setString("nota", String.valueOf(getNote())); mf.setString("notaStato", notaStato); mf.setString("codiceOrdine", String.valueOf(getId_ordine())); mf.setString("telefono", getClifor().getCellulare()); String theSubject = subject; if (mailUser) rp = mf.sendMailMessageSystem(getClifor().getEMail(), theSubject + " - Ordine n. " + theSubject, true); if (isPagamentoVariato) { theSubject = theSubject + " - Ordine n. " + theSubject + " - " + String.valueOf(getId_ordine()) + " - "; theSubject = theSubject + "PAGAMENTO VARIATO "; theSubject = theSubject + theSubject; rp.append(mf.sendMailMessageSystem(getMailTo(), theSubject, false)); } } if (mailAdmin) { String mmfAdmMessage = getCheckOutMailMessage(lang); MailMessage mfAdm = new MailMessage(getApFull(), mmfAdmMessage); mfAdm.setQuestionMark(false); mfAdm.setString("id_ordine", String.valueOf(getId_ordine())); mfAdm.setString("stato", getStato()); mfAdm.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mfAdm.setString("statoPagamento", statoPagamento); mfAdm.setString("notaPagamento", notePagamento); mfAdm.setLong("id_users", getClifor().getId_clifor()); mfAdm.setString("nominativo", getClifor().getCognome()); mfAdm.setString("nome", getClifor().getNome()); mfAdm.setString("cognome", getClifor().getCognome()); mfAdm.setString("indirizzo", getClifor().getIndirizzo()); mfAdm.setString("numero", getClifor().getNumeroCivico()); mfAdm.setString("cap", getClifor().getCapComune()); mfAdm.setString("citta", getClifor().getDescrizioneComune()); mfAdm.setString("provincia", getClifor().getProvinciaComune()); mfAdm.setString("codfisc", getClifor().getCodFisc()); mfAdm.setString("piva", getClifor().getPIva()); mfAdm.setString("email", getClifor().getEMail()); if (getIndirizzoSped().trim().equals("")) { if (getPresso().isEmpty()) { mfAdm.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mfAdm.setString("indirizzoSped", getClifor().getIndirizzo() + " c/o " + getClifor().getIndirizzo()); } mfAdm.setString("numeroSped", getClifor().getNumeroCivico()); mfAdm.setString("capSped", getClifor().getCapComune()); mfAdm.setString("cittaSped", getClifor().getDescrizioneComune()); mfAdm.setString("provinciaSped", getClifor().getProvinciaComune()); } else { if (getPresso().isEmpty()) { mfAdm.setString("indirizzoSped", getIndirizzoSped()); } else { mfAdm.setString("indirizzoSped", getIndirizzoSped() + " c/o " + getIndirizzoSped()); } mfAdm.setString("numeroSped", getNumeroCivicoSped()); mfAdm.setString("capSped", getCapSped()); mfAdm.setString("cittaSped", getCittaSped()); mfAdm.setString("provinciaSped", getProvinciaSped()); } orderLine2 = ""; totaleCosto = new DoubleOperator(); totaleQta = 0.0D; String stileRicarico = ""; Vectumerator enu = findRigheDocumento(0, 0, ordineInverso); while (enu.hasMoreElements()) { RigaDocumento row = (RigaDocumento)enu.nextElement(); orderLine2 = orderLine2 + " " + orderLine2 + " " + row.getDescrizioneRigaCompleta() + " " + nf.format(row.getImponibile()) + " " + nf.format(row.getSconto()) + " " + row.getQuantita() + "\n"; DoubleOperator totaleArticolo = new DoubleOperator(row.getImponibile()); totaleArticolo.multiply(row.getQuantita()); totaleCosto.add(totaleArticolo); totaleQta += row.getQuantita(); } mfAdm.setString("orderline", orderLine2); mfAdm.setString("qta", nf.format(totaleQta)); mfAdm.setString("iva", nf.format(getImportoIvaTotale())); mfAdm.setString("speseSped", nf.format(getSpeseTrasporto())); mfAdm.setString("totale", nf.format(getImponibileTotale())); mfAdm.setString("totaleOrdine", nf.format(getTotaleDocumento())); mfAdm.setString("nota", String.valueOf(getNote())); mfAdm.setString("notaAmm", "Nota su cliente:" + String.valueOf(getClifor().getNota() + "\nNota su Ordine: " + getClifor().getNota() + "\nNota Mail: " + getNotaAggiuntiva())); mfAdm.setString("codiceOrdine", String.valueOf(getId_ordine())); mfAdm.setString("telefono", getClifor().getCellulare()); mfAdm.setString("orderline", orderLine2); mfAdm.setString("notaStato", notaStato); String sbjAdmin = subject + " - Adm Ordine n. " + subject + " - " + String.valueOf(getId_ordine()) + " - "; if (isPagamentoVariato) sbjAdmin = sbjAdmin + "PAGAMENTO VARIATO "; sbjAdmin = sbjAdmin + sbjAdmin; String to = getMailTo(); rp.append(mfAdm.sendMailMessageSystem(to, sbjAdmin, true)); } } catch (Exception e) { handleDebug(e); rp.setStatus(false); rp.setMsg(e); System.out.println("ERRORE INVIO EMAIL:"); e.printStackTrace(); } if (!rp.getStatus()) { handleDebug(rp.getMsg(), 2); System.out.println("ERRORE INVIO EMAIL:" + rp.getMsg()); } return rp; } public String getCheckOutMailMessage(String lang) { if (lang != null && lang.isEmpty()) lang = "it"; String temp = getDocBase() + getDocBase(); if (lang != null && !lang.isEmpty()) { int dot = temp.lastIndexOf("."); if (dot > 0) temp = temp.substring(0, dot) + "_" + temp.substring(0, dot) + lang.toLowerCase(); } return temp; } public String getId_ordineCript() { return crypt(String.valueOf(getId_ordine())); } public ResParm stampaScontrinoEpson(boolean isFiscale, RegCassa l_regCassa) { EpsonCash ep; ResParm rp = new ResParm(true); boolean footerFirma = false; BarcodeCash bc = null; NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); if (isFiscale) { ep = new EpsonCash(1L, 1, l_regCassa.getIpCassa()); } else { ep = new EpsonCash(1L, 2, l_regCassa.getIpCassa()); } Vectumerator vec = new RigaDocumento(getApFull()).findByDocumento(0L, getId_documento(), "", 0, 0, 0); while (vec.hasMoreElements()) { String descrizioneAggiuntiva; RigaDocumento row = (RigaDocumento)vec.nextElement(); String reparto = "" + row.getReparto().getSiglaEpson() + row.getReparto().getSiglaEpson(); StringBuffer temp = new StringBuffer(); if (row.isDescScontrinoFull()) { temp.append(" "); if (row.getId_articoloVariante() != 0L) { temp.append(row.getArticoloVariante().getDescrizioneCompleta()); } else { temp.append(row.getArticolo().getDescrizioneCompleta()); } if (!row.getSeriale().isEmpty()) { temp.append(" "); temp.append(row.getSeriale()); } } temp.append(" "); temp.append(row.getDescrizioneRiga()); String desc = temp.toString().trim(); desc = desc.replaceAll("€", "euro"); if (row.getImportoConSconto() < 0.0D) { if (row.getFlgReso() == 1L || row.getArticolo().getFlgNegativo() == 1L) { ep.addRefund(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), 4L); continue; } ep.addDiscoutUplift(desc, row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), 3L); continue; } String notaRigaDocumento = row.getNotaRigaDocumento() + " "; if (getCodiceIvaVendStd() != row.getIva().getId_iva()) { if (isFiscale) { descrizioneAggiuntiva = DBAdapter.spaceRight(row.getIva().getDescrizione(), 37) + DBAdapter.spaceRight(row.getIva().getDescrizione(), 37); if (!row.getSeriale().isEmpty()) descrizioneAggiuntiva = descrizioneAggiuntiva + descrizioneAggiuntiva; } else if (row.getSconto() > 0.0D) { descrizioneAggiuntiva = DBAdapter.spaceRight("SCONT0 APPLICATO " + String.valueOf(nf.format(row.getSconto())) + "%", 37) + DBAdapter.spaceRight("SCONT0 APPLICATO " + String.valueOf(nf.format(row.getSconto())) + "%", 37); if (!row.getSeriale().isEmpty()) descrizioneAggiuntiva = descrizioneAggiuntiva + descrizioneAggiuntiva; } else { descrizioneAggiuntiva = notaRigaDocumento; if (!row.getSeriale().isEmpty()) descrizioneAggiuntiva = descrizioneAggiuntiva + descrizioneAggiuntiva; } } else { descrizioneAggiuntiva = notaRigaDocumento; if (!row.getSeriale().isEmpty()) descrizioneAggiuntiva = descrizioneAggiuntiva + descrizioneAggiuntiva; } if (isFiscale) { if (row.getSconto() > 0.0D) { ep.addArticle(desc, row.getQuantita(), row.getImporto(), false, row.getReparto().getSiglaEpson(), descrizioneAggiuntiva); ep.addDiscoutUplift("SCONT0 " + row.getSconto() + "%", row.getImportoSconto(), false, row.getReparto().getSiglaEpson(), 3L); continue; } ep.addArticle(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), descrizioneAggiuntiva); continue; } bc = null; if (row.getArticolo().getTipo().getFlgStampaBarcode() == 1L && !row.getNotaBarcode().isEmpty()) { footerFirma = true; bc = new BarcodeCash(); bc.setPosizione(10L); bc.setLarghezza(2L); bc.setAltezza(66L); bc.setPosizioneTesto(BarcodeCash.POSIZIONE_TESTO_SOTTO); bc.setFontTesto(BarcodeCash.FONT_C); bc.setTipoBarcode(BarcodeCash.BARCODE_CODE39); bc.setCode(row.getNotaBarcode()); } System.out.println(desc + "\n" + desc); ep.addArticle(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), descrizioneAggiuntiva, bc); } DoubleOperator importoPagatoD = new DoubleOperator(getContanti()); importoPagatoD.add(getAcconto()); double importoPagato = importoPagatoD.getResult(); if (importoPagato < getTotaleDocumento()) importoPagato = getTotaleDocumento(); ep.addTotal(getTipoPagamento().getDescrizione(), importoPagato, Long.valueOf(getTipoPagamento().getCodiceCassaEpson()).longValue()); String leNote = ""; if (getAcconto() > 0.0D) leNote = "ACCONTO EURO " + String.valueOf(nf.format(getAcconto())).replace(".", ","); if (!getCliforListino().getCodiceCartaFidelity().isEmpty()) leNote = leNote + "Fidelity Card: " + leNote + " " + getCliforListino().getCodiceCartaFidelity() + " LISTINO " + getCliforListino().getDescrizioneCompleta(); if (!getNote().isEmpty()) leNote = (leNote + " " + leNote).trim(); if (leNote.length() > 0) ep.addMessageFooter(leNote); if (footerFirma) { ep.addMessageFooter(" "); ep.addMessageFooter(" "); ep.addMessageFooter("FIRMA PER CONVALIDA"); ep.addMessageFooter(" "); ep.addMessageFooter(" "); ep.addMessageFooter("____________________________"); ep.addMessageFooter(" "); } if (isFiscale) { ep.addMessageFooter("N. DOCUMENTO " + getProgDocumento() + "/" + getId_esercizio()); ep.addMessageFooter("OP. " + getId_users()); if (!getParm("CASSA_STAMPA_PROMO").isEmpty()) { ep.addMessageFooter(" "); ep.addMessageFooter(getParm("CASSA_STAMPA_PROMO").getTesto()); } } else { ep.addMessageBody("N. DOCUMENTO " + getProgDocumento() + "/" + getId_esercizio()); ep.addMessageBody("OP. " + getId_users()); } rp = ep.stampa(); if (rp.getStatus() && isFiscale) { Calendar cal = Calendar.getInstance(); Timestamp ts = new Timestamp(cal.getTimeInMillis()); rp.append(aggiornaEchoScontrino(rp.getMsg() + " - " + rp.getMsg())); } if (!getParm("CASSA_STAMPA_DISPLAY").getTesto().isEmpty() || !getParm("CASSA_STAMPA_DISPLAY1").getTesto().equals("")) stampaDisplayCassa(l_regCassa, getParm("CASSA_STAMPA_DISPLAY").getTesto(), getParm("CASSA_STAMPA_DISPLAY1").getTesto(), 5); return rp; } public ResParm stampaScontrinoSiemens(boolean isFiscale, RegCassa l_regCassa) { ResParm rp = new ResParm(true); return rp; } public double getContanti() { return this.contanti; } public void setContanti(double contanti) { this.contanti = contanti; } public long getFlgRitiroNegozio() { return this.flgRitiroNegozio; } public void setFlgRitiroNegozio(long flgRitiroNegozio) { this.flgRitiroNegozio = flgRitiroNegozio; } private int hasRigheDisponibili() { if (getDBState() == 1) { Vectumerator vec = findRigheDocumento(0, 0, 0); int isDisponibile = 0; boolean isRowDisponibile = false; while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_articoloTaglia() > 0L) { if (row.getArticoloTaglia().getQuantitaT() > 0.0D) isRowDisponibile = true; } else if (row.getId_articoloVariante() > 0L) { if (row.getArticoloVariante().getQuantitaAv() > 0.0D) isRowDisponibile = true; } else if (row.getArticolo().getQuantita() > 0.0D) { isRowDisponibile = true; } if (isRowDisponibile) { isDisponibile = 2; continue; } if (isDisponibile == 2) { isDisponibile = 1; break; } } return isDisponibile; } return 0; } public ResParm sendDocumentiMailMessage(DocumentoCR CR, String eMail, String path) { ResParm rp = new ResParm(true); creaDocumentoPdf(CR, true); String fileName = CR.getFilePdf(); if (isFileExist(fileName)) try { MailProperties mp = new MailProperties(); String corpoMessaggio = ""; if (CR.getFlgLink() == 1L) { fileName = fileName.replace(getDocBase(), ""); fileName = fileName.replace(getPathStampeDocumenti(), ""); fileName = URLEncoder.encode(EcDc.encodeDizionario(fileName, _AnagAdapter.KEY_ENCODE_DIZ), "utf-8"); String id = URLEncoder.encode(EcDc.encodeDizionario(String.valueOf(getId_documento()), _AnagAdapter.KEY_ENCODE_DIZ), "utf-8"); corpoMessaggio = "Clicca sul documento per scaricarlo:
" + getDescDocumenti() + ""; } else { corpoMessaggio = "In allegato i seguenti documenti in formato PDF.

" + getDescDocumenti(); mp.put("FILES", fileName); } if (!getTestoAgg().isEmpty()) corpoMessaggio = corpoMessaggio + "

" + corpoMessaggio; if (!getParm("DOC_FIRMA_INVIO_FATTURA").getTesto().isEmpty() && getFlgStato() == 1L) corpoMessaggio = corpoMessaggio + "

" + corpoMessaggio + "

"; mp.setProperty("TO", eMail); mp.setProperty("ISHTML", "true"); mp.setProperty("FROM", getMessaggioDocumentiEmailFrom()); if (CR.getId_documentoS() > 0L) { mp.setProperty("SUBJECT", getMailSubject() + " - Documento n. " + getMailSubject()); } else { mp.setProperty("SUBJECT", getMailSubject() + " - Spedizione documenti "); } mp.setProperty("MSG", corpoMessaggio); mp.setProperty("BCC", getParm("DOC_BCC").getTesto()); sendMailMessage(mp); } catch (Exception e) { rp.setStatus(false); rp.setException(e); } if (rp.getStatus()) { Timestamp tmst = getTimestamp(); setTmstInvioMail(tmst); superSave(); } return rp; } public final ResParm startInvioMailExt(DocumentoCR CR, String email, String path, String testoAgg) { if (!isThreadAttivo()) { new ThreadSendMailExt(CR, email, path, testoAgg); return new ResParm(true, "Thread Invio Mail a clienti avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public ResParm stampaReportFinanziario(RegCassa l_regCassa) { ResParm rp = new ResParm(true); EpsonCash ep = new EpsonCash(1L, 5, l_regCassa.getIpCassa()); rp = ep.stampa(); return rp; } public ResParm stampaReportGiornaliero(RegCassa l_regCassa) { ResParm rp = new ResParm(true); EpsonCash ep = new EpsonCash(1L, 4, l_regCassa.getIpCassa()); rp = ep.stampa(); return rp; } public ResParm ristampaScontrino(RegCassa l_regCassa) { ResParm rp = new ResParm(true); EpsonCash ep = new EpsonCash(1L, 3, l_regCassa.getIpCassa()); rp = ep.stampa(); return rp; } public void stampaDisplayCassa(final RegCassa l_regCassa, final String linea1, final String linea2, int sec) { final int ssec = sec; new Thread() { public void run() { try { Thread.sleep((long)(ssec * 1000)); Documento.this.stampaDisplayCassa(l_regCassa, linea1, linea2); } catch (Exception e) { e.printStackTrace(); } } }.start(); } public ResParm apriCassa(RegCassa l_regCassa) { ResParm rp = new ResParm(true); if (l_regCassa.getFlgTipoCassa() == 0L) return rp; EpsonCash ep = new EpsonCash(1L, 7, l_regCassa.getIpCassa()); ep.openDrawer(getParm("CASSA_STAMPA_DISPLAY").getTesto(), getParm("CASSA_STAMPA_DISPLAY1").getTesto(), getParm("CASSA_STAMPA_DISPLAY_TIMEOUT").getNumeroInt()); rp = ep.stampa(); return rp; } public ResParm stampaDisplayCassa(RegCassa l_regCassa, String linea1, String linea2) { ResParm rp = new ResParm(true); EpsonCash ep = new EpsonCash(1L, 6, l_regCassa.getIpCassa()); if (l_regCassa.getFlgTipoCassa() == 0L) return rp; ep.displayString(linea1, linea2); rp = ep.stampa(); return rp; } public ResParm stampaDisplayCassa(RegCassa l_regCassa, RigaDocumento row) { ResParm rp = new ResParm(true); EpsonCash ep = new EpsonCash(1L, 6, l_regCassa.getIpCassa()); if (l_regCassa.getFlgTipoCassa() == 0L) return rp; ep.displayString(row.getArticolo().getNome(), row.getQuantita(), row.getPrezzoPubblicoConIva()); rp = ep.stampa(); return rp; } public ResParm ristampaListaScontrini(DocumentoCR CR, boolean isFiscale, RegCassa l_regCassa) { ResParm rp = new ResParm(true); if (l_regCassa.getFlgTipoCassa() == 0L) return rp; return ristampaListaScontriniEpson(CR, isFiscale, l_regCassa); } public ResParm ristampaListaScontriniEpson(DocumentoCR CR, boolean isFiscale, RegCassa l_regCassa) { ResParm rp = new ResParm(true); Documento doc = new Documento(getApFull()); Vectumerator vec = findByCR(CR, 0, 0); while (vec.hasMoreElements()) { doc = (Documento)vec.nextElement(); EpsonCash ep = new EpsonCash(1L, 8, l_regCassa.getIpCassa()); String[] num = doc.getEchoScontrino().split(" - "); long cod = Long.valueOf("0" + num[0]); if (cod > 0L) ep.reprintReceipt(Long.valueOf(num[0]).longValue(), doc.getDataPagamento()); } return rp; } public ResParm stampaScontrinoPrenotazione(boolean isFiscale, RegCassa l_regCassa) { ResParm rp = new ResParm(true); if (l_regCassa.getFlgTipoCassa() == 0L) { rp.setMsg(""); } else { rp = stampaScontrinoPrenotazioneEpson(isFiscale, l_regCassa); } return rp; } public ResParm stampaScontrinoPrenotazioneEpson(boolean isFiscale, RegCassa l_regCassa) { EpsonCash ep; ResParm rp = new ResParm(true); boolean footerFirma = false; BarcodeCash bc = null; if (isFiscale) { ep = new EpsonCash(1L, 1, l_regCassa.getIpCassa()); } else { ep = new EpsonCash(1L, 2, l_regCassa.getIpCassa()); StringBuilder sb = new StringBuilder(); sb.append(getNominativoDocumento() + " "); sb.append(getClifor().getIndirizzoCompleto() + " "); if (!getCellDocumento().isEmpty()) { sb.append(" Cell. " + getCellDocumento() + " "); } else if (!getClifor().getCellulare().isEmpty()) { sb.append(" Cell. " + getClifor().getCellulare() + " "); } if (!getTelDocumento().isEmpty()) { sb.append(" Tel. " + getTelDocumento() + " "); } else if (!getClifor().getTelefono().isEmpty()) { sb.append(" Tel. " + getClifor().getTelefono() + " "); } if (!getEMailDocumento().isEmpty()) { sb.append(" EMail. " + getEMailDocumento() + " "); } else if (!getClifor().getEMail().isEmpty()) { sb.append(" EMail. " + getClifor().getEMail() + " "); } ep.addMessageBody(sb.toString()); } int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); while (vec.hasMoreElements()) { String descIva; RigaDocumento row = (RigaDocumento)vec.nextElement(); String reparto = "" + row.getReparto().getSiglaEpson() + row.getReparto().getSiglaEpson(); StringBuffer temp = new StringBuffer(); if (row.isDescScontrinoFull()) { temp.append(" "); if (row.getId_articoloVariante() != 0L) { temp.append(row.getArticoloVariante().getDescrizioneCompleta()); } else { temp.append(row.getArticolo().getDescrizioneCompleta()); } if (!row.getSeriale().isEmpty()) { temp.append(" "); temp.append(row.getSeriale()); } } temp.append(" "); temp.append(row.getDescrizioneRiga()); String desc = temp.toString().trim(); desc = desc.replaceAll("€", "euro"); if (row.getImportoConSconto() < 0.0D) { if (row.getFlgReso() == 1L) { ep.addRefund(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), 4L); continue; } ep.addDiscoutUplift(desc, row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), 3L); continue; } if (getCodiceIvaVendStd() != row.getIva().getId_iva()) { if (isFiscale) { descIva = DBAdapter.spaceRight(row.getIva().getDescrizione(), 38) + DBAdapter.spaceRight(row.getIva().getDescrizione(), 38); } else { descIva = DBAdapter.spaceRight(row.getIva().getDescrizione(), 40) + DBAdapter.spaceRight(row.getIva().getDescrizione(), 40); } } else { descIva = row.getNotaRigaDocumento(); } if (isFiscale) { ep.addArticle(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), descIva); continue; } bc = null; if (row.getArticolo().getTipo().getFlgStampaBarcode() == 1L && !row.getNotaBarcode().isEmpty()) { footerFirma = true; bc = new BarcodeCash(); bc.setPosizione(10L); bc.setLarghezza(2L); bc.setAltezza(66L); bc.setPosizioneTesto(BarcodeCash.POSIZIONE_TESTO_SOTTO); bc.setFontTesto(BarcodeCash.FONT_C); bc.setTipoBarcode(BarcodeCash.BARCODE_CODE39); bc.setCode(row.getNotaBarcode()); } ep.addArticle(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), descIva, bc); } Double importoPagato = getContanti(); if (importoPagato == 0.0D) importoPagato = getTotaleDocumento(); ep.addTotal(getTipoPagamento().getDescrizione(), importoPagato.doubleValue(), Long.valueOf(getTipoPagamento().getCodiceCassaEpson()).longValue()); String leNote = ""; if (!getCliforListino().getCodiceCartaFidelity().isEmpty()) leNote = "Fidelity Card: " + getCliforListino().getCodiceCartaFidelity() + " - " + getCliforListino().getListino().getDescrizione(); if (leNote.length() > 0) ep.addMessageFooter(leNote); if (footerFirma) { ep.addMessageFooter(" "); ep.addMessageFooter(" "); ep.addMessageFooter("FIRMA PER CONVALIDA"); ep.addMessageFooter(" "); ep.addMessageFooter(" "); ep.addMessageFooter("____________________________"); ep.addMessageFooter(" "); } if (isFiscale) { ep.addMessageFooter("N. DOCUMENTO " + getProgDocumento() + "/" + getId_esercizio()); ep.addMessageFooter("OP. " + getProgDocumento()); } else { if (getAcconto() > 0.0D) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); ep.addMessageBody(DBAdapter.spaceRight("ACCONTO ", 20) + DBAdapter.spaceRight("ACCONTO ", 20)); } ep.addMessageBody("N. DOCUMENTO " + getProgDocumento() + "/" + getId_esercizio()); ep.addMessageBody("OP. " + getId_users()); } rp = ep.stampa(); if (rp.getStatus() && isFiscale) { Calendar cal = Calendar.getInstance(); Timestamp ts = new Timestamp(cal.getTimeInMillis()); rp.append(aggiornaEchoScontrino(rp.getMsg() + " - " + rp.getMsg())); } if (!getParm("CASSA_STAMPA_DISPLAY").getTesto().isEmpty() || !getParm("CASSA_STAMPA_DISPLAY1").getTesto().equals("")) stampaDisplayCassa(l_regCassa, getParm("CASSA_STAMPA_DISPLAY").getTesto(), getParm("CASSA_STAMPA_DISPLAY1").getTesto(), 5); return rp; } public String getCurrentTab() { if (super.getCurrentTab().isEmpty()) { if (getTipoDocumento().getFlgTipologia() == 5L) return "#DIF"; if (getTipoDocumento().getFlgAFT() == 0L) return "#RIGHE"; if (getTipoDocumento().getFlgAFT() == 1L) return "#RIGHEF"; if (getTipoDocumento().getFlgAFT() == 2L) return "#RIGHET"; return "#RIGHE"; } return super.getCurrentTab(); } public Vectumerator findDocumentiFiglioRiga(long l_id_rigaDocumento) { StringBuffer s_Sql_Find = new StringBuffer("select D.* from DOCUMENTO AS D where id_documento in (select B.id_documento from DOCUMENTO AS A, RIGA_DOCUMENTO AS B "); WcString wc = new WcString(); wc.addWc("A.id_documento=B.id_documento"); wc.addWc("B.id_rigaDocumentoPadre=" + l_id_rigaDocumento); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + ")"); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public double getTotDocumentiFiglioRiga(long l_id_rigaDocumento) { StringBuffer s_Sql_Find = new StringBuffer("select count(id_documento) as _sum from DOCUMENTO AS D where id_documento= (select B.id_documentoPadre from DOCUMENTO AS A, RIGA_DOCUMENTO AS B "); WcString wc = new WcString(); wc.addWc("A.id_documento=B.id_documento"); wc.addWc("B.id_rigaDocumentoPadre=" + l_id_rigaDocumento); String s_Sql_Group = " GROUP BY D.id_documento "; try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + ")" + wc.toString()); return getSum(stmt); } catch (SQLException e) { handleDebug(e); return 0.0D; } } private Document creaReportUnaVenditex(DocumentoCR CR, boolean soloCompatto) { int rowCellLeading = 6; NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col_1 = 3, col_2 = 10, col_3 = 7, col_4 = 4, col_99 = 3, col_98 = 1, col_5 = 4, col_6 = 2, col_7 = 3, col_8 = 4; int cellLeading = 12; DoubleOperator totArt = new DoubleOperator(); DoubleOperator totVendita = new DoubleOperator(); DoubleOperator totImportoChiusi = new DoubleOperator(); DoubleOperator totImportoScontrino = new DoubleOperator(); DoubleOperator totImportoFatDaSc = new DoubleOperator(); DoubleOperator totImportoDDTDaSc = new DoubleOperator(); DoubleOperator totQtaChiusi = new DoubleOperator(); DoubleOperator totQtaScontrino = new DoubleOperator(); DoubleOperator totQtaFatDaSc = new DoubleOperator(); DoubleOperator totQtaDDTDaSc = new DoubleOperator(); List lstCh = new ArrayList<>(); List lstScont = new ArrayList<>(); List lstFatt = new ArrayList<>(); List lstDDT = new ArrayList<>(); Hashtable htPag = new Hashtable(); Hashtable htArticoli = new Hashtable(); SimpleDateFormat df = getDataFormat(); try { Cell rigaVuota = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); String intestazioneReport = "Data: dal " + df.format(CR.getDataDocumentoDa()) + " al " + df.format(CR.getDataDocumentoA()); if (CR.getId_tipo() != 0L) intestazioneReport = intestazioneReport + " - Tipo: " + intestazioneReport; creaIntestazioneReport(CR.getTipoReport(), intestazioneReport); Cell cell = new Cell(new Chunk("Doc.", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Articolo", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Cliente", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("N.Telefono", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Operatore", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_99); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Pag.", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Pr. V.", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Q.tà", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Tot.", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); Vectumerator vec = new RigaDocumento(getApFull()).findVenditeGiornaliere(CR, getId_docCassa()); while (vec.hasMoreElements()) { String nDoc, descCliente, descPag; DoubleOperator dopPag, doubleOperator1, doubleOperator2; ArticoloGroup ag; RigaDocumento row = (RigaDocumento)vec.nextElement(); totArt.add(row.getQuantita()); totVendita.add(row.getTotImportoRigaConSconto()); String descArticolo = row.getReparto().getDescrizione() + " - " + row.getReparto().getDescrizione() + "-" + row.getArticolo().getTipo().getDescrizione(); if (!row.getDocumento().isUnDocumentoFiglioCreato()) { nDoc = row.getDocumento().getNumeroDocumentoCompleto(); if (row.getDocumento().getEchoScontrino().equals("CHIUSO")) { descCliente = "NO SCONTRINO"; } else { descCliente = "scontrino"; } descPag = row.getDocumento().getTipoPagamento().getDescrizione(); } else { Documento docFiglio = row.getDocumento().getDocumentoFiglioUno(); nDoc = docFiglio.getNumeroDocumentoCompleto(); descCliente = docFiglio.getClifor().getDescrizioneCompleta(); descPag = docFiglio.getTipoPagamento().getDescrizione(); } if (!row.getNotaRigaDocumento().isEmpty()) descCliente = descCliente + " - " + descCliente; String nTel = ""; if (!row.getNotaBarcode().isEmpty()) nTel = row.getNotaBarcode(); String descOper = ""; if (row.getDocumento().getId_users() != 0L) descOper = row.getDocumento().getUsers().getDescrizione(); if (row.getDocumento().getEchoScontrino().equals("CHIUSO")) { if (!lstCh.contains(row.getDocumento().getNumeroDocumento())) { totQtaChiusi.add(1); lstCh.add(row.getDocumento().getNumeroDocumento()); } totImportoChiusi.add(row.getTotImportoRigaConSconto()); } else if (row.getDocumento().getTipoDocumento().getId_tipoDocumento() == 1L && !row.getDocumento().isUnDocumentoFiglioCreato()) { if (!lstScont.contains(row.getDocumento().getNumeroDocumento())) { totQtaScontrino.add(1); lstScont.add(row.getDocumento().getNumeroDocumento()); } totImportoScontrino.add(row.getTotImportoRigaConSconto()); } else { Documento docFiglio = row.getDocumento().getDocumentoFiglioUno(); if (docFiglio.getTipoDocumento().getFlgTipologia() == 1L) { if (!lstFatt.contains(row.getDocumento().getNumeroDocumento())) { totQtaFatDaSc.add(1); lstFatt.add(row.getDocumento().getNumeroDocumento()); } totImportoFatDaSc.add(row.getTotImportoRigaConSconto()); } if (docFiglio.getTipoDocumento().getFlgTipologia() == 0L) { if (!lstDDT.contains(row.getDocumento().getNumeroDocumento())) { totQtaDDTDaSc.add(1); lstDDT.add(row.getDocumento().getNumeroDocumento()); } totImportoDDTDaSc.add(row.getTotImportoRigaConSconto()); } } if (htPag.containsKey(descPag)) { dopPag = (DoubleOperator)htPag.get(descPag); } else { dopPag = new DoubleOperator(); } dopPag.add(row.getTotImportoRigaConSconto()); htPag.put(descPag, dopPag); String descArticoloGroup = row.getReparto().getDescrizione(); String agKey = descArticoloGroup; if (htArticoli.containsKey(agKey)) { ag = (ArticoloGroup)htArticoli.get(agKey); doubleOperator1 = new DoubleOperator(ag.getQuantita()); doubleOperator2 = new DoubleOperator(ag.getValore()); } else { ag = new ArticoloGroup(); ag.setDescrizione(descArticoloGroup); doubleOperator1 = new DoubleOperator(); doubleOperator2 = new DoubleOperator(); } doubleOperator1.add(row.getQuantita()); doubleOperator2.add(row.getTotImportoRigaConSconto()); ag.setQuantita(doubleOperator1.getResult()); ag.setValore(doubleOperator2.getResult()); htArticoli.put(agKey, ag); if (!soloCompatto) { cell = new Cell(new Chunk(nDoc, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descArticolo, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descCliente, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(nTel, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descOper, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_99); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descPag, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getImporto()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getQuantita()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getTotImportoRigaConSconto()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } } if (!soloCompatto) { Enumeration tpEnum = htPag.keys(); while (tpEnum.hasMoreElements()) { String tpKey = tpEnum.nextElement(); cell = new Cell(new Chunk(tpKey, PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(htPag.get(tpKey).getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("Totale Scontrini ", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totQtaScontrino.getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totImportoScontrino.getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Totale Chiusi ", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totQtaChiusi.getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totImportoChiusi.getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Totale DDT da Scontrino ", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totQtaDDTDaSc.getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totImportoDDTDaSc.getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Totale Fattura da Scontrino ", PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totQtaFatDaSc.getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totImportoFatDaSc.getResult()), PdfFontFactory.PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("TOTALI ", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); totQtaScontrino.add(totQtaChiusi.getResult()); totQtaScontrino.add(totQtaDDTDaSc.getResult()); totQtaScontrino.add(totQtaFatDaSc.getResult()); cell = new Cell(new Chunk(getNf().format(totQtaScontrino.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totVendita.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE RECORD: ", PdfFontFactory.PDF_fGrande)); cell.add(new Chunk(String.valueOf(vec.getTotNumberOfRecords()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("ELENCO VENDITE RAGGRUPPATE PER REPARTI", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6 + col_7 + col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); Enumeration agEnum = htArticoli.keys(); Vectumerator agVectum = new Vectumerator(agEnum); Collections.sort((List)agVectum); DoubleOperator dopQ = new DoubleOperator(); DoubleOperator dopValore = new DoubleOperator(); while (agVectum.hasMoreElements()) { String agKey = (String)agVectum.nextElement(); ArticoloGroup agRow = htArticoli.get(agKey); dopQ.add(agRow.getQuantita()); dopValore.add(agRow.getValore()); cell = new Cell(new Chunk(agRow.getDescrizione(), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(agRow.getQuantita()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(agRow.getValore()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("TOTALI ", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(dopQ.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(dopValore.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); } catch (Exception e) { handleDebug(e); } return this.document; } public long findTotRigheDocumentoDaPrelevare() { return new RigaDocumento(getApFull()).findRigheDaPrelevareByDocumento(getId_documento()); } public double getTotAccontiByDocumentoPadre(long l_id_documento) { String s_Sql_Find = "select SUM(A.acconto) AS _sum from DOCUMENTO AS A, RIGA_DOCUMENTO AS B"; String s_Sql_Order = " "; WcString wc = new WcString(); wc.addWc("A.id_documento=B.id_documento"); wc.addWc("B.id_documentoPadre=" + l_id_documento); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return getSum(stmt); } catch (SQLException e) { handleDebug(e); return 0.0D; } } public double getTotAccontiByDocumento(long l_id_documento) { String s_Sql_Find = "select SUM(A.acconto) AS _sum from DOCUMENTO AS A "; String s_Sql_Order = " "; WcString wc = new WcString(); wc.addWc("A.id_documento=" + l_id_documento); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return getSum(stmt); } catch (SQLException e) { handleDebug(e); return 0.0D; } } public long getFlgStatoPrenotazionePrecedene() { return this.flgStatoPrenotazionePrecedene; } public void setFlgStatoPrenotazionePrecedene(long flgStatoPrenotazionePrecedene) { this.flgStatoPrenotazionePrecedene = flgStatoPrenotazionePrecedene; } public ResParm stampaScontrinoEpsonScontoManuale(boolean isFiscale, RegCassa l_regCassa) { EpsonCash ep; ResParm rp = new ResParm(true); boolean footerFirma = false; BarcodeCash bc = null; NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); if (isFiscale) { ep = new EpsonCash(1L, 1, l_regCassa.getIpCassa()); } else { ep = new EpsonCash(1L, 2, l_regCassa.getIpCassa()); } Vectumerator vec = new RigaDocumento(getApFull()).findByDocumento(0L, getId_documento(), "", 0, 0, 0); while (vec.hasMoreElements()) { String descIva; RigaDocumento row = (RigaDocumento)vec.nextElement(); String reparto = "" + row.getReparto().getSiglaEpson() + row.getReparto().getSiglaEpson(); StringBuffer temp = new StringBuffer(); if (row.isDescScontrinoFull()) { temp.append(" "); if (row.getId_articoloVariante() != 0L) { temp.append(row.getArticoloVariante().getDescrizioneCompleta()); } else { temp.append(row.getArticolo().getDescrizioneCompleta()); } if (!row.getSeriale().isEmpty()) { temp.append(" "); temp.append(row.getSeriale()); } } temp.append(" "); temp.append(row.getDescrizioneRiga()); String desc = temp.toString().trim(); desc = desc.replaceAll("€", "euro"); if (row.getImportoConSconto() < 0.0D) { if (row.getFlgReso() == 1L || row.getArticolo().getFlgNegativo() == 1L) { ep.addRefund(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), 4L); continue; } ep.addDiscoutUplift(desc, row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), 3L); continue; } String notaRigaDocumento = row.getNotaRigaDocumento() + " "; if (getCodiceIvaVendStd() != row.getIva().getId_iva()) { if (isFiscale) { if (row.getSconto() > 0.0D) { descIva = DBAdapter.spaceRight(row.getIva().getDescrizione(), 37) + DBAdapter.spaceRight(row.getIva().getDescrizione(), 37) + DBAdapter.spaceRight("SCONT0 APPLICATO " + String.valueOf(nf.format(row.getSconto())) + "%", 37); if (!row.getSeriale().isEmpty()) descIva = descIva + descIva; } else { descIva = DBAdapter.spaceRight(row.getIva().getDescrizione(), 37) + DBAdapter.spaceRight(row.getIva().getDescrizione(), 37); if (!row.getSeriale().isEmpty()) descIva = descIva + descIva; } } else { descIva = DBAdapter.spaceRight(row.getIva().getDescrizione(), 39) + DBAdapter.spaceRight(row.getIva().getDescrizione(), 39); if (!row.getSeriale().isEmpty()) descIva = descIva + descIva; } } else if (row.getSconto() > 0.0D) { descIva = DBAdapter.spaceRight("SCONT0 APPLICATO " + String.valueOf(nf.format(row.getSconto())) + "%", 37) + DBAdapter.spaceRight("SCONT0 APPLICATO " + String.valueOf(nf.format(row.getSconto())) + "%", 37); if (!row.getSeriale().isEmpty()) descIva = descIva + descIva; } else { descIva = notaRigaDocumento; if (!row.getSeriale().isEmpty()) descIva = descIva + descIva; } if (isFiscale) { ep.addArticle(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), descIva); continue; } bc = null; if (row.getArticolo().getTipo().getFlgStampaBarcode() == 1L && !row.getNotaBarcode().isEmpty()) { footerFirma = true; bc = new BarcodeCash(); bc.setPosizione(10L); bc.setLarghezza(2L); bc.setAltezza(66L); bc.setPosizioneTesto(BarcodeCash.POSIZIONE_TESTO_SOTTO); bc.setFontTesto(BarcodeCash.FONT_C); bc.setTipoBarcode(BarcodeCash.BARCODE_CODE39); bc.setCode(row.getNotaBarcode()); } ep.addArticle(desc, row.getQuantita(), row.getImportoConSconto(), false, row.getReparto().getSiglaEpson(), descIva, bc); } if (getAcconto() > 0.0D) ep.addDiscoutUplift("ACCONTO ", getAcconto(), false, 0L, 0L); Double importoPagato = getContanti(); if (importoPagato == 0.0D) importoPagato = getTotaleDocumento(); ep.addTotal(getTipoPagamento().getDescrizione(), importoPagato.doubleValue(), Long.valueOf(getTipoPagamento().getCodiceCassaEpson()).longValue()); String leNote = ""; if (!getCliforListino().getCodiceCartaFidelity().isEmpty()) leNote = "Fidelity Card: " + getCliforListino().getCodiceCartaFidelity() + " " + getCliforListino().getDescrizioneCompleta() + " LISTINO " + getCliforListino().getListino().getDescrizione(); if (!getNote().isEmpty()) leNote = (leNote + " " + leNote).trim(); if (leNote.length() > 0) ep.addMessageFooter(leNote); if (footerFirma) { ep.addMessageFooter(" "); ep.addMessageFooter(" "); ep.addMessageFooter("FIRMA PER CONVALIDA"); ep.addMessageFooter(" "); ep.addMessageFooter(" "); ep.addMessageFooter("____________________________"); ep.addMessageFooter(" "); } if (isFiscale) { ep.addMessageFooter("N. DOCUMENTO " + getProgDocumento() + "/" + getId_esercizio()); ep.addMessageFooter("OP. " + getId_users()); if (!getParm("CASSA_STAMPA_PROMO").isEmpty()) { ep.addMessageFooter(" "); ep.addMessageFooter(getParm("CASSA_STAMPA_PROMO").getTesto()); } } else { ep.addMessageBody("N. DOCUMENTO " + getProgDocumento() + "/" + getId_esercizio()); ep.addMessageBody("OP. " + getId_users()); } rp = ep.stampa(); if (rp.getStatus() && isFiscale) { Calendar cal = Calendar.getInstance(); Timestamp ts = new Timestamp(cal.getTimeInMillis()); rp.append(aggiornaEchoScontrino(rp.getMsg() + " - " + rp.getMsg())); } if (!getParm("CASSA_STAMPA_DISPLAY").getTesto().isEmpty() || !getParm("CASSA_STAMPA_DISPLAY1").getTesto().equals("")) stampaDisplayCassa(l_regCassa, getParm("CASSA_STAMPA_DISPLAY").getTesto(), getParm("CASSA_STAMPA_DISPLAY1").getTesto(), 5); return rp; } public Vectumerator findPrenConAccontiByDate(Date dataInizio, Date dataFine) { String s_Sql_Find = "select A.* from DOCUMENTO AS A "; String s_Sql_Order = " "; WcString wc = new WcString(); wc.addWc("A.dataDocumento>=?"); wc.addWc("A.dataDocumento<=?"); wc.addWc("A.acconto>0"); wc.addWc("A.dataRestituzioneAcconto IS NULL"); wc.addWc("A.id_tipoDocumento= " + getParm("ID_DOC_PRENOTAZIONE").getNumeroLong()); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); int dataCount = 0; dataCount++; stmt.setDate(dataCount, dataInizio); dataCount++; stmt.setDate(dataCount, dataFine); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findPrenAnnConAccontiByDate(Date dataInizio, Date dataFine) { String s_Sql_Find = "select A.* from DOCUMENTO AS A "; String s_Sql_Order = " "; WcString wc = new WcString(); wc.addWc("A.dataRestituzioneAcconto>=?"); wc.addWc("A.dataRestituzioneAcconto<=?"); wc.addWc("A.acconto>0"); wc.addWc("NOT A.dataRestituzioneAcconto IS NULL"); wc.addWc("A.id_tipoDocumento= " + getParm("ID_DOC_PRENOTAZIONE").getNumeroLong()); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); int dataCount = 0; dataCount++; stmt.setDate(dataCount, dataInizio); dataCount++; stmt.setDate(dataCount, dataFine); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public ResParm addRigaPrenotazionePrelevataDaOrdine(RigaDocumento rdPrenotazione, double l_qtaDaPrelevare) { ResParm rp = new ResParm(false); rp = checkEMSTA(); if (rp.getStatus()) { DoubleOperator dop = new DoubleOperator(l_qtaDaPrelevare); Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_articolo() == rdPrenotazione.getId_articolo() && row.getId_articoloVariante() == rdPrenotazione.getId_articoloVariante()) if (row.getQuantita() != 0.0D) { RigaDocumentoPM rdp = new RigaDocumentoPM(getApFull()); rdp.setId_rigaDocumento(row.getId_rigaDocumento()); rdp.setId_rigaDocumentoPrelevata(rdPrenotazione.getId_rigaDocumento()); if (row.getQuantita() <= dop.getResult()) { rdp.setQuantitaPrelevata(row.getQuantita()); } else { rdp.setQuantitaPrelevata(dop.getResult()); } rp = row.addRigaDocumentoPM(rdp); if (rp.getStatus()) dop.subtract(rdp.getQuantitaPrelevata()); if (dop.getResult() <= 0.0D) break; } } } else { rp.setMsg("ERRORE! Fattura emessa o stampata! Impossibile eliminare."); } return rp; } protected StringBuffer formattaNoteDocumento(String temp, int caratteriTotali, int righeTotali, boolean righeMancanti) { StringBuffer rigaNote = new StringBuffer(); int righe = 0; int totLen = 0; if (caratteriTotali > 0) { totLen = caratteriTotali; } else { totLen = temp.length(); } temp = temp.trim(); for (int i = 0; i < totLen; i++) { if (temp.charAt(i) == '\n') { righe++; if (righe >= righeTotali) break; } rigaNote.append(temp.charAt(i)); } if (righeMancanti) for (int j = 0; j < righeTotali - righe; j++) rigaNote.append('\n'); return rigaNote; } public ResParm checkStatoPrenotazioneByDocumento() { long stato = -1L; ResParm rp = new ResParm(false); long l_flgStatoPrenotazionePrecedente = getFlgStatoPrenotazione(); setFlgStatoPrenotazione(0L); superSave(); stato = -1L; Vectumerator vecRig = findRigheDocumento(0, 0, 0); while (vecRig.hasMoreElements()) { RigaDocumento rig = (RigaDocumento)vecRig.nextElement(); stato = rig.getStatoPrenotazione(); if (stato != 30L) break; } if (stato == 30L) rp = aggiornaStatoPrenotazione(l_flgStatoPrenotazionePrecedente, 20L); return rp; } public ResParm superSave() { return super.save(); } public Vectumerator findDocumentiOrdiniByRigaPrenotazione(long l_id_rigaDocumento) { StringBuffer s_Sql_Find = new StringBuffer("select A.* from DOCUMENTO AS A inner join RIGA_DOCUMENTO as B on A.id_documento =B.id_documento inner join RIGA_DOCUMENTO_P_M AS C ON B.id_rigaDocumento= C.id_rigaDocumento"); WcString wc = new WcString(); wc.addWc("C.id_rigaDocumentoPrelevata=" + l_id_rigaDocumento); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public String getDescrizioneStampaDocumento() { if (getTipoDocumento().getFlgTipoStampa() == 10L) return "Copia Non Fiscale"; if (getTipoDocumento().getFlgTipoStampa() == 9L) return "Stampa Scontrino Fiscale"; return "Stampa Documento"; } public long getId_magFisicoPartenza() { return this.id_magFisicoPartenza; } public void setId_magFisicoPartenza(long id_magFisicoPartenza) { this.id_magFisicoPartenza = id_magFisicoPartenza; setMagFisicoPartenza(null); } public long getId_magFisicoArrivo() { return this.id_magFisicoArrivo; } public void setId_magFisicoArrivo(long id_magFisicoArrivo) { this.id_magFisicoArrivo = id_magFisicoArrivo; setMagFisicoArrivo(null); } public MagFisico getMagFisicoArrivo() { this.magFisicoArrivo = (MagFisico)getSecondaryObject(this.magFisicoArrivo, MagFisico.class, getId_magFisicoArrivo()); return this.magFisicoArrivo; } public void setMagFisicoArrivo(MagFisico magFisicoArrivo) { this.magFisicoArrivo = magFisicoArrivo; } public MagFisico getMagFisicoPartenza() { this.magFisicoPartenza = (MagFisico)getSecondaryObject(this.magFisicoPartenza, MagFisico.class, getId_magFisicoPartenza()); return this.magFisicoPartenza; } public void setMagFisicoPartenza(MagFisico magFisicoPartenza) { this.magFisicoPartenza = magFisicoPartenza; } public double getTotDocumentiPrelievoOrdine(long l_id_rigaDocumento) { StringBuffer s_Sql_Find = new StringBuffer("select count(*) as _sum from RIGA_DOCUMENTO_P AS A "); WcString wc = new WcString(); wc.addWc("A.id_rigaDocumentoPrelevata=" + l_id_rigaDocumento); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); return getSum(stmt); } catch (SQLException e) { handleDebug(e); return 0.0D; } } public Vectumerator findDocumentiPrelievoOrdine(long l_id_rigaDocumento) { StringBuffer s_Sql_Find = new StringBuffer("select A.* from DOCUMENTO AS A inner join RIGA_DOCUMENTO as B on A.id_documento = B.id_documento inner join RIGA_DOCUMENTO_P AS C ON B.id_rigaDocumento= C.id_rigaDocumento "); WcString wc = new WcString(); wc.addWc("C.id_rigaDocumentoPrelevata=" + l_id_rigaDocumento); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public double getTotDocumentiPrelievoOrdineP(long l_id_rigaDocumento) { StringBuffer s_Sql_Find = new StringBuffer(" select count(*) as _sum from RIGA_DOCUMENTO_P AS A "); WcString wc = new WcString(); wc.addWc(" A.id_rigaDocumento = " + l_id_rigaDocumento); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); return getSum(stmt); } catch (SQLException e) { handleDebug(e); return 0.0D; } } public Vectumerator findDocumentiPrelievoOrdineP(long l_id_rigaDocumento) { StringBuffer s_Sql_Find = new StringBuffer("select A.* from DOCUMENTO AS A inner join RIGA_DOCUMENTO as B on A.id_documento = B.id_documento inner join RIGA_DOCUMENTO_P AS C ON B.id_rigaDocumento= C.id_rigaDocumentoPrelevata "); WcString wc = new WcString(); wc.addWc("C.id_rigaDocumento=" + l_id_rigaDocumento); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findRigheDocumentoPerSlip() { return new RigaDocumento(getApFull()).findByDocumentoPerSlip(getId_documento()); } public Date getDataDownload() { return this.dataDownload; } public void setDataDownload(Date dataDownload) { this.dataDownload = dataDownload; } public String getIpDownload() { return this.ipDownload; } public void setIpDownload(String ipDownload) { this.ipDownload = ipDownload; } public long getFlgDownload() { return this.flgDownload; } public void setFlgDownload(long flgDownload) { this.flgDownload = flgDownload; } public Timestamp getTmstStampato() { return this.tmstStampato; } public void setTmstStampato(Timestamp tmstStampato) { this.tmstStampato = tmstStampato; } public Vectumerator findByClifor(long l_id_clifor, int pageNumber, int pageRows) { StringBuffer s_Sql_Find = new StringBuffer("select A.* from DOCUMENTO AS A "); WcString wc = new WcString(); wc.addWc(" A.id_clifor = " + l_id_clifor); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public String getTestoAgg() { return (this.testoAgg == null) ? "" : this.testoAgg; } public void setTestoAgg(String testoAgg) { this.testoAgg = testoAgg; } public Time getOraDownload() { return this.oraDownload; } public void setOraDownload(Time oraDownload) { this.oraDownload = oraDownload; } public void findUltimoDocumentoEmesso() { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.dataDocumento desc, A.id_esercizio desc, A.progDocumento desc"; WcString wc = new WcString(); wc.addWc("A.id_tipoDocumento=" + getId_tipoDocumento()); wc.addWc("A.flgStato=1"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public String getBic() { return (this.bic == null) ? "" : this.bic; } public void setBic(String bic) { this.bic = bic; } protected int inserisciRigaDocumento(ArrayList dati, int idColDesc, int riga, Document l_document, Table pdfcorpo, int cellLeading, boolean hasMoreRow) { String indent = ""; boolean debug = false; if (getTipoDocumento().getIndentNuovaRiga() > 0L) indent = " ".substring(0, (int)getTipoDocumento().getIndentNuovaRiga()); int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); int maxCharLength = (int)getTipoDocumento().getMaxCarDesc(); if (maxCharLength == 0) maxCharLength = 35; int righeAggiuntivePagineIntermedie = 5; String temp = dati.get(idColDesc).getDesc(); temp = temp.replace("€", "€"); int bordi = 0; Color colore = Color.black; long bordoColonne = getTipoDocumento().getFlgBordoColonna(); long bordoRighe = getTipoDocumento().getFlgBordoRiga(); String coloreBordo = getTipoDocumento().getColoreBordoInterno(); boolean allineamentoInAlto = (getTipoDocumento().getFlgAllineamentoRiga() == 0L); try { ArrayList righeDescrizione = convertStringToMultiline(temp, maxCharLength); int allineamentoInAltoVal = 0; int allineamentoIBassoVal = righeDescrizione.size() - 1; for (int row = 0; row < righeDescrizione.size(); row++) { boolean moreDesc; String desc = righeDescrizione.get(row); if (row > 0) desc = indent + indent; if (row + 1 < righeDescrizione.size()) { moreDesc = true; } else { moreDesc = false; } for (int col = 0; col < dati.size(); col++) { Cell cell; if (allineamentoInAlto) { if (row == allineamentoInAltoVal || col == idColDesc) { if (col == idColDesc) { cell = new Cell(new Chunk(desc, dati.get(col).getPdfFont())); } else { cell = new Cell(new Chunk(dati.get(col).getDesc(), dati.get(col).getPdfFont())); } } else { cell = new Cell(new Chunk("", dati.get(col).getPdfFont())); } } else if ((row == 0 && col == 0) || (row == allineamentoIBassoVal && row > 0 && col > 0) || col == idColDesc) { if (col == idColDesc) { cell = new Cell(new Chunk(desc, dati.get(col).getPdfFont())); } else { cell = new Cell(new Chunk(dati.get(col).getDesc(), dati.get(col).getPdfFont())); } } else if (moreDesc) { cell = new Cell(new Chunk("", dati.get(col).getPdfFont())); } else { cell = new Cell(new Chunk(dati.get(col).getDesc(), dati.get(col).getPdfFont())); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(dati.get(col).getCellAlign()); cell.setLeading((float)cellLeading); if (dati.get(col).getPdfFont().getColor() == Color.white) { settaBordiEColori(cell, bordoColonne, 0L, moreDesc, coloreBordo); } else { settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); } cell.setMaxLines(1); cell.setColspan(dati.get(col).getColSpan()); pdfcorpo.addCell(cell); } riga = incrementaNumRighe(riga, righePerPagina, l_document, pdfcorpo, (hasMoreRow || moreDesc)); } } catch (Exception e) { handleDebug(e); } return riga; } protected void settaBordiEColori(Cell cell, long bordoColonne, long bordoRighe, boolean moreDesc, String coloreBordo) { int bordi = 0; Color colore = Color.black; if (bordoColonne == 1L) { bordi = 12; if (bordoRighe == 1L && !moreDesc) bordi = 14; } else if (bordoRighe == 1L && !moreDesc) { bordi = 2; } cell.setBorder(bordi); if (!coloreBordo.isEmpty()) colore = getColorFromHex("#" + coloreBordo); cell.setBorderColor(colore); } protected ResParm saveTmstStampato() { if (getFlgStato() == 1L) { Calendar cal = Calendar.getInstance(); Timestamp ts = new Timestamp(cal.getTimeInMillis()); setTmstStampato(ts); return super.save(); } return new ResParm(true); } public Vectumerator findDocumentiFiglio(int pageNumber, int pageRow) { if (getId_documento() == 0L) return AB_EMPTY_VECTUMERATOR; StringBuffer s_Sql_Find = new StringBuffer("select D.* from DOCUMENTO AS D where id_documento in (select B.id_documento from DOCUMENTO AS A, RIGA_DOCUMENTO AS B "); WcString wc = new WcString(); wc.addWc("A.id_documento=B.id_documento"); wc.addWc("B.id_documentoPadre=" + getId_documento()); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + ")"); return findRows(stmt, pageNumber, pageRow); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } private boolean hasDocumentiPadre() { Vectumerator vec = findDocumentiPadre(); if (vec.hasMoreElements()) return true; return false; } public long getId_bancaAnticipo() { return this.id_bancaAnticipo; } public void setId_bancaAnticipo(long id_bancaAnticipo) { this.id_bancaAnticipo = id_bancaAnticipo; setBancaAnticipo(null); } public Banca getBancaAnticipo() { this.bancaAnticipo = (Banca)getSecondaryObject(this.bancaAnticipo, Banca.class, getId_bancaAnticipo()); return this.bancaAnticipo; } public void setBancaAnticipo(Banca bancaAnticipo) { this.bancaAnticipo = bancaAnticipo; } public void aggiornaFlgHasDocumentiPrelavabili() { setFlgHasDocumentiPrelevabili(-1L); super.save(); } public double getQuantitaTotaleDocumento() { if (getId_documento() == 0L) return 0.0D; return new RigaDocumento(getApFull()).getQuantitaTotaleByDocumento(getId_documento()); } protected void creaDocumentoFooterFattureConTotaliNewDaTestare(Table l_pdfCorpo, boolean isUltimaPagina) { int cellLeading = 8; NumberFormat nf = getNf(); RigheRegistroIva rri = getRigaRegistroIvaCompleto(); String codIva = "", imponibile = "", aliquota = "", imposta = ""; if (rri != null) { Enumeration enuRrri = rri.elementsFatt(); while (enuRrri.hasMoreElements()) { RigaRegistroIvaItem rrii = enuRrri.nextElement(); if (rrii.getImponibile() != 0.0D) { if (getFlgArt8() == 1L) { imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n0"; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; continue; } imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n" + imposta; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; } } } try { Cell cell = new Cell(new Chunk("ALIQ.", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(codIva, PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPONIBILE", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(1); l_pdfCorpo.addCell(cell); if (isUltimaPagina) { cell.add(new Chunk(imponibile, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPOSTA\t", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imposta, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); cell.setRowspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE MERCE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImponibileRighe() != 0.0D) { cell.add(new Chunk(nf.format(getImponibileRighe()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SCONTO INCONDIZIONATO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getScontoIncondizionato()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(9); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE NETTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImponibileTotale() != 0.0D) { cell.add(new Chunk(nf.format(getImponibileTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE TRASPORTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseTrasporto() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseTrasporto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE INCASSO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseIncasso() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseIncasso()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE VARIE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseAltre() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseAltre()), PdfFontFactory.PDF_fPiccoloB)); if (!getDescSpeseAltre().isEmpty()) cell.add(new Chunk(" " + getDescSpeseAltre(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(13); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SCADENZE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && !getNotePagamento().isEmpty()) { cell.add(new Chunk(getNotePagamento(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(23); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PESO LORDO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getKgLordo() != 0.0D) { cell.add(new Chunk(nf.format(getKgLordo()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PESO NETTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getKgNetto() != 0.0D) { cell.add(new Chunk(nf.format(getKgNetto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("N. COLLI\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getNColli() != 0L) { cell.add(new Chunk(nf.format(getNColli()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("Q.TA' ARTICOLI\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getQuantitaTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getQuantitaTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("\n", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPONIBILE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getImponibileTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPOSTA\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getImportoIvaTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. ESENTE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("ACCONTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getAcconto() != 0.0D) { cell.add(new Chunk(nf.format(getAcconto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("ABBUONO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getAbbuono() != 0.0D) { cell.add(new Chunk(nf.format(getAbbuono()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } public boolean isPrelevata() { if (getTipoDocumento().getFlgTipoDocumentoPrelevabile() == 0L || getTipoDocumento().getFlgObbligoPrelievo() == 0L) return true; return !(getFlgDocumentoPrelevato() == 0L); } public long getFlgDocumentoPrelevatoPrecedente() { return this.flgDocumentoPrelevatoPrecedente; } public void setFlgDocumentoPrelevatoPrecedente(long flgDocumentoPrelevatoPrecedente) { this.flgDocumentoPrelevatoPrecedente = flgDocumentoPrelevatoPrecedente; } public String getPagamentiHtml() { SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); StringBuilder html = new StringBuilder(); NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); html.append(""); html.append("Data: "); html.append(""); html.append(""); html.append("Importo: "); html.append(""); html.append(""); html.append("Tipo pagamento: "); html.append(""); html.append(""); html.append("Nota "); html.append(""); DocumentoPagamento dp = new DocumentoPagamento(getApFull()); Vectumerator vec = dp.findByDocumento(getId_documento()); while (vec.hasMoreElements()) { dp = (DocumentoPagamento)vec.nextElement(); html.append(""); html.append(df.format(dp.getData())); html.append(""); html.append(""); html.append(nf.format(Math.abs(dp.getImporto()))); html.append(""); html.append(""); html.append(dp.getTipoPagamento().getDescrizione()); html.append(""); html.append(""); html.append(dp.getNota()); html.append(""); } return html.toString(); } public void impostaPagato(Date data) { if (getFlgPagata() == 0L || getDataPagamento() != data) { setFlgPagata(1L); setDataPagamento(data); superSave(); } if (isFatturaONotaDiCredito()) { DocumentoPagamento pag = new DocumentoPagamento(getApFull()); double saldoPagamenti = pag.getSaldoRateByDocumento(getId_documento()); DoubleOperator dp = new DoubleOperator(getTotaleDocumento()); dp.subtract(Math.abs(saldoPagamenti)); if (dp.getResult() > 0.0D) { pag.setId_documento(getId_documento()); pag.setData((data == null) ? getToday() : data); pag.setImporto(dp.getResult()); pag.setFlgTipoMovimento(3L); pag.setFlgTipoIncasso(1L); pag.save(); } } } public void impostaNonPagato() { setFlgPagata(0L); setDataPagamento(null); superSave(); String sql = "DELETE FROM DOCUMENTO_PAGAMENTO WHERE id_documento = " + getId_documento() + " AND flgTipoMovimento = 3"; update(sql); } public ResParm delete() { return super.delete(); } public ResParm checkEMSTA() { ResParm rp = new ResParm(true); if (getTmstInvioXml() != null) { rp.setStatus(false); rp.setMsg("Attenzione! File XML fattura elettronica impostato a inviato! Saranno salvati solo alcuni dati."); return rp; } if (getFlgEmsta() == 0L && getFlgStatoPrecedente() == 1L) { if (getParm("BLOCCO_FATTURE_EMSTA").getNumeroLong() == 1L) { rp.setStatus(false); rp.setMsg("Attenzione! Fattura emessa! Saranno salvati solo alcuni dati."); return rp; } if (getParm("BLOCCO_FATTURE_EMSTA").getNumeroLong() == 2L && getTmstStampato() != null) { rp.setStatus(false); rp.setMsg("Attenzione! Fattura stampata! Saranno salvati solo alcuni dati."); return rp; } } return rp; } protected void creaDocumentoIntestazioneRicevutaOld(Table l_pdfCorpo) { try { String descCliente, descDestinazione; int cellLeading = 8; SimpleDateFormat df = getDataFormat(); float imgLogoWidth = getDocLogoWidth(); Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); Cell cell = new Cell(); cell.addElement(new Chunk(imgLogo, 0.0F, 0.0F)); cell.addElement(new Chunk("\n" + getHeaderDoocumento(1) + "\n" + getHeaderDoocumento(2), PdfFontFactory.PDF_fPiccolo)); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); l_pdfCorpo.addCell(cell); if (getId_clifor() > 0L) { descCliente = ""; if (!getClienteNome().isEmpty() && !getClienteCognome().isEmpty() && !getClienteCf().isEmpty()) { descCliente = getClienteCognome() + " " + getClienteCognome() + "\n"; descCliente = descCliente + descCliente + "\n"; } else if (getClifor().getpIva().isEmpty() && getClifor().getCodFisc().isEmpty() && getClifor().getCognome().isEmpty()) { descCliente = "AUTOFATTURA\n"; descCliente = descCliente + descCliente; } else { descCliente = descCliente + descCliente + "\n"; descCliente = descCliente + descCliente; if (!getClifor().getNumeroCivico().isEmpty()) descCliente = descCliente + " n." + descCliente; descCliente = descCliente + "\n" + descCliente + " " + getClifor().getCapComune(); if (!getClifor().getProvinciaComune().isEmpty()) descCliente = descCliente + " (" + descCliente + ")"; if (!getClifor().getId_nazione().isEmpty()) descCliente = descCliente + " " + descCliente; } } else { descCliente = getNominativoDocumento(); } if (!getIndirizzoSped().isEmpty() && !getPresso().isEmpty()) { descDestinazione = getClifor().getCognomeNome() + "\n"; descDestinazione = descDestinazione + "c/o " + descDestinazione + "\n"; descDestinazione = descDestinazione + descDestinazione + " n." + getIndirizzoSped() + "\n" + getNumeroCivicoSped() + " " + getCapSped() + " (" + getCittaSped() + ")"; if (!getId_nazioneSped().isEmpty()) descDestinazione = descDestinazione + " " + descDestinazione; } else if (getId_destinazioneDiversa() == 0L) { if (getParm("DESTINAZIONE").getNumeroLong() == 1L) { descDestinazione = "IDEM\n\n"; } else { descDestinazione = ""; } } else { descDestinazione = getClifor().getCognomeNome() + "\n"; if (!getDestinazioneDiversa().getPressoDD().isEmpty()) descDestinazione = descDestinazione + "c/o " + descDestinazione + "\n"; descDestinazione = descDestinazione + descDestinazione + " n." + getDestinazioneDiversa().getIndirizzoDD() + "\n" + getDestinazioneDiversa().getNumeroCivicoDD() + " " + getDestinazioneDiversa().getCapComuneDD() + " (" + getDestinazioneDiversa().getDescrizioneComuneDD() + ")"; if (!getDestinazioneDiversa().getId_nazioneDD().isEmpty()) descDestinazione = descDestinazione + " " + descDestinazione; } cell = new Cell(); cell.addElement(new Chunk("\n\nSPETT.LE\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(descCliente, PdfFontFactory.PDF_fGrande)); if (!descDestinazione.isEmpty()) { cell.addElement(new Chunk("\nDESTINAZIONE\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(descDestinazione, PdfFontFactory.PDF_fGrande)); } cell.setVerticalAlignment(4); cell.setLeading(12.0F); cell.setBorder(0); cell.setRowspan(3); cell.setColspan(18); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("TIPO DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (getFlgStato() == 0L) cell.addElement(new Chunk("(B) ", PdfFontFactory.PDF_fMedioB)); if (getFlgStato() == 2L) { cell.addElement(new Chunk("FATTURA PROFORMA\n", PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.addElement(new Chunk(getTipoDocumento().getDescrizioneStampa() + "\n", PdfFontFactory.PDF_fPiccoloB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("N. DOC.\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(String.valueOf(getNumeroDocumento()), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("DATA\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(df.format(getDataDocumento()), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Pag.\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(getNf0().format(getNumPagDocumento()), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("xx", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); cell.setRowspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("RIF. INTERNO \n", PdfFontFactory.PDF_fPiccolissimo)); if (!getDescrizioneDocumentiPadre().isEmpty()) { cell.addElement(new Chunk(getDescrizioneDocumentiPadre(), PdfFontFactory.PDF_fPiccolissimo4)); } else { cell.addElement(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimoB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setMaxLines(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("COD. C/F\t\n", PdfFontFactory.PDF_fPiccolissimo)); if (getClienteNome().isEmpty() && getClienteCognome().isEmpty() && getClienteCf().isEmpty()) cell.addElement(new Chunk(String.valueOf(getClifor().getId_clifor()), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("PARTITA IVA/CF\n", PdfFontFactory.PDF_fPiccolissimo)); if (getClienteNome().isEmpty() && getClienteCognome().isEmpty() && getClienteCf().isEmpty()) { cell.addElement(new Chunk(getClifor().getPIva() + " / " + getClifor().getPIva(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.addElement(new Chunk(getClientePiva() + " / " + getClientePiva(), PdfFontFactory.PDF_fPiccoloB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(11); l_pdfCorpo.addCell(cell); creaDocumentoIntestazioneCorpoRicevuta(l_pdfCorpo); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoCorpoRicevuta(Document l_document, Table l_pdfCorpo) { int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); if (righePerPagina <= 0) righePerPagina = 10; int maxCarDesc = (int)getTipoDocumento().getMaxCarDesc(); if (maxCarDesc == 0) maxCarDesc = 35; int riga = 0; int cellLeadingRow = getDocLeadRow(); if (cellLeadingRow == 0) cellLeadingRow = 12; Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowSmall = getTipoDocumento().getPdfFontRowSmall(); NumberFormat nf = getNf(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); try { String s_note; long resHasUsato = hasRigheConUsato(); if (!getPudoId().isEmpty()) { s_note = "Fermo Point BRT\n" + getPudoDesc() + "\n" + getNote(); } else { s_note = getNote(); } if (resHasUsato == 1L || resHasUsato == 2L || resHasUsato == 5L || resHasUsato == 6L) { Iva ivaRM = new Iva(getApFull()); ivaRM.findByPrimaryKey(getCodiceIvaRegimeMargine()); s_note = s_note + "\n" + s_note; } ArrayList alNote = RigaDocumentoItemPdf.getArrayListNota(s_note, 0, cols_RICEVUTA_, PDF_frow); if (getDocPosizioneNota() == 0L) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); while (vec.hasMoreElements()) { String desc, descQta; double prezzoUnitarioConIva, importoRigaConIva; RigaDocumento row = (RigaDocumento)vec.nextElement(); double quantita = row.getQuantita(); if (row.getSconto() > 0.0D) { String scontoS = nf.format(row.getSconto()); } else { String scontoS = ""; } if (!row.getIva().getFlgTipo().equals("R")) { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; prezzoUnitarioConIva = row.getImportoConSconto(); importoRigaConIva = row.getTotImportoRigaConSconto(); } else { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; prezzoUnitarioConIva = row.getImportoConSconto(); importoRigaConIva = row.getTotImportoRigaConSconto(); } if (row.getSeriale().isEmpty() && !row.getArticolo().getNMatricola().isEmpty()) desc = desc + " Mat. N. " + desc; if (!row.getNotaBarcode().isEmpty()) desc = desc + " - " + desc; String codIva = row.getIva().getDescrizioneRigaStampaAuto(); if (!row.getNotaRigaDocumento().isEmpty()) desc = desc + " " + desc; if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() != 1L) { if (isQuantitaMagazzinoIntere()) { descQta = row.getUdm() + " " + row.getUdm(); } else { descQta = row.getUdm() + " " + row.getUdm(); } } else if (isQuantitaMagazzinoIntere()) { descQta = getNf0().format(quantita); } else { descQta = nf.format(quantita); } ArrayList dati = new ArrayList<>(); dati.add(new RigaDocumentoItemPdf(cols_RICEVUTA_[0], desc, PDF_frow)); dati.add(new RigaDocumentoItemPdf(cols_RICEVUTA_[1], descQta, PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_RICEVUTA_[2], nf.format(prezzoUnitarioConIva), PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_RICEVUTA_[3], nf.format(importoRigaConIva), PDF_frow, 2)); riga = inserisciRigaDocumento(dati, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); } if (getDocPosizioneNota() == 1L && !s_note.isEmpty()) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); if (righePerPagina - riga > 0) riga = inserisciRigheVuote(righePerPagina - riga, cols_RICEVUTA_, riga, l_document, l_pdfCorpo, cellLeadingRow); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoCorpoRicevutaOld(Document l_document, Table l_pdfCorpo) { long bordoColonne = getTipoDocumento().getFlgBordoColonna(); long bordoRighe = getTipoDocumento().getFlgBordoRiga(); String coloreBordo = getTipoDocumento().getColoreBordoInterno(); int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); int maxCarDesc = (int)getTipoDocumento().getMaxCarDesc(); if (maxCarDesc == 0) maxCarDesc = 35; int riga = 0; int cellLeadingRow = getDocLeadRow(); if (cellLeadingRow == 0) cellLeadingRow = 12; Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowSmall = getTipoDocumento().getPdfFontRowSmall(); NumberFormat nf = getNf(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); int colonneDesc = 18; int[] ncb = new int[0]; int[] nca = { 8, 7, 7 }; try { String s_note = getNote(); if (getDocPosizioneNota() == 0L) riga = inserisciNoteDocumento(s_note, riga, righePerPagina, l_document, l_pdfCorpo, cellLeadingRow, maxCarDesc, colonneDesc, ncb, nca, PDF_frow, vec.hasMoreElements()); while (vec.hasMoreElements()) { String desc; double prezzoUnitarioConIva, importoRigaConIva; RigaDocumento row = (RigaDocumento)vec.nextElement(); double quantita = row.getQuantita(); if (!row.getIva().getFlgTipo().equals("R")) { desc = row.getDescrizioneRiga(); prezzoUnitarioConIva = row.getImportoConSconto(); importoRigaConIva = row.getTotImportoRigaConSconto(); } else { desc = "???"; prezzoUnitarioConIva = row.getImportoConSconto(); importoRigaConIva = row.getTotImportoRigaConSconto(); } if (!row.getNotaRigaDocumento().isEmpty()) desc = desc + " " + desc; riga = inserisciDescRigaDocumentoNew(desc, riga, righePerPagina, l_document, l_pdfCorpo, cellLeadingRow, maxCarDesc, colonneDesc, ncb, nca, PDF_frow, vec.hasMoreElements()); if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() != 1L) { cell = new Cell(new Chunk(row.getArticolo().getTipo().getTipologiaArticolo().getUdm() + " " + row.getArticolo().getTipo().getTipologiaArticolo().getUdm(), PDF_frow)); } else { cell = new Cell(new Chunk(nf.format(quantita), PDF_frow)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeadingRow); settaBordiEColori(cell, bordoColonne, bordoRighe, false, coloreBordo); cell.setColspan(nca[0]); l_pdfCorpo.addCell(cell); Cell cell = new Cell(new Chunk("€ " + nf.format(prezzoUnitarioConIva), PDF_frow)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeadingRow); settaBordiEColori(cell, bordoColonne, bordoRighe, false, coloreBordo); cell.setColspan(nca[1]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("€ " + nf.format(importoRigaConIva), PDF_frow)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeadingRow); settaBordiEColori(cell, bordoColonne, bordoRighe, false, coloreBordo); cell.setColspan(nca[2]); l_pdfCorpo.addCell(cell); riga = incrementaNumRighe(riga, righePerPagina, l_document, l_pdfCorpo, vec.hasMoreElements()); } if (getDocPosizioneNota() == 1L && !s_note.isEmpty()) riga = inserisciNoteDocumento(s_note, riga, righePerPagina, l_document, l_pdfCorpo, cellLeadingRow, maxCarDesc, colonneDesc, ncb, nca, PDF_frow, vec.hasMoreElements()); for (int i = riga; i < righePerPagina; i++) { for (int k = 0; k < ncb.length; k++) { Cell cell1 = new Cell(new Chunk(".", PdfFontFactory.PDF_fMedioBianco)); cell1.setLeading((float)cellLeadingRow); cell1.setBorder(0); cell1.setColspan(ncb[k]); l_pdfCorpo.addCell(cell1); } Cell cell = new Cell(new Chunk(".", PdfFontFactory.PDF_fMedioBianco)); cell.setLeading((float)cellLeadingRow); cell.setBorder(0); cell.setColspan(colonneDesc); l_pdfCorpo.addCell(cell); for (int j = 0; j < nca.length; j++) { cell = new Cell(new Chunk(".", PdfFontFactory.PDF_fMedioBianco)); cell.setLeading((float)cellLeadingRow); cell.setBorder(0); cell.setColspan(nca[j]); l_pdfCorpo.addCell(cell); } } } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoIntestazioneCorpoRicevuta(Table l_pdfCorpo) { int cellLeading = 8; try { Cell cell = new Cell(); cell.addElement(new Chunk("DESCRIZIONE", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_RICEVUTA_[0]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("QUAN.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_RICEVUTA_[1]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PREZZO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_RICEVUTA_[2]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPORTO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_RICEVUTA_[3]); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoFooterRicevute(Table l_pdfCorpo, boolean isUltimaPagina) { int cellLeading = 8; NumberFormat nf = getNf(); RigheRegistroIva rri = getRigaRegistroIvaCompleto(); String codIva = "", imponibile = "", aliquota = "", imposta = ""; if (rri != null) { Enumeration enuRrri = rri.elementsFatt(); while (enuRrri.hasMoreElements()) { RigaRegistroIvaItem rrii = enuRrri.nextElement(); if (rrii.getImponibile() != 0.0D) { if (getFlgArt8() == 1L) { imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n0"; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; continue; } imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n" + imposta; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; } } } try { Cell cell = new Cell(new Chunk("SPESE TRASPORTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseTrasportoConIva() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseTrasportoConIva()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE INCASSO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseIncassoConIva() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseIncassoConIva()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE VARIE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseAltre() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseAltreConIva()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SCONTI E ABBUONI\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleScontiAbbuoni() != 0.0D) { cell.add(new Chunk(nf.format(getTotaleScontiAbbuoniConIva()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("Q.TA' ARTICOLI\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getQuantitaTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getQuantitaTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } public long getFlgSuper() { return this.flgSuper; } public void setFlgSuper(long flgSuper) { this.flgSuper = flgSuper; } protected void creaDocumentoFooterFattureConPesiEColli(Table l_pdfCorpo, boolean isUltimaPagina) { int cellLeading = 8; NumberFormat nf = getNf(); RigheRegistroIva rri = getRigaRegistroIvaCompleto(); String codIva = "", imponibile = "", aliquota = "", imposta = ""; if (rri != null) { Enumeration enuRrri = rri.elementsFatt(); while (enuRrri.hasMoreElements()) { RigaRegistroIvaItem rrii = enuRrri.nextElement(); if (rrii.getImponibile() != 0.0D) { if (getFlgArt8() == 1L) { imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n0"; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; continue; } imponibile = imponibile + "\n" + imponibile; imposta = imposta + "\n" + imposta; codIva = codIva + "\n" + codIva; aliquota = aliquota + "\n" + aliquota; } } } try { Cell cell = new Cell(new Chunk("ALIQ.", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(codIva, PdfFontFactory.PDF_fPiccolissimoB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPONIBILE", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imponibile, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setRowspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPOSTA\t", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(imposta, PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); cell.setRowspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SCONTO INC.\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getScontoIncondizionato()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("ABBUONO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getAbbuono() != 0.0D) { cell.add(new Chunk(nf.format(getAbbuono()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE TRASPORTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseTrasporto() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseTrasporto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE MERCE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImponibileRighe() != 0.0D) { cell.add(new Chunk(nf.format(getImponibileRighe()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE INCASSO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseIncasso() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseIncasso()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SPESE VARIE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getSpeseAltre() != 0.0D) { cell.add(new Chunk(nf.format(getSpeseAltre()), PdfFontFactory.PDF_fPiccoloB)); if (!getDescSpeseAltre().isEmpty()) cell.add(new Chunk(" " + getDescSpeseAltre(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(11); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE NETTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getImponibileTotale() != 0.0D) { cell.add(new Chunk(nf.format(getImponibileTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SCADENZE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && !getNotePagamento().isEmpty()) { cell.add(new Chunk(getNotePagamento(), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(23); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PESO LORDO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getKgLordo() != 0.0D) { cell.add(new Chunk(nf.format(getKgLordo()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PESO NETTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getKgNetto() != 0.0D) { cell.add(new Chunk(nf.format(getKgNetto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("N. COLLI\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getNColli() != 0L) { cell.add(new Chunk(nf.format(getNColli()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("Q.TA' ARTICOLI\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getQuantitaTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getQuantitaTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. ESENTE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPONIBILE\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getImponibileTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOT. IMPOSTA\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina) { cell.add(new Chunk(nf.format(getImportoIvaTotale()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(5); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("\n", PdfFontFactory.PDF_fPiccolissimo)); cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("ACCONTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getAcconto() != 0.0D) { cell.add(new Chunk(nf.format(getAcconto()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); if (isUltimaPagina && getTotaleDocumento() != 0.0D) { cell.add(new Chunk(nf.format(getTotaleDocumento()), PdfFontFactory.PDF_fPiccoloB)); } else { cell.add(new Chunk("_", PdfFontFactory.PDF_fMedioBianco)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(7); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e, 2); } } public String getClienteNome() { return (this.clienteNome == null) ? "" : this.clienteNome; } public void setClienteNome(String clienteNome) { this.clienteNome = clienteNome; } public String getClienteCognome() { return (this.clienteCognome == null) ? "" : this.clienteCognome; } public void setClienteCognome(String clienteCognome) { this.clienteCognome = clienteCognome; } public String getClienteIndirizzo() { return (this.clienteIndirizzo == null) ? "" : this.clienteIndirizzo; } public void setClienteIndirizzo(String clienteIndirizzo) { this.clienteIndirizzo = clienteIndirizzo; } public String getClienteCf() { return (this.clienteCf == null) ? "" : this.clienteCf; } public void setClienteCf(String clienteCf) { this.clienteCf = clienteCf; } public String getClientePiva() { return (this.clientePiva == null) ? "" : this.clientePiva; } public void setClientePiva(String clientePiva) { this.clientePiva = clientePiva; } public long getFlgEmsta() { return this.flgEmsta; } public void setFlgEmsta(long flgEmsta) { this.flgEmsta = flgEmsta; } public String getNotaSblocco() { return (this.notaSblocco == null) ? "" : this.notaSblocco; } public void setNotaSblocco(String notaSblocco) { this.notaSblocco = notaSblocco; } private Document creaReportUnaVendite(DocumentoCR CR, boolean soloCompatto) { long l_id_tipoDocumento = CR.getId_tipoDocumento(); if (l_id_tipoDocumento == 0L) l_id_tipoDocumento = getId_docCassa(); int rowCellLeading = 6; NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col_4 = 0, col_99 = 0; int col_1 = 2, col_2 = 11, col_3 = 5, col_98 = 3, col_5 = 4, col_6 = 2, col_7 = 3, col_8 = 4; int col_97 = 2, col_96 = 2, col_95 = 2; int cellLeading = 12; String descCliente = "", descDocumento = ""; DoubleOperator totArt = new DoubleOperator(); DoubleOperator totVendita = new DoubleOperator(); DoubleOperator totImportoChiusi = new DoubleOperator(); DoubleOperator totImportoScontrino = new DoubleOperator(); DoubleOperator totImportoFatDaSc = new DoubleOperator(); DoubleOperator totImportoDDTDaSc = new DoubleOperator(); DoubleOperator totQtaChiusi = new DoubleOperator(); DoubleOperator totQtaScontrino = new DoubleOperator(); DoubleOperator totQtaFatDaSc = new DoubleOperator(); DoubleOperator totQtaDDTDaSc = new DoubleOperator(); List lstCh = new ArrayList<>(); List lstScont = new ArrayList<>(); List lstFatt = new ArrayList<>(); List lstDDT = new ArrayList<>(); Hashtable htAcconti = new Hashtable<>(); Hashtable htPag = new Hashtable(); Hashtable htArticoli = new Hashtable(); DoubleOperator dopAcc = new DoubleOperator(); DoubleOperator totImp = new DoubleOperator(); DoubleOperator totAcc = new DoubleOperator(); DoubleOperator totAccEnt = new DoubleOperator(); SimpleDateFormat df = getDataFormat(); try { Cell rigaVuota = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); String intestazioneReport = "Data: dal " + df.format(CR.getDataDocumentoDa()) + " al " + df.format(CR.getDataDocumentoA()); if (CR.getId_tipo() != 0L) intestazioneReport = intestazioneReport + " - Tipo: " + intestazioneReport; creaIntestazioneReport(CR.getTipoReport(), intestazioneReport); Cell cell = new Cell(new Chunk("Doc.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Articolo", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Cliente", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); if (col_4 > 0) { cell = new Cell(new Chunk("N. Tel.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } if (col_99 > 0) { cell = new Cell(new Chunk("Operatore", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_99); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("Tipo Doc.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_98); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Pag.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Pr. V.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Q.tà", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Tot.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Stampe", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_97); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Moduli", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_96); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("N.Gest", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_95); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); Vectumerator vec = new RigaDocumento(getApFull()).findVenditeGiornaliere(CR, l_id_tipoDocumento); while (vec.hasMoreElements()) { String nDoc, descPag, descOper, nTel; DoubleOperator dopPag, dopQ, dopValore; ArticoloGroup ag; descCliente = ""; descDocumento = ""; RigaDocumento row = (RigaDocumento)vec.nextElement(); totArt.add(row.getQuantita()); totVendita.add(row.getTotImportoRigaConSconto()); String descArticolo = row.getReparto().getDescrizione() + " - " + row.getReparto().getDescrizione() + "-" + row.getArticolo().getTipo().getDescrizione(); if (row.getDocumento().getId_tipoDocumento() == getId_docCassa()) { if (!row.getDocumento().isUnDocumentoFiglioCreato()) { nDoc = row.getDocumento().getNumeroDocumentoCompleto(); if (row.getDocumento().getEchoScontrino().equals("CHIUSO")) { descDocumento = "NO SCONTRINO"; } else { descDocumento = "scontrino"; } descPag = row.getDocumento().getTipoPagamento().getDescrizione(); } else { Documento docFiglio = row.getDocumento().getDocumentoFiglioUno(); nDoc = docFiglio.getNumeroDocumentoCompleto(); descCliente = docFiglio.getClifor().getDescrizioneCompleta(); descPag = docFiglio.getTipoPagamento().getDescrizione(); } if (!row.getNotaRigaDocumento().isEmpty()) { if (!descCliente.isEmpty()) descCliente = descCliente + " - "; descCliente = descCliente + descCliente; } nTel = ""; if (!row.getNotaBarcode().isEmpty()) nTel = row.getNotaBarcode(); descOper = ""; if (row.getDocumento().getId_users() != 0L) descOper = row.getDocumento().getUsers().getDescrizione(); if (row.getDocumento().getEchoScontrino().equals("CHIUSO")) { if (!lstCh.contains(row.getDocumento().getNumeroDocumento())) { totQtaChiusi.add(1); lstCh.add(row.getDocumento().getNumeroDocumento()); } totImportoChiusi.add(row.getTotImportoRigaConSconto()); } else if (row.getDocumento().getTipoDocumento().getId_tipoDocumento() == 1L && !row.getDocumento().isUnDocumentoFiglioCreato()) { if (!lstScont.contains(row.getDocumento().getNumeroDocumento())) { totQtaScontrino.add(1); lstScont.add(row.getDocumento().getNumeroDocumento()); } totImportoScontrino.add(row.getTotImportoRigaConSconto()); } else { Documento docFiglio = row.getDocumento().getDocumentoFiglioUno(); if (docFiglio.getTipoDocumento().getFlgTipologia() == 1L) { if (!lstFatt.contains(row.getDocumento().getNumeroDocumento())) { totQtaFatDaSc.add(1); lstFatt.add(row.getDocumento().getNumeroDocumento()); } totImportoFatDaSc.add(row.getTotImportoRigaConSconto()); } if (docFiglio.getTipoDocumento().getFlgTipologia() == 0L) { if (!lstDDT.contains(row.getDocumento().getNumeroDocumento())) { totQtaDDTDaSc.add(1); lstDDT.add(row.getDocumento().getNumeroDocumento()); } totImportoDDTDaSc.add(row.getTotImportoRigaConSconto()); } } } else { nDoc = row.getDocumento().getNumeroDocumentoCompleto(); descCliente = row.getDocumento().getClifor().getDescrizioneCompleta(); descDocumento = row.getDocumento().getTipoDocumento().getDescrizioneStampa(); descPag = row.getDocumento().getTipoPagamento().getDescrizione(); nTel = ""; descOper = ""; } if (htPag.containsKey(descPag)) { dopPag = (DoubleOperator)htPag.get(descPag); } else { dopPag = new DoubleOperator(); } dopPag.add(row.getTotImportoRigaConSconto()); htPag.put(descPag, dopPag); totImp.add(row.getTotImportoRigaConSconto()); String descArticoloGroup = row.getReparto().getDescrizione(); String agKey = descArticoloGroup; if (htArticoli.containsKey(agKey)) { ag = (ArticoloGroup)htArticoli.get(agKey); dopQ = new DoubleOperator(ag.getQuantita()); dopValore = new DoubleOperator(ag.getValore()); } else { ag = new ArticoloGroup(); ag.setDescrizione(descArticoloGroup); dopQ = new DoubleOperator(); dopValore = new DoubleOperator(); } dopQ.add(row.getQuantita()); dopValore.add(row.getTotImportoRigaConSconto()); ag.setQuantita(dopQ.getResult()); ag.setValore(dopValore.getResult()); htArticoli.put(agKey, ag); if (!soloCompatto) { cell = new Cell(new Chunk(nDoc, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descArticolo, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descCliente, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); if (col_4 > 0) { cell = new Cell(new Chunk(nTel, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } if (col_99 > 0) { cell = new Cell(new Chunk(descOper, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_99); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk(descDocumento, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_98); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descPag, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getImporto()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getQuantita()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); double totAcconti = getTotAccontiByDocumento(row.getId_documento()); if (totAcconti > 0.0D) { cell = new Cell(new Chunk(getNf().format(row.getTotImportoRigaConSconto()) + " *", PdfFontFactory.PDF_fPiccolissimo)); if (!htAcconti.containsKey(nDoc)) { dopAcc = new DoubleOperator(totAcconti); htAcconti.put(nDoc, dopAcc); } else { dopAcc = new DoubleOperator(); } } else { cell = new Cell(new Chunk(getNf().format(row.getTotImportoRigaConSconto()), PdfFontFactory.PDF_fPiccolissimo)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_97); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_96); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_95); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } } cell = new Cell(new Chunk("TOTALI", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_99 + col_5 + col_6 + col_98); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totImp.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_8); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col_97 + col_96 + col_95); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); int corpoPadding = 2; this.document.newPage(); } catch (Exception e) { handleDebug(e); } return this.document; } public void creaFileCvs(DocumentoCR CR) { try { Vectumerator list = findByCR(CR, 0, 0); CR.setFileName(getPathTmp() + "reportDocumenti_" + getPathTmp() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "Numero;Data;Tipo;Intestazione;Articolo;Stato;Anticipato;Imponibile;Importo;Doc. Padre;Doc. figlio;Pagamenti;Fatt. Elett"; outCvsFile.writeLine("Criteri di ricerca: " + CR.getDescrizioneCR()); outCvsFile.writeLine(s1); while (list.hasMoreElements()) { Documento row = (Documento)list.nextElement(); StringBuilder theLine = new StringBuilder(); theLine.append(row.getNumeroDocumentoCompleto()); theLine.append(SEP); theLine.append(getDataFormat().format(row.getDataDocumento())); theLine.append(SEP); theLine.append(row.getTipoDocumento().getDescrizione()); theLine.append(SEP); if (row.getNominativoDocumento().isEmpty()) { theLine.append(row.getClifor().getDescrizioneCompleta()); } else { theLine.append(row.getNominativoDocumento()); } theLine.append(SEP); if (row.getId_articolo() != 0L) theLine.append(row.getArticolo().getDescrizioneCompleta()); theLine.append(SEP); theLine.append(row.getStatoCompleto()); theLine.append(SEP); theLine.append(row.getBancaAnticipo().getDescrizione()); theLine.append(SEP); theLine.append(getNf().format(row.getImponibileTotaleConSegno())); theLine.append(SEP); theLine.append(getNf().format(row.getTotaleDocumentoConSegno())); theLine.append(SEP); theLine.append(row.getDocumentiPadreDesc()); theLine.append(SEP); theLine.append(row.getDocumentiFiglioDesc()); theLine.append(SEP); theLine.append(row.getTipoPagamento().getDescrizione()); theLine.append(SEP); if (row.getTmstInvioXml() == null) { theLine.append(""); } else { theLine.append(row.getFEProgressivoFile() + " " + row.getFEProgressivoFile()); } theLine.append(SEP); outCvsFile.writeLine(theLine.toString()); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public void creaFileArticoliCvs(DocumentoCR CR) { try { Vectumerator list = new RigaDocumento(getApFull()).findRigheReportArticoliCsv(CR); CR.setFileName(getPathTmp() + "reportDocumentiArticoli_" + getPathTmp() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "DOCUMENTO;CODICE ARTICOLO;ARTICOLO;SERIALE;PREZZO VENDITA;Q.TA"; outCvsFile.writeLine(s1); while (list.hasMoreElements()) { RigaDocumento row = (RigaDocumento)list.nextElement(); s1 = "\"" + row.getDocumento().getNumeroDocumento() + "\"" + SEP + "\"" + row.getArticolo().getCodice() + "\"" + SEP + "\"" + ((row.getId_articolo() > 0L) ? row.getArticolo().getDescrizioneCompleta() : (row.getDescrizioneRiga() + "*")) + "\"" + SEP + "\"" + row.getSeriale() + "\"" + SEP + getNf().format(row.getTotImportoRigaConSconto()) + SEP + getNf0().format(row.getQuantita()) + SEP; outCvsFile.writeLine(s1); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public Date getDataRestituzioneAcconto() { return this.dataRestituzioneAcconto; } public void setDataRestituzioneAcconto(Date dataRestituzioneAcconto) { this.dataRestituzioneAcconto = dataRestituzioneAcconto; } public Vectumerator findParmTipiFattureVendita() { Vectumerator ret = new Vectumerator(); String parm = getParm("TIPO_FATTURE_VENDITA").getTesto(); TipoDocumento td = new TipoDocumento(getApFull()); if (!parm.isEmpty()) for (String p : parm.split(",")) { td = new TipoDocumento(getApFull()); td.findByPrimaryKey(Long.parseLong(p)); if (td.getDBState() == 1) ret.add(td); } return ret; } public Vectumerator findParmTipiFattureAcquisto() { Vectumerator ret = new Vectumerator(); String parm = getParm("TIPO_FATTURE_ACQUISTO").getTesto(); TipoDocumento td = new TipoDocumento(getApFull()); if (!parm.isEmpty()) for (String p : parm.split(",")) { td = new TipoDocumento(getApFull()); td.findByPrimaryKey(Long.parseLong(p)); if (td.getDBState() == 1) ret.add(td); } return ret; } public ResParm creaFattureDaLista(DocumentoCR CR) { ResParm rp = new ResParm(true); Vectumerator vec = findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Documento doc = (Documento)vec.nextElement(); if (!doc.hasDocumentiFiglio()) rp = doc.creaDocumentoFiglio(doc.getId_clifor(), CR.getId_tipoDocumentoF(), CR.getUsers(), true, CR.getFlgTipoGenerazione()); } return rp; } public void creaFileCvsRiparazioni(DocumentoCR CR) { try { SimpleDateFormat df = getApFull().getDataFormat(); NumberFormat nf = getApFull().getNf(); Vectumerator list = findByCR(CR, 0, 0); CR.setFileName(getPathTmp() + "reportRiparazioni_" + getPathTmp() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); StringBuilder sb = new StringBuilder(); String s1 = "Numero;Data;Intestazione;;Stato;Cauzione;Data avviso;Data chiusura;Operatore accettazione;Operatore chiusura"; outCvsFile.writeLine(CR.getDescrizioneCR()); outCvsFile.writeLine(s1); while (list.hasMoreElements()) { Documento row = (Documento)list.nextElement(); sb = new StringBuilder(); sb.append(row.getNumeroDocumentoCompleto()); sb.append(SEP); sb.append(df.format(row.getDataDocumento())); sb.append(SEP); sb.append(row.getNominativoDocumento()); sb.append(SEP); sb.append(row.getDescrizioneRighe()); sb.append(SEP); sb.append(row.getStatoCompleto()); sb.append(SEP); sb.append(nf.format(row.getCauzione())); sb.append(SEP); sb.append(df.format(row.getDataAvviso())); sb.append(SEP); sb.append(df.format(row.getDataChiusura())); sb.append(SEP); sb.append(row.getUsers().getCognomeNome()); sb.append(SEP); sb.append(row.getUsersChiusura().getCognomeNome()); outCvsFile.writeLine(sb.toString()); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public void creaFileCvsPrenotazioni(DocumentoCR CR) { try { SimpleDateFormat df = getApFull().getDataFormat(); NumberFormat nf = getApFull().getNf(); Vectumerator list = new Vectumerator(); if (CR.getFlgStatoPrenotazioneArt() > -1L) { list = findPrenotazioniByCR(CR); } else { list = findByCR(CR, 0, 0); } CR.setFileName(getPathTmp() + "reportPrenotazioni_" + getPathTmp() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); StringBuilder sb = new StringBuilder(); String s1 = "Numero;Data;Intestazione;Oggetti;Stato;Acconto;Data avviso;Data chiusura;Operatore"; outCvsFile.writeLine(CR.getDescrizioneCR()); outCvsFile.writeLine(s1); list.moveFirst(); while (list.hasMoreElements()) { Documento row = (Documento)list.nextElement(); sb = new StringBuilder(); sb.append(row.getNumeroDocumentoCompleto()); sb.append(SEP); sb.append(df.format(row.getDataDocumento())); sb.append(SEP); sb.append(row.getNominativoDocumento()); sb.append(SEP); if (CR.getFlgStatoPrenotazioneArt() > -1L) { sb.append(row.getDescrizioneRighePrenotazione()); } else { sb.append(row.getDescrizioneRigheCompleta()); } sb.append(SEP); sb.append(row.getStatoCompleto()); sb.append(SEP); sb.append(nf.format(row.getAcconto())); sb.append(SEP); sb.append(df.format(row.getDataAvviso())); sb.append(SEP); sb.append(df.format(row.getDataChiusura())); sb.append(SEP); sb.append(row.getUsers().getCognomeNome()); outCvsFile.writeLine(sb.toString()); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public String getDescrizioneRighePrenotazione() { return (this.descrizioneRighePrenotazione == null) ? "" : this.descrizioneRighePrenotazione; } public Vectumerator findPrenotazioniByCR(DocumentoCR CR) { long nRighe = 0L; long nRigheScartate = 0L; Vectumerator vec = new Documento(getApFull()).findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Documento doc = (Documento)vec.nextElement(); RigaDocumento row = new RigaDocumento(getApFull()); Vectumerator vecr = row.findByDocumento(doc.getId_documento(), 0L, "", 0, 0, 0); nRighe = (long)vecr.size(); nRigheScartate = 0L; while (vecr.hasMoreElements()) { row = (RigaDocumento)vecr.nextElement(); long stato = row.getStatoPrenotazione(); if (stato != CR.getFlgStatoPrenotazioneArt()) { nRigheScartate++; continue; } StringBuilder sb = new StringBuilder(); sb.append(getNf().format(row.getQuantita())); sb.append(" "); sb.append(row.getDescrizioneRigaCompleta()); sb.append(" "); if (row.getId_articolo() != 0L) { sb.append(getNf().format(row.getArticolo().getQuantitaEffettiva())); sb.append(" "); sb.append(getNf().format(row.getArticolo().getQuantita())); sb.append(" "); } sb.append(" - "); doc.setDescrizioneRighePrenotazione(doc.getDescrizioneRighePrenotazione() + doc.getDescrizioneRighePrenotazione()); } if (nRighe == nRigheScartate) vec.remove(doc); } return vec; } public void setDescrizioneRighePrenotazione(String descrizioneRighePrenotazione) { this.descrizioneRighePrenotazione = descrizioneRighePrenotazione; } public static final synchronized ResParm addRigaDocumentoMov(DocumentoInterface doc, RigaDocumento row) { Movimento mov = new Movimento(doc.getApFull()); double l_quantitaDisponibileMagPartenza = 0.0D; double l_quantitaDisponibileTuttiMagazziniInterniEsterni = 0.0D; double l_quantitaDisponibileMagazziniInterni = 0.0D; long l_id_magFisicoPartenza = row.getDocumento().getId_magFisicoPartenza(); long l_id_magFisicoArrivo = row.getDocumento().getId_magFisicoArrivo(); ResParm rp = new ResParm(true); RigaDocumento rowOnDb = new RigaDocumento(doc.getApFull()); rowOnDb.findByPrimaryKey(row.getId_rigaDocumento()); if (!row.getSeriale().trim().isEmpty() && row.getArticolo().getFlgSerialiMassivi() == 0L) { row.setQuantita(1.0D); row.setQuantitaUdm(1.0D); } if (rowOnDb.getDBState() == 1 && (rowOnDb.getId_articolo() != row.getId_articolo() || rowOnDb.getId_articoloVariante() != row.getId_articoloVariante() || !rowOnDb.getSeriale().equals(row.getSeriale()))) { rp = rowOnDb.delete(); if (!rp.getStatus()) return rp; row.setId_rigaDocumento(0L); row.setDBState(0); } if (row.getId_articolo() != 0L && l_id_magFisicoPartenza > 0L) { mov.findDisponibilitaPuntuale(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), row.getSeriale(), l_id_magFisicoPartenza, 0L); l_quantitaDisponibileMagPartenza = mov.getQuantita(); if (rowOnDb.getDBState() == 1) l_quantitaDisponibileMagPartenza += rowOnDb.getQuantita(); if (row.getArticolo().getTipo().getFlgTipoMagazzino() > 0L && row.getArticolo().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articolo() != 0L && l_id_magFisicoPartenza != 0L && row.getFlgReso() == 0L && l_quantitaDisponibileMagPartenza < row.getQuantita()) { rp.setStatus(false); rp.setMsg("Attenzione. Tentativo di utilizzare un articolo non disponibile"); return rp; } } if (row.getId_articolo() != 0L && l_id_magFisicoPartenza > 0L && row.getDocumento().getMagFisicoPartenza().getFlgTipo() == 1L && row.getArticolo().getTipo().getFlgTipoMagazzino() > 0L && row.getArticolo().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articolo() != 0L && rowOnDb.getDBState() == 0 && row.getFlgReso() == 0L && row.getFlgIgnoraPrenotazione() == 0L) { double totArticoliEffettivi = 0.0D; if (row.getSeriale().isEmpty()) { mov.findDisponibilitaPuntualeMagazziniInterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), null, 0L); l_quantitaDisponibileMagazziniInterni = mov.getQuantita(); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - row.getTotArticoliImpegnati(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia()); } else { RigaDocumento rd = new RigaDocumento(row.getApFull()); rd.findRigaImpegnoBySeriale(row.getId_articolo(), row.getId_articoloVariante(), row.getSeriale()); if (rd.getDBState() == 1) { if (row.getFlgIgnoraPrenotazione() == 1L) { rd.setSeriale(""); rd.save(); totArticoliEffettivi = 1.0D; } else { totArticoliEffettivi = 0.0D; } } else { mov.findDisponibilitaPuntualeMagazziniInterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), null, 0L); l_quantitaDisponibileMagazziniInterni = mov.getQuantita(); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - row.getTotArticoliImpegnati(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia()); } if (totArticoliEffettivi <= 0.0D) { rp.setStatus(false); rp.setMsg("Attenzione. L'articolo è in magazzino ma non disponibile perchè risulta impegnato. "); return rp; } } } if (l_id_magFisicoArrivo > 0L && ( row.getDocumento().getMagFisicoArrivo().getFlgTipo() == 1L || row.getDocumento().getMagFisicoArrivo().getFlgTipo() == 2L) && !row.getSeriale().trim().isEmpty() && row.getArticolo().getTipo().getFlgTipoMagazzino() == 2L && rowOnDb.getDBState() == 0) { if (mov.getParm("SERIALI_UNIVOCI").isTrue()) { mov.findDisponibilitaGlobaleMagazziniInterniEsterni(row.getId_articolo(), row.getSeriale(), 0L); } else { mov.findDisponibilitaPuntualeMagazziniInterniEsterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), row.getSeriale(), 0L); } l_quantitaDisponibileTuttiMagazziniInterniEsterni = mov.getQuantita(); if (l_quantitaDisponibileTuttiMagazziniInterniEsterni >= 1.0D) { rp.setStatus(false); rp.setMsg("Attenzione. Stai inserendo un seriale già caricato in magazzino."); return rp; } } long l_numSeriali = 1L; if (doc.getTipoDocumento().getFlgTipologia() != 3L && row.getArticolo().getFlgSerialiMassivi() == 1L && row.getQuantita() > 1.0D) { l_numSeriali = (long)row.getQuantita(); row.setQuantita(1.0D); row.setQuantitaUdm(1.0D); } for (int i = 0; (long)i < l_numSeriali; i++) { RigaDocumento bean = new RigaDocumento(doc.getApFull()); if (row.getId_rigaDocumento() != 0L) { bean.findByPrimaryKey(row.getId_rigaDocumento()); } else if (row.getId_articolo() != 0L && row.getFlgSingleLineArt() == 1L && ( doc.getTipoDocumento().getFlgTipologia() == 3L || doc.getTipoDocumento().getFlgTipologia() == 4L || row.getArticolo().getTipo().getFlgTipoMagazzino() != 2L)) { if (row.getId_articoloTaglia() != 0L) { bean.findFirstByDocumentoArticoloTaglia(row.getId_documento(), row.getId_articoloTaglia()); } else if (row.getId_articoloVariante() != 0L) { bean.findFirstByDocumentoArticoloVariante(row.getId_documento(), row.getId_articoloVariante()); } else if (row.getId_articolo() != 0L) { bean.findFirstByDocumentoArticolo(row.getId_documento(), row.getId_articolo()); } row.setId_rigaDocumento(bean.getId_rigaDocumento()); row.addQuantita(bean.getQuantita()); } row.setDBState(bean.getDBState()); row.setQuantitaOld(bean.getQuantitaOld()); row.setId_documento(doc.getId_documento()); rp.append(row.save()); if (!rp.getStatus()) return rp; if (l_numSeriali > 1L) try { long currentSeriale = Long.valueOf(row.getSeriale()); currentSeriale++; String newSeriale = zeroLeft(currentSeriale, row.getSeriale().length()); row.setSeriale(newSeriale); row.setId_rigaDocumento(0L); row.setDBState(0); } catch (Exception e) { rp.setStatus(false); rp.setMsg("Errore! seriale non numerico per carico massivo: " + row.getSeriale()); return rp; } } if (rp.getStatus()) rp.setMsg(AbMessages.getMessage("SAVE_OK")); return rp; } 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 String getPathStampeDocumenti() { if (getApFull() == null) return ""; if (getDataDocumento() != null) { Calendar cal = Calendar.getInstance(); cal.setTime(getDataDocumento()); return getApFull().getAp().getResource("DOC_PATH") + getApFull().getAp().getResource("DOC_PATH") + "/"; } return getPathTmp(); } public String getPathStampaDocumentoFull() { if (getTmstFilePdf() == null) setTmstFilePdf(getTimestamp()); File pathDir = new File(getDocBase() + getDocBase()); if (!pathDir.exists()) pathDir.mkdirs(); return getDocBase() + getDocBase() + getPathStampeDocumenti() + "_" + getNumeroDocumentoPdf() + ".pdf"; } public Timestamp getTmstFilePdf() { return this.tmstFilePdf; } public void setTmstFilePdf(Timestamp tmstFilePdf) { this.tmstFilePdf = tmstFilePdf; } public boolean hasScadenzeSuRiba() { return new DocumentoScadenza(getApFull()).hasScadenzaConRiba(getId_documento()); } public Timestamp getTmstInvioMail() { return this.tmstInvioMail; } public void setTmstInvioMail(Timestamp tmstInvioMail) { this.tmstInvioMail = tmstInvioMail; } public ByteArrayOutputStream creaPdfEtichettePackingListZEBRA(String l_printer) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); int cellLeading = 6; try { Chunk destinazione; String dim = getParm("LABEL_PK_LIST_SIZE").getTesto(); long xx = Long.parseLong(dim.substring(0, dim.indexOf(','))); long yy = Long.parseLong(dim.substring(dim.indexOf(',') + 1)); 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(); creaPdfEtichettePackingListPreparaIntestazioneZebra(); int numColli = 0; long numTotColli = 0L; Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getArticolo().hasComponentiArticoli()) { Vectumerator vecAac = row.getArticolo().getArticoliComponenti(); numTotColli += (long)vecAac.getTotNumberOfRecords() * (long)row.getQuantita(); continue; } numTotColli += (long)row.getQuantita(); } String sp = " "; Font pdfTagliando = new Font(2, 14.0F, 1); Chunk nome = new Chunk(sp + "Spett.le " + sp + "\n", pdfTagliando); if (getId_destinazioneDiversa() == 0L) { StringBuilder sb = new StringBuilder(sp); sb.append(getClifor().getIndirizzo()); sb.append(getClifor().getNumeroCivico()); sb.append("\n"); sb.append(sp); sb.append(getClifor().getCapZona().isEmpty() ? getClifor().getCapComune() : getClifor().getCapZona()); sb.append(" ("); sb.append(getClifor().getProvinciaComune()); sb.append(")"); sb.append("\n"); sb.append("\n"); destinazione = new Chunk(sb.toString(), pdfTagliando); } else { destinazione = new Chunk(sp + sp + "\n" + getDestinazioneDiversa().getPressoDD() + sp + "\n\n", pdfTagliando); } vec.moveFirst(); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); for (int i = 0; (double)i < row.getQuantita(); i++) { if (row.getId_articolo() > 0L) { String descrizioneArticolo = row.getArticolo().getCodice() + "\n" + row.getArticolo().getCodice() + sp; if (row.getId_articoloVariante() > 0L) descrizioneArticolo = row.getArticolo().getCodice() + " " + row.getArticolo().getCodice() + "\n" + row.getArticoloVariante().getCodiceVariante() + sp + " " + row.getArticolo().getNome(); if (row.getArticolo().hasComponentiArticoli()) { Vectumerator vecAac = row.getArticolo().getArticoliComponenti(); while (vecAac.hasMoreElements()) { numColli++; ArticoloArticoloComponente rowAac = (ArticoloArticoloComponente)vecAac.nextElement(); Chunk descrizione = new Chunk(sp + sp + "\n" + descrizioneArticolo + sp + "\n", PdfFontFactory.PDF_fMedioB); Chunk colli = new Chunk(sp + " Collo " + sp + "/" + numColli + "\n", PdfFontFactory.PDF_fMedioB); Paragraph p = new Paragraph(); p.add(nome); p.add(destinazione); p.add(colli); p.add(descrizione); Cell cell = new Cell((Element)p); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); this.pdfcorpo.addCell(cell); if (vecAac.hasMoreElements()) { this.document.add((Element)this.pdfcorpo); this.document.newPage(); creaPdfEtichettePackingListPreparaIntestazioneZebra(); } } } else { numColli++; Chunk descrizione = new Chunk(sp + sp + "\n", PdfFontFactory.PDF_fMedioB); Chunk colli = new Chunk(sp + " Collo " + sp + "/" + numColli + "\n", PdfFontFactory.PDF_fMedioB); Paragraph p = new Paragraph(); p.add(nome); p.add(destinazione); p.add(colli); p.add(descrizione); Cell cell = new Cell((Element)p); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); this.pdfcorpo.addCell(cell); } } else { String descrizioneArticolo = row.getDescrizioneRigaCompleta(); numColli++; Chunk descrizione = new Chunk(sp + sp + "\n", PdfFontFactory.PDF_fMedioB); Chunk colli = new Chunk(sp + " Collo " + sp + "/" + numColli + "\n", PdfFontFactory.PDF_fMedioB); Paragraph p = new Paragraph(); p.add(nome); p.add(destinazione); p.add(colli); p.add(descrizione); Cell cell = new Cell((Element)p); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); this.pdfcorpo.addCell(cell); } if ((double)i < row.getQuantita() - 1.0D) { this.document.add((Element)this.pdfcorpo); this.document.newPage(); creaPdfEtichettePackingListPreparaIntestazioneZebra(); } } if (vec.hasMoreElements()) { this.document.add((Element)this.pdfcorpo); this.document.newPage(); creaPdfEtichettePackingListPreparaIntestazioneZebra(); } } this.document.add((Element)this.pdfcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } private PdfPCell creaPdfEtichettePackingListPreparaIntestazioneCellaA4(float fixedHeight) { String sp = ""; int cellLeading = 18, cellLeading2 = 0; int paddingLeft = 10; PdfPCell cell = new PdfPCell(); cell.setFixedHeight(fixedHeight); try { float imgLogoWidth = getDocLogoWidth(); Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); imgLogo.scaleToFit(imgLogoWidth - 70.0F, imgLogoWidth - 70.0F); cell.addElement(new Chunk(imgLogo, 2.0F, -imgLogo.getScaledHeight() + 12.0F)); cell.addElement(new Chunk("\n\n" + sp + "Mittente:,", PdfFontFactory.PDF_fPiccolo)); Paragraph paragraph = creaParagrafoConGrassetto(sp + sp + getHeaderDoocumento(1) + sp, PDF_fPiccolo, PDF_fPiccoloB); paragraph.setLeading(10.0F); cell.addElement((Element)paragraph); cell.setBorder(0); cell.setPaddingLeft((float)paddingLeft); cell.setPaddingRight((float)paddingLeft); cell.setColspan(1); } catch (Exception e) { e.printStackTrace(); } return cell; } public String getElencoScadenze() { StringBuilder sb = new StringBuilder(); if (getId_documento() > 0L) { DocumentoScadenza scadenza = new DocumentoScadenza(getApFull()); Vectumerator vec = scadenza.findByDocumento(getId_documento()); if (vec.hasMoreElements()) while (vec.hasMoreElements()) { scadenza = (DocumentoScadenza)vec.nextElement(); if (sb.length() > 0) sb.append(" - "); sb.append(getDataFormat().format(scadenza.getDataScadenza())); sb.append(" "); sb.append(getNf().format(scadenza.getImportoScadenza())); } } return sb.toString(); } public Vectumerator getElencoScadenze(DocumentoPagamentoCR CR) { DocumentoScadenza scadenza = new DocumentoScadenza(getApFull()); DocumentoScadenzaCR CRDS = new DocumentoScadenzaCR(); CRDS.setId_documento(getId_documento()); CRDS.setDataScadenzaDa(CR.getDataScadenzaDa()); CRDS.setDataScadenzaA(CR.getDataScadenzaA()); return scadenza.findByCR(CRDS, 0, 0); } public ResParm sendOrderMailMessageRavinale(String lang, boolean mailAdmin, boolean mailUser, boolean isPagamentoVariato) { ResParm rp = new ResParm(true); mailAdmin = false; String urlBase = getParm("CODA_MESSAGGI_IMG_URL_BASE").getTesto() + "_img/_imgArt/_var/80/"; MailProperties mp = new MailProperties(); if (getId_documento() == 0L) { rp.setStatus(false); rp.setMsg("ERRORE! Codice Documento nullo! contattare l'amministratore del sito"); handleDebug(rp.getMsg(), 0); return rp; } try { int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; String subject = getMailSubject(); NumberFormat nf = getNf(); String notePagamento = "", statoPagamento = ""; String notaStato = " " + translate("in lavorazione", lang) + " "; String orderLine = ""; String orderLine2 = ""; DoubleOperator totaleCosto = new DoubleOperator(); double totaleQta = 0.0D; statoPagamento = translate("Metodo di pagamento scelto", lang) + ": " + translate("Metodo di pagamento scelto", lang); if (getStatoPagato() == 1L) statoPagamento = statoPagamento + "
" + statoPagamento + translate("Transazione n. ", lang) + " " + getDescTransaction() + " " + translate("del", lang); if (getStatoPagato() == 2L) statoPagamento = statoPagamento + "
" + statoPagamento + ": " + translate("Data Pagamento", lang); Users l_user = getClifor().getUserWww(); String linkOrdineDiretto = ""; if (l_user.isProfileNoReg()) { linkOrdineDiretto = "
" + translate("Per accedere direttamente all'ordine: ", lang); linkOrdineDiretto = linkOrdineDiretto + "" + getLinkOrdineWwwNoReg(l_user) + ""; } if (l_user.isProfileNoReg()) { linkOrdineDiretto = "
" + translate("Per accedere direttamente all'ordine: ", lang); linkOrdineDiretto = linkOrdineDiretto + "" + getLinkOrdineWwwNoReg(l_user) + ""; } else { linkOrdineDiretto = "
" + translate("Per accedere direttamente all'ordine: ", lang); linkOrdineDiretto = linkOrdineDiretto + "" + getLinkOrdineWww() + ""; } if (getStatoPagato() == 0L) { if (getFlgProcediPagamento() == 1L) { notePagamento = getTipoPagamento().getMsgMailProcedi(lang); if (getTipoPagamento().getFlgTipoPagamento() != 5L); notePagamento = notePagamento + notePagamento; } else { notePagamento = getTipoPagamento().getMsgMailAspetta(lang); } } else { notePagamento = ""; } if (getFlgStatoOrdineWww() == 2L) notaStato = translate(getParm("MSG_ORDINE_SPEDITO").getTesto(), lang); if (mailUser || isPagamentoVariato) { MailMessage mf = new MailMessage(getApFull(), getCheckOutMailMessage(lang)); mf.setQuestionMark(false); if (getFlgStatoOrdineWww() == 2L) { if (getDataSpedizione() == null) setDataSpedizione(DBAdapter.getToday()); mf.setString("dataSpedizione", getDataFormat().format(getDataSpedizione())); mf.setString("corriere", getVettore().getDescrizione()); mf.setString("nColli", String.valueOf(getNColli())); String temp = ""; if (!getNotaSpedizione().isEmpty()) temp = temp + "

" + temp; mf.setString("notaContrassegno", temp); if (!getVettore().getLinkTracking().isEmpty() && !getTrackingSpedizione().isEmpty()) { String id_docCrypt = crypt(String.valueOf(getId_documento())); String link = getVettore().getLinkTracking() + getVettore().getLinkTracking(); String track = translate("Potra' verificare la spedizione al seguente", lang) + " link "; mf.setString("tracking", track); } } mf.setString("id_ordine", getNumeroDocumentoCompleto()); mf.setString("stato", translate(getStatoOrdineWww(), lang)); mf.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mf.setString("statoPagamento", statoPagamento); mf.setString("notaPagamento", notePagamento); mf.setLong("id_users", getClifor().getId_clifor()); mf.setString("nominativo", getClifor().getCognome()); mf.setString("nome", getClifor().getNome()); mf.setString("cognome", getClifor().getCognome()); mf.setString("indirizzo", getClifor().getIndirizzo()); mf.setString("numero", getClifor().getNumeroCivico()); String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); mf.setString("cap", capComune); mf.setString("citta", getClifor().getDescrizioneComune()); mf.setString("provincia", getClifor().getProvinciaComune()); mf.setString("codfisc", getClifor().getCodFisc()); mf.setString("codSDI", getClifor().getCodiceIdentificativoFE()); mf.setString("pec", getClifor().getPec()); mf.setString("piva", getClifor().getPIva()); mf.setString("email", getClifor().getEMail()); mf.setString("nazione", getClifor().getNazione().getDescrizione(lang)); if (getIndirizzoSped().trim().equals("")) { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mf.setString("indirizzoSped", getClifor().getIndirizzo() + " c/o " + getClifor().getIndirizzo()); } mf.setString("numeroSped", getClifor().getNumeroCivico()); mf.setString("capSped", getClifor().getCapComune()); mf.setString("cittaSped", getClifor().getDescrizioneComune()); mf.setString("provinciaSped", getClifor().getProvinciaComune()); mf.setString("nazioneSped", getClifor().getNazione().getDescrizione(lang)); } else { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getIndirizzoSped()); } else { mf.setString("indirizzoSped", getIndirizzoSped() + " c/o " + getIndirizzoSped()); } mf.setString("numeroSped", getNumeroCivicoSped()); mf.setString("capSped", getCapSped()); mf.setString("cittaSped", getCittaSped()); mf.setString("provinciaSped", getProvinciaSped()); mf.setString("nazioneSped", getNazioneSped().getDescrizione(lang)); } Vectumerator enu = findRigheDocumento(0, 0, ordineInverso); while (enu.hasMoreElements()) { RigaDocumento row = (RigaDocumento)enu.nextElement(); orderLine = orderLine + " " + row.getArticoloVariante().getImgFileName(1) + "" + row.getDescrizioneRigaCompleta() + "" + row.getImportoConSconto() + "Eu " + row.getQuantita() + "\n"; totaleQta += row.getQuantita(); } if (getSpeseAltre() > 0.0D) orderLine = orderLine + "\n " + orderLine + "\n Eu " + getDescSpeseAltre() + "\n "; mf.setString("orderline", orderLine); if (getTotaleScontiAbbuoniConIva() > 0.0D) { mf.setString("descSconto", "**** " + translate("SCONTO INCONDIZIONATO", lang) + " *****"); mf.setString("scontoInc", " - " + nf.format(getTotaleScontiAbbuoniConIva())); } mf.setString("qta", nf.format(totaleQta)); mf.setString("totale", nf.format(getImponibileTotale())); mf.setString("totaleOrdine", nf.format(getTotaleDocumento())); mf.setString("iva", nf.format(getImportoIvaTotale())); mf.setString("speseSped", nf.format(getSpeseTrasportoConIva())); if (getNotePagamento().isEmpty()) { mf.setString("nota", String.valueOf(getNote())); } else { mf.setString("nota", "" + getNotePagamento() + "
" + String.valueOf(getNote())); } mf.setString("codiceOrdine", getNumeroDocumentoCompleto()); mf.setString("telefono", getClifor().getCellulare()); String theSubject = translate(subject, lang); String l_email = getClifor().getEMail(); if (mailUser) theSubject = theSubject + " - " + theSubject + " " + translate("Ordine n.", lang) + " - " + getNumeroDocumentoCompleto(); if (isPagamentoVariato) { l_email = getMailTo(); theSubject = theSubject + theSubject + " " + translate("Ordine n.", lang) + " - " + getNumeroDocumentoCompleto() + " - "; theSubject = theSubject + theSubject; theSubject = theSubject + theSubject; } mp.put("TO", l_email); mp.setProperty("FROM", getParm("FROM").getTesto()); if (this.flgWwwRichiedeFattura == 1L) Vectumerator vectumerator = findDocumentiFiglio(); if (hasDocumentiFiglio()) { Documento fattura = getDocumentoFiglioUno(); if (fattura.getId_documento() > 0L) { DocumentoCR CRf = new DocumentoCR(getApFull()); CRf.setId_documentoS(fattura.getId_documento()); fattura.creaDocumentoPdf(CRf, true); mp.put("FILES", CRf.getFilePdf()); } } mp.put("SUBJECT", theSubject); mp.put("MSG", mf.getMessage()); mp.setProperty("ISHTML", "true"); rp = sendMailMessage(mp); } if (mailAdmin) { String mmfAdmMessage = getCheckOutMailMessage(lang); MailMessage mfAdm = new MailMessage(getApFull(), mmfAdmMessage); mfAdm.setQuestionMark(false); mfAdm.setString("id_ordine", getNumeroDocumentoCompleto()); mfAdm.setString("stato", getStato()); mfAdm.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mfAdm.setString("statoPagamento", statoPagamento); mfAdm.setString("notaPagamento", notePagamento); mfAdm.setLong("id_users", getClifor().getId_clifor()); mfAdm.setString("nominativo", getClifor().getCognome()); mfAdm.setString("nome", getClifor().getNome()); mfAdm.setString("cognome", getClifor().getCognome()); mfAdm.setString("indirizzo", getClifor().getIndirizzo()); mfAdm.setString("numero", getClifor().getNumeroCivico()); mfAdm.setString("cap", getClifor().getCapComune()); mfAdm.setString("citta", getClifor().getDescrizioneComune()); mfAdm.setString("provincia", getClifor().getProvinciaComune()); mfAdm.setString("codfisc", getClifor().getCodFisc()); mfAdm.setString("piva", getClifor().getPIva()); mfAdm.setString("email", getClifor().getEMail()); if (getIndirizzoSped().trim().equals("")) { if (getPresso().isEmpty()) { mfAdm.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mfAdm.setString("indirizzoSped", getClifor().getIndirizzo() + " c/o " + getClifor().getIndirizzo()); } mfAdm.setString("numeroSped", getClifor().getNumeroCivico()); mfAdm.setString("capSped", getClifor().getCapComune()); mfAdm.setString("cittaSped", getClifor().getDescrizioneComune()); mfAdm.setString("provinciaSped", getClifor().getProvinciaComune()); } else { if (getPresso().isEmpty()) { mfAdm.setString("indirizzoSped", getIndirizzoSped()); } else { mfAdm.setString("indirizzoSped", getIndirizzoSped() + " c/o " + getIndirizzoSped()); } mfAdm.setString("numeroSped", getNumeroCivicoSped()); mfAdm.setString("capSped", getCapSped()); mfAdm.setString("cittaSped", getCittaSped()); mfAdm.setString("provinciaSped", getProvinciaSped()); } orderLine2 = ""; totaleCosto = new DoubleOperator(); totaleQta = 0.0D; String stileRicarico = ""; Vectumerator enu = findRigheDocumento(0, 0, ordineInverso); while (enu.hasMoreElements()) { RigaDocumento row = (RigaDocumento)enu.nextElement(); orderLine2 = orderLine2 + " " + row.getArticoloVariante().getImgFileName(1) + "" + row.getDescrizioneRigaCompleta() + "" + row.getImportoConSconto() + "Eu " + row.getQuantita() + "\n"; DoubleOperator totaleArticolo = new DoubleOperator(row.getImponibile()); totaleArticolo.multiply(row.getQuantita()); totaleCosto.add(totaleArticolo); totaleQta += row.getQuantita(); } mfAdm.setString("orderline", orderLine2); mfAdm.setString("qta", nf.format(totaleQta)); mfAdm.setString("iva", nf.format(getImportoIvaTotale())); mfAdm.setString("speseSped", nf.format(getSpeseTrasporto())); mfAdm.setString("totale", nf.format(getImponibileTotale())); mfAdm.setString("totaleOrdine", nf.format(getTotaleDocumento())); if (getNotePagamento().isEmpty()) { mfAdm.setString("nota", String.valueOf(getNote())); } else { mfAdm.setString("nota", "" + getNotePagamento() + "
" + String.valueOf(getNote())); } mfAdm.setString("notaAmm", "Nota su cliente:" + String.valueOf(getClifor().getNota() + "\nNota su Ordine: " + getClifor().getNota())); mfAdm.setString("codiceOrdine", getNumeroDocumentoCompleto()); mfAdm.setString("telefono", getClifor().getCellulare()); mfAdm.setString("orderline", orderLine2); mfAdm.setString("notaStato", notaStato); String sbjAdmin = subject + " - Adm Ordine n. " + subject + " - " + String.valueOf(getId_ordine()) + " - "; if (isPagamentoVariato) sbjAdmin = sbjAdmin + "PAGAMENTO VARIATO "; sbjAdmin = sbjAdmin + sbjAdmin; String to = getMailTo(); rp.append(mfAdm.sendMailMessageSystem(to, sbjAdmin, true)); } } catch (Exception e) { handleDebug(e); rp.setStatus(false); rp.setMsg(e); System.out.println("ERRORE INVIO EMAIL:"); e.printStackTrace(); } if (!rp.getStatus()) { handleDebug(rp.getMsg(), 2); System.out.println("ERRORE INVIO EMAIL:" + rp.getMsg()); } return rp; } public static final synchronized ResParm addRigaDocumentoFilato(Documento doc, RigaDocumento row) { long l_id_magFisicoPartenza, l_id_magFisicoArrivo; ResParm rp = doc.checkEMSTA(); if (!rp.getStatus()) return new ResParm(false, "ATTENZIONE! Tentativo di aggiungere una riga documento: " + rp.getMsg()); RigaDocumento RD = new RigaDocumento(doc.getApFull()); double l_quantitaDisponibileMagPartenza = 0.0D; double l_quantitaDisponibileTuttiMagazziniInterniEsterni = 0.0D; double l_quantitaDisponibileMagazziniInterni = 0.0D; if (row.getFlgCodiceRiga() == 0L) { l_id_magFisicoPartenza = row.getDocumento().getId_magFisicoPartenza(); l_id_magFisicoArrivo = row.getDocumento().getId_magFisicoArrivo(); } else { l_id_magFisicoPartenza = row.getDocumento().getId_magFisicoPartenza2(); l_id_magFisicoArrivo = row.getDocumento().getId_magFisicoArrivo2(); } rp = new ResParm(true); RigaDocumento rowOnDb = new RigaDocumento(doc.getApFull()); rowOnDb.findByPrimaryKey(row.getId_rigaDocumento()); if (rowOnDb.getDBState() == 1 && (rowOnDb.getId_articoloFilatoColore() != row.getId_articoloFilatoColore() || !rowOnDb.getSeriale().equals(row.getSeriale()))) { rp = rowOnDb.delete(); if (!rp.getStatus()) return rp; row.setId_rigaDocumento(0L); row.setDBState(0); } if (row.getId_articoloFilatoColore() != 0L && l_id_magFisicoPartenza > 0L) { RD.findMagFilatoDisponibilitaPuntuale(row.getId_articoloFilatoColore(), 0L, 0L, row.getSeriale(), l_id_magFisicoPartenza, 0L, 0L, ""); l_quantitaDisponibileMagPartenza = RD.getQuantita(); if (rowOnDb.getDBState() == 1) l_quantitaDisponibileMagPartenza += rowOnDb.getQuantita(); if (row.getArticoloFilatoColore().getArticoloFilato().getTipo().getFlgTipoMagazzino() > 0L && row.getArticoloFilatoColore().getArticoloFilato().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articoloFilatoColore() != 0L && l_id_magFisicoPartenza != 0L && row.getFlgReso() == 0L && l_quantitaDisponibileMagPartenza < row.getQuantita()) { rp.setStatus(false); rp.setMsg("Attenzione. Tentativo di utilizzare un articolo non disponibile"); return rp; } } if (row.getId_articoloFilatoColore() != 0L && l_id_magFisicoPartenza > 0L && row.getDocumento().getMagFisicoPartenza().getFlgTipo() == 1L && row.getArticoloFilatoColore().getArticoloFilato().getTipo().getFlgTipoMagazzino() > 0L && row.getArticoloFilatoColore().getArticoloFilato().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articoloFilatoColore() != 0L && rowOnDb.getDBState() == 0 && row.getFlgReso() == 0L && row.getFlgIgnoraPrenotazione() == 0L) { double totArticoliEffettivi = 0.0D; if (row.getSeriale().isEmpty()) { RD.findMagFilatoDisponibilitaPuntualeMagazziniInterni(row.getId_articoloFilatoColore(), 0L, 0L, null); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); double totArticoliImpegnati = row.getTotFilatiImpegnati(row.getId_articoloFilatoColore(), 0L, 0L, ""); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - totArticoliImpegnati; } else { if (row.getArticoloFilatoColore().getArticoloFilato().getTipo().getFlgTipoMagazzino() != 2L) if (row.getArticoloFilatoColore().getArticoloFilato().getTipo().getFlgTipoMagazzino() == 3L) { RD.findMagFilatoDisponibilitaPuntualeMagazziniInterni(row.getId_articoloFilatoColore(), 0L, 0L, null); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); double totArticoliImpegnati = row.getTotFilatiImpegnati(row.getId_articoloFilatoColore(), 0L, 0L, row.getSeriale()); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - totArticoliImpegnati; } else { RD.findMagFilatoDisponibilitaPuntualeMagazziniInterni(row.getId_articoloFilatoColore(), 0L, 0L, null); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); double totArticoliImpegnati = row.getTotFilatiImpegnati(row.getId_articoloFilatoColore(), 0L, 0L, ""); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - totArticoliImpegnati; } if (totArticoliEffettivi <= 0.0D) { rp.setStatus(false); rp.setMsg("Attenzione. L'articolo è in magazzino ma non disponibile perchè risulta impegnato. "); return rp; } } } if (l_id_magFisicoArrivo > 0L && ( row.getDocumento().getMagFisicoArrivo().getFlgTipo() == 1L || row.getDocumento().getMagFisicoArrivo().getFlgTipo() == 2L) && !row.getSeriale().trim().isEmpty() && rowOnDb.getDBState() == 0) { RD.findMagFilatoDisponibilitaPuntualeMagazziniInterniEsterni(row.getId_articoloFilatoColore(), 0L, 0L, row.getSeriale(), 0L); l_quantitaDisponibileTuttiMagazziniInterniEsterni = RD.getQuantita(); if (l_quantitaDisponibileTuttiMagazziniInterniEsterni >= 1.0D) { rp.setStatus(false); rp.setMsg("Attenzione. Stai inserendo un seriale già caricato in magazzino."); return rp; } } row.setId_documento(doc.getId_documento()); rp.append(row.saveFilato()); if (rp.getStatus() && doc.getTipoDocumento().getFlgTipologia() == 201L) rp.append(doc.aggiornaSerialeTessutoDisposizioneTessitura()); return rp; } public long getFlgWwwRichiedeFattura() { return this.flgWwwRichiedeFattura; } public void setFlgWwwRichiedeFattura(long flgWwwRichiedeFattura) { this.flgWwwRichiedeFattura = flgWwwRichiedeFattura; } public ByteArrayOutputStream creaPdfEtichettePackingListA4(DocumentoCR CR) { long pHMarg = getParm("LABEL_PK_LIST_A4_MARGINE").getNumeroLong(); int cellLeading = 6; boolean stampaImmagineArticolo = false; ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { this.document = new Document(PageSize.A4, 2.0F, 2.0F, 2.0F, 2.0F); this.writer = PdfWriter.getInstance(this.document, ba); String titoloReport = getNumeroDocumentoCompleto(); SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.document.open(); int altezzaCod = 40; int larghezzaCod = 300; PdfContentByte cb = this.writer.getDirectContent(); Barcode128 codeBar = new Barcode128(); codeBar.setCodeType(9); long labelNumber = 0L; String dim = getParm("LABEL_PK_LIST_A4_COL_ROW").getTesto(); int nCol = Integer.parseInt(dim.substring(0, dim.indexOf(','))); int nRow = Integer.parseInt(dim.substring(dim.indexOf(',') + 1)); float fixedHeight = (PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow - 4.0F; this.pdfPcorpo = new PdfPTable(nCol); this.pdfPcorpo.setWidthPercentage(100.0F); Documento doc = new Documento(getApFull()); doc.findByPrimaryKey(CR.getId_documentoS()); if (CR.getBlankLabels() > 0L) { PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); for (int i = 0; (long)i < CR.getBlankLabels(); i++) { labelNumber++; this.pdfPcorpo.addCell(cell); } } Vectumerator vec = findByCR(CR, 0, 0); long numbOfLabels = 1L; while (vec.hasMoreElements()) { Chunk destinazione; Documento rowDoc = (Documento)vec.nextElement(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vecRighe = rowDoc.findRigheDocumento(0, 0, ordineInverso); int numColli = 0; long numTotColli = 0L; while (vecRighe.hasMoreElements()) { RigaDocumento rd = (RigaDocumento)vecRighe.nextElement(); if (rd.getArticolo().hasComponentiArticoli()) { Vectumerator vecAac = rd.getArticolo().getArticoliComponenti(); numTotColli += (long)vecAac.getTotNumberOfRecords() * (long)rd.getQuantita(); continue; } numTotColli += (long)rd.getQuantita(); } String sp = ""; Font pdfTagliando = new Font(2, 12.0F, 1); Chunk numDoc = new Chunk(sp + sp + " " + getTipoDocumento().getDescrizioneStampa() + " del " + getNumeroDocumento() + "\n", PdfFontFactory.PDF_fPiccoloB); Chunk nome = new Chunk(sp + "Spett.le\n" + sp + "\n", pdfTagliando); if (getId_destinazioneDiversa() == 0L) { StringBuilder sb = new StringBuilder(sp); sb.append(getClifor().getIndirizzo()); sb.append(getClifor().getNumeroCivico()); sb.append("\n"); sb.append(sp); sb.append(getClifor().getCapZona().isEmpty() ? getClifor().getCapComune() : getClifor().getCapZona()); sb.append(" ("); sb.append(getClifor().getProvinciaComune()); sb.append(")"); sb.append("\n"); sb.append("__________________________________________\n"); destinazione = new Chunk(sb.toString(), pdfTagliando); } else { destinazione = new Chunk(sp + sp + "\n" + getDestinazioneDiversa().getPressoDD() + sp + "\n\n", pdfTagliando); } vecRighe.moveFirst(); while (vecRighe.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRighe.nextElement(); for (int i = 0; (double)i < row.getQuantita(); i++) { if (row.getId_articolo() > 0L) { String descrizioneArticolo = row.getArticolo().getCodice() + "\n" + row.getArticolo().getCodice() + sp; if (row.getId_articoloVariante() > 0L) descrizioneArticolo = row.getArticolo().getCodice() + "\n" + row.getArticolo().getCodice() + "\n" + row.getArticoloVariante().getCodiceVariante() + sp + " " + row.getArticolo().getNome(); if (!row.getNotaRigaDocumento().isEmpty()) descrizioneArticolo = descrizioneArticolo + ": " + descrizioneArticolo; if (row.getArticolo().hasComponentiArticoli()) { Vectumerator vecAac = row.getArticolo().getArticoliComponenti(); while (vecAac.hasMoreElements()) { numColli++; ArticoloArticoloComponente rowAac = (ArticoloArticoloComponente)vecAac.nextElement(); Chunk descrizione = new Chunk(sp + sp + "\n" + descrizioneArticolo + sp + "\n", PdfFontFactory.PDF_fMedioB); Chunk colli = new Chunk(sp + "Collo " + sp + "/" + numColli + "\n", PdfFontFactory.PDF_fMedioB); Paragraph p = new Paragraph(); p.add(numDoc); p.add(nome); p.add(destinazione); p.add(colli); p.add(descrizione); StringBuilder pv = new StringBuilder(); if (rowAac.getArticoloComponente().getPesoKg() > 0.0D) { pv.append("Peso: Kg " + getNf().format(rowAac.getArticoloComponente().getPesoKg())); pv.append(" "); } if (rowAac.getArticoloComponente().getVolumeM3() > 0.0D) pv.append("Volume: mc " + getNf().format(rowAac.getArticoloComponente().getVolumeM3())); if (pv.length() > 0) p.add(new Chunk(pv.toString(), PdfFontFactory.PDF_fMedioB)); PdfPCell pdfPCell = creaPdfEtichettePackingListPreparaIntestazioneCellaA4(fixedHeight); pdfPCell.addElement((Element)p); codeBar.setCode(row.getArticolo().getCodice() + " " + row.getArticolo().getCodice() + " " + row.getArticoloVariante().getCodiceVariante()); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); pdfPCell.addElement(new Chunk(imgBarcode, 1.0F, -50.0F)); if (rowAac.getArticoloComponente().isImgExist(1) && stampaImmagineArticolo) { Image imgArticolo = Image.getInstance(getDocBase() + getDocBase() + rowAac.getArticolo().getPathImg()); imgArticolo.scaleToFit(100.0F, 100.0F); pdfPCell.addElement(new Chunk(imgArticolo, 2.0F, -imgArticolo.getScaledHeight() - 10.0F)); } this.pdfPcorpo.addCell(pdfPCell); labelNumber++; } } else { numColli++; Chunk descrizione = new Chunk(sp + sp + "\n", PdfFontFactory.PDF_fMedioB); Chunk colli = new Chunk(sp + "Collo " + sp + "/" + numColli + "\n", PdfFontFactory.PDF_fMedioB); Paragraph p = new Paragraph(); p.add(numDoc); p.add(nome); p.add(destinazione); p.add(colli); p.add(descrizione); StringBuilder pv = new StringBuilder(); if (row.getArticolo().getPesoKg() > 0.0D) { pv.append("Peso: Kg " + getNf().format(row.getArticolo().getPesoKg())); pv.append(" "); } if (row.getArticolo().getVolumeM3() > 0.0D) pv.append("Volume: mc " + getNf().format(row.getArticolo().getVolumeM3())); if (pv.length() > 0) p.add(new Chunk(pv.toString(), PdfFontFactory.PDF_fMedioB)); PdfPCell pdfPCell = creaPdfEtichettePackingListPreparaIntestazioneCellaA4(fixedHeight); pdfPCell.addElement((Element)p); codeBar.setCode(row.getArticolo().getCodice() + " " + row.getArticolo().getCodice()); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); pdfPCell.addElement(new Chunk(imgBarcode, 1.0F, -50.0F)); if (row.getArticoloVariante().isImgExist(1) && stampaImmagineArticolo) { Image imgArticolo = Image.getInstance(getDocBase() + getDocBase() + row.getArticoloVariante().getPathImg()); imgArticolo.scaleToFit(100.0F, 100.0F); pdfPCell.addElement(new Chunk(imgArticolo, 10.0F, -imgArticolo.getScaledHeight() - 50.0F)); } this.pdfPcorpo.addCell(pdfPCell); labelNumber++; } } else { String descrizioneArticolo = row.getDescrizioneRigaCompleta(); numColli++; Chunk descrizione = new Chunk(sp + sp + "\n", PdfFontFactory.PDF_fMedioB); Chunk colli = new Chunk(sp + "Collo " + sp + "/" + numColli + "\n", PdfFontFactory.PDF_fMedioB); Paragraph p = new Paragraph(); p.add(numDoc); p.add(nome); p.add(destinazione); p.add(colli); p.add(descrizione); PdfPCell pdfPCell = creaPdfEtichettePackingListPreparaIntestazioneCellaA4(fixedHeight); pdfPCell.addElement((Element)p); this.pdfPcorpo.addCell(pdfPCell); labelNumber++; } } } long numberBlankCell = (long)nCol - labelNumber % (long)nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); if (numberBlankCell != (long)nCol) for (int i = 0; (long)i < numberBlankCell; i++) this.pdfPcorpo.addCell(cell); this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } } catch (Exception e) { e.printStackTrace(); } return ba; } public int addLabelPkListA4Pdf(RigaDocumento row, int nRow, long numberOflabel, String l_descrizione) { long pHMarg = 2L; long l_indent = 4L; int totNumbOflabel = 1; try { long numTotColli = 0L; if (row.getArticolo().hasComponentiArticoli()) { Vectumerator vecAac = row.getArticolo().getArticoliComponenti(); numTotColli += (long)vecAac.getTotNumberOfRecords() * (long)row.getQuantita(); } else { numTotColli += (long)row.getQuantita(); } int altezzaCod = 50; int larghezzaCod = 120; PdfContentByte cb = this.writer.getDirectContent(); Barcode128 codeBar = new Barcode128(); codeBar.setCodeType(9); codeBar.setCode("9898"); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.addElement(new Chunk(imgBarcode, 20.0F, (float)(-altezzaCod + 10))); cell.addElement(new Chunk("\n\n\n\n " + l_descrizione, PdfFontFactory.PDF_fPiccolissimo6)); cell.setVerticalAlignment(4); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setIndent((float)l_indent); } catch (Exception e) { e.printStackTrace(); } return totNumbOflabel; } private void creaPdfEtichettePackingListPreparaIntestazioneZebra() { int cellLeading = 8; try { prepareNewPdfCorpoDocument(); float imgLogoWidth = getDocLogoWidth(); Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); imgLogo.scaleToFit(imgLogoWidth - 10.0F, imgLogoWidth - 10.0F); Cell cell = new Cell(); cell.addElement(new Chunk(imgLogo, 0.0F, 0.0F)); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(18); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Mittente:,", PdfFontFactory.PDF_fPiccolo)); Paragraph paragraph = creaParagrafoConGrassetto("\n" + getHeaderDoocumento(1) + "\n" + getHeaderDoocumento(2), PDF_fPiccolo, PDF_fPiccoloB); paragraph.setLeading(10.0F); cell.addElement((Element)paragraph); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); this.pdfcorpo.addCell(cell); } catch (Exception e) { e.printStackTrace(); } } public boolean isOrdineWwwFatturaObbligatoria() { if (getClifor().getNazione().getFlgCee() == 0L) return true; return false; } public boolean isOrdineWwwCodiceFiscaleObbligatorio() { if (getId_tipoDocumento() == getId_docOrdineWWW()) { if (getClifor().getNazione().getCodice().toLowerCase().equals(Locale.ITALY.getLanguage())) return true; return false; } return false; } public boolean isOrdineWwwPagabile() { if (getId_tipoDocumento() == getId_docOrdineWWW()) { if (getFlgProcediPagamento() == 1L && getStatoPagato() == 0L && (!isOrdineWwwCodiceFiscaleObbligatorio() || ( isOrdineWwwCodiceFiscaleObbligatorio() && !getClifor().getCodFisc().isEmpty()))) return true; return false; } return false; } public boolean isFlgWwwRichiedeFatturaModificabile() { if (getId_tipoDocumento() == getId_docOrdineWWW()) { if (isOrdineWwwFatturaObbligatoria()) return false; if (hasDocumentiFiglio() || getStatoPagato() == 1L) return false; return true; } return false; } public ByteArrayOutputStream creaDocumentoPdfMerge(DocumentoCR CR, boolean soloFile) { if (CR.getId_documentoS() > 0L) return creaDocumentoPdf(CR, soloFile); CR.setFilePdf(getPathTmpFull() + "docs_" + getPathTmpFull() + ".pdf"); Vectumerator vec = new Documento(getApFull()).findByCR(CR, 0, 0); String[] args = new String[vec.getTotNumberOfRecords() + 1]; int i = 0; List listOfPdfFiles = new ArrayList<>(); while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); String currentInputFile = row.getPathStampaDocumentoFull(); if (!new File(currentInputFile).exists()) { DocumentoCR CRrow = new DocumentoCR(getApFull()); CRrow.setId_documentoS(row.getId_documento()); System.out.println("Creo file " + currentInputFile); creaDocumentoPdf(CRrow, soloFile); } args[i] = currentInputFile; listOfPdfFiles.add(new File(currentInputFile)); i++; } args[i] = CR.getFilePdf(); if (this.document != null) { this.document.close(); this.document = null; } PDFMerger.concatenatePdfs(listOfPdfFiles, new File(CR.getFilePdf())); return getByteArrayFromFile(CR.getFilePdf()); } public boolean isCaricoConIva() { if (getTipoDocumento().getFlgImportoIva() == 1L) return true; return false; } public ResParm crontabJob(ApplParmFull ap) { ResParm rp = new ResParm(true); setApFull(ap); rp.append(annullaOrdiniWebVecchi()); System.out.println("Crontab ordini eseguita"); return rp; } public ResParm annullaOrdiniWebVecchi() { ResParm rp = new ResParm(true); int oreAnnullamento = getParm("ORDINI_WEB_ORE_ANNULLAMENTO").getNumeroInt(); if (oreAnnullamento == 0) { rp.setMsg("Annulla Ordini Web non pagati: oreAnnullamento a 0"); return rp; } int numAnnullati = 0; StringBuffer msg = new StringBuffer(); DocumentoCR CR = new DocumentoCR(getApFull()); CR.setId_tipoDocumento(getParm("ID_DOC_ORDINE_WWW").getNumeroLong()); CR.setFlgPagata(0L); Calendar cal = Calendar.getInstance(); cal.add(12, -oreAnnullamento); CR.setCreateTmst(new Timestamp(cal.getTimeInMillis())); Vectumerator vec = findByCR(CR, 0, 0); String lang = "it"; while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); Vectumerator vecUsers = row.getClifor().findUsers(1, 1); if (vecUsers.hasMoreElements()) { Users user = (Users)vecUsers.nextElement(); if (!user.getLang().isEmpty()) lang = user.getLang(); } rp = row.sendOrderDeleteMailMessage(lang, true, true); if (rp.getStatus()) { rp = row.delete(); numAnnullati++; } } msg.append("Tot Ordini Annullati: " + numAnnullati); msg.append("\n Fine Annulla Ordini Web non pagati ---\n"); rp.setMsg(msg.toString()); return rp; } public ResParm sendOrderDeleteMailMessage(String lang, boolean mailAdmin, boolean mailUser) { ResParm rp = new ResParm(true); mailAdmin = false; int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; String urlBase = getParm("CODA_MESSAGGI_IMG_URL_BASE").getTesto() + "_img/_imgArt/_var/80/"; MailProperties mp = new MailProperties(); if (getId_documento() == 0L) { rp.setStatus(false); rp.setMsg("ERRORE! Codice Documento nullo! contattare l'amministratore del sito"); handleDebug(rp.getMsg(), 0); return rp; } try { String subject = "Ordine Annullato "; NumberFormat nf = getNf(); String notePagamento = "", statoPagamento = "", notaStato = " "; String orderLine = ""; String orderLine2 = ""; DoubleOperator totaleCosto = new DoubleOperator(); double totaleQta = 0.0D; statoPagamento = translate("ORDINE ANNULLATO", lang); notePagamento = ""; if (mailUser) { MailMessage mf = new MailMessage(getApFull(), getCheckOutMailMessage(lang)); mf.setQuestionMark(false); mf.setString("id_ordine", getNumeroDocumentoCompleto()); mf.setString("stato", translate(getStatoOrdineWww(), lang)); mf.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mf.setString("statoPagamento", statoPagamento); mf.setString("notaPagamento", notePagamento); mf.setLong("id_users", getClifor().getId_clifor()); mf.setString("nominativo", getClifor().getCognome()); mf.setString("nome", getClifor().getNome()); mf.setString("cognome", getClifor().getCognome()); mf.setString("indirizzo", getClifor().getIndirizzo()); mf.setString("numero", getClifor().getNumeroCivico()); String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); mf.setString("cap", capComune); mf.setString("citta", getClifor().getDescrizioneComune()); mf.setString("provincia", getClifor().getProvinciaComune()); mf.setString("codfisc", getClifor().getCodFisc()); mf.setString("piva", getClifor().getPIva()); mf.setString("email", getClifor().getEMail()); if (getIndirizzoSped().trim().equals("")) { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mf.setString("indirizzoSped", getClifor().getIndirizzo() + " c/o " + getClifor().getIndirizzo()); } mf.setString("numeroSped", getClifor().getNumeroCivico()); mf.setString("capSped", getClifor().getCapComune()); mf.setString("cittaSped", getClifor().getDescrizioneComune()); mf.setString("provinciaSped", getClifor().getProvinciaComune()); } else { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getIndirizzoSped()); } else { mf.setString("indirizzoSped", getIndirizzoSped() + " c/o " + getIndirizzoSped()); } mf.setString("numeroSped", getNumeroCivicoSped()); mf.setString("capSped", getCapSped()); mf.setString("cittaSped", getCittaSped()); mf.setString("provinciaSped", getProvinciaSped()); } Vectumerator enu = findRigheDocumento(0, 0, ordineInverso); while (enu.hasMoreElements()) { RigaDocumento row = (RigaDocumento)enu.nextElement(); orderLine = orderLine + " " + row.getArticoloVariante().getImgFileName(1) + "" + row.getDescrizioneRigaCompleta() + "" + row.getImportoConSconto() + "€" + row.getQuantita() + "\n"; totaleQta += row.getQuantita(); } mf.setString("orderline", orderLine); if (getTotaleScontiAbbuoniConIva() > 0.0D) { mf.setString("descSconto", "**** " + translate("SCONTO INCONDIZIONATO", lang) + " *****"); mf.setString("scontoInc", " - " + nf.format(getTotaleScontiAbbuoniConIva())); } mf.setString("qta", nf.format(totaleQta)); mf.setString("totale", nf.format(getImponibileTotale())); mf.setString("totaleOrdine", nf.format(getTotaleDocumento())); mf.setString("iva", nf.format(getImportoIvaTotale())); mf.setString("speseSped", nf.format(getSpeseTrasportoConIva())); mf.setString("nota", String.valueOf(getNote())); mf.setString("notaStato", notaStato); mf.setString("codiceOrdine", getNumeroDocumentoCompleto()); mf.setString("telefono", getClifor().getCellulare()); String theSubject = translate(subject, lang); String l_email = getClifor().getEMail(); if (mailUser) theSubject = theSubject + " - " + theSubject + " " + translate("Ordine n.", lang); mp.put("TO", l_email); mp.setProperty("FROM", getParm("FROM").getTesto()); mp.put("SUBJECT", theSubject); mp.put("MSG", mf.getMessage()); mp.setProperty("ISHTML", "true"); rp = sendMailMessage(mp); } if (mailAdmin) { String mmfAdmMessage = getCheckOutMailMessage(lang); MailMessage mfAdm = new MailMessage(getApFull(), mmfAdmMessage); mfAdm.setQuestionMark(false); mfAdm.setString("id_ordine", getNumeroDocumentoCompleto()); mfAdm.setString("stato", getStato()); mfAdm.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mfAdm.setString("statoPagamento", statoPagamento); mfAdm.setString("notaPagamento", notePagamento); mfAdm.setLong("id_users", getClifor().getId_clifor()); mfAdm.setString("nominativo", getClifor().getCognome()); mfAdm.setString("nome", getClifor().getNome()); mfAdm.setString("cognome", getClifor().getCognome()); mfAdm.setString("indirizzo", getClifor().getIndirizzo()); mfAdm.setString("numero", getClifor().getNumeroCivico()); mfAdm.setString("cap", getClifor().getCapComune()); mfAdm.setString("citta", getClifor().getDescrizioneComune()); mfAdm.setString("provincia", getClifor().getProvinciaComune()); mfAdm.setString("codfisc", getClifor().getCodFisc()); mfAdm.setString("piva", getClifor().getPIva()); mfAdm.setString("email", getClifor().getEMail()); if (getIndirizzoSped().trim().equals("")) { if (getPresso().isEmpty()) { mfAdm.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mfAdm.setString("indirizzoSped", getClifor().getIndirizzo() + " c/o " + getClifor().getIndirizzo()); } mfAdm.setString("numeroSped", getClifor().getNumeroCivico()); mfAdm.setString("capSped", getClifor().getCapComune()); mfAdm.setString("cittaSped", getClifor().getDescrizioneComune()); mfAdm.setString("provinciaSped", getClifor().getProvinciaComune()); } else { if (getPresso().isEmpty()) { mfAdm.setString("indirizzoSped", getIndirizzoSped()); } else { mfAdm.setString("indirizzoSped", getIndirizzoSped() + " c/o " + getIndirizzoSped()); } mfAdm.setString("numeroSped", getNumeroCivicoSped()); mfAdm.setString("capSped", getCapSped()); mfAdm.setString("cittaSped", getCittaSped()); mfAdm.setString("provinciaSped", getProvinciaSped()); } orderLine2 = ""; totaleCosto = new DoubleOperator(); totaleQta = 0.0D; String stileRicarico = ""; Vectumerator enu = findRigheDocumento(0, 0, ordineInverso); while (enu.hasMoreElements()) { RigaDocumento row = (RigaDocumento)enu.nextElement(); orderLine2 = orderLine2 + " " + row.getArticoloVariante().getImgFileName(1) + "" + row.getDescrizioneRigaCompleta() + "" + row.getImportoConSconto() + "€" + row.getQuantita() + "\n"; DoubleOperator totaleArticolo = new DoubleOperator(row.getImponibile()); totaleArticolo.multiply(row.getQuantita()); totaleCosto.add(totaleArticolo); totaleQta += row.getQuantita(); } mfAdm.setString("orderline", orderLine2); mfAdm.setString("qta", nf.format(totaleQta)); mfAdm.setString("iva", nf.format(getImportoIvaTotale())); mfAdm.setString("speseSped", nf.format(getSpeseTrasporto())); mfAdm.setString("totale", nf.format(getImponibileTotale())); mfAdm.setString("totaleOrdine", nf.format(getTotaleDocumento())); mfAdm.setString("nota", String.valueOf(getNote())); mfAdm.setString("notaAmm", "Nota su cliente:" + String.valueOf(getClifor().getNota() + "\nNota su Ordine: " + getClifor().getNota()) + "\nNota Mail: " + getNotaMail()); mfAdm.setString("codiceOrdine", getNumeroDocumentoCompleto()); mfAdm.setString("telefono", getClifor().getCellulare()); mfAdm.setString("orderline", orderLine2); mfAdm.setString("notaStato", notaStato); String sbjAdmin = subject + " - Adm Ordine n. " + subject + " - " + String.valueOf(getId_ordine()) + " - "; sbjAdmin = sbjAdmin + sbjAdmin; String to = getMailTo(); rp.append(mfAdm.sendMailMessageSystem(to, sbjAdmin, true)); } } catch (Exception e) { handleDebug(e); rp.setStatus(false); rp.setMsg(e); System.out.println("ERRORE INVIO EMAIL:"); e.printStackTrace(); } if (!rp.getStatus()) { handleDebug(rp.getMsg(), 2); System.out.println("ERRORE INVIO EMAIL:" + rp.getMsg()); } return rp; } protected int inserisciNoteDocumento(String temp, int riga, int righePerPagina, Document l_document, Table l_pdfCorpo, int cellLeading, int maxCharLength, int numColonneDesc, int[] numColonneBefore, int[] numColonneAfter, Font theFont, boolean hasMoreRow) { String indent = ""; if (getTipoDocumento().getIndentNuovaRiga() > 0L) indent = " ".substring(0, (int)getTipoDocumento().getIndentNuovaRiga()); int rows = 0; temp = temp.trim(); temp = temp.replace("€", "€"); int bordi = 0; Color colore = Color.black; long bordoColonne = getTipoDocumento().getFlgBordoColonna(); long bordoRighe = getTipoDocumento().getFlgBordoRiga(); String coloreBordo = getTipoDocumento().getColoreBordoInterno(); try { ArrayList res = convertStringToMultiline(temp, maxCharLength); for (int j = 0; j < res.size(); j++) { Cell cell; boolean moreDesc; String desc = res.get(j); if (rows > 0) desc = indent + indent; if (j + 1 < res.size()) { moreDesc = true; } else { moreDesc = false; } for (int k = 0; k < numColonneBefore.length; k++) { cell = new Cell(); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setMaxLines(1); cell.setColspan(numColonneBefore[k]); l_pdfCorpo.addCell(cell); } if (desc.isEmpty()) { cell = new Cell(new Chunk(".", theFont)); } else { cell = new Cell(new Chunk(desc, theFont)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setColspan(numColonneDesc); l_pdfCorpo.addCell(cell); for (int i = 0; i < numColonneAfter.length; i++) { cell = new Cell(); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setMaxLines(1); cell.setColspan(numColonneAfter[i]); l_pdfCorpo.addCell(cell); } riga = incrementaNumRighe(riga, righePerPagina, l_document, l_pdfCorpo, hasMoreRow); desc = ""; rows++; } } catch (Exception e) { handleDebug(e); } return riga; } protected int inserisciDescRigaDocumentoNewOLD(String temp, int riga, int righePerPagina, Document l_document, Table pdfcorpo, int cellLeading, int maxCharLength, int numColonneDesc, int[] numColonneBefore, int[] numColonneAfter, Font theFont, boolean hasMoreRow) { String indent = ""; boolean debug = false; if (getTipoDocumento().getIndentNuovaRiga() > 0L) indent = " ".substring(0, (int)getTipoDocumento().getIndentNuovaRiga()); int rows = 0; temp = temp.trim(); temp = temp.replace("€", "€"); int bordi = 0; Color colore = Color.black; long bordoColonne = getTipoDocumento().getFlgBordoColonna(); long bordoRighe = getTipoDocumento().getFlgBordoRiga(); String coloreBordo = getTipoDocumento().getColoreBordoInterno(); try { StringTokenizer st = new StringTokenizer(temp.replaceAll("\n", "\n "), " "); StringBuffer currentLine = new StringBuffer(); String desc = ""; while (st.hasMoreTokens()) { if (currentLine.toString().endsWith("\n")) { desc = currentLine.toString().replaceAll("\n", ""); currentLine = new StringBuffer(); } else { String token = st.nextToken(); if (currentLine.length() + token.length() > maxCharLength) { desc = currentLine.toString(); currentLine = new StringBuffer(token); } else { if (currentLine.length() > 0) currentLine.append(" "); currentLine.append(token); if (token.endsWith("\n") || !st.hasMoreTokens()) { desc = currentLine.toString().replaceAll("\n", ""); currentLine = new StringBuffer(); } } } if (desc.length() > 0) { Cell cell; boolean moreDesc; if (rows > 0) desc = indent + indent; if (currentLine.length() > 0 || st.hasMoreTokens()) { moreDesc = true; } else { moreDesc = false; } if (rows > 0) for (int i = 0; i < numColonneBefore.length; i++) { cell = new Cell(); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setMaxLines(1); cell.setColspan(numColonneBefore[i]); pdfcorpo.addCell(cell); } if (debug) desc = "" + riga + "/" + riga + " " + righePerPagina; if (desc.isEmpty()) { cell = new Cell(new Chunk(".", theFont)); } else { cell = new Cell(new Chunk(desc, theFont)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setColspan(numColonneDesc); pdfcorpo.addCell(cell); if (moreDesc) { for (int i = 0; i < numColonneAfter.length; i++) { cell = new Cell(); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setMaxLines(1); cell.setColspan(numColonneAfter[i]); pdfcorpo.addCell(cell); } riga = incrementaNumRighe(riga, righePerPagina, l_document, pdfcorpo, hasMoreRow); } desc = ""; rows++; } } if (currentLine.length() > 0) { String descrizione = currentLine.toString(); if (rows > 0) { descrizione = indent + indent; for (int i = 0; i < numColonneBefore.length; i++) { Cell cell1 = new Cell(); cell1.setVerticalAlignment(4); cell1.setLeading((float)cellLeading); settaBordiEColori(cell1, bordoColonne, bordoRighe, false, coloreBordo); cell1.setMaxLines(1); cell1.setColspan(numColonneBefore[i]); pdfcorpo.addCell(cell1); } } if (debug) descrizione = "" + riga + "/" + riga + " " + righePerPagina; Cell cell = new Cell(new Chunk(descrizione, theFont)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, false, coloreBordo); cell.setColspan(numColonneDesc); pdfcorpo.addCell(cell); } } catch (Exception e) { handleDebug(e); } return riga; } protected int inserisciDescRigaDocumentoNew(String temp, int riga, int righePerPagina, Document l_document, Table pdfcorpo, int cellLeading, int maxCharLength, int numColonneDesc, int[] numColonneBefore, int[] numColonneAfter, Font theFont, boolean hasMoreRow) { String indent = ""; boolean debug = false; if (getTipoDocumento().getIndentNuovaRiga() > 0L) indent = " ".substring(0, (int)getTipoDocumento().getIndentNuovaRiga()); int rows = 0; temp = temp.trim(); temp = temp.replace("€", "€"); int bordi = 0; Color colore = Color.black; long bordoColonne = getTipoDocumento().getFlgBordoColonna(); long bordoRighe = getTipoDocumento().getFlgBordoRiga(); String coloreBordo = getTipoDocumento().getColoreBordoInterno(); try { ArrayList res = convertStringToMultiline(temp, maxCharLength); for (int j = 0; j < res.size(); j++) { Cell cell; boolean moreDesc; String desc = res.get(j); if (rows > 0) desc = indent + indent; if (j + 1 < res.size()) { moreDesc = true; } else { moreDesc = false; } if (rows > 0) for (int i = 0; i < numColonneBefore.length; i++) { cell = new Cell(); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setMaxLines(1); cell.setColspan(numColonneBefore[i]); pdfcorpo.addCell(cell); } if (debug) desc = "" + riga + "/" + riga + " " + righePerPagina; if (desc.isEmpty()) { cell = new Cell(new Chunk(".", theFont)); } else { cell = new Cell(new Chunk(desc, theFont)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setColspan(numColonneDesc); pdfcorpo.addCell(cell); if (moreDesc) { for (int i = 0; i < numColonneAfter.length; i++) { cell = new Cell(); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setMaxLines(1); cell.setColspan(numColonneAfter[i]); pdfcorpo.addCell(cell); } riga = incrementaNumRighe(riga, righePerPagina, l_document, pdfcorpo, hasMoreRow); } rows++; } } catch (Exception e) { handleDebug(e); } return riga; } protected int inserisciNotaDocumento(ArrayList dati, int idColDesc, int riga, Document l_document, Table pdfcorpo, int cellLeading, boolean hasMoreRow) { String indent = ""; boolean debug = false; if (getTipoDocumento().getIndentNuovaRiga() > 0L) indent = " ".substring(0, (int)getTipoDocumento().getIndentNuovaRiga()); int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); int maxCharLength = (int)getTipoDocumento().getMaxCarDesc(); if (maxCharLength == 0) maxCharLength = 35; String temp = dati.get(idColDesc).getDesc(); temp = temp.replace("€", "€"); int bordi = 0; Color colore = Color.black; long bordoColonne = getTipoDocumento().getFlgBordoColonna(); long bordoRighe = getTipoDocumento().getFlgBordoRiga(); String coloreBordo = getTipoDocumento().getColoreBordoInterno(); boolean allineamentoInAlto = (getTipoDocumento().getFlgAllineamentoRiga() == 0L); try { ArrayList righeDescrizione = convertStringToMultiline(temp, maxCharLength); int allineamentoInAltoVal = 0; int allineamentoIBassoVal = righeDescrizione.size() - 1; for (int row = 0; row < righeDescrizione.size(); row++) { boolean moreDesc; String desc = righeDescrizione.get(row); if (row > 0) desc = indent + indent; if (row + 1 < righeDescrizione.size()) { moreDesc = true; } else { moreDesc = false; } for (int col = 0; col < dati.size(); col++) { Cell cell; if (allineamentoInAlto) { if (row == allineamentoInAltoVal || col == idColDesc) { if (col == idColDesc) { cell = new Cell(new Chunk(desc, dati.get(col).getPdfFont())); } else { cell = new Cell(new Chunk(dati.get(col).getDesc(), dati.get(col).getPdfFont())); } } else { cell = new Cell(new Chunk("", dati.get(col).getPdfFont())); } } else if (row == allineamentoIBassoVal || col == idColDesc) { if (col == idColDesc) { cell = new Cell(new Chunk(desc, dati.get(col).getPdfFont())); } else { cell = new Cell(new Chunk(dati.get(col).getDesc(), dati.get(col).getPdfFont())); } } else { cell = new Cell(new Chunk("", dati.get(col).getPdfFont())); } cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setMaxLines(1); cell.setColspan(dati.get(col).getColSpan()); pdfcorpo.addCell(cell); } riga = incrementaNumRighe(riga, righePerPagina, l_document, pdfcorpo, hasMoreRow); } } catch (Exception e) { handleDebug(e); } return riga; } protected int inserisciRigheVuote(int nRighe, int[] colsDocumento_, int riga, Document l_document, Table l_pdfCorpo, int cellLeadingRow) { Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowBianco = new Font(1, PDF_frow.getSize(), 1, Color.white); ArrayList alNote = RigaDocumentoItemPdf.getArrayListNota(".", 0, colsDocumento_, PDF_frowBianco); for (int i = 0; i < nRighe; i++) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, false); return riga; } protected int inserisciRigheVuoteOLD(int nRighe, int[] colSpan, int riga, Document l_document, Table pdfcorpo, int cellLeading) { String indent = ""; boolean debug = false; if (getTipoDocumento().getIndentNuovaRiga() > 0L) indent = " ".substring(0, (int)getTipoDocumento().getIndentNuovaRiga()); int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); int maxCharLength = (int)getTipoDocumento().getMaxCarDesc(); if (maxCharLength == 0) maxCharLength = 35; long bordoColonne = getTipoDocumento().getFlgBordoColonna(); long bordoRighe = getTipoDocumento().getFlgBordoRiga(); String coloreBordo = getTipoDocumento().getColoreBordoInterno(); boolean allineamentoInAlto = (getTipoDocumento().getFlgAllineamentoRiga() == 0L); Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowBianco = new Font(1, PDF_frow.getSize(), 1, Color.white); try { for (int row = 0; row < nRighe; row++) { boolean moreDesc; if (row + 1 < nRighe) { moreDesc = true; } else { moreDesc = false; } for (int col = 0; col < colSpan.length; col++) { Cell cell; if (col == 0) { cell = new Cell(new Chunk(".", PDF_frowBianco)); } else { cell = new Cell(new Chunk("", PDF_frowBianco)); } cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); settaBordiEColori(cell, bordoColonne, bordoRighe, moreDesc, coloreBordo); cell.setMaxLines(1); cell.setColspan(colSpan[col]); pdfcorpo.addCell(cell); } riga = incrementaNumRighe(riga, righePerPagina, l_document, pdfcorpo, moreDesc); } } catch (Exception e) { handleDebug(e); } return riga; } public Vectumerator findByCROld(DocumentoCR CR, int pageNumber, int pageRows) { String s_Sql_Order; boolean flgOttimizzo = (getParm("OTTIMIZZO").getNumero() == 1.0D); if (CR.getId_contatore() != 0L || CR.getFlgTipologia() >= 0L || CR.getFlgSlip() > 0L || CR.getId_tipo() != 0L) flgOttimizzo = false; StringBuffer s_Sql_Find = new StringBuffer("select A.* from DOCUMENTO AS A "); if (CR.getTipoDocumento().getFlgClienteFornitore().equals("F") && ( CR.getTipoDocumento().getFlgTipologia() == 1L || CR.getTipoDocumento().getFlgTipologia() == 2L)) { if (CR.getFlgOrderBy() == 1L) { s_Sql_Order = " order by A.dataRiferimento asc, A.id_esercizio asc, A.progDocumento asc"; } else { s_Sql_Order = " order by A.dataRiferimento desc, A.id_esercizio desc, A.progDocumento desc"; } } else if (CR.getFlgOrderBy() == 1L) { s_Sql_Order = " order by A.dataDocumento asc, A.id_esercizio asc, A.progDocumento asc"; } else { s_Sql_Order = " order by A.dataDocumento desc, A.id_esercizio desc, A.progDocumento desc"; } WcString wc = new WcString(); findByCRCreateWC(CR, s_Sql_Find, wc); try { PreparedStatement stmt; if ((pageNumber == 0 && pageRows == 0) || !flgOttimizzo) { stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); } else { if (pageNumber == 0) pageNumber = 1; int start = (pageNumber - 1) * pageRows; int stop = start + pageRows; stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString() + " limit " + s_Sql_Order + "," + start); } findByCRCreateStmtDate(CR, stmt); if ((pageNumber == 0 && pageRows == 0) || !flgOttimizzo) return findRows(stmt, pageNumber, pageRows); Vectumerator vec = findRows(stmt, 1, pageRows); vec.setPageNumber(pageNumber); vec.setTotNumberOfRecords(findByCRTotRecord(CR)); return vec; } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public double getPesoKg() { return (getId_documento() == 0L) ? 0.0D : (double)new RigaDocumento(getApFull()).getPesoKgByDocumento(getId_documento()); } public Vectumerator findByAgenti(DocumentoCR CR) { String s_Sql_Find = "SELECT A.id_agente, A.percAgente, A.id_respCommerciale, A.percRespCommerciale, SUM(A.imponibileTotale) AS imponibileTotale FROM DOCUMENTO AS A INNER JOIN TIPO_DOCUMENTO AS B ON A.id_tipoDocumento = B.id_tipoDocumento "; String s_Sql_Group = " GROUP BY A.id_agente, A.percAgente, A.id_respCommerciale, A.percRespCommerciale "; String s_Sql_Order = " ORDER BY A.id_agente, A.id_respCommerciale "; WcString wc = new WcString(); wc.addWc(" B.flgTipologia = 1"); if (CR.getDataDocumentoDa() != null) wc.addWc(" A.dataDocumento >= ? "); if (CR.getDataDocumentoA() != null) wc.addWc(" A.dataDocumento <= ? "); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString() + s_Sql_Group); int i = 1; if (CR.getDataDocumentoDa() != null) { stmt.setDate(i, CR.getDataDocumentoDa()); i++; } if (CR.getDataDocumentoA() != null) stmt.setDate(i, CR.getDataDocumentoA()); return findRows(stmt, 0, 0); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public static final synchronized ResParm addRigaDocumentoTessuto(Documento doc, RigaDocumento row, long l_flgCodiceRiga) { long l_id_magFisicoPartenza, l_id_magFisicoArrivo; MagFisico magFisicoPartenza, magFisicoArrivo; if (row.getId_articoloTessutoColore() > 0L) row.setId_articoloTessuto(row.getArticoloTessutoColore().getId_articoloTessuto()); ResParm rp = doc.checkEMSTA(); if (!rp.getStatus()) return new ResParm(false, "ATTENZIONE! Tentativo di aggiungere una riga documento: " + rp.getMsg()); RigaDocumento RD = new RigaDocumento(doc.getApFull()); double l_quantitaDisponibileMagPartenza = 0.0D; double l_quantitaDisponibileTuttiMagazziniInterniEsterni = 0.0D; double l_quantitaDisponibileMagazziniInterni = 0.0D; if (l_flgCodiceRiga == 0L) { l_id_magFisicoPartenza = row.getDocumento().getId_magFisicoPartenza(); l_id_magFisicoArrivo = row.getDocumento().getId_magFisicoArrivo(); magFisicoPartenza = row.getDocumento().getMagFisicoPartenza(); magFisicoArrivo = row.getDocumento().getMagFisicoArrivo(); } else { l_id_magFisicoPartenza = row.getDocumento().getId_magFisicoPartenza2(); l_id_magFisicoArrivo = row.getDocumento().getId_magFisicoArrivo2(); magFisicoPartenza = row.getDocumento().getMagFisicoPartenza2(); magFisicoArrivo = row.getDocumento().getMagFisicoArrivo2(); } rp = new ResParm(true); RigaDocumento rowOnDb = new RigaDocumento(doc.getApFull()); rowOnDb.findByPrimaryKey(row.getId_rigaDocumento()); if (!row.getSeriale().trim().isEmpty() && row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() == 2L) row.setQuantita(1.0D); if (rowOnDb.getDBState() == 1 && ( rowOnDb.getId_articoloTessuto() != row.getId_articoloTessuto() || !rowOnDb.getSeriale().equals(row.getSeriale()))) { rp = rowOnDb.delete(); if (!rp.getStatus()) return rp; row.setId_rigaDocumento(0L); row.setDBState(0); } if (row.getId_articoloTessuto() != 0L && l_id_magFisicoPartenza > 0L) { RD.findMagTessutoDisponibilita(row.getId_articoloTessuto(), row.getId_articoloTessutoColore(), row.getSeriale(), l_id_magFisicoPartenza, 0L, -1L, 0L, "", DATA_NULL); l_quantitaDisponibileMagPartenza = RD.getQuantita(); if (rowOnDb.getDBState() == 1) l_quantitaDisponibileMagPartenza += rowOnDb.getQuantita(); if (row.getArticoloTessuto().getTipo().getFlgMagNegativo() == 0L && row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() > 0L && row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articoloTessuto() != 0L && l_id_magFisicoPartenza != 0L && row.getFlgReso() == 0L && l_quantitaDisponibileMagPartenza < row.getQuantita()) { rp.setStatus(false); rp.setMsg("Attenzione. Tentativo di utilizzare un articolo non disponibile"); return rp; } } if (row.getId_articoloTessuto() != 0L && l_id_magFisicoPartenza > 0L && magFisicoPartenza.getFlgTipo() == 1L && row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() > 0L && row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articoloTessuto() != 0L && rowOnDb.getDBState() == 0 && row.getFlgReso() == 0L && row.getFlgIgnoraPrenotazione() == 0L) { double totArticoliEffettivi = 0.0D; if (row.getSeriale().isEmpty()) { RD.findMagTessutoDisponibilitaPuntualeMagazziniInterni(row.getId_articoloTessuto(), row.getId_articoloTessutoColore(), null, -1L); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); double totArticoliImpegnati = row.getTotTessutiImpegnati(row.getId_articoloTessuto(), ""); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - totArticoliImpegnati; } else { if (row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() != 2L) if (row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() == 3L) { RD.findMagTessutoDisponibilitaPuntualeMagazziniInterni(row.getId_articoloTessuto(), row.getId_articoloTessutoColore(), row.getSeriale(), -1L); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); double totArticoliImpegnati = row.getTotTessutiImpegnati(row.getId_articoloTessuto(), row.getSeriale()); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - totArticoliImpegnati; } else { RD.findMagTessutoDisponibilitaPuntualeMagazziniInterni(row.getId_articoloTessuto(), row.getId_articoloTessutoColore(), row.getSeriale(), -1L); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); double totArticoliImpegnati = row.getTotTessutiImpegnati(row.getId_articoloTessuto(), ""); totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - totArticoliImpegnati; } if (totArticoliEffettivi <= 0.0D) { rp.setStatus(false); rp.setMsg("Attenzione. L'articolo è in magazzino ma non disponibile perchè risulta impegnato. "); return rp; } } } if (l_id_magFisicoArrivo > 0L && ( magFisicoArrivo.getFlgTipo() == 1L || magFisicoArrivo.getFlgTipo() == 2L) && !row.getSeriale().trim().isEmpty() && row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() == 2L && rowOnDb.getDBState() == 0) { if (row.getParm("SERIALI_UNIVOCI").isTrue() && row.getArticoloTessuto().getTipo().getFlgTipoMagazzino() == 2L) { RD.findMagDisponibilitaGlobaleMagazziniInterniEsterni(row.getId_articoloTessuto(), row.getSeriale(), 0L); RD.findMagTessutoDisponibilitaGlobaleMagazziniInterniEsterni(row.getId_articoloTessuto(), row.getId_articoloTessutoColore(), row.getSeriale(), 0L); } else { RD.findMagTessutoDisponibilitaPuntualeMagazziniInterniEsterni(row.getId_articoloTessuto(), row.getId_articoloTessutoColore(), row.getSeriale(), -1L, 0L); } l_quantitaDisponibileTuttiMagazziniInterniEsterni = RD.getQuantita(); if (l_quantitaDisponibileTuttiMagazziniInterniEsterni >= 1.0D) { rp.setStatus(false); rp.setMsg("Attenzione. Stai inserendo un seriale già caricato in magazzino."); return rp; } } row.setId_documento(doc.getId_documento()); if (l_flgCodiceRiga == 1L) row.setFlgCodiceRiga(1L); rp.append(row.saveTessuto()); if (rp.getStatus() && doc.getTipoDocumento().getFlgTipologia() == 202L && row.getFlgCodiceRiga() == 1L) rp.append(doc.aggiornaSerialeTessutoLavorazione()); if (rp.getStatus()) rp.setMsg(AbMessages.getMessage("SAVE_OK")); return rp; } public static final ArrayList convertStringToMultiline(String temp, int maxCharLength) { if (temp.trim().isEmpty()) { ArrayList arrayList = new ArrayList<>(); arrayList.add(""); return arrayList; } String SPACE = " "; String NL = "\n"; temp = temp.trim(); ArrayList res = new ArrayList<>(); StringTokenizer st = new StringTokenizer(temp.replaceAll("\n", "\n "), " "); StringBuffer currentLine = new StringBuffer(); String desc = ""; while (st.hasMoreTokens()) { if (currentLine.toString().endsWith("\n")) { desc = currentLine.toString().replaceAll("\n", ""); currentLine = new StringBuffer(); } else { String token = st.nextToken(); if (currentLine.length() + token.length() > maxCharLength) { desc = currentLine.toString(); currentLine = new StringBuffer(token); } else { if (currentLine.length() > 0) currentLine.append(" "); currentLine.append(token); if (token.endsWith("\n") || !st.hasMoreTokens()) { desc = currentLine.toString().replaceAll("\n", ""); currentLine = new StringBuffer(); } } } if (desc.length() > 0) { res.add(desc); desc = ""; } } if (currentLine.length() > 0) res.add(currentLine.toString()); return res; } public static final synchronized ResParm addRigaDocumentoOld(DocumentoInterface doc, RigaDocumento row) { Movimento mov = new Movimento(doc.getApFull()); RigaDocumento RD = new RigaDocumento(doc.getApFull()); double l_quantitaDisponibileMagPartenza = 0.0D; double l_quantitaDisponibileTuttiMagazziniInterniEsterni = 0.0D; double l_quantitaDisponibileMagazziniInterni = 0.0D; long l_id_magFisicoPartenza = row.getDocumento().getId_magFisicoPartenza(); long l_id_magFisicoArrivo = row.getDocumento().getId_magFisicoArrivo(); ResParm rp = new ResParm(true); RigaDocumento rowOnDb = new RigaDocumento(doc.getApFull()); rowOnDb.findByPrimaryKey(row.getId_rigaDocumento()); if (!row.getSeriale().trim().isEmpty() && row.getArticolo().getFlgSerialiMassivi() == 0L) { row.setQuantita(1.0D); row.setQuantitaUdm(1.0D); } if (rowOnDb.getDBState() == 1 && (rowOnDb.getId_articolo() != row.getId_articolo() || rowOnDb.getId_articoloVariante() != row.getId_articoloVariante() || !rowOnDb.getSeriale().equals(row.getSeriale()))) { rp = rowOnDb.delete(); if (!rp.getStatus()) return rp; row.setId_rigaDocumento(0L); row.setDBState(0); } if (row.getId_articolo() != 0L && l_id_magFisicoPartenza > 0L) { mov.findDisponibilitaPuntuale(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), row.getSeriale(), l_id_magFisicoPartenza, 0L); RD.findMagDisponibilitaPuntuale(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), row.getSeriale(), l_id_magFisicoPartenza, 0L, 0L); l_quantitaDisponibileMagPartenza = RD.getQuantita(); if (l_quantitaDisponibileMagPartenza != mov.getQuantita()) { l_quantitaDisponibileMagPartenza = mov.getQuantita(); System.out.println("Documento.addrigadocumento: ERRORE findMagDisponibilitaPuntuale : l_quantitaDisponibileMagPartenza " + RD.getQuantita() + " " + mov.getQuantita()); } if (rowOnDb.getDBState() == 1) l_quantitaDisponibileMagPartenza += rowOnDb.getQuantita(); if (row.getArticolo().getTipo().getFlgTipoMagazzino() > 0L && row.getArticolo().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articolo() != 0L && l_id_magFisicoPartenza != 0L && row.getFlgReso() == 0L && l_quantitaDisponibileMagPartenza < row.getQuantita()) { rp.setStatus(false); rp.setMsg("Attenzione. Tentativo di utilizzare un articolo non disponibile"); return rp; } } if (row.getId_articolo() != 0L && l_id_magFisicoPartenza > 0L && row.getDocumento().getMagFisicoPartenza().getFlgTipo() == 1L && row.getArticolo().getTipo().getFlgTipoMagazzino() > 0L && row.getArticolo().getTipo().getFlgTipoMagazzino() < 9L && row.getId_articolo() != 0L && rowOnDb.getDBState() == 0 && row.getFlgReso() == 0L && row.getFlgIgnoraPrenotazione() == 0L) { double totArticoliEffettivi = 0.0D; if (row.getSeriale().isEmpty()) { mov.findDisponibilitaPuntualeMagazziniInterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), null, 0L); RD.findMagDisponibilitaPuntualeMagazziniInterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), null, 0L); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); if (l_quantitaDisponibileMagazziniInterni != mov.getQuantita()) { l_quantitaDisponibileMagazziniInterni = mov.getQuantita(); System.out.println("Documento.addrigadocumento: ERRORE findMagDisponibilitaPuntuale l_quantitaDisponibileMagazziniInterni:" + RD.getQuantita() + " " + mov.getQuantita()); } totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - row.getTotArticoliImpegnati(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia()); } else { RigaDocumento rd = new RigaDocumento(row.getApFull()); rd.findRigaImpegnoBySeriale(row.getId_articolo(), row.getId_articoloVariante(), row.getSeriale()); if (rd.getDBState() == 1) { if (row.getFlgIgnoraPrenotazione() == 1L) { rd.setSeriale(""); rd.save(); totArticoliEffettivi = 1.0D; } else { totArticoliEffettivi = 0.0D; } } else { mov.findDisponibilitaPuntualeMagazziniInterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), null, 0L); RD.findMagDisponibilitaPuntualeMagazziniInterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), null, 0L); l_quantitaDisponibileMagazziniInterni = mov.getQuantita(); l_quantitaDisponibileMagazziniInterni = RD.getQuantita(); if (l_quantitaDisponibileMagazziniInterni != mov.getQuantita()) { l_quantitaDisponibileMagazziniInterni = mov.getQuantita(); System.out.println("Documento.addrigadocumento: ERRORE findMagDisponibilitaPuntuale l_quantitaDisponibileMagazziniInterni non ser:" + RD.getQuantita() + " " + mov.getQuantita()); } totArticoliEffettivi = l_quantitaDisponibileMagazziniInterni - row.getTotArticoliImpegnati(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia()); } if (totArticoliEffettivi <= 0.0D) { rp.setStatus(false); rp.setMsg("Attenzione. L'articolo è in magazzino ma non disponibile perchè risulta impegnato. "); return rp; } } } if (l_id_magFisicoArrivo > 0L && ( row.getDocumento().getMagFisicoArrivo().getFlgTipo() == 1L || row.getDocumento().getMagFisicoArrivo().getFlgTipo() == 2L) && !row.getSeriale().trim().isEmpty() && row.getArticolo().getTipo().getFlgTipoMagazzino() == 2L && rowOnDb.getDBState() == 0) { if (mov.getParm("SERIALI_UNIVOCI").isTrue()) { mov.findDisponibilitaGlobaleMagazziniInterniEsterni(row.getId_articolo(), row.getSeriale(), 0L); RD.findMagDisponibilitaGlobaleMagazziniInterniEsterni(row.getId_articolo(), row.getSeriale(), 0L); } else { mov.findDisponibilitaPuntualeMagazziniInterniEsterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), row.getSeriale(), 0L); RD.findMagDisponibilitaPuntualeMagazziniInterniEsterni(row.getId_articolo(), row.getId_articoloVariante(), row.getId_articoloTaglia(), row.getSeriale(), 0L); } l_quantitaDisponibileTuttiMagazziniInterniEsterni = RD.getQuantita(); if (l_quantitaDisponibileTuttiMagazziniInterniEsterni != mov.getQuantita()) { l_quantitaDisponibileTuttiMagazziniInterniEsterni = mov.getQuantita(); System.out.println("Documento.addrigadocumento: ERRORE findMagDisponibilitaPuntualeMagazziniInterniEsterni l_quantitaDisponibileTuttiMagazziniInterniEsterni:" + RD.getQuantita() + " " + mov.getQuantita()); } if (l_quantitaDisponibileTuttiMagazziniInterniEsterni >= 1.0D) { rp.setStatus(false); rp.setMsg("Attenzione. Stai inserendo un seriale già caricato in magazzino."); return rp; } } long l_numSeriali = 1L; if (doc.getTipoDocumento().getFlgTipologia() != 3L && row.getArticolo().getFlgSerialiMassivi() == 1L && row.getQuantita() > 1.0D) { l_numSeriali = (long)row.getQuantita(); row.setQuantita(1.0D); row.setQuantitaUdm(1.0D); } for (int i = 0; (long)i < l_numSeriali; i++) { RigaDocumento bean = new RigaDocumento(doc.getApFull()); if (row.getId_rigaDocumento() != 0L) { bean.findByPrimaryKey(row.getId_rigaDocumento()); } else if (row.getId_articolo() != 0L && row.getFlgSingleLineArt() == 1L && ( doc.getTipoDocumento().getFlgTipologia() == 3L || doc.getTipoDocumento().getFlgTipologia() == 4L || row.getArticolo().getTipo().getFlgTipoMagazzino() != 2L)) { if (row.getId_articoloTaglia() != 0L) { bean.findFirstByDocumentoArticoloTaglia(row.getId_documento(), row.getId_articoloTaglia()); } else if (row.getId_articoloVariante() != 0L) { bean.findFirstByDocumentoArticoloVariante(row.getId_documento(), row.getId_articoloVariante()); } else if (row.getId_articolo() != 0L) { bean.findFirstByDocumentoArticolo(row.getId_documento(), row.getId_articolo()); } row.setId_rigaDocumento(bean.getId_rigaDocumento()); row.addQuantita(bean.getQuantita()); } row.setDBState(bean.getDBState()); row.setQuantitaOld(bean.getQuantitaOld()); row.setId_documento(doc.getId_documento()); rp.append(row.save()); if (!rp.getStatus()) return rp; if (l_numSeriali > 1L) try { long currentSeriale = Long.valueOf(row.getSeriale()); currentSeriale++; String newSeriale = zeroLeft(currentSeriale, row.getSeriale().length()); row.setSeriale(newSeriale); row.setId_rigaDocumento(0L); row.setDBState(0); } catch (Exception e) { rp.setStatus(false); rp.setMsg("Errore! seriale non numerico per carico massivo: " + row.getSeriale()); return rp; } } if (rp.getStatus()) rp.setMsg(AbMessages.getMessage("SAVE_OK")); return rp; } public long getId_cliforPrecedente() { return this.id_cliforPrecedente; } public void setId_cliforPrecedente(long id_cliforDb) { this.id_cliforPrecedente = id_cliforDb; } public boolean isDataOk() { if (getTipoDocumento().getContatore().getFlgControllo() == 0L) return true; if (getDBState() == 1 && getFlgStato() == 1L) { Documento beanPrec = new Documento(getApFull()); beanPrec.findPrecedente(getProgDocumento(), getId_esercizio(), getId_contatore()); boolean l_flgOk = true; if (beanPrec != null && beanPrec.getDBState() == 1) if (getDateDiff(beanPrec.getDataDocumento(), getDataDocumento()) >= 0L) { l_flgOk = true; } else { l_flgOk = false; } if (l_flgOk) { Documento beanSucc = new Documento(getApFull()); beanSucc.findSuccessiva(getProgDocumento(), getId_esercizio(), getId_contatore()); if (beanSucc != null && beanSucc.getDBState() == 1) if (getDateDiff(beanSucc.getDataDocumento(), getDataDocumento()) <= 0L) { l_flgOk = true; } else { l_flgOk = false; } } return l_flgOk; } return true; } public String getIbanCF() { return (this.ibanCF == null) ? "" : this.ibanCF.trim(); } public void setIbanCF(String ibanCF) { this.ibanCF = ibanCF; } public String getBancaCFDesc() { return (this.bancaCFDesc == null) ? "" : this.bancaCFDesc.trim(); } public void setBancaCFDesc(String bancaCFDesc) { this.bancaCFDesc = bancaCFDesc; } public double getPercScontoIncondizionato() { return this.percScontoIncondizionato; } public void setPercScontoIncondizionato(double percScontoIncondizionato) { this.percScontoIncondizionato = percScontoIncondizionato; } public String getAbi() { if (getIban().length() < 11) return "??"; return getIban().substring(5, 10); } public String getCabCF() { if (getIbanCF().length() < 16) return "??"; return getIbanCF().substring(10, 15); } public String getContoCF() { if (getIbanCF().length() < 27) return "??"; return getIbanCF().substring(15); } public String getId_nazioneSped() { return (this.id_nazioneSped == null) ? "" : this.id_nazioneSped.trim(); } public void setId_nazioneSped(String id_nazioneSped) { this.id_nazioneSped = id_nazioneSped; setNazioneSped(null); } public Nazione getNazioneSped() { this.nazioneSped = (Nazione)getSecondaryObject(this.nazioneSped, Nazione.class, getId_nazioneSped()); return this.nazioneSped; } public void setNazioneSped(Nazione nazioneSped) { this.nazioneSped = nazioneSped; } public String getElencoScadenze2Righe() { StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); if (getId_documento() > 0L) { DocumentoScadenza scadenza = new DocumentoScadenza(getApFull()); Vectumerator vec = scadenza.findByDocumento(getId_documento()); if (vec.hasMoreElements()) while (vec.hasMoreElements()) { scadenza = (DocumentoScadenza)vec.nextElement(); sb1.append(" " + getDataFormat().format(scadenza.getDataScadenza()) + " "); String temp = getNf().format(scadenza.getImportoScadenza()); sb2.append(spaceRight(spaceLeft("", (14 - temp.length()) / 2 + 1) + spaceLeft("", (14 - temp.length()) / 2 + 1), 14)); } } return sb1.toString() + "\n" + sb1.toString(); } private Document creaReportUnoGiornaliero(DocumentoCR CR, boolean soloCompatto) { long l_id_tipoDocumento = CR.getId_tipoDocumento(); if (l_id_tipoDocumento == 0L) l_id_tipoDocumento = getId_docCassa(); int rowCellLeading = 6; NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col_1 = 5, col_2 = 3, col_3 = 3, col_4 = 19, col_5 = 5, col_6 = 5; int cellLeading = 12; String descCliente = "", descDocumento = ""; DoubleOperator totGiorno = new DoubleOperator(); DoubleOperator totaleComplessivo = new DoubleOperator(); SimpleDateFormat df = getDataFormat(); Color currentColor = Color.ORANGE; try { Cell rigaVuota = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); String intestazioneReport = "Data: dal " + df.format(CR.getDataDocumentoDa()) + " al " + df.format(CR.getDataDocumentoA()); if (CR.getId_tipo() != 0L) intestazioneReport = intestazioneReport + " - Tipo: " + intestazioneReport; creaIntestazioneReport(CR.getTipoReport(), intestazioneReport); Cell cell = new Cell(new Chunk("Doc.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Data", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Tipo", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Intestazione", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Importo", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); CR.setFlgOrderBy(1L); Vectumerator vec = new Documento(getApFull()).findByCR(CR, 0, 0); Date currentData = null; while (vec.hasMoreElements()) { descCliente = ""; descDocumento = ""; Documento row = (Documento)vec.nextElement(); if (currentData == null) { currentData = row.getDataDocumento(); } else if (DBAdapter.getDateDiff(currentData, row.getDataDocumento()) != 0L) { cell = new Cell(new Chunk("TOTALE " + getDataFormat().format(currentData), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totGiorno.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); currentData = row.getDataDocumento(); totGiorno = new DoubleOperator(); } totGiorno.add(row.getTotaleDocumentoConSegno()); totaleComplessivo.add(row.getTotaleDocumentoConSegno()); String nDoc = row.getNumeroDocumentoCompleto(); descCliente = row.getClifor().getDescrizioneCompleta(); descDocumento = row.getTipoDocumento().getDescrizioneStampa(); String descPag = row.getStatoCompleto(); cell = new Cell(new Chunk(nDoc, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getDataFormat().format(row.getDataDocumento()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descDocumento, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descCliente, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getTotaleDocumentoConSegno()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("TOTALE " + getDataFormat().format(currentData), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totGiorno.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE da " + getDataFormat().format(CR.getDataDocumentoDa()) + " a " + getDataFormat().format(CR.getDataDocumentoA()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.green); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totaleComplessivo.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.green); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); this.document.newPage(); } catch (Exception e) { handleDebug(e); } return this.document; } public String getFECodiceDestinatario() { return getClifor().getCodiceIdentificativoFE(); } public String getFEPecDestinatario() { return getClifor().getPec(); } public String getFEProgressivo() { return Long.toString(getId_documento(), 36); } public String getFERappFiscaleIdPaese() { return null; } public String getFERappFiscalepartitaIva() { return null; } public String getFERappFiscaleCodiceFiscale() { return null; } public String getFERappFiscaleDenominazione() { return null; } public String getFERappFiscaleNome() { return null; } public String getFERappFiscaleCognome() { return null; } public String getFERappFiscaleTitolo() { return null; } public String getFERappFiscaleCodEORI() { return null; } public boolean isPubblicaAmministrazione() { return (getClifor().getFlgPA() == 1L); } public Date getFeDataDocumento() { return getDataDocumento(); } public boolean isFatturaElettronicaGenerabile() { if (isFatturaElettronicaOn()) { if ((getTipoDocumento().getFlgTipologia() == 1L || getTipoDocumento().getFlgTipologia() == 2L) && getTipoDocumento().getFlgClienteFornitore().equals("C") && getFlgStato() == 1L && getId_esercizio() >= 2019L) return true; return false; } return false; } public ResParm getFatturaElettronicaXml() { ResParm rp = new ResParm(); if (isFatturaElettronicaGenerabile()) { if (getTmstInvioXml() == null) { FeXml feXml = new FeXml(this); rp = feXml.getXmlFile(false); } else { rp.setStatus(false); rp.setMsg("Errore! XML Impostato ad inviato!"); } } else { rp.setStatus(false); rp.setMsg("Errore! Impossibile creare fattura xml."); } return rp; } public ResParm getFattureElettronicaXmlZip(DocumentoCR CR) { ResParm rp = new ResParm(); CR.setFlgSoloFattureElettroniche(1L); Vectumerator vec = findByCR(CR, 0, 0); if (vec.hasMoreElements()) { FeXml feXml = new FeXml(this, vec); rp = feXml.getXmlFile(false); } else { rp.setStatus(false); rp.setMsg("Errore! Impossibile creare zip fatture xml! Non e' stata trovata nessuna fattura idonea"); } return rp; } public Timestamp getTmstFileXml() { return this.tmstFileXml; } public void setTmstFileXml(Timestamp tmstFileXml) { this.tmstFileXml = tmstFileXml; } public FEDatiAnagraficiInterface getFEDatiAnagraficiCessionario() { return getClifor(); } public String getFEDivisa() { return "EUR"; } public String getFENumeroDocumento() { if (getTipoDocumento().getFlgFETipoNumeroFattura() == 1L) return String.valueOf(getProgDocumento()); return getNumeroDocumentoCompleto(); } public double getFEImportoTotaleDocumento() { return getTotaleDocumento(); } public double getFEArrotondamento() { return 0.0D; } public String getFECausale() { return getCausale(); } public boolean isFEArt73() { return false; } public String getFETipoDocumento() { return getTipoDocumento().getTipologiaDocumento().getFlgTDFelett(); } public String getFEDatiOrdineAcquistoRifNumLinea() { return null; } public String getFEDatiOrdineAcquistoNumItem() { return ""; } public String getFEDatiOrdineAcquistoCodCommessaConv() { return ""; } public String getFEDatiOrdineAcquistoCodiceCUP() { return getOrdineCodiceCUP(); } public String getFEDatiOrdineAcquistoCodiceCIG() { return getOrdineCodiceCIG(); } public String getFEDatiOrdineAcquistoIdDocumento() { return getRiferimento(); } public Date getFEDatiOrdineAcquistoData() { return getDataRiferimento(); } public String getFEDatiSALRiferimentoFase() { return null; } public Vectumerator getFEDatiDDT() { return null; } public FESedeInterface getFESedeCessonario() { return getClifor(); } public FESedeInterface getFEStabileOrg() { return null; } public FEDatiRitenutaInterface getFeDatiRitenuta() { return null; } public FEDatiTrasportoInterface getFEDatiTrasporto() { return this; } public Vectumerator getFEDettaglioLinee() { Vectumerator vec = findRigheDocumento(0, 0, 1); Vectumerator vec2 = new Vectumerator(vec.elements()); return vec2; } public Vectumerator getFEDatiRiepilogo() { Vectumerator vec; RigheRegistroIva rri = getRigaRegistroIvaCompleto(); if (getTipoDocumento().getFlgUsato() == 1L) { vec = new Vectumerator(rri.elementsFattNoType()); } else { vec = new Vectumerator(rri.elementsNoType()); } return vec; } public FEAllegatiInterface getFEAllegatiInterface() { return null; } public String getFeBolloVirtuale() { if (getImportoBolloEsenzione() > 0.0D) return "SI"; return ""; } public double getFEImportoBollo() { return getImportoBolloEsenzione(); } public double getImportoBolloEsenzione() { return this.importoBolloEsenzione; } public void setImportoBolloEsenzione(double importoBolloEsenzione) { this.importoBolloEsenzione = importoBolloEsenzione; } public FEDatiAnagraficiInterface getFEDatiTrasportoAnagraficiVettore() { return getVettore(); } public String getFEDatiTrasportoInterfaceNumeroLicenzaGuida() { return null; } public String getFEDatiTrasportoMezzoTrasporto() { return null; } public String getFEDatiTrasportoCausaleTrasporto() { return getCausaleTrasporto().getDescrizione(); } public long getFEDatiTrasportoNumeroColli() { return getNColli(); } public String getFEDatiTrasportoDescrizione() { return getNotaSpedizione(); } public String getFEDatiTrasportoUnitaMisuraPeso() { return "Kg"; } public double getFEDatiTrasportoPesoLordo() { return getKgLordo(); } public double getFEDatiTrasportoPesoNetto() { return getKgNetto(); } public Time getFEDatiTrasportoDataOraRitiro() { return null; } public Date getFEDatiTrasportoDataInizioTrasporto() { return getDataDocumento(); } public String getFEDatiTrasportoTipoResa() { return null; } public FESedeInterface getFEDatiTrasportoIndirizzoResa() { return null; } public Time getFEDatiTrasportoDataOraConsegna() { return null; } public Vectumerator getFEScontoMaggiorazione() { if (getScontoIncondizionato() == 0.0D && getAbbuono() == 0.0D) return null; Vectumerator vec = new Vectumerator(); if (getScontoIncondizionato() > 0.0D) vec.add(new FEScontoMaggiorazione("SC", 0.0D, getScontoIncondizionato())); if (getAbbuono() > 0.0D) vec.add(new FEScontoMaggiorazione("SC", 0.0D, getAbbuono())); return vec; } public ResParm sendDocumentiMailMessageExt(DocumentoCR CR, String eMail, String path, String testoAgg) { ResParm rp = new ResParm(true); StatusMsg.updateMsgByTag(getApFull(), "Sendmail Docs Ext", "Preparazione mail massiva a " + eMail + " in corso.."); Vectumerator vec = findByCR(CR, 0, 0); StringBuilder sbFileNames = new StringBuilder(); StringBuilder sbFileNamesDesc = new StringBuilder(); while (vec.hasMoreElements()) { Documento doc = (Documento)vec.nextElement(); CR.setId_documentoS(doc.getId_documento()); StatusMsg.updateMsgByTag(getApFull(), "Sendmail Docs Ext", "Preparazione documento pdf " + doc.getNumeroDocumento() + " in corso."); doc.creaDocumentoPdf(CR, true); sbFileNames.append(CR.getFilePdf()); sbFileNamesDesc.append(doc.getNumeroDocumento()); if (vec.hasMoreElements()) { sbFileNames.append(","); sbFileNamesDesc.append("
"); } } String subject = getMailSubject() + " - Spedizione documenti "; String l_testoAgg = testoAgg + "

Elenco documenti allegati:
" + testoAgg + "

"; StatusMsg.updateMsgByTag(getApFull(), "Sendmail Docs Ext", "Invio mail massiva a " + eMail + " in corso.."); rp = sendDocumentiMailMessage(sbFileNames.toString(), subject, eMail, l_testoAgg, path, (CR.getFlgLink() == 1L)); if (rp.getStatus()) { vec.moveFirst(); Timestamp tmst = getTimestamp(); while (vec.hasMoreElements()) { Documento doc = (Documento)vec.nextElement(); doc.setTmstInvioMail(tmst); } } return rp; } private ResParm sendDocumentiMailMessage(String fileNames, String subject, String eMail, String testoAgg, String path, boolean useLink) { ResParm rp = new ResParm(true); if (!fileNames.isEmpty()) try { MailProperties mp = new MailProperties(); String corpoMessaggio = ""; if (useLink) { fileNames = fileNames.replace(getDocBase(), ""); fileNames = fileNames.replace(getPathStampeDocumenti(), ""); fileNames = URLEncoder.encode(EcDc.encodeDizionario(fileNames, _AnagAdapter.KEY_ENCODE_DIZ), "utf-8"); String id = URLEncoder.encode(EcDc.encodeDizionario(String.valueOf(getId_documento()), _AnagAdapter.KEY_ENCODE_DIZ), "utf-8"); corpoMessaggio = "Clicca sul documento per scaricarlo:
" + getDescDocumenti() + ""; } else { corpoMessaggio = "In allegato i seguenti documenti in formato PDF.
" + getDescDocumenti(); mp.put("FILES", fileNames); } if (!testoAgg.isEmpty()) corpoMessaggio = corpoMessaggio + "

" + corpoMessaggio; if (!getParm("DOC_FIRMA_INVIO_FATTURA").getTesto().isEmpty() && getFlgStato() == 1L) corpoMessaggio = corpoMessaggio + "

" + corpoMessaggio + "

"; mp.setProperty("TO", eMail); mp.setProperty("ISHTML", "true"); mp.setProperty("FROM", getMessaggioDocumentiEmailFrom()); mp.setProperty("SUBJECT", subject); mp.setProperty("MSG", corpoMessaggio); mp.setProperty("BCC", getParm("DOC_BCC").getTesto()); sendMailMessage(mp); } catch (Exception e) { rp.setException(e); } return rp; } public static boolean isThreadAttivo() { return (threadSendMail || threadCreaFattureTessitura); } public final ResParm startThreadCreaFtTessitura(DocumentoCR l_CR, long l_id_cliforR, long l_id, long l_id_tipoDocumentoFiglio, long l_flgTipoGenerazione, Users operatore) { if (!isThreadAttivo()) { new ThreadCreaFtTessitura(l_CR, l_id_cliforR, l_id, l_id_tipoDocumentoFiglio, l_flgTipoGenerazione, operatore); return new ResParm(true, "Thread Crea Fattura Tessitura avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public ResParm sendDocumentiMailMessagePerClifor(DocumentoCR CR, String path, String testoAgg) { ResParm rp = new ResParm(true); CR.setFlgTipologia(20L); CR.setFlgStato(1L); Vectumerator vec = findByCR(CR, 0, 0); HashMap hmClifor = new HashMap<>(); while (vec.hasMoreElements()) { Documento documento = (Documento)vec.nextElement(); if (!hmClifor.containsKey(Long.valueOf(documento.getId_clifor()))) hmClifor.put(new Long(documento.getId_clifor()), documento.getClifor()); } Clifor row = new Clifor(getApFull()); for (Map.Entry entry : hmClifor.entrySet()) { long key = entry.getKey(); row.findByPrimaryKey(key); System.out.println("Invio mail massive a " + row.getNominativoCompleto() + " - " + row.getEMail()); StatusMsg.updateMsgByTag(getApFull(), "Sendmail Docs", "Invio mail massive a " + row.getNominativoCompleto() + " - " + row.getEMail() + " in corso.."); CR.setId_clifor(key); CR.setId_documentoS(0L); vec = findByCR(CR, 0, 0); StringBuilder sbFileNames = new StringBuilder(); StringBuilder sbFileNamesDesc = new StringBuilder(); while (vec.hasMoreElements()) { Documento doc = (Documento)vec.nextElement(); CR.setId_documentoS(doc.getId_documento()); doc.creaDocumentoPdf(CR, true); sbFileNames.append(CR.getFilePdf()); sbFileNamesDesc.append(doc.getNumeroDocumento()); if (vec.hasMoreElements()) { sbFileNames.append(","); sbFileNamesDesc.append("
"); } } String subject = getMailSubject() + " - Spedizione documenti "; String l_testoAgg = testoAgg + "

Elenco documenti allegati:
" + testoAgg + "

"; rp = sendDocumentiMailMessage(sbFileNames.toString(), subject, row.getEMail(), l_testoAgg, path, (CR.getFlgLink() == 1L)); if (rp.getStatus()) { vec.moveFirst(); Timestamp tmst = getTimestamp(); while (vec.hasMoreElements()) { Documento doc = (Documento)vec.nextElement(); doc.setTmstInvioMail(tmst); doc.superSave(); } } } return rp; } public String getProgFileFE() { if (getId_documento() == 0L) return null; return Long.toString(getId_documento(), 36); } public void setProgFileFE(String progFileFE) { this.progFileFE = progFileFE; } public String getFEProgressivoFile() { return getProgFileFE(); } public Vectumerator getFEDettaglioLineeAltre() { if (getSpeseTrasporto() > 0.0D || getSpeseIncasso() > 0.0D || getSpeseAltre() > 0.0D || getScontoIncondizionato() > 0.0D || getAbbuono() > 0.0D) { Vectumerator vec = new Vectumerator(); if (getSpeseTrasporto() > 0.0D) vec.add(new FEDettaglioLinea("", "Spesa trasporto", 1.0D, getSpeseTrasporto(), getSpeseTrasporto(), (double)getIvaDoc().getAliquota(), getIvaDoc().getFENatura())); if (getSpeseIncasso() > 0.0D) vec.add(new FEDettaglioLinea("", "Spese incasso", 1.0D, getSpeseIncasso(), getSpeseIncasso(), (double)getIvaDoc().getAliquota(), getIvaDoc().getFENatura())); if (getSpeseAltre() > 0.0D) vec.add(new FEDettaglioLinea("", getDescSpeseAltre().equals("") ? "Altre Spese" : getDescSpeseAltre(), 1.0D, getSpeseAltre(), getSpeseAltre(), (double)getIvaDoc().getAliquota(), getIvaDoc().getFENatura())); if (getScontoIncondizionato() > 0.0D) vec.add(new FEDettaglioLinea("SC", "Sconto Incondizionato", 1.0D, -getScontoIncondizionato(), -getScontoIncondizionato(), (double)getIvaDoc().getAliquota(), getIvaDoc().getFENatura())); if (getAbbuono() > 0.0D) vec.add(new FEDettaglioLinea("SC", "Sconto Incondizionato", 1.0D, -getAbbuono(), -getAbbuono(), (double)getIvaDoc().getAliquota(), getIvaDoc().getFENatura())); return vec; } return null; } public String getFEParmSfx() { return getTipoDocumento().getSuffissoFattElett(); } public ResParm setFEAggiornaTmstFileXml() { setTmstFileXml(getTimestamp()); return superSave(); } public long getFlgStatoInvioXml() { return this.flgStatoInvioXml; } public void setFlgStatoInvioXml(long flgStatoInvioXml) { this.flgStatoInvioXml = flgStatoInvioXml; } public Timestamp getTmstInvioXml() { return this.tmstInvioXml; } public void setTmstInvioXml(Timestamp tmstInvioXml) { this.tmstInvioXml = tmstInvioXml; } public boolean isFileXmlCreato() { if (getTmstFileXml() == null) return false; return true; } public String getFELinkXml(String parmSfx) { return FeXml.getFileXmlToDocbase(this, parmSfx); } public String getCodiceCIG() { return (this.codiceCIG == null) ? "" : this.codiceCIG.trim(); } public void setCodiceCIG(String codiceCIG) { this.codiceCIG = codiceCIG; } public String getCodiceCUP() { return (this.codiceCUP == null) ? "" : this.codiceCUP.trim(); } public void setCodiceCUP(String codiceCUP) { this.codiceCUP = codiceCUP; } public String getCodiceCommessa() { return (this.codiceCommessa == null) ? "" : this.codiceCommessa.trim(); } public void setCodiceCommessa(String codiceCommessa) { this.codiceCommessa = codiceCommessa; } public Vectumerator getFEDatiPagamento() { if (getId_tipoPagamento() == 0L) return null; Vectumerator res = new Vectumerator(); FEDatiPagamento datiPagamento = new FEDatiPagamento(); datiPagamento.setCondizioniPagamento("TP02"); Vectumerator vecDettaglioPagamento = new Vectumerator(); DocumentoScadenza scadenza = new DocumentoScadenza(getApFull()); Vectumerator vec = scadenza.findByDocumento(getId_documento()); if (vec.hasMoreElements()) while (vec.hasMoreElements()) { scadenza = (DocumentoScadenza)vec.nextElement(); FEDettaglioPagamento dp = new FEDettaglioPagamento(); dp.setModalitaPagamento(getTipoPagamento().getFEModalitaPagamento()); dp.setDataScadenzaPagamento(scadenza.getDataScadenza()); dp.setImportoPagamento(scadenza.getImportoScadenza()); if (getTipoPagamento().getFlgTipoPagamento() == 1L) { if (!getBancaCFDesc().isEmpty()) dp.setIstitutoFinanziario(getBancaCFDesc()); if (!getClifor().getAbi().isEmpty() && !getClifor().getCab().isEmpty()) { dp.setABI(getClifor().getAbi()); dp.setCAB(getClifor().getCab()); } } else if (getTipoPagamento().getFlgTipoPagamento() == 2L) { if (!getIban().isEmpty()) dp.setIBAN(getIban()); if (!getBic().isEmpty()) dp.setBIC(getBic()); } vecDettaglioPagamento.add(dp); } datiPagamento.setVecDettaglioPagamento(vecDettaglioPagamento); res.add(datiPagamento); return res; } public long getId_magFisicoPartenza2() { return this.id_magFisicoPartenza2; } public void setId_magFisicoPartenza2(long id_magFisicoPartenza2) { this.id_magFisicoPartenza2 = id_magFisicoPartenza2; setMagFisicoPartenza2(null); } public String getDescrizioneDocumento() { return this.descrizioneDocumento; } public void setDescrizioneDocumento(String descrizioneDocumento) { this.descrizioneDocumento = descrizioneDocumento; } public long getId_magFisicoArrivo2() { return this.id_magFisicoArrivo2; } public void setId_magFisicoArrivo2(long id_magFisicoArrivo2) { this.id_magFisicoArrivo2 = id_magFisicoArrivo2; setMagFisicoArrivo2(null); } public MagFisico getMagFisicoArrivo2() { this.magFisicoArrivo2 = (MagFisico)getSecondaryObject(this.magFisicoArrivo2, MagFisico.class, getId_magFisicoArrivo2()); return this.magFisicoArrivo2; } public void setMagFisicoArrivo2(MagFisico magFisicoArrivo2) { this.magFisicoArrivo2 = magFisicoArrivo2; } public MagFisico getMagFisicoPartenza2() { this.magFisicoPartenza2 = (MagFisico)getSecondaryObject(this.magFisicoPartenza2, MagFisico.class, getId_magFisicoPartenza2()); return this.magFisicoPartenza2; } public void setMagFisicoPartenza2(MagFisico magFisicoPartenza2) { this.magFisicoPartenza2 = magFisicoPartenza2; } public boolean isRigheArticoliEnabled(int tabNumber) { if (tabNumber == 1) { if (getTipoDocumento().getFlgAFT() == 0L) return true; return false; } if (getTipoDocumento().getFlgAFT2() == 0L) return true; return false; } public long isRigheArticoliEnabled() { return isRigheArticoliEnabled(1) ? 1L : 0L; } public boolean isRigheTessutiEnabled(int tabNumber) { if (tabNumber == 1) { if (getTipoDocumento().getFlgAFT() == 2L) return true; return false; } if (getTipoDocumento().getFlgAFT2() == 2L) return true; return false; } public long isRigheTessutiEnabled() { return isRigheTessutiEnabled(1) ? 1L : 0L; } public boolean isRigheFilatiEnabled(int tabNumber) { if (tabNumber == 1) { if (getTipoDocumento().getFlgAFT() == 1L) return true; return false; } if (getTipoDocumento().getFlgAFT2() == 1L) return true; return false; } public long isRigheFilatiEnabled() { return isRigheFilatiEnabled(1) ? 1L : 0L; } public boolean isMagazzinoArticoloEnabled(int l_numArticolo) { if (isRigheArticoliEnabled(l_numArticolo) && ((l_numArticolo == 1 && getTipoDocumento().getId_causaleMagazzino() > 0L) || (l_numArticolo == 2 && getTipoDocumento().getId_causaleMagazzino2() > 0L))) return true; return false; } public boolean isMagazzinoFilatoEnabled(int l_numArticolo) { if (isRigheFilatiEnabled(l_numArticolo) && ((l_numArticolo == 1 && getTipoDocumento().getId_causaleMagazzino() > 0L) || (l_numArticolo == 2 && getTipoDocumento().getId_causaleMagazzino2() > 0L))) return true; return false; } public boolean isMagazzinoFilatoSelected(int l_numArticolo) { if (!isMagazzinoFilatoEnabled(l_numArticolo)) return true; if (l_numArticolo == 1) { if (getId_magFisicoArrivo() > 0L || getId_magFisicoPartenza() > 0L) return true; return false; } if (getId_magFisicoArrivo2() > 0L || getId_magFisicoPartenza2() > 0L) return true; return false; } public boolean isMagazzinoTessutoEnabled(int l_numArticolo) { if (isRigheTessutiEnabled(l_numArticolo) && ((l_numArticolo == 1 && getTipoDocumento().getId_causaleMagazzino() > 0L) || (l_numArticolo == 2 && getTipoDocumento().getId_causaleMagazzino2() > 0L))) return true; return false; } public boolean isMagazzinoTessutoSelected(int l_numArticolo) { if (!isMagazzinoTessutoEnabled(l_numArticolo)) return true; if (l_numArticolo == 1) { if (getId_magFisicoArrivo() > 0L || getId_magFisicoPartenza() > 0L) return true; return false; } if (getId_magFisicoArrivo2() > 0L || getId_magFisicoPartenza2() > 0L) return true; return false; } public Timestamp getTsFineLavorazione() { return this.tsFineLavorazione; } public String getTsFineLavorazioneS() { return (getTsFineLavorazione() == null) ? "" : getTimestampFormat().format(getTsFineLavorazione()); } public Timestamp getTsInizioLavorazione() { return this.tsInizioLavorazione; } public String getTsInizioLavorazioneS() { return (getTsInizioLavorazione() == null) ? "" : getTimestampFormat().format(getTsInizioLavorazione()); } public void setTsFineLavorazione(Timestamp tsFineLavorazione) { this.tsFineLavorazione = tsFineLavorazione; } public static final String getStatoLavorazione(long l_flgStatoLavorazione) { if (l_flgStatoLavorazione == 0L) return "Da Pianificare"; if (l_flgStatoLavorazione == 10L) return "Pianificata"; if (l_flgStatoLavorazione == 20L) return "In Lavorazione"; if (l_flgStatoLavorazione == 30L) return "In Fase di Taglio"; if (l_flgStatoLavorazione == 100L) return "Concluso"; if (l_flgStatoLavorazione == -1L) return "Aperta"; return "-- scegli stato lavorazione --"; } public void setTsInizioLavorazione(Timestamp tsInizioLavorazione) { this.tsInizioLavorazione = tsInizioLavorazione; } public long getFlgStatoLavorazione() { return this.flgStatoLavorazione; } public String getStatoLavorazione() { return getStatoLavorazione(getFlgStatoLavorazione()); } public void setFlgStatoLavorazione(long flgStatoLavorazione) { this.flgStatoLavorazione = flgStatoLavorazione; } public double getMtTotali() { if (getId_documento() == 0L || getTipoDocumento().getFlgTipologia() != 200L) return 0.0D; return new LavPezza(getApFull()).getTotMetriByDocumentoDTESS(getId_documento(), false); } public long getPezzeTotali() { if (getId_documento() > 0L) return new LavPezza(getApFull()).getTotPezzeByDocumentoDTESS(getId_documento()); return 0L; } public long getPezzeTotaliInviate() { if (getId_documento() > 0L) return new LavPezza(getApFull()).getTotPezzeInviateByDocumentoDTESS(getId_documento()); return 0L; } public long getPezzeTotaliFatturate() { if (getId_documento() > 0L) return new LavPezza(getApFull()).getTotPezzeFatturateByDocumentoDTESS(getId_documento()); return 0L; } public long getStacchiTotali() { if (getId_documento() > 0L) return new RigaDocumento(getApFull()).getTotalePezzeStacchiByDocumento(getId_documento()); return 0L; } public long getFlgBarcodeType() { return this.flgBarcodeType; } public void setFlgBarcodeType(long flgBarcodeType) { this.flgBarcodeType = flgBarcodeType; } public long getFlgBarcodeSequenzaNumeri() { return this.flgBarcodeSequenzaNumeri; } public void setFlgBarcodeSequenzaNumeri(long flgBarcodeSequenzaNumeri) { this.flgBarcodeSequenzaNumeri = flgBarcodeSequenzaNumeri; } public String getBarcodeType() { return getBarcodeType(getFlgBarcodeType()); } public String getOrdineCodiceCIG() { return (this.ordineCodiceCIG == null) ? "" : this.ordineCodiceCIG.trim(); } public String getOrdineCodiceCUP() { return (this.ordineCodiceCUP == null) ? "" : this.ordineCodiceCUP.trim(); } public void setOrdineCodiceCIG(String ordineCodiceCIG) { this.ordineCodiceCIG = ordineCodiceCIG; } public void setOrdineCodiceCUP(String ordineCodiceCUP) { this.ordineCodiceCUP = ordineCodiceCUP; } public ResParm addRigaDocumentoDaPrelevareOLD(RigaDocumento rddp, double l_qtaDaPrelevare) { ResParm rp = new ResParm(false); rp = checkEMSTA(); if (rp.getStatus()) { DoubleOperator dop = new DoubleOperator(l_qtaDaPrelevare); Vectumerator vec = findRigheDocumentoByArticoloArticoloVariante(rddp.getId_articolo(), rddp.getId_articoloVariante()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getId_articolo() == rddp.getId_articolo() && row.getId_articoloVariante() == rddp.getId_articoloVariante()) if (row.getQuantita() != 0.0D) { RigaDocumentoP rdp = new RigaDocumentoP(getApFull()); rdp.setId_rigaDocumento(row.getId_rigaDocumento()); rdp.setId_documento(row.getId_documento()); rdp.setId_rigaDocumentoPrelevata(rddp.getId_rigaDocumento()); if (row.getQuantita() <= dop.getResult()) { rdp.setQuantitaPrelevata(row.getQuantita()); } else { rdp.setQuantitaPrelevata(dop.getResult()); } rp = row.addRigaDocumentoP(rdp); try { double qtaPrelevata; RigaDocumento rd = (RigaDocumento)row.clone(); rd.setId_rigaDocumento(0L); rd.setDBState(0); rd.setId_rigaDocumentoMov(row.getId_rigaDocumento()); rd.setId_rigaDocumentoPrelevata(rddp.getId_rigaDocumento()); rd.setId_magFisico(rddp.getDocumento().getTipoDocumento().getCausaleMagazzino().getId_magFisicoArrivo()); rd.setSegnoMov(-1L); if (row.getQuantita() <= dop.getResult()) { qtaPrelevata = row.getQuantita(); } else { qtaPrelevata = dop.getResult(); } if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 1L) { rd.setNr(qtaPrelevata); } else if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 2L) { rd.setKg(qtaPrelevata); } else if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 3L) { rd.setMt(qtaPrelevata); } rp = rd.saveMov(); } catch (Exception e) { e.printStackTrace(); } if (rp.getStatus()) { Movimento mov = new Movimento(getApFull()); mov.setId_articolo(row.getId_articolo()); mov.setId_articoloVariante(row.getId_articoloVariante()); mov.setId_articoloTaglia(row.getId_articoloTaglia()); mov.setId_clifor(getId_clifor()); mov.setId_causaleMagazzino(getTipoDocumento().getId_causaleMagazzino()); long l_id_magazzinoFisicoDocumentoDaPrelevare = rddp.getDocumento().getTipoDocumento().getCausaleMagazzino() .getId_magFisicoArrivo(); mov.setId_magFisico(l_id_magazzinoFisicoDocumentoDaPrelevare); mov.setId_rigaDocumento(row.getId_rigaDocumento()); if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 1L) { mov.setNr(-1.0D * rdp.getQuantitaPrelevata()); } else if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 2L) { mov.setKg(-1.0D * rdp.getQuantitaPrelevata()); } else if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() == 3L) { mov.setMt(-1.0D * rdp.getQuantitaPrelevata()); } rp = mov.save(); dop.subtract(rdp.getQuantitaPrelevata()); } if (dop.getResult() <= 0.0D) break; } } boolean checkPrelievo = true; Documento ordine = rddp.getDocumento(); Vectumerator vecRows = ordine.findRigheDocumento(0, 0, 0); while (vecRows.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRows.nextElement(); if (row.getFlgRigaPrelevata() == 0L) { checkPrelievo = false; break; } } if (checkPrelievo) { ordine.setFlgDocumentoPrelevato(1L); ordine.superSave(); } } else { rp.setMsg("ERRORE! Fattura emessa o stampata! Impossibile salvare."); } return rp; } public ResParm save() { return saveSynchro(this); } public Vectumerator findByCRSoloArticoli(DocumentoCR CR, int pageNumber, int pageRows) { StringBuffer s_Sql_Find = new StringBuffer("select A.id_documento,A.progDocumento,A.dataDocumento, A.id_esercizio,A.id_clifor,A.id_tipoDocumento, A.id_articolo,A.id_taglia from DOCUMENTO AS A "); String s_Sql_Order = " order by A.dataDocumento asc, A.id_esercizio asc, A.progDocumento asc, D.nome"; WcString wc = new WcString(); CR.setFlgRicercaPerTaglio(1L); findByCRCreateWC(CR, s_Sql_Find, wc); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); findByCRCreateStmtDate(CR, stmt); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public Articolo getArticolo() { this.articolo = (Articolo)getSecondaryObject(this.articolo, Articolo.class, getId_articolo()); return this.articolo; } public long getId_articolo() { return this.id_articolo; } public void setArticolo(Articolo newArticolo) { this.articolo = newArticolo; } public void setId_articolo(long newId_articolo) { this.id_articolo = newId_articolo; setArticolo(null); } public static String getBarcodeType(long l_flgBarcodeType) { switch ((int)l_flgBarcodeType) { case 100: return "Generato"; case 0: return "Lunghezza Totale"; case 1: return "Lunghezza Totale -1"; } return "????"; } public long getTipoCaricoScarico2() { if (getTipoDocumento().getFlgNoAnag2() == 1L) return -1L; if (getId_magFisicoPartenza2() != 0L) return 1L; if (getTipoDocumento().getCausaleMagazzino2().getId_magFisicoPartenza() != 0L) return 1L; return 0L; } public long getId_taglia() { return this.id_taglia; } public Taglia getTaglia() { this.taglia = (Taglia)getSecondaryObject(this.taglia, Taglia.class, getId_taglia()); return this.taglia; } public void setId_taglia(long id_taglia) { this.id_taglia = id_taglia; } public void setTaglia(Taglia taglia) { this.taglia = taglia; } public double getTotNr() { if (getId_documento() == 0L) return 0.0D; String s_Sql_Find = "select SUM(A.nr) AS _sum from RIGA_DOCUMENTO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("id_documento = " + getId_documento()); wc.addWc("flgCodiceRiga =0 "); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return getSum(stmt); } catch (SQLException e) { handleDebug(e); return 0.0D; } } public static final synchronized ResParm calcolaTessutiTaglioCHENONSERVEAUNTUBO(Documento bean, String lang) { ResParm rp = new ResParm(true); boolean debug = false; String debugInfo = "calcolaTessutiTaglio"; RigaDocumento rd = new RigaDocumento(bean.getApFull()); rd.impostaDaCancellareByDocumentoCodiceriga(bean.getId_documento(), 1L, true); Vectumerator vecRd = bean.findRigheDocumento(0, 0, 0); if (vecRd.getTotNumberOfRecords() > 0) { Vectumerator vecTessTaglio = findTessutiPerTaglio(bean); while (vecTessTaglio.hasMoreElements()) { ArticoloTessutoColore row = (ArticoloTessutoColore)vecTessTaglio.nextElement(); rd = new RigaDocumento(bean.getApFull()); rd.findByDocumentoArticoloTessutoColore(bean.getId_documento(), row.getId_articoloTessutoColore(), 1L); if (rd.getId_rigaDocumento() > 0L) { rd.setMt(row.getMtLavorazioneTaglio()); } else { rd.setId_documento(bean.getId_documento()); rd.setFlgCodiceRiga(1L); rd.setId_articoloTessutoColore(row.getId_articoloTessutoColore()); rd.setId_articoloTessuto(rd.getArticoloTessutoColore().getId_articoloTessuto()); rd.setMt(row.getMtLavorazioneTaglio()); rd.setDescrizioneRiga(rd.getArticoloTessutoColore().getDescrizioneCompleta()); rd.setId_causaleMagazzino(bean.getTipoDocumento().getId_causaleMagazzino2()); } rd.setFlgDaCancellare(0L); addRigaDocumentoTessuto(bean, rd, 1L); } ArticoloArticoloTessuto att = new ArticoloArticoloTessuto(bean.getApFull()); boolean salvaNtr = true; while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); if (row.getFlgDaCancellare() == 1L) { row.delete(); continue; } NumeroTeliRiga ntr = new NumeroTeliRiga(bean.getApFull()); Vectumerator vec100 = bean.findRigheDocumentoDisposizioneTaglio(0, 0, 2); while (vec100.hasMoreElements()) { RigaDocumento row100 = (RigaDocumento)vec100.nextElement(); ntr.findByRDArticoloRDTessuto(row.getId_rigaDocumento(), row100.getId_rigaDocumento()); if (ntr.getId_numeroTeliRiga() > 0L); salvaNtr = true; if (row100.getId_articoloTessutoColore() > 0L) { att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), row100.getId_articoloTessutoColore()); if (att.getId_articoloArticoloTessuto() == 0L) salvaNtr = false; } if (salvaNtr) { ntr.setId_rigaDocumentoArticolo(row.getId_rigaDocumento()); ntr.setId_rigaDocumentoTessuto(row100.getId_rigaDocumento()); long numTeli = (long)Math.ceil(row.getNr() / (double)row100.getCapiPerTelo()); ntr.setNumTeliRiga(numTeli); if (att.getId_articoloArticoloTessuto() <= 0L) att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), 0L); DoubleOperator metriRd = new DoubleOperator(row.getNr()); metriRd.multiply(att.getMtATT()); metriRd.setScale(2, 5); ntr.setMtTessutoRiga(metriRd.getResult()); ntr.save(); } att.setId_articoloArticoloTessuto(0L); att.setDBState(0); } } } RigaDocumentoCR CR = new RigaDocumentoCR(); CR.setFlgDaCancellare(1L); CR.setId_documento(bean.getId_documento()); vecRd = rd.findByCR(CR, 0, 0); while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); row.delete(); } return rp; } public String getCausale() { return (this.causale == null) ? "" : this.causale.trim(); } public void setCausale(String causale) { this.causale = causale; } public ByteArrayOutputStream creaLabelDocumentoArticoliA4Pdf(DocumentoCR CR) { long pHMarg = getParm("LABEL_ART_A4_MARGINE").getNumeroLong(); ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { this.document = new Document(PageSize.A4, 0.0F, 0.0F, 0.0F, 0.0F); this.writer = PdfWriter.getInstance(this.document, ba); String titoloReport = getNumeroDocumentoCompleto(); SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.document.open(); long labelNumber = 0L; String dim = getParm("LABEL_ART_A4_COL_ROW").getTesto(); int nCol = Integer.parseInt(dim.substring(0, dim.indexOf(','))); int nRow = Integer.parseInt(dim.substring(dim.indexOf(',') + 1)); this.pdfPcorpo = new PdfPTable(nCol); this.pdfPcorpo.setWidthPercentage(100.0F); Documento doc = new Documento(getApFull()); doc.findByPrimaryKey(CR.getId_documentoS()); if (doc.hasLabelDaStampare()) { if (CR.getBlankLabels() > 0L) { PdfPCell pdfPCell = new PdfPCell(); pdfPCell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); pdfPCell.setBorder(0); for (int i = 0; (long)i < CR.getBlankLabels(); i++) { labelNumber++; this.pdfPcorpo.addCell(pdfPCell); } } Vectumerator vec = findByCR(CR, 0, 0); long numbOfLabels = 1L; while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vecRighe = row.findRigheDocumento(0, 0, ordineInverso); while (vecRighe.hasMoreElements()) { RigaDocumento rowRD = (RigaDocumento)vecRighe.nextElement(); if (rowRD.getFlgUdm() == 1L) { numbOfLabels = (long)rowRD.getQuantita(); } else { numbOfLabels = 1L; } rowRD.getArticolo().setWriter(getWriter()); rowRD.getArticolo().setPdfPcorpo(getPdfPcorpo()); String descLabel = rowRD.getDescrizioneRigaCompleta(); numbOfLabels = (long)rowRD.getArticolo().addLabelUnArticoloA4Pdf(titoloReport, nRow, numbOfLabels, descLabel, rowRD.getId_articoloVariante()); labelNumber += numbOfLabels; } } long numberBlankCell = (long)nCol - labelNumber % (long)nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); if (numberBlankCell != (long)nCol) for (int i = 0; (long)i < numberBlankCell; i++) this.pdfPcorpo.addCell(cell); } else { Phrase ph = new Phrase("Attenzione! Non ci sono etichette da stampare!"); PdfPCell cell = new PdfPCell(ph); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); cell.setColspan(nCol); this.pdfPcorpo.addCell(cell); } this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public boolean hasTutteRigheTessTelaio() { if (getId_documento() == 0L) return false; Vectumerator vec = new RigaDocumento(getApFull()).findRigheSenzaTelaioByDocumento(getId_documento()); if (vec.hasMoreElements()) return false; return true; } public boolean hasAlmentoUnaRigaTessTelaio() { if (getId_documento() == 0L) return false; Vectumerator vec = new RigaDocumento(getApFull()).findRigheConTelaioByDocumento(getId_documento()); if (vec.hasMoreElements()) return true; return false; } public long getTotaleColpi() { return this.totaleColpi; } public void setTotaleColpi(long totaleColpi) { this.totaleColpi = totaleColpi; } public Vectumerator findRigheDocumento2(String l_search, int pageNumber, int pageRows, int ordinamentoRiga) { return findRigheDocumento(1L, l_search, pageNumber, pageRows, ordinamentoRiga); } public ResParm creaDocumentoFiglio(long l_id_clifor, long l_id_tipoDocumentoDaGenerare, Users operatore, boolean creaBozza, long l_flgTipoCreazione) { String TAG_THREAD_MSG = "CREAZIONE DOCUMENTO FIGLIO"; StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "inizio...."); ResParm rp = new ResParm(true); if (getTipoDocumento().getTipologiaDocumento().getCodice() == 200L) { rp.append(creaDocumentoFiglioDaDisposizioniTessitura(l_id_clifor, l_id_tipoDocumentoDaGenerare, operatore, creaBozza, l_flgTipoCreazione)); } else { long resRigheUsato = hasRigheConUsato(); if (resRigheUsato == 0L) { rp.append(creaDocumentoFiglioConControlloUsato(l_id_clifor, l_id_tipoDocumentoDaGenerare, operatore, creaBozza, l_flgTipoCreazione, false)); } else { Vectumerator vecDP; TipoDocumento tdDaGenerare = new TipoDocumento(getApFull()); tdDaGenerare.findByPrimaryKey(l_id_tipoDocumentoDaGenerare); if (tdDaGenerare.getId_tipoDocumento() == 0L) { vecDP = AB_EMPTY_VECTUMERATOR; } else { vecDP = getTipoDocumento().findDocGen(2L, tdDaGenerare.getId_tipologiaDocumento(), 1, 1); } if (vecDP.hasMoreElements()) { DocPrel dpUsato = (DocPrel)vecDP.nextElement(); long l_id_tipoDocumentoUSATO = dpUsato.getId_tipoDocumento(); if (resRigheUsato == 2L || resRigheUsato == 4L || resRigheUsato == 6L) rp.append(creaDocumentoFiglioConControlloUsato(l_id_clifor, l_id_tipoDocumentoDaGenerare, operatore, creaBozza, l_flgTipoCreazione, false)); if (resRigheUsato == 2L || resRigheUsato == 1L || resRigheUsato == 6L || resRigheUsato == 5L) rp.append(creaDocumentoFiglioConControlloUsato(l_id_clifor, l_id_tipoDocumentoUSATO, operatore, false, l_flgTipoCreazione, true)); if (resRigheUsato == 3L || resRigheUsato == 4L || resRigheUsato == 6L || resRigheUsato == 5L) rp.append(creaDocumentoFiglioConControlloUsato(l_id_clifor, l_id_tipoDocumentoUSATO, operatore, false, l_flgTipoCreazione, false)); } else { rp.setStatus(false); rp.setMsg("ERRORE! Non ho documenti di tipo usato come figlio."); } } } StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, rp.getMsg()); StatusMsg.deleteMsgByTag(getApFull(), TAG_THREAD_MSG); return rp; } private ResParm creaDocumentoFiglioConControlloUsato(long l_id_clifor, long l_id_tipoDocumentoFiglio, Users operatore, boolean creaBozza, long l_flgTipoCreazioneRiga, boolean seUsatoCreaRm) { if (l_id_clifor == 0L) l_id_clifor = getId_clifor(); if (getTipoDocumento().getFlgObbligoPrelievo() == 1L) return new ResParm(false, "ERRORE! Figlio non generabile. Documento con obbligo di prelievo"); long righeCreate = 0L; ResParm rp = new ResParm(); ResParm rpRow = new ResParm(); if (getDBState() == 1) { TipoDocumento tdGen = new TipoDocumento(getApFull()); tdGen.findByPrimaryKey(l_id_tipoDocumentoFiglio); boolean isDocUsato = (tdGen.getFlgUsato() == 1L); long resRigheUsato = hasRigheConUsato(); if (!isDocumentoFiglioCreabile()) { rp.setStatus(false); rp.setMsg("Errore! Documento figlio non creabile..."); } else if (!getTipoDocumento().isTipoDocGenerabile(l_id_tipoDocumentoFiglio)) { rp.setStatus(false); rp.setMsg("Errore! Il tipo di documento " + tdGen.getDescrizioneCompleta() + " non è generabile!"); } else { TipoDocumento tdf = new TipoDocumento(getApFull()); tdf.findByPrimaryKey(l_id_tipoDocumentoFiglio); if (tdf.getId_causaleMagazzino() != 0L && hasRigheDisponibili() == 0) { rp.setMsg("Errore! L'attuale documento non ha articoli disponibili per lo scarico mentre il documento figlio prevede lo scarico dal magazzino."); } else { Documento doc = new Documento(getApFull()); if (creaBozza) doc.findDocumentoBozza(l_id_tipoDocumentoFiglio, l_id_clifor); if (doc.getDBState() == 0) { Clifor clienteDoc; doc.setId_tipoDocumento(l_id_tipoDocumentoFiglio); if (tdf.getId_tipoDocumento() == getId_docCassa()) { if (getTipoDocumento().getFlgTipologia() == 4L) { if (getId_clifor() > 1L) { doc.setId_clifor(getId_clifor()); doc.setId_cliforListino(getId_clifor()); clienteDoc = doc.getCliforListino(); } else { clienteDoc = new Clifor(getApFull()); } } else { doc.setId_clifor(1L); doc.setId_cliforListino(l_id_clifor); clienteDoc = doc.getCliforListino(); } } else { doc.setId_clifor(l_id_clifor); clienteDoc = doc.getClifor(); } if (operatore != null) { if (getId_tipoDocumento() == getId_docCassa()) { Vectumerator vecp = findDocumentiPadre(); if (vecp.size() == 1) { Documento docp = (Documento)vecp.nextElement(); if (docp.getTipoDocumento().getTipologiaDocumento() .getCodice() == 4L) doc.setId_users(docp.getId_users()); } else { doc.setId_users(operatore.getId_users()); } } else if (getTipoDocumento().getFlgTipologia() == 4L) { doc.setId_users(0L); } else { doc.setId_users(operatore.getId_users()); } } else { doc.setId_users(getId_users()); } doc.setNominativoDocumento(getNominativoDocumento()); if (clienteDoc.getId_tipoPagamento() != 0L) { doc.setId_tipoPagamento(clienteDoc.getId_tipoPagamento()); } else { doc.setId_tipoPagamento(getId_tipoPagamento()); } doc.setDataDocumento(getToday()); if (getFlgPagata() == 1L) { doc.setFlgPagata(1L); doc.setDescTransaction(getDescTransaction()); } } if (creaBozza) doc.setFlgStato(0L); double accontiDiff = 0.0D; double importiRighe = 0.0D; double totAcconti = getTotAccontiByDocumentoPadre(getId_documento()); if (getAcconto() > totAcconti) accontiDiff = getAcconto() - totAcconti; doc.setNote(getNote()); doc.setDataScadenzaPagamento(getDataScadenzaPagamento()); doc.setFlgPagamentoDataFissa(getFlgPagamentoDataFissa()); doc.setIban(getIban()); doc.setBic(getBic()); doc.setId_destinazioneDiversa(getId_destinazioneDiversa()); doc.setPresso(getPresso()); doc.setIndirizzoSped(getIndirizzoSped()); doc.setNumeroCivicoSped(getNumeroCivicoSped()); doc.setCittaSped(getCittaSped()); doc.setProvinciaSped(getProvinciaSped()); doc.setCapSped(getCapSped()); doc.setId_nazioneSped(getId_nazioneSped()); doc.setNColli(getNColli()); doc.setKgLordo(getKgLordo()); doc.setKgNetto(getKgNetto()); doc.setVolume(getVolume()); doc.setId_causaleTrasporto(getId_causaleTrasporto()); doc.setId_vettore(getId_vettore()); doc.setFlgTrasporto(getFlgTrasporto()); doc.setId_aspetto(getId_aspetto()); doc.setId_porto(getId_porto()); doc.setNotePagamento(getNotePagamento()); doc.setNotaSpedizione(getNotaSpedizione()); doc.setNote(getNote()); doc.setNotaAggiuntiva(getNotaAggiuntiva()); doc.setNotaMail(getNotaMail()); doc.setRiferimento(getRiferimento()); doc.setDataRiferimento(getDataRiferimento()); doc.setFlgDeliveryType(getFlgDeliveryType()); doc.setPudoId(getPudoId()); doc.setPudoDesc(getPudoDesc()); DoubleOperator totCosti = new DoubleOperator(); long speseStd = 0L; if (!isDocUsato) { speseStd = 0L; } else if (resRigheUsato == 2L || resRigheUsato == 4L || resRigheUsato == 6L) { speseStd = 2L; } else if (seUsatoCreaRm) { if (resRigheUsato == 1L) { speseStd = 1L; } else { speseStd = 2L; } } else if (resRigheUsato == 3L || resRigheUsato == 5L) { speseStd = 0L; } else { speseStd = 2L; } if (speseStd == 0L) { doc.setSpeseTrasporto(getSpeseTrasporto()); doc.setSpeseIncasso(getSpeseIncasso()); doc.setSpeseAltre(getSpeseAltre()); doc.setDescSpeseAltre(getDescSpeseAltre()); doc.setId_ivaDoc(getId_ivaDoc()); doc.setScontoIncondizionato(getScontoIncondizionato()); doc.setAbbuono(getAbbuono()); } if (speseStd == 1L) { totCosti.add(getSpeseAltreConIva()); totCosti.add(getSpeseIncassoConIva()); totCosti.add(getSpeseTrasportoConIva()); } if (speseStd == 2L); doc.setOrdineCodiceCIG(getOrdineCodiceCIG()); doc.setOrdineCodiceCUP(getOrdineCodiceCUP()); rp = doc.save(); if (rp.getStatus()) if (l_flgTipoCreazioneRiga == 0L) { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements() && rp.getStatus()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); boolean aggiungiRiga = false; if (!isDocUsato && row.getArticolo().getFlgUsato() == 0L) { aggiungiRiga = true; } else if (isDocUsato && row.getArticolo().getFlgUsato() > 0L) { if (seUsatoCreaRm && row.getIva().getFlgTipo().equals("R")) { aggiungiRiga = true; } else if (!seUsatoCreaRm && !row.getIva().getFlgTipo().equals("R")) { aggiungiRiga = true; } } if (aggiungiRiga && row.getFlgRigaPrelevata() == 0L) { boolean isDisponibile = false; double qta = row.getQuantita(); boolean totPrelevata = false; if (tdf.getId_causaleMagazzino() == 0L) { totPrelevata = true; isDisponibile = true; } else if ((row.getArticolo().getTipo().getFlgTipoMagazzino() == 2L && !row.getSeriale().equals("")) || row.getArticolo().getTipo().getFlgTipoMagazzino() != 2L) { if (row.getId_articoloVariante() > 0L) { if (row.getArticoloVariante().getQuantitaAv() > 0.0D) { if (row.getArticoloVariante().getQuantitaAv() < row.getQuantita()) { qta = row.getArticoloVariante().getQuantitaAv(); } else { qta = row.getQuantita(); totPrelevata = true; } isDisponibile = true; } } else if (row.getArticolo().getQuantita() > 0.0D) { if (row.getArticolo().getQuantita() < row.getQuantita()) { qta = row.getArticolo().getQuantita(); } else { qta = row.getQuantita(); totPrelevata = true; } isDisponibile = true; } } if (isDisponibile) { righeCreate++; RigaDocumento rDoc = new RigaDocumento(getApFull()); rDoc.setId_documento(doc.getId_documento()); rDoc.setId_articolo(row.getId_articolo()); rDoc.setId_articoloVariante(row.getId_articoloVariante()); rDoc.setId_iva(row.getId_iva()); rDoc.setId_magFisico(row.getId_magFisico()); rDoc.setSeriale(row.getSeriale()); if (righeCreate == 1L && totCosti.getResult() > 0.0D) { totCosti.add(row.getImponibile()); rDoc.setImponibile(totCosti.getResult()); } else { rDoc.setImponibile(row.getImponibile()); } rDoc.setQuantita(qta); rDoc.setQuantitaUdm(qta); rDoc.setDescrizioneRiga(row.getDescrizioneRiga()); rDoc.setNotaRigaDocumento(row.getNotaRigaDocumento()); rDoc.setNotaBarcode(row.getNotaBarcode()); rDoc.setSconto(row.getSconto()); rDoc.setPercL1(row.getPercL1()); rDoc.setPercL2(row.getPercL2()); rDoc.setPercL3(row.getPercL3()); rDoc.setImporto(row.getImporto()); importiRighe += row.getTotImportoRigaConSconto(); rDoc.setId_documentoPadre(getId_documento()); rDoc.setId_rigaDocumentoPadre(row.getId_rigaDocumento()); if (getId_tipoDocumento() == getId_docRiparazione()) if (getImportoConsuntivo() > 0.0D) { rDoc.setImponibile(getImportoConsuntivo()); } else { rDoc.setImponibile(getImportoPreventivo()); } if (doc.getTipoDocumento().getFlgImportoIva() == 1L) rDoc.setPrezzoPubblicoConIva(row.getImporto()); rpRow = rDoc.save(); if (rpRow.getStatus()) { rp.append(rpRow); if (totPrelevata) { row.setFlgRigaPrelevata(1L); rp.append(row.superSave()); continue; } row.setQuantita(row.getQuantita() - qta); rp.append(row.superSave()); } } } } } else if (l_flgTipoCreazioneRiga == 1L) { righeCreate++; RigaDocumento rDoc = new RigaDocumento(getApFull()); rDoc.setId_documento(doc.getId_documento()); rDoc.setId_iva(getId_ivaDoc()); rDoc.setImponibile(getImponibileTotale()); rDoc.setNr(1.0D); rDoc.setDescrizioneRiga("Ns. documento " + getNumeroDocumentoCompleto() + " del " + getDataFormat().format(getDataDocumento())); rDoc.setImporto(getTotaleDocumento()); importiRighe += getTotaleDocumento(); rDoc.setId_documentoPadre(getId_documento()); if (doc.getTipoDocumento().getFlgImportoIva() == 1L) rDoc.setPrezzoPubblicoConIva(getTotaleDocumento()); rpRow = rDoc.save(); if (rpRow.getStatus()) { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements() && rp.getStatus()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getFlgRigaPrelevata() == 0L) { row.setFlgRigaPrelevata(1L); rp.append(row.superSave()); } } } } else if (l_flgTipoCreazioneRiga == 2L) { } rp = doc.save(); if (rp.getStatus()) { if (righeCreate == 0L) { rp = new ResParm(false); rp.setMsg("ERRORE! Nessun rigo prelevabile!"); doc.delete(); } else if (accontiDiff > 0.0D) { if (findTotRigheDocumentoDaPrelevare() == 0L) { doc.setAcconto(accontiDiff); } else if (importiRighe < accontiDiff) { doc.setAcconto(importiRighe); } else { doc.setAcconto(accontiDiff); } doc.save(); } if (operatore != null) { setId_users(operatore.getId_users()); StringBuffer sb = new StringBuffer(); sb.append(getLogRecord()); if (!getLogRecord().equals("")) sb.append("
"); sb.append("Creato Documento figlio "); sb.append(tdGen.getDescrizione()); sb.append(" da "); sb.append(operatore.getCognomeNome()); sb.append(" il "); sb.append(getTimestampFormat().format(getTimestamp())); setLogRecord(sb.toString()); save(); } if (findTotRigheDocumentoDaPrelevare() == 0L) { setFlgStato(1L); setFlgDocumentoPrelevato(1L); setFlgStatoPrenotazione(90L); super.save(); } } } } } findByPrimaryKey(getId_documento()); return rp; } public Vectumerator findOrdiniTaglioAperti() { String s_Sql_Find = "select A.* from DOCUMENTO AS A INNER JOIN TIPO_DOCUMENTO AS B ON A.id_tipoDocumento=B.id_tipoDocumento inner join TIPOLOGIA_DOCUMENTO AS C ON C.id_tipologiaDocumento=B.id_tipologiaDocumento left join DOC_FIGLIO_PADRE AS E ON A.id_documento=E.id_documentoFiglio"; String s_Sql_Order = " order by A.dataDocumento desc, A.id_esercizio desc, A.progDocumento desc"; WcString wc = new WcString(); wc.addWc("A.flgStato=1"); wc.addWc("C.codice=210"); wc.addWc("E.id_docFiglioPadre is null"); wc.addWc("A.id_articolo=" + getId_articolo()); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); System.out.println(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public static final String getTipoGenerazione(long l_flgTipoGenerazione) { return DocPrel.getTipoGenerazione(l_flgTipoGenerazione); } public long getFlgTipoGenerazione() { return this.flgTipoGenerazione; } public String getTipoGenerazione() { return getTipoGenerazione(getFlgTipoGenerazione()); } public void setFlgTipoGenerazione(long flgTipoGenerazione) { this.flgTipoGenerazione = flgTipoGenerazione; } protected void creaDocumentoCorpoFt(Document l_document, Table l_pdfCorpo) { int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); if (righePerPagina <= 0) righePerPagina = 10; int maxCarDesc = (int)getTipoDocumento().getMaxCarDesc(); if (maxCarDesc == 0) maxCarDesc = 35; int riga = 0; int cellLeadingRow = getDocLeadRow(); if (cellLeadingRow == 0) cellLeadingRow = 12; Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowSmall = getTipoDocumento().getPdfFontRowSmall(); NumberFormat nf = getNf(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); try { String s_note; long resHasUsato = hasRigheConUsato(); if (!getPudoId().isEmpty()) { s_note = "Fermo Point BRT\n" + getPudoDesc() + "\n" + getNote(); } else { s_note = getNote(); } if (resHasUsato == 1L || resHasUsato == 2L || resHasUsato == 5L || resHasUsato == 6L) { Iva ivaRM = new Iva(getApFull()); ivaRM.findByPrimaryKey(getCodiceIvaRegimeMargine()); s_note = s_note + "\n" + s_note; } ArrayList alNote = RigaDocumentoItemPdf.getArrayListNota(s_note, 0, cols_FT_STD_, PDF_frow); if (getDocPosizioneNota() == 0L) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); while (vec.hasMoreElements()) { String desc, descQta; double imponibile, importo; String scontoS; RigaDocumento row = (RigaDocumento)vec.nextElement(); double quantita = row.getQuantita(); if (row.getSconto() > 0.0D) { scontoS = nf.format(row.getSconto()); } else { scontoS = ""; } if (!row.getIva().getFlgTipo().equals("R")) { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } else { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } if (row.getSeriale().isEmpty() && !row.getArticolo().getNMatricola().isEmpty()) desc = desc + " Mat. N. " + desc; if (!row.getNotaBarcode().isEmpty()) desc = desc + " - " + desc; String codIva = row.getIva().getDescrizioneRigaStampaAuto(); if (!row.getNotaRigaDocumento().isEmpty()) desc = desc + " " + desc; if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() != 1L) { if (isQuantitaMagazzinoIntere()) { descQta = row.getArticolo().getTipo().getTipologiaArticolo().getUdm() + " " + row.getArticolo().getTipo().getTipologiaArticolo().getUdm(); } else if (row.getRifTipoArticolo() == 20L) { descQta = "C. " + getNf0().format(quantita * 1000.0D); } else if (row.getRifTipoArticolo() == 21L) { descQta = nf.format(quantita); } else { descQta = row.getUdm() + " " + row.getUdm(); } } else if (isQuantitaMagazzinoIntere()) { descQta = getNf0().format(quantita); } else { descQta = nf.format(quantita); } ArrayList dati = new ArrayList<>(); dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[0], desc, PDF_frow)); dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[1], descQta, PDF_frow, 2)); if (row.getRifTipoArticolo() == 20L) { dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[2], getNf5().format(imponibile / 1000.0D), PDF_frow, 2)); } else { dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[2], nf.format(imponibile), PDF_frow, 2)); } dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[3], scontoS, PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[4], nf.format(importo), PDF_frow, 2)); if (codIva.length() >= 10) { dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[5], codIva, PDF_frowSmall, 2)); } else { dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[5], codIva, PDF_frow, 2)); } riga = inserisciRigaDocumento(dati, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); } if (getDocPosizioneNota() == 1L && !s_note.isEmpty()) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); if (righePerPagina - riga > 0) riga = inserisciRigheVuote(righePerPagina - riga, cols_FT_STD_, riga, l_document, l_pdfCorpo, cellLeadingRow); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoCorpoFtSemplice(Document l_document, Table l_pdfCorpo) { int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); if (righePerPagina <= 0) righePerPagina = 10; int maxCarDesc = (int)getTipoDocumento().getMaxCarDesc(); if (maxCarDesc == 0) maxCarDesc = 35; int riga = 0; int cellLeadingRow = getDocLeadRow(); if (cellLeadingRow == 0) cellLeadingRow = 12; Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowSmall = getTipoDocumento().getPdfFontRowSmall(); NumberFormat nf = getNf(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); int colSpanDescrizione = cols_FT_SEMPLICE_[0]; try { String s_note; long resHasUsato = hasRigheConUsato(); if (!getPudoId().isEmpty()) { s_note = "Fermo Point BRT\n" + getPudoDesc() + "\n" + getNote(); } else { s_note = getNote(); } if (resHasUsato == 1L || resHasUsato == 2L || resHasUsato == 5L || resHasUsato == 6L) { Iva ivaRM = new Iva(getApFull()); ivaRM.findByPrimaryKey(getCodiceIvaRegimeMargine()); s_note = s_note + "\n" + s_note; } ArrayList alNote = RigaDocumentoItemPdf.getArrayListNota(s_note, 0, cols_FT_SEMPLICE_, PDF_frow); if (getDocPosizioneNota() == 0L) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); while (vec.hasMoreElements()) { String desc; double importo; RigaDocumento row = (RigaDocumento)vec.nextElement(); double quantita = row.getQuantita(); if (row.getSconto() > 0.0D) { String scontoS = nf.format(row.getSconto()); } else { String scontoS = ""; } if (!row.getIva().getFlgTipo().equals("R")) { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; double imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } else { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; double imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } if (row.getSeriale().isEmpty() && !row.getArticolo().getNMatricola().isEmpty()) desc = desc + " Mat. N. " + desc; if (!row.getNotaBarcode().isEmpty()) desc = desc + " - " + desc; String codIva = row.getIva().getDescrizioneRigaStampaAuto(); if (!row.getNotaRigaDocumento().isEmpty()) desc = desc + " " + desc; if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() != 1L) { if (isQuantitaMagazzinoIntere()) { String descQta = row.getUdm() + " " + row.getUdm(); } else { String descQta = row.getUdm() + " " + row.getUdm(); } } else if (isQuantitaMagazzinoIntere()) { String descQta = getNf0().format(quantita); } else { String descQta = nf.format(quantita); } ArrayList dati = new ArrayList<>(); dati.add(new RigaDocumentoItemPdf(colSpanDescrizione, desc, PDF_frow)); dati.add(new RigaDocumentoItemPdf(cols_FT_SEMPLICE_[1], nf.format(importo), PDF_frow, 2)); if (codIva.length() >= 10) { dati.add(new RigaDocumentoItemPdf(cols_FT_SEMPLICE_[2], codIva, PDF_frowSmall, 2)); } else { dati.add(new RigaDocumentoItemPdf(cols_FT_SEMPLICE_[2], codIva, PDF_frow, 2)); } riga = inserisciRigaDocumento(dati, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); } if (getDocPosizioneNota() == 1L && !s_note.isEmpty()) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); if (righePerPagina - riga > 0) riga = inserisciRigheVuote(righePerPagina - riga, cols_FT_SEMPLICE_, riga, l_document, l_pdfCorpo, cellLeadingRow); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoCorpoFtPro(Document l_document, Table l_pdfCorpo) { creaDocumentoCorpoFt(l_document, l_pdfCorpo); } protected void creaDocumentoCorpoFtProS(Document l_document, Table l_pdfCorpo) { int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); if (righePerPagina <= 0) righePerPagina = 10; int maxCarDesc = (int)getTipoDocumento().getMaxCarDesc(); if (maxCarDesc == 0) maxCarDesc = 35; int riga = 0; int cellLeadingRow = getDocLeadRow(); if (cellLeadingRow == 0) cellLeadingRow = 12; Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowSmall = getTipoDocumento().getPdfFontRowSmall(); NumberFormat nf = getNf(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); int colSpanDescrizione = cols_FT_PRO_SEMPLICE_[0]; try { long resHasUsato = hasRigheConUsato(); String s_note = getNote(); if (resHasUsato == 1L || resHasUsato == 2L || resHasUsato == 5L || resHasUsato == 6L) { Iva ivaRM = new Iva(getApFull()); ivaRM.findByPrimaryKey(getCodiceIvaRegimeMargine()); s_note = s_note + "\n" + s_note; } ArrayList alNote = RigaDocumentoItemPdf.getArrayListNota(s_note, 0, cols_FT_PRO_SEMPLICE_, PDF_frow); if (getDocPosizioneNota() == 0L) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); while (vec.hasMoreElements()) { String desc; double importo; RigaDocumento row = (RigaDocumento)vec.nextElement(); double quantita = row.getQuantita(); if (row.getSconto() > 0.0D) { String scontoS = nf.format(row.getSconto()); } else { String scontoS = ""; } if (!row.getIva().getFlgTipo().equals("R")) { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; double imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } else { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; double imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } if (row.getSeriale().isEmpty() && !row.getArticolo().getNMatricola().isEmpty()) desc = desc + " Mat. N. " + desc; if (!row.getNotaBarcode().isEmpty()) desc = desc + " - " + desc; String codIva = row.getIva().getDescrizioneRigaStampaAuto(); if (!row.getNotaRigaDocumento().isEmpty()) desc = desc + " " + desc; if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() != 1L) { if (isQuantitaMagazzinoIntere()) { String descQta = row.getUdm() + " " + row.getUdm(); } else { String descQta = row.getUdm() + " " + row.getUdm(); } } else if (isQuantitaMagazzinoIntere()) { String descQta = getNf0().format(quantita); } else { String descQta = nf.format(quantita); } ArrayList dati = new ArrayList<>(); dati.add(new RigaDocumentoItemPdf(colSpanDescrizione, desc, PDF_frow)); dati.add(new RigaDocumentoItemPdf(cols_FT_PRO_SEMPLICE_[1], "€ " + nf.format(importo), PDF_frow, 2)); riga = inserisciRigaDocumento(dati, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); } if (getDocPosizioneNota() == 1L && !s_note.isEmpty()) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); if (righePerPagina - riga > 0) riga = inserisciRigheVuote(righePerPagina - riga, cols_FT_PRO_SEMPLICE_, riga, l_document, l_pdfCorpo, cellLeadingRow); } catch (Exception e) { handleDebug(e); } } public boolean puoRiaprireInvioXml(long l_id_userLogon) { if (l_id_userLogon == 0L) return false; if (getUserLogon(l_id_userLogon).getGrantType("RIAPRI_FATTURA_XML", false) > 0L) return true; return false; } public Vectumerator findDocFiglioPadreByPadre() { if (getId_documento() == 0L) return AB_EMPTY_VECTUMERATOR; DocFiglioPadre dfp = new DocFiglioPadre(getApFull()); return dfp.findByPadre(getId_documento()); } public Vectumerator findDocFiglioPadreByFiglio() { if (getId_documento() == 0L) return AB_EMPTY_VECTUMERATOR; DocFiglioPadre dfp = new DocFiglioPadre(getApFull()); return dfp.findByFiglio(getId_documento()); } public String getDescDocFiglioPadreByFiglio() { if (getId_documento() == 0L) return ""; Vectumerator vec = findDocFiglioPadreByFiglio(); StringBuilder sb = new StringBuilder(); while (vec.hasMoreElements()) { DocFiglioPadre row = (DocFiglioPadre)vec.nextElement(); sb.append(row.getDocumentoPadre().getNumeroDocumentoCompleto() + " " + row.getDocumentoPadre().getNumeroDocumentoCompleto()); if (vec.hasMoreElements()) sb.append("\n"); } return sb.toString(); } public String getDescDocFiglioPadreByFiglioHtml() { return DBAdapter.convertStringToHtml(getDescDocFiglioPadreByFiglio()); } public String getDescDocFiglioPadreByPadre() { if (getId_documento() == 0L) return ""; Vectumerator vec = findDocFiglioPadreByPadre(); StringBuilder sb = new StringBuilder(); while (vec.hasMoreElements()) { DocFiglioPadre row = (DocFiglioPadre)vec.nextElement(); sb.append( row.getDocumentoFiglio().getNumeroDocumentoCompleto() + " " + row.getDocumentoFiglio().getNumeroDocumentoCompleto()); if (vec.hasMoreElements()) sb.append("\n"); } return sb.toString(); } public String getDescDocFiglioPadreByPadreHtml() { return DBAdapter.convertStringToHtml(getDescDocFiglioPadreByPadre()); } public ResParm ricalcolaDisposizioneTaglio() { if (getId_documento() == 0L || getTipoDocumento().getFlgTipologia() != 220L) return new ResParm(false, "Errore! Documento nullo o non e' una disposizione di taglio"); ResParm rp = new ResParm(true); RigaDocumentoCR rdCR = new RigaDocumentoCR(getApFull()); rdCR.setId_documento(getId_documento()); Vectumerator vecRo = findRigheDocumento(rdCR, 0, 0, false); while (vecRo.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRo.nextElement(); rp.append(row.delete()); } if (rp.getStatus()) { Vectumerator vecDfp = findDocFiglioPadreByPadre(); long l_id_documentoOrdineTaglio = 0L; while (vecDfp.hasMoreElements()) { DocFiglioPadre rowOrdineTaglio = (DocFiglioPadre)vecDfp.nextElement(); l_id_documentoOrdineTaglio = rowOrdineTaglio.getId_documentoFiglio(); rowOrdineTaglio.delete(); associaOrdineTaglioADosposizioneTaglio(l_id_documentoOrdineTaglio); } } else { rp.setMsg("Errore ricalcolo disposizioni taglio: " + rp.getMsg()); } if (!rp.getStatus()) rp.setMsg("Errore ricalcolo disposizioni taglio: " + rp.getMsg()); return rp; } public static final synchronized ResParm calcolaTessutiTaglio(Documento bean, String lang) { boolean nuovo = true; if (nuovo) return calcolaTessutiTaglioNew(bean, lang); return calcolaTessutiTaglioNONOTTIMIZZATO(bean, lang); } public static final synchronized ResParm calcolaTessutiTaglioNew(Documento bean, String lang) { ResParm rp = new ResParm(true); boolean debug = false; String debugInfo = "calcolaTessutiTaglio"; RigaDocumento rd = new RigaDocumento(bean.getApFull()); rd.impostaDaCancellareByDocumentoCodiceriga(bean.getId_documento(), 1L, true); rd.impostaDaCancellareByDocumentoCodiceriga(bean.getId_documento(), 100L, true); Vectumerator vecRd = bean.findRigheDocumento(0, 0, 0); if (vecRd.getTotNumberOfRecords() > 0) { Vectumerator vec = bean.getArticolo().findArticoliTessuto(); HashMap hmTess = new HashMap<>(); HashMap hmTessCol = new HashMap<>(); while (vec.hasMoreElements()) { ArticoloArticoloTessuto rowAAT = (ArticoloArticoloTessuto)vec.nextElement(); if (rowAAT.getId_articoloTessutoColore() == 0L) if (!hmTess.containsKey(Long.valueOf(rowAAT.getId_articoloTessuto()))) { System.out.println("AT: " + rowAAT.getId_articoloTessuto()); ArticoloTessuto at = rowAAT.getArticoloTessuto(); hmTess.put(Long.valueOf(rowAAT.getId_articoloTessuto()), at); } if (rowAAT.getId_articoloTessutoColore() > 0L) { if (hmTessCol.containsKey(Long.valueOf(rowAAT.getId_articoloTessutoColore()))) continue; System.out.println("AC: " + rowAAT.getId_articoloTessutoColore()); ArticoloTessutoColore atc = rowAAT.getArticoloTessutoColore(); hmTessCol.put(Long.valueOf(rowAAT.getId_articoloTessutoColore()), atc); } } Set keySet = hmTess.keySet(); for (Long key : keySet) { ArticoloTessuto at = hmTess.get(key); RigaDocumento rdTessTaglio = new RigaDocumento(bean.getApFull()); rdTessTaglio.findByDocumentoArticoloTessuto(bean.getId_documento(), at.getId_articoloTessuto(), 100L); if (rdTessTaglio.getId_rigaDocumento() > 0L) { rdTessTaglio.setFlgDaCancellare(0L); } else { rdTessTaglio.setFlgCodiceRiga(100L); rdTessTaglio.setDescrizioneRiga(at.getDescrizioneCompleta(lang)); rdTessTaglio.setId_documento(bean.getId_documento()); rdTessTaglio.setId_articoloTessuto(at.getId_articoloTessuto()); } if (rdTessTaglio.getCapiPerTelo() == 0L) if (at.getCapiPerTelo() > 0L) { rdTessTaglio.setCapiPerTelo(at.getCapiPerTelo()); } else { rdTessTaglio.setCapiPerTelo(8L); } rp = rdTessTaglio.superSave(); } Set keySetCol = hmTessCol.keySet(); for (Long key : keySetCol) { ArticoloTessutoColore atc = hmTessCol.get(key); RigaDocumento rdTessTaglio = new RigaDocumento(bean.getApFull()); rdTessTaglio.findByDocumentoArticoloTessutoColore(bean.getId_documento(), atc.getId_articoloTessutoColore(), 100L); if (rdTessTaglio.getId_rigaDocumento() > 0L) { rdTessTaglio.setFlgDaCancellare(0L); } else { rdTessTaglio.setFlgCodiceRiga(100L); rdTessTaglio.setDescrizioneRiga(atc.getDescrizioneCompleta(lang)); rdTessTaglio.setId_documento(bean.getId_documento()); rdTessTaglio.setId_articoloTessutoColore(atc.getId_articoloTessutoColore()); } if (rdTessTaglio.getCapiPerTelo() == 0L) rdTessTaglio.setCapiPerTelo(8L); rp = rdTessTaglio.superSave(); } ArticoloArticoloTessuto att = new ArticoloArticoloTessuto(bean.getApFull()); boolean salvaNtr = true; while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); NumeroTeliRiga ntr = new NumeroTeliRiga(bean.getApFull()); Vectumerator vec100 = bean.findRigheDocumentoDisposizioneTaglio(0, 0, 2); while (vec100.hasMoreElements()) { RigaDocumento row100 = (RigaDocumento)vec100.nextElement(); if (row.isTessutoPrincipale(row100.getId_articoloTessuto(), row100.getId_articoloTessutoColore())) { ntr.findByRDArticoloRDTessuto(row.getId_rigaDocumento(), row100.getId_rigaDocumento()); if (ntr.getId_numeroTeliRiga() > 0L); salvaNtr = true; if (row100.getId_articoloTessutoColore() > 0L) { att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), row100.getId_articoloTessutoColore()); if (att.getId_articoloArticoloTessuto() == 0L) salvaNtr = false; } if (salvaNtr) { ntr.setId_rigaDocumentoArticolo(row.getId_rigaDocumento()); ntr.setId_rigaDocumentoTessuto(row100.getId_rigaDocumento()); long numTeli = (long)Math.ceil(row.getNrOriginale() / (double)row100.getCapiPerTelo()); ntr.setNumTeliRiga(numTeli); long nrNew = numTeli * row100.getCapiPerTelo(); if ((double)nrNew >= row.getNrOriginale()) { row.setNr((double)nrNew); row.superSave(); } if (att.getId_articoloArticoloTessuto() <= 0L) att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), 0L); DoubleOperator metriRd = new DoubleOperator(row.getNr()); metriRd.multiply(att.getMtATT()); metriRd.setScale(2, 5); ntr.setMtTessutoRiga(metriRd.getResult()); ntr.save(); } att.setId_articoloArticoloTessuto(0L); att.setDBState(0); } } vec100.moveFirst(); while (vec100.hasMoreElements()) { RigaDocumento row100 = (RigaDocumento)vec100.nextElement(); if (!row.isTessutoPrincipale(row100.getId_articoloTessuto(), row100.getId_articoloTessutoColore())) { ntr.findByRDArticoloRDTessuto(row.getId_rigaDocumento(), row100.getId_rigaDocumento()); if (ntr.getId_numeroTeliRiga() > 0L); salvaNtr = true; if (row100.getId_articoloTessutoColore() > 0L) { att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), row100.getId_articoloTessutoColore()); if (att.getId_articoloArticoloTessuto() == 0L) salvaNtr = false; } if (salvaNtr) { ntr.setId_rigaDocumentoArticolo(row.getId_rigaDocumento()); ntr.setId_rigaDocumentoTessuto(row100.getId_rigaDocumento()); long numTeli = (long)Math.ceil(row.getNr() / (double)row100.getCapiPerTelo()); System.out.println(numTeli); ntr.setNumTeliRiga(numTeli); if (att.getId_articoloArticoloTessuto() <= 0L) att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), 0L); long nrNew = numTeli * row100.getCapiPerTelo(); DoubleOperator metriRd = new DoubleOperator((float)nrNew); metriRd.multiply(att.getMtATT()); metriRd.setScale(2, 5); ntr.setMtTessutoRiga(metriRd.getResult()); ntr.save(); } att.setId_articoloArticoloTessuto(0L); att.setDBState(0); } } } Vectumerator vecTessTaglio = findTessutiPerTaglio(bean); while (vecTessTaglio.hasMoreElements()) { ArticoloTessutoColore row = (ArticoloTessutoColore)vecTessTaglio.nextElement(); rd = new RigaDocumento(bean.getApFull()); rd.findByDocumentoArticoloTessutoColore(bean.getId_documento(), row.getId_articoloTessutoColore(), 1L); if (rd.getId_rigaDocumento() > 0L) { rd.setMt(row.getMtLavorazioneTaglio()); } else { rd.setId_documento(bean.getId_documento()); rd.setFlgCodiceRiga(1L); rd.setId_articoloTessutoColore(row.getId_articoloTessutoColore()); rd.setId_articoloTessuto(rd.getArticoloTessutoColore().getId_articoloTessuto()); rd.setMt(row.getMtLavorazioneTaglio()); rd.setDescrizioneRiga(rd.getArticoloTessutoColore().getDescrizioneCompleta()); rd.setId_causaleMagazzino(bean.getTipoDocumento().getId_causaleMagazzino2()); } rd.setFlgDaCancellare(0L); addRigaDocumentoTessuto(bean, rd, 1L); boolean trovato = false; if (rd.getId_articoloTessutoColore() > 0L && hmTessCol.containsKey(Long.valueOf(rd.getId_articoloTessutoColore()))) { ArticoloTessutoColore atc = hmTessCol.get(Long.valueOf(rd.getId_articoloTessutoColore())); DoubleOperator dop = new DoubleOperator(atc.getMtLavorazioneTaglio()); dop.add(rd.getMt()); atc.setMtLavorazioneTaglio(dop.getResult()); hmTessCol.put(Long.valueOf(rd.getId_articoloTessutoColore()), atc); trovato = true; } if (!trovato && hmTess.containsKey(Long.valueOf(rd.getId_articoloTessuto()))) { ArticoloTessuto at = hmTess.get(Long.valueOf(rd.getId_articoloTessuto())); DoubleOperator dop = new DoubleOperator(at.getMtLavorazioneTaglio()); dop.add(rd.getMt()); at.setMtLavorazioneTaglio(dop.getResult()); hmTess.put(Long.valueOf(rd.getId_articoloTessuto()), at); } } while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); if (row.getFlgDaCancellare() == 1L) { row.delete(); continue; } NumeroTeliRiga ntr = new NumeroTeliRiga(bean.getApFull()); Vectumerator vec100 = bean.findRigheDocumentoDisposizioneTaglio(0, 0, 2); while (vec100.hasMoreElements()) { RigaDocumento row100 = (RigaDocumento)vec100.nextElement(); ntr.findByRDArticoloRDTessuto(row.getId_rigaDocumento(), row100.getId_rigaDocumento()); if (ntr.getId_numeroTeliRiga() > 0L); salvaNtr = true; if (row100.getId_articoloTessutoColore() > 0L) { att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), row100.getId_articoloTessutoColore()); if (att.getId_articoloArticoloTessuto() == 0L) salvaNtr = false; } if (salvaNtr) { ntr.setId_rigaDocumentoArticolo(row.getId_rigaDocumento()); ntr.setId_rigaDocumentoTessuto(row100.getId_rigaDocumento()); long numTeli = (long)Math.ceil(row.getNr() / (double)row100.getCapiPerTelo()); ntr.setNumTeliRiga(numTeli); long nrNew = numTeli * row100.getCapiPerTelo(); if ((double)nrNew > row.getNr()) { row.setNr((double)nrNew); row.superSave(); } if (att.getId_articoloArticoloTessuto() <= 0L) att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), 0L); DoubleOperator metriRd = new DoubleOperator(row.getNr()); metriRd.multiply(att.getMtATT()); metriRd.setScale(2, 5); ntr.setMtTessutoRiga(metriRd.getResult()); ntr.save(); } att.setId_articoloArticoloTessuto(0L); att.setDBState(0); } } } RigaDocumentoCR CR = new RigaDocumentoCR(); CR.setFlgDaCancellare(1L); CR.setId_documento(bean.getId_documento()); vecRd = rd.findByCR(CR, 0, 0); while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); row.delete(); } return rp; } public static final synchronized ResParm calcolaDisposizioneTaglio(Documento bean, String lang) { ResParm rp = new ResParm(true); boolean debug = false; String debugInfo = "calcolaTessutiTaglio"; RigaDocumento rd = new RigaDocumento(bean.getApFull()); rd.impostaDaCancellareByDocumentoCodiceriga(bean.getId_documento(), 100L, true); Vectumerator vecRd = bean.findRigheDocumento(0, 0, 0); if (vecRd.getTotNumberOfRecords() > 0) { Vectumerator vec = bean.getArticolo().findArticoliTessuto(); HashMap hmTess = new HashMap<>(); HashMap hmTessCol = new HashMap<>(); while (vec.hasMoreElements()) { ArticoloArticoloTessuto rowAAT = (ArticoloArticoloTessuto)vec.nextElement(); if (rowAAT.getId_articoloTessutoColore() == 0L) if (!hmTess.containsKey(Long.valueOf(rowAAT.getId_articoloTessuto()))) { System.out.println("AT: " + rowAAT.getId_articoloTessuto()); ArticoloTessuto at = rowAAT.getArticoloTessuto(); hmTess.put(Long.valueOf(rowAAT.getId_articoloTessuto()), at); } if (rowAAT.getId_articoloTessutoColore() > 0L) { if (hmTessCol.containsKey(Long.valueOf(rowAAT.getId_articoloTessutoColore()))) continue; System.out.println("AC: " + rowAAT.getId_articoloTessutoColore()); ArticoloTessutoColore atc = rowAAT.getArticoloTessutoColore(); hmTessCol.put(Long.valueOf(rowAAT.getId_articoloTessutoColore()), atc); } } Vectumerator vecTessTaglio = findTessutiPerTaglio(bean); while (vecTessTaglio.hasMoreElements()) { ArticoloTessutoColore row = (ArticoloTessutoColore)vecTessTaglio.nextElement(); rd = new RigaDocumento(bean.getApFull()); rd.findByDocumentoArticoloTessutoColore(bean.getId_documento(), row.getId_articoloTessutoColore(), 1L); if (rd.getId_rigaDocumento() > 0L) { rd.setMt(row.getMtLavorazioneTaglio()); } else { rd.setId_documento(bean.getId_documento()); rd.setFlgCodiceRiga(1L); rd.setId_articoloTessutoColore(row.getId_articoloTessutoColore()); rd.setId_articoloTessuto(rd.getArticoloTessutoColore().getId_articoloTessuto()); rd.setMt(row.getMtLavorazioneTaglio()); rd.setDescrizioneRiga(rd.getArticoloTessutoColore().getDescrizioneCompleta()); rd.setId_causaleMagazzino(bean.getTipoDocumento().getId_causaleMagazzino2()); } rd.setFlgDaCancellare(0L); addRigaDocumentoTessuto(bean, rd, 1L); boolean trovato = false; if (rd.getId_articoloTessutoColore() > 0L && hmTessCol.containsKey(Long.valueOf(rd.getId_articoloTessutoColore()))) { ArticoloTessutoColore atc = hmTessCol.get(Long.valueOf(rd.getId_articoloTessutoColore())); DoubleOperator dop = new DoubleOperator(atc.getMtLavorazioneTaglio()); dop.add(rd.getMt()); atc.setMtLavorazioneTaglio(dop.getResult()); hmTessCol.put(Long.valueOf(rd.getId_articoloTessutoColore()), atc); trovato = true; } if (!trovato && hmTess.containsKey(Long.valueOf(rd.getId_articoloTessuto()))) { ArticoloTessuto at = hmTess.get(Long.valueOf(rd.getId_articoloTessuto())); DoubleOperator dop = new DoubleOperator(at.getMtLavorazioneTaglio()); dop.add(rd.getMt()); at.setMtLavorazioneTaglio(dop.getResult()); hmTess.put(Long.valueOf(rd.getId_articoloTessuto()), at); } } Set keySet = hmTess.keySet(); for (Long key : keySet) { ArticoloTessuto at = hmTess.get(key); RigaDocumento rdTessTaglio = new RigaDocumento(bean.getApFull()); rdTessTaglio.findByDocumentoArticoloTessuto(bean.getId_documento(), at.getId_articoloTessuto(), 100L); if (rdTessTaglio.getId_rigaDocumento() > 0L) { rdTessTaglio.setFlgDaCancellare(0L); } else { rdTessTaglio.setFlgCodiceRiga(100L); rdTessTaglio.setDescrizioneRiga(at.getDescrizioneCompleta(lang)); rdTessTaglio.setId_documento(bean.getId_documento()); rdTessTaglio.setId_articoloTessuto(at.getId_articoloTessuto()); } if (rdTessTaglio.getCapiPerTelo() == 0L) if (at.getCapiPerTelo() > 0L) { rdTessTaglio.setCapiPerTelo(at.getCapiPerTelo()); } else { rdTessTaglio.setCapiPerTelo(8L); } rdTessTaglio.setMt(at.getMtLavorazioneTaglio()); rp = rdTessTaglio.superSave(); } Set keySetCol = hmTessCol.keySet(); for (Long key : keySetCol) { ArticoloTessutoColore atc = hmTessCol.get(key); RigaDocumento rdTessTaglio = new RigaDocumento(bean.getApFull()); rdTessTaglio.findByDocumentoArticoloTessutoColore(bean.getId_documento(), atc.getId_articoloTessutoColore(), 100L); if (rdTessTaglio.getId_rigaDocumento() > 0L) { rdTessTaglio.setFlgDaCancellare(0L); } else { rdTessTaglio.setFlgCodiceRiga(100L); rdTessTaglio.setDescrizioneRiga(atc.getDescrizioneCompleta(lang)); rdTessTaglio.setId_documento(bean.getId_documento()); rdTessTaglio.setId_articoloTessutoColore(atc.getId_articoloTessutoColore()); } rdTessTaglio.setCapiPerTelo(8L); rdTessTaglio.setMt(atc.getMtLavorazioneTaglio()); rp = rdTessTaglio.superSave(); } ArticoloArticoloTessuto att = new ArticoloArticoloTessuto(bean.getApFull()); boolean salvaNtr = true; while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); if (row.getFlgDaCancellare() == 1L) { row.delete(); continue; } NumeroTeliRiga ntr = new NumeroTeliRiga(bean.getApFull()); Vectumerator vec100 = bean.findRigheDocumentoDisposizioneTaglio(0, 0, 2); while (vec100.hasMoreElements()) { RigaDocumento row100 = (RigaDocumento)vec100.nextElement(); ntr.findByRDArticoloRDTessuto(row.getId_rigaDocumento(), row100.getId_rigaDocumento()); if (ntr.getId_numeroTeliRiga() > 0L); salvaNtr = true; if (row100.getId_articoloTessutoColore() > 0L) { att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), row100.getId_articoloTessutoColore()); if (att.getId_articoloArticoloTessuto() == 0L) salvaNtr = false; } if (salvaNtr) { ntr.setId_rigaDocumentoArticolo(row.getId_rigaDocumento()); ntr.setId_rigaDocumentoTessuto(row100.getId_rigaDocumento()); long numTeli = (long)Math.ceil(row.getNr() / (double)row100.getCapiPerTelo()); ntr.setNumTeliRiga(numTeli); if (att.getId_articoloArticoloTessuto() <= 0L) att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), 0L); DoubleOperator metriRd = new DoubleOperator(row.getNr()); metriRd.multiply(att.getMtATT()); metriRd.setScale(2, 5); ntr.setMtTessutoRiga(metriRd.getResult()); ntr.save(); } att.setId_articoloArticoloTessuto(0L); att.setDBState(0); } } } RigaDocumentoCR CR = new RigaDocumentoCR(); CR.setFlgDaCancellare(1L); CR.setId_documento(bean.getId_documento()); vecRd = rd.findByCR(CR, 0, 0); while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); row.delete(); } return rp; } public ResParm creaFileMailingList(DocumentoCR CR) { ResParm rp = new ResParm(); try { CR.setFlgMl(1L); CR.setFlgOrderBy(2L); Vectumerator vec = findByCR(CR, 0, 0); CR.setFileName(DBAdapter.getTimeNameForFileUpload() + ".txt"); String fullFileName = getPathTmpFull() + getPathTmpFull(); FileWr fw = new FileWr(fullFileName, "UTF-8"); HashSet mailInviateHM = new HashSet<>(); System.out.println("---------------------- CREAZIONE MAILING LIST FATTURE.... ----------------------"); while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); String email = row.getClifor().getEMail().trim(); if (!email.isEmpty()) { if (!mailInviateHM.contains(email)) { mailInviateHM.add(email); fw.writeLine(email); continue; } System.out.println("doppione: " + email); } } System.out.println("----------------------"); fw.closeFile(); if (mailInviateHM.size() > 0) { rp.setStatus(true); rp.setMsg(getPathTmp() + getPathTmp()); } else { rp.setStatus(false); rp.setMsg("Elenco mailing listo vuoto!!"); } } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } return rp; } public static final synchronized ResParm calcolaTessutiTaglioNONOTTIMIZZATO(Documento bean, String lang) { ResParm rp = new ResParm(true); boolean debug = false; String debugInfo = "calcolaTessutiTaglio"; RigaDocumento rd = new RigaDocumento(bean.getApFull()); rd.impostaDaCancellareByDocumentoCodiceriga(bean.getId_documento(), 1L, true); rd.impostaDaCancellareByDocumentoCodiceriga(bean.getId_documento(), 100L, true); Vectumerator vecRd = bean.findRigheDocumento(0, 0, 0); if (vecRd.getTotNumberOfRecords() > 0) { Vectumerator vec = bean.getArticolo().findArticoliTessuto(); HashMap hmTess = new HashMap<>(); HashMap hmTessCol = new HashMap<>(); while (vec.hasMoreElements()) { ArticoloArticoloTessuto rowAAT = (ArticoloArticoloTessuto)vec.nextElement(); if (rowAAT.getId_articoloTessutoColore() == 0L) if (!hmTess.containsKey(Long.valueOf(rowAAT.getId_articoloTessuto()))) { System.out.println("AT: " + rowAAT.getId_articoloTessuto()); ArticoloTessuto at = rowAAT.getArticoloTessuto(); hmTess.put(Long.valueOf(rowAAT.getId_articoloTessuto()), at); } if (rowAAT.getId_articoloTessutoColore() > 0L) { if (hmTessCol.containsKey(Long.valueOf(rowAAT.getId_articoloTessutoColore()))) continue; System.out.println("AC: " + rowAAT.getId_articoloTessutoColore()); ArticoloTessutoColore atc = rowAAT.getArticoloTessutoColore(); hmTessCol.put(Long.valueOf(rowAAT.getId_articoloTessutoColore()), atc); } } Vectumerator vecTessTaglio = findTessutiPerTaglio(bean); while (vecTessTaglio.hasMoreElements()) { ArticoloTessutoColore row = (ArticoloTessutoColore)vecTessTaglio.nextElement(); rd = new RigaDocumento(bean.getApFull()); rd.findByDocumentoArticoloTessutoColore(bean.getId_documento(), row.getId_articoloTessutoColore(), 1L); if (rd.getId_rigaDocumento() > 0L) { rd.setMt(row.getMtLavorazioneTaglio()); } else { rd.setId_documento(bean.getId_documento()); rd.setFlgCodiceRiga(1L); rd.setId_articoloTessutoColore(row.getId_articoloTessutoColore()); rd.setId_articoloTessuto(rd.getArticoloTessutoColore().getId_articoloTessuto()); rd.setMt(row.getMtLavorazioneTaglio()); rd.setDescrizioneRiga(rd.getArticoloTessutoColore().getDescrizioneCompleta()); rd.setId_causaleMagazzino(bean.getTipoDocumento().getId_causaleMagazzino2()); } rd.setFlgDaCancellare(0L); addRigaDocumentoTessuto(bean, rd, 1L); boolean trovato = false; if (rd.getId_articoloTessutoColore() > 0L && hmTessCol.containsKey(Long.valueOf(rd.getId_articoloTessutoColore()))) { ArticoloTessutoColore atc = hmTessCol.get(Long.valueOf(rd.getId_articoloTessutoColore())); DoubleOperator dop = new DoubleOperator(atc.getMtLavorazioneTaglio()); dop.add(rd.getMt()); atc.setMtLavorazioneTaglio(dop.getResult()); hmTessCol.put(Long.valueOf(rd.getId_articoloTessutoColore()), atc); trovato = true; } if (!trovato && hmTess.containsKey(Long.valueOf(rd.getId_articoloTessuto()))) { ArticoloTessuto at = hmTess.get(Long.valueOf(rd.getId_articoloTessuto())); DoubleOperator dop = new DoubleOperator(at.getMtLavorazioneTaglio()); dop.add(rd.getMt()); at.setMtLavorazioneTaglio(dop.getResult()); hmTess.put(Long.valueOf(rd.getId_articoloTessuto()), at); } } Set keySet = hmTess.keySet(); for (Long key : keySet) { ArticoloTessuto at = hmTess.get(key); RigaDocumento rdTessTaglio = new RigaDocumento(bean.getApFull()); rdTessTaglio.findByDocumentoArticoloTessuto(bean.getId_documento(), at.getId_articoloTessuto(), 100L); if (rdTessTaglio.getId_rigaDocumento() > 0L) { rdTessTaglio.setFlgDaCancellare(0L); } else { rdTessTaglio.setFlgCodiceRiga(100L); rdTessTaglio.setDescrizioneRiga(at.getDescrizioneCompleta(lang)); rdTessTaglio.setId_documento(bean.getId_documento()); rdTessTaglio.setId_articoloTessuto(at.getId_articoloTessuto()); } if (rdTessTaglio.getCapiPerTelo() == 0L) rdTessTaglio.setCapiPerTelo(8L); rdTessTaglio.setMt(at.getMtLavorazioneTaglio()); rp = rdTessTaglio.superSave(); } Set keySetCol = hmTessCol.keySet(); for (Long key : keySetCol) { ArticoloTessutoColore atc = hmTessCol.get(key); RigaDocumento rdTessTaglio = new RigaDocumento(bean.getApFull()); rdTessTaglio.findByDocumentoArticoloTessutoColore(bean.getId_documento(), atc.getId_articoloTessutoColore(), 100L); if (rdTessTaglio.getId_rigaDocumento() > 0L) { rdTessTaglio.setFlgDaCancellare(0L); } else { rdTessTaglio.setFlgCodiceRiga(100L); rdTessTaglio.setDescrizioneRiga(atc.getDescrizioneCompleta(lang)); rdTessTaglio.setId_documento(bean.getId_documento()); rdTessTaglio.setId_articoloTessutoColore(atc.getId_articoloTessutoColore()); } if (rdTessTaglio.getCapiPerTelo() == 0L) rdTessTaglio.setCapiPerTelo(8L); rdTessTaglio.setMt(atc.getMtLavorazioneTaglio()); rp = rdTessTaglio.superSave(); } ArticoloArticoloTessuto att = new ArticoloArticoloTessuto(bean.getApFull()); boolean salvaNtr = true; while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); if (row.getFlgDaCancellare() == 1L) { row.delete(); continue; } NumeroTeliRiga ntr = new NumeroTeliRiga(bean.getApFull()); Vectumerator vec100 = bean.findRigheDocumentoDisposizioneTaglio(0, 0, 2); while (vec100.hasMoreElements()) { RigaDocumento row100 = (RigaDocumento)vec100.nextElement(); ntr.findByRDArticoloRDTessuto(row.getId_rigaDocumento(), row100.getId_rigaDocumento()); if (ntr.getId_numeroTeliRiga() > 0L); salvaNtr = true; if (row100.getId_articoloTessutoColore() > 0L) { att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), row100.getId_articoloTessutoColore()); if (att.getId_articoloArticoloTessuto() == 0L) salvaNtr = false; } if (salvaNtr) { ntr.setId_rigaDocumentoArticolo(row.getId_rigaDocumento()); ntr.setId_rigaDocumentoTessuto(row100.getId_rigaDocumento()); long numTeli = (long)Math.ceil(row.getNr() / (double)row100.getCapiPerTelo()); ntr.setNumTeliRiga(numTeli); long nrNew = numTeli * row100.getCapiPerTelo(); if ((double)nrNew > row.getNr()) { row.setNr((double)nrNew); row.superSave(); } if (att.getId_articoloArticoloTessuto() <= 0L) att.findByArticoloVarianteArticoloTessutoColore(row.getId_articoloVariante(), row100.getId_articoloTessuto(), 0L); DoubleOperator metriRd = new DoubleOperator(row.getNr()); metriRd.multiply(att.getMtATT()); metriRd.setScale(2, 5); ntr.setMtTessutoRiga(metriRd.getResult()); ntr.save(); } att.setId_articoloArticoloTessuto(0L); att.setDBState(0); } } } RigaDocumentoCR CR = new RigaDocumentoCR(); CR.setFlgDaCancellare(1L); CR.setId_documento(bean.getId_documento()); vecRd = rd.findByCR(CR, 0, 0); while (vecRd.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRd.nextElement(); row.delete(); } return rp; } public static final synchronized ResParm calcolaTessutiTaglioOld(Documento bean, String lang) { ResParm rp = new ResParm(true); boolean debug = false; String debugInfo = "calcolaTessutiTaglio"; Vectumerator vecRdTess = bean.findRigheDocumento2(0, 0, 2); while (vecRdTess.hasMoreElements()) { RigaDocumento rowRdTess = (RigaDocumento)vecRdTess.nextElement(); rowRdTess.delete(); } Vectumerator vecRdTag = bean.findRigheDocumentoDisposizioneTaglio(0, 0, 2); while (vecRdTag.hasMoreElements()) { RigaDocumento rowRdTess = (RigaDocumento)vecRdTag.nextElement(); rowRdTess.delete(); } Vectumerator vec = bean.getArticolo().findArticoliTessuto(); HashMap hmTess = new HashMap<>(); HashMap hmTessCol = new HashMap<>(); while (vec.hasMoreElements()) { ArticoloArticoloTessuto rowAAT = (ArticoloArticoloTessuto)vec.nextElement(); if (rowAAT.getId_articoloTessutoColore() == 0L) if (!hmTess.containsKey(Long.valueOf(rowAAT.getId_articoloTessuto()))) { System.out.println("AT: " + rowAAT.getId_articoloTessuto()); ArticoloTessuto at = rowAAT.getArticoloTessuto(); hmTess.put(Long.valueOf(rowAAT.getId_articoloTessuto()), at); } if (rowAAT.getId_articoloTessutoColore() > 0L) { if (hmTessCol.containsKey(Long.valueOf(rowAAT.getId_articoloTessutoColore()))) continue; System.out.println("AC: " + rowAAT.getId_articoloTessutoColore()); ArticoloTessutoColore atc = rowAAT.getArticoloTessutoColore(); hmTessCol.put(Long.valueOf(rowAAT.getId_articoloTessutoColore()), atc); } } Vectumerator vecTessTaglio = findTessutiPerTaglio(bean); while (vecTessTaglio.hasMoreElements()) { ArticoloTessutoColore row = (ArticoloTessutoColore)vecTessTaglio.nextElement(); RigaDocumento rd = new RigaDocumento(bean.getApFull()); rd.findByDocumentoArticoloTessutoColore(bean.getId_documento(), row.getId_articoloTessutoColore(), 1L); if (rd.getId_rigaDocumento() > 0L) { rd.setMt(row.getMtLavorazioneTaglio()); } else { rd.setId_documento(bean.getId_documento()); rd.setFlgCodiceRiga(1L); rd.setId_articoloTessutoColore(row.getId_articoloTessutoColore()); rd.setId_articoloTessuto(rd.getArticoloTessutoColore().getId_articoloTessuto()); rd.setMt(row.getMtLavorazioneTaglio()); rd.setDescrizioneRiga(rd.getArticoloTessutoColore().getDescrizioneCompleta()); rd.setId_causaleMagazzino(bean.getTipoDocumento().getId_causaleMagazzino2()); } addRigaDocumentoTessuto(bean, rd, 1L); boolean trovato = false; if (rd.getId_articoloTessutoColore() > 0L && hmTessCol.containsKey(Long.valueOf(rd.getId_articoloTessutoColore()))) { ArticoloTessutoColore atc = hmTessCol.get(Long.valueOf(rd.getId_articoloTessutoColore())); DoubleOperator dop = new DoubleOperator(atc.getMtLavorazioneTaglio()); dop.add(rd.getMt()); atc.setMtLavorazioneTaglio(dop.getResult()); hmTessCol.put(Long.valueOf(rd.getId_articoloTessutoColore()), atc); trovato = true; } if (!trovato && hmTess.containsKey(Long.valueOf(rd.getId_articoloTessuto()))) { ArticoloTessuto at = hmTess.get(Long.valueOf(rd.getId_articoloTessuto())); DoubleOperator dop = new DoubleOperator(at.getMtLavorazioneTaglio()); dop.add(rd.getMt()); at.setMtLavorazioneTaglio(dop.getResult()); hmTess.put(Long.valueOf(rd.getId_articoloTessuto()), at); } } Set keySet = hmTess.keySet(); for (Long key : keySet) { ArticoloTessuto at = hmTess.get(key); RigaDocumento rdTessTaglio = new RigaDocumento(bean.getApFull()); rdTessTaglio.setFlgCodiceRiga(100L); rdTessTaglio.setDescrizioneRiga(at.getDescrizioneCompleta(lang)); rdTessTaglio.setId_documento(bean.getId_documento()); rdTessTaglio.setId_articoloTessuto(at.getId_articoloTessuto()); rdTessTaglio.setCapiPerTelo(8L); rdTessTaglio.setMt(at.getMtLavorazioneTaglio()); rp = rdTessTaglio.superSave(); } Set keySetCol = hmTessCol.keySet(); for (Long key : keySetCol) { ArticoloTessutoColore atc = hmTessCol.get(key); RigaDocumento rdTessTaglio = new RigaDocumento(bean.getApFull()); rdTessTaglio.setFlgCodiceRiga(100L); rdTessTaglio.setDescrizioneRiga(atc.getDescrizioneCompleta(lang)); rdTessTaglio.setId_documento(bean.getId_documento()); rdTessTaglio.setId_articoloTessutoColore(atc.getId_articoloTessutoColore()); rdTessTaglio.setCapiPerTelo(8L); rdTessTaglio.setMt(atc.getMtLavorazioneTaglio()); rp = rdTessTaglio.superSave(); } return rp; } public long getNumDisposizioniByArticolo() { if (getId_articolo() > 0L) return getNumDisposizioniByArticolo(getId_articolo()); return 0L; } public long getNumDisposizioniByArticolo(long l_id_articolo) { StringBuffer s_Sql_Find = new StringBuffer("select count(id_documento) as _count from DOCUMENTO AS D inner join TIPO_DOCUMENTO AS T ON D.id_tipoDocumento=T.id_tipoDocumento inner join TIPOLOGIA_DOCUMENTO AS TD ON T.id_tipologiaDocumento=TD.id_tipologiaDocumento"); WcString wc = new WcString(); wc.addWc("TD.codice=220"); wc.addWc("D.id_articolo=" + l_id_articolo); String s_Sql_Group = ""; try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); return getCount(stmt, "_count"); } catch (SQLException e) { handleDebug(e); return 0L; } } public ResParm sendOrderMailMessageTuttofoto(Users l_user, boolean mailAdmin, boolean mailUser, boolean isPagamentoVariato, boolean isSpedito) { String lang = l_user.getLang(); lang = "it"; ResParm rp = new ResParm(true); if (getId_tipoDocumento() == getId_docOrdineWWW() && getTmstInvioMailOrdine() == null) sendOrderEbayWarningMessage(); String urlBase = getParm("CODA_MESSAGGI_IMG_URL_BASE").getTesto() + "_img/_imgArt/"; MailProperties mp = new MailProperties(); if (getId_documento() == 0L) { rp.setStatus(false); rp.setMsg("ERRORE! Codice Documento nullo! contattare l'amministratore del sito"); handleDebug(rp.getMsg(), 0); return rp; } try { int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Documento fattura = null; if (isSpedito) fattura = getDocumentoFiglioUno(); String subject = getMailSubject(); NumberFormat nf = getNf(); String notePagamento = "", statoPagamento = ""; String notaStato = " " + translate(getStatoOrdineWww(), lang) + " "; String linkOrdineDiretto = ""; String orderLine = ""; String orderLine2 = ""; DoubleOperator totaleCosto = new DoubleOperator(); double totaleQta = 0.0D; statoPagamento = translate("Metodo di pagamento scelto", lang) + ": " + translate("Metodo di pagamento scelto", lang); if (getStatoPagato() == 1L) statoPagamento = statoPagamento + "
" + statoPagamento + translate("Transazione n. ", lang) + " " + getDescTransaction() + " " + translate("del", lang); if (getStatoPagato() == 2L) statoPagamento = statoPagamento + "
" + statoPagamento + ": " + translate("Data Pagamento", lang); if (getStatoPagato() == 0L) { if (getFlgProcediPagamento() == 1L) { notePagamento = getTipoPagamento().getMsgMailProcedi(lang); if (getTipoPagamento().getFlgTipoPagamento() == 5L) notePagamento = notePagamento + "
" + getLinkOrdineWww() + ""; } else { notePagamento = getTipoPagamento().getMsgMailAspetta(lang); } } else { notePagamento = ""; } if (l_user.isProfileNoReg()) { linkOrdineDiretto = "
" + translate("Per accedere direttamente all'ordine: ", lang); linkOrdineDiretto = linkOrdineDiretto + "" + getLinkOrdineWwwNoReg(l_user) + ""; } if (getFlgStatoOrdineWww() == 2L) notaStato = translate(getParm("MSG_ORDINE_SPEDITO").getTesto(), lang); if (mailUser || isPagamentoVariato) { String mmFile = getCheckOutMailMessage(lang); if (isSpedito) mmFile = mmFile.replace(".html", "_spedito.html"); MailMessage mf = new MailMessage(getApFull(), mmFile); if (isSpedito) { mf.setString("dataSpedizione", getDataFormat().format(fattura.getDataSpedizione())); mf.setString("corriere", fattura.getVettore().getDescrizione()); mf.setString("nColli", String.valueOf(fattura.getNColli())); String temp = ""; if (getId_tipoPagamento() == 1L) temp = "La informiamo che alla consegna, il corriere richiedera' l'importo di " + nf.format(fattura.getTotaleDocumento()) + " euro del contrassegno"; if (!getNotaSpedizione().isEmpty()) temp = temp + "

" + temp; mf.setString("notaContrassegno", temp); if (!fattura.getVettore().getLinkTracking().isEmpty() && !fattura.getTrackingSpedizione().isEmpty()) { String id_docCrypt = crypt(String.valueOf(fattura.getId_documento())); String link = fattura.getVettore().getLinkTracking() + fattura.getVettore().getLinkTracking(); String track = "Potra' verificare la spedizione da domani mattina al seguente link "; mf.setString("tracking", track); } } mf.setQuestionMark(false); mf.setLong("id_ordine", getProgOrdineWww()); mf.setString("stato", translate(getStatoOrdineWww(), lang)); mf.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mf.setString("statoPagamento", statoPagamento); mf.setString("notaPagamento", notePagamento); mf.setLong("id_users", getClifor().getId_clifor()); mf.setString("nome", getClifor().getNome()); mf.setString("cognome", getClifor().getCognome()); mf.setString("indirizzo", getClifor().getIndirizzo()); mf.setString("numero", getClifor().getNumeroCivico()); if (getClifor().getCapZona().isEmpty()) { mf.setString("cap", getClifor().getCapComune()); } else { mf.setString("cap", getClifor().getCapZona()); } mf.setString("citta", getClifor().getDescrizioneComune()); mf.setString("provincia", getClifor().getProvinciaComune()); mf.setString("codfisc", getClifor().getCodFisc()); mf.setString("codSDI", getClifor().getCodiceIdentificativoFE()); mf.setString("pec", getClifor().getPec()); mf.setString("piva", getClifor().getPIva()); mf.setString("email", getClifor().getEMail()); mf.setString("nazione", getClifor().getNazione().getDescrizione(lang)); if (getFlgDeliveryType() == 2L) { mf.setString("indirizzoSped", "Presso punto di ritiro
" + getPudoDesc()); } else if (getIndirizzoSped().trim().equals("")) { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mf.setString("indirizzoSped", "c/o " + getPresso() + "
" + getClifor().getIndirizzo()); } mf.setString("numeroSped", getClifor().getNumeroCivico()); if (getClifor().getCapZona().isEmpty()) { mf.setString("capSped", getClifor().getCapComune()); } else { mf.setString("capSped", getClifor().getCapZona()); } mf.setString("cittaSped", getClifor().getDescrizioneComune()); mf.setString("provinciaSped", getClifor().getProvinciaComune()); mf.setString("nazioneSped", getClifor().getNazione().getDescrizione(lang)); } else { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getIndirizzoSped()); } else { mf.setString("indirizzoSped", " c/o " + getPresso() + "
" + getIndirizzoSped()); } mf.setString("numeroSped", getNumeroCivicoSped()); mf.setString("capSped", getCapSped()); mf.setString("cittaSped", getCittaSped()); mf.setString("provinciaSped", getProvinciaSped()); mf.setString("nazioneSped", getNazioneSped().getDescrizione(lang)); } Vectumerator enu = findRigheDocumento(0, 0, ordineInverso); while (enu.hasMoreElements()) { String imgSrc; RigaDocumento row = (RigaDocumento)enu.nextElement(); if (row.getId_articolo() > 0L) { imgSrc = ""; } else { imgSrc = ""; } orderLine = orderLine + " " + orderLine + imgSrc + "" + row.getDescrizioneRigaCompleta() + "" + nf.format(row.getImponibile()) + " " + row.getQuantita() + "\n"; totaleQta += row.getQuantita(); } mf.setString("orderline", orderLine); if (getTotaleScontiAbbuoniConIva() > 0.0D) { mf.setString("descSconto", "**** " + translate("SCONTO INCONDIZIONATO", lang) + " *****"); mf.setString("scontoInc", " - " + nf.format(getTotaleScontiAbbuoni())); } mf.setString("qta", nf.format(totaleQta)); mf.setString("totale", nf.format(getImponibileTotale())); mf.setString("totaleOrdine", nf.format(getTotaleDocumento())); mf.setString("iva", nf.format(getImportoIvaTotale())); mf.setString("speseSped", nf.format(getSpeseTrasporto())); mf.setString("speseSpedIva", nf.format(getSpeseTrasportoConIva())); if (getNotePagamento().isEmpty()) { mf.setString("nota", String.valueOf(getNotaAggiuntiva())); } else { mf.setString("nota", "" + getNotePagamento() + "
" + String.valueOf(getNotaAggiuntiva())); } mf.setLong("codiceOrdine", getProgOrdineWww()); mf.setString("telefono", getClifor().getCellulare() + " " + getClifor().getCellulare()); mf.setString("linkOrdineDiretto", linkOrdineDiretto); String theSubject = translate(subject, lang); String l_email = getClifor().getEMail(); if (mailUser) theSubject = theSubject + " - " + theSubject + " " + translate("Ordine n.", lang) + " - " + getProgOrdineWww(); if (isPagamentoVariato) { theSubject = theSubject + theSubject + " " + translate("Ordine n.", lang) + " - " + getProgOrdineWww() + " - "; theSubject = theSubject + theSubject; theSubject = theSubject + theSubject; } mp.put("TO", l_email); mp.put("BCC", getMailTo()); mp.setProperty("FROM", getParm("FROM").getTesto()); mp.put("SUBJECT", theSubject); mp.put("MSG", mf.getMessage()); mp.setProperty("ISHTML", "true"); rp = sendMailMessage(mp); if (rp.getStatus() && isSpedito) { fattura.setDataInvioMailSped(getToday()); fattura.save(); } } if (mailAdmin) { String mmfAdmMessage = getCheckOutMailMessage(lang); mmfAdmMessage = mmfAdmMessage.replace(".html", "_Adm.html"); MailMessage mfAdm = new MailMessage(getApFull(), mmfAdmMessage); mfAdm.setQuestionMark(false); mfAdm.setLong("id_ordine", getProgOrdineWww()); mfAdm.setString("stato", getStato()); mfAdm.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mfAdm.setString("statoPagamento", statoPagamento); mfAdm.setString("notaPagamento", notePagamento); mfAdm.setLong("id_users", getClifor().getId_clifor()); mfAdm.setLong("id_clifor", getClifor().getId_clifor()); mfAdm.setString("nominativo", getClifor().getCognome()); mfAdm.setString("nome", getClifor().getNome()); mfAdm.setString("cognome", getClifor().getCognome()); mfAdm.setString("indirizzo", getClifor().getIndirizzo()); mfAdm.setString("numero", getClifor().getNumeroCivico()); if (getClifor().getCapZona().isEmpty()) { mfAdm.setString("cap", getClifor().getCapComune()); } else { mfAdm.setString("cap", getClifor().getCapZona()); } mfAdm.setString("citta", getClifor().getDescrizioneComune()); mfAdm.setString("provincia", getClifor().getProvinciaComune()); mfAdm.setString("codfisc", getClifor().getCodFisc()); mfAdm.setString("codSDI", getClifor().getCodiceIdentificativoFE()); mfAdm.setString("pec", getClifor().getPec()); mfAdm.setString("piva", getClifor().getPIva()); mfAdm.setString("email", getClifor().getEMail()); if (getFlgDeliveryType() == 2L) { mfAdm.setString("indirizzoSped", "Presso punto di ritiro
" + getPudoDesc()); } else if (getIndirizzoSped().trim().equals("")) { if (getPresso().isEmpty()) { mfAdm.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mfAdm.setString("indirizzoSped", "c/o " + getPresso() + "
" + getClifor().getIndirizzo()); } mfAdm.setString("numeroSped", getClifor().getNumeroCivico()); if (getClifor().getCapZona().isEmpty()) { mfAdm.setString("capSped", getClifor().getCapComune()); } else { mfAdm.setString("capSped", getClifor().getCapZona()); } mfAdm.setString("cittaSped", getClifor().getDescrizioneComune()); mfAdm.setString("provinciaSped", getClifor().getProvinciaComune()); mfAdm.setString("nazioneSped", getClifor().getNazione().getDescrizione(lang)); } else { if (getPresso().isEmpty()) { mfAdm.setString("indirizzoSped", getIndirizzoSped()); } else { mfAdm.setString("indirizzoSped", "c/o " + getPresso() + "
" + getIndirizzoSped()); } mfAdm.setString("numeroSped", getNumeroCivicoSped()); mfAdm.setString("capSped", getCapSped()); mfAdm.setString("cittaSped", getCittaSped()); mfAdm.setString("provinciaSped", getProvinciaSped()); mfAdm.setString("nazioneSped", getNazioneSped().getDescrizione(lang)); } orderLine2 = ""; totaleCosto = new DoubleOperator(); totaleQta = 0.0D; String stileRicarico = ""; Vectumerator enu = findRigheDocumento(0, 0, ordineInverso); while (enu.hasMoreElements()) { RigaDocumento row = (RigaDocumento)enu.nextElement(); orderLine2 = orderLine2 + " " + orderLine2 + "" + row.getCodiceArticolo() + " " + row.getDescrizioneRigaCompleta() + "" + row.getArticolo().getCodiciAlternativi() + row.getArticolo().getScaffale() + ((row.getArticolo().getFlgEbay() == 1L) ? " EBAY " : "") + "" + ((row.getArticolo().getFlgStockOfferte() == 2L) ? " OUTLET " : "") + "" + getNf0().format(row.getArticolo().getQuantita()) + "" + nf.format(row.getArticolo().getCostoNetto()) + "" + row.getArticolo().getRicaricoEffettivoDaCostoNetto() + "" + nf.format(row.getImponibile()) + "" + nf.format(row.getSconto()) + "" + getNf0().format(row.getQuantita()) + "\n"; DoubleOperator totaleArticolo = new DoubleOperator(row.getImponibile()); totaleArticolo.multiply(row.getQuantita()); totaleCosto.add(totaleArticolo); totaleQta += row.getQuantita(); } mfAdm.setString("orderline", orderLine2); mfAdm.setString("qta", nf.format(totaleQta)); mfAdm.setString("iva", nf.format(getImportoIvaTotale())); mfAdm.setString("speseSped", nf.format(getSpeseTrasporto())); mfAdm.setString("speseSpedIva", nf.format(getSpeseTrasportoConIva())); mfAdm.setString("totale", nf.format(getImponibileTotale())); mfAdm.setString("totaleOrdine", nf.format(getTotaleDocumento())); if (getNotePagamento().isEmpty()) { mfAdm.setString("nota", String.valueOf(getNotaAggiuntiva())); } else { mfAdm.setString("nota", "" + getNotePagamento() + "
" + String.valueOf(getNotaAggiuntiva())); } mfAdm.setString("notaAmm", "Nota su cliente: " + String.valueOf(getClifor().getNota() + "
Nota su Ordine: " + getClifor().getNota())); mfAdm.setLong("codiceOrdine", getProgOrdineWww()); mfAdm.setString("telefono", getClifor().getCellulare() + " " + getClifor().getCellulare()); mfAdm.setString("orderline", orderLine2); mfAdm.setString("notaStato", notaStato); String sbjAdmin = subject + " - Adm Ordine n. " + subject + " - " + String.valueOf(getProgOrdineWww()) + " - "; if (isPagamentoVariato) sbjAdmin = sbjAdmin + "PAGAMENTO VARIATO "; sbjAdmin = sbjAdmin + sbjAdmin; String to = getMailTo(); rp.append(mfAdm.sendMailMessageSystem(to, sbjAdmin, true)); } } catch (Exception e) { handleDebug(e); rp.setStatus(false); rp.setMsg(e); System.out.println("ERRORE INVIO EMAIL:"); e.printStackTrace(); } if (!rp.getStatus()) { handleDebug(rp.getMsg(), 2); System.out.println("ERRORE INVIO EMAIL:" + rp.getMsg()); } else { Timestamp tmst = getTimestamp(); setTmstInvioMailOrdine(tmst); superSave(); } return rp; } private Document creaReportDettagliDocumenti(DocumentoCR CR, boolean conDdt) { String prtLang = getLangPrimary(); long l_id_tipoDocumento = CR.getId_tipoDocumento(); if (l_id_tipoDocumento == 0L) l_id_tipoDocumento = getId_docCassa(); int rowCellLeading = 6; NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col_1 = 5, col_2 = 3, col_3 = 5, col_4 = 12, col_5 = 5, col_6 = 5, col_7 = 5; int cellLeading = 12; String descCliente = "", descDocumento = ""; DoubleOperator totQuantita = new DoubleOperator(); DoubleOperator totDdt = new DoubleOperator(); DoubleOperator totaleComplessivo = new DoubleOperator(); DoubleOperator totaleDocumento = new DoubleOperator(); DoubleOperator totalePezzeDocumento = new DoubleOperator(); SimpleDateFormat df = getDataFormat(); Color currentColor = Color.ORANGE; try { Cell rigaVuota = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); String intestazioneReport = translate("Data: dal ", prtLang) + translate("Data: dal ", prtLang) + " " + df.format(CR.getDataDocumentoDa()) + " " + translate("al", prtLang); if (CR.getId_tipo() != 0L) intestazioneReport = intestazioneReport + " - Tipo: " + intestazioneReport; creaIntestazioneReport(CR.getTipoReport(), intestazioneReport); Cell cell = new Cell(new Chunk("Doc.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(currentColor); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(translate("Data", prtLang), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(currentColor); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(translate("Tipo", prtLang), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(currentColor); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(translate("Intestazione", prtLang), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(currentColor); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Stato", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(currentColor); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Q.ta", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(currentColor); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Importo", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(currentColor); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); CR.setFlgOrderBy(1L); Vectumerator vec = new Documento(getApFull()).findByCR(CR, 0, 0); Date currentData = null; Color coloreIntestazioneRiga = Color.LIGHT_GRAY; while (vec.hasMoreElements()) { descCliente = ""; descDocumento = ""; Documento row = (Documento)vec.nextElement(); String nDoc = row.getNumeroDocumentoCompleto(); descCliente = row.getClifor().getDescrizioneCompleta(); descDocumento = row.getTipoDocumento().getDescrizioneStampa(); String descPag = row.getStatoCompleto(); totaleDocumento = new DoubleOperator(); Vectumerator vecRiga = row.findRigheDocumento(0, 0, (int)row.getTipoDocumento().getFlgOrdinamentoRigheStampa()); while (vecRiga.hasMoreElements()) { RigaDocumento rowRD = (RigaDocumento)vecRiga.nextElement(); if (CR.getId_articoloTessuto() == 0L || ( CR.getId_articoloTessuto() > 0L && CR.getId_articoloTessuto() == rowRD.getId_articoloTessuto())) { double importoRigaConSconto = (double)rowRD.getDocumento().getTipoDocumento().fixDocumentoConImportiNegativi() * rowRD.getTotImportoRigaConSconto(); totaleDocumento.add(importoRigaConSconto); cell = new Cell(new Chunk(rowRD.getDescrizioneRigaCompleta(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); if (row.getTipoDocumento().getFlgTipologia() == 200L) { cell = new Cell(new Chunk(getNf().format(rowRD.getStacchi()), PdfFontFactory.PDF_fPiccolissimo)); } else { cell = new Cell(new Chunk(rowRD.getUdmQuantita(), PdfFontFactory.PDF_fPiccolissimo)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(importoRigaConSconto), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); if (conDdt && row.getTipoDocumento().getFlgTipologia() == 200L) { LavPezza lp = new LavPezza(getApFull()); Vectumerator vecLP = lp.findDdtByRigaDocumento(rowRD.getId_rigaDocumento()); while (vecLP.hasMoreElements()) { LavPezza rowLP = (LavPezza)vecLP.nextElement(); Documento ddt = rowLP.getRigaDocumentoBolla().getDocumento(); cell = new Cell(new Chunk("====> " + ddt.getNumeroDocumentoCompleto() + " del " + df.format(ddt.getDataDocumento()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(String.valueOf(rowLP.getCount()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } } } } totaleComplessivo.add(totaleDocumento); totQuantita.add(row.getTotNr()); totalePezzeDocumento.add(row.getStacchiTotali()); cell = new Cell(new Chunk(nDoc, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setBackgroundColor(coloreIntestazioneRiga); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getDataFormat().format(row.getDataDocumento()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setBackgroundColor(coloreIntestazioneRiga); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descDocumento, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setBackgroundColor(coloreIntestazioneRiga); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descCliente, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, prtLang))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setBackgroundColor(coloreIntestazioneRiga); cell.setColspan(col_4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descPag, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setBackgroundColor(coloreIntestazioneRiga); cell.setColspan(col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); if (row.getTipoDocumento().getFlgTipologia() == 200L) { cell = new Cell(new Chunk(getNf().format(row.getStacchiTotali()), PdfFontFactory.PDF_fPiccolissimo)); } else { cell = new Cell(new Chunk(getNf().format(row.getTotNr()), PdfFontFactory.PDF_fPiccolissimo)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setBackgroundColor(coloreIntestazioneRiga); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totaleDocumento.getResult()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setBackgroundColor(coloreIntestazioneRiga); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("TOTALE " + getDataFormat().format(currentData), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); if (totalePezzeDocumento.getResult() != 0.0D) { cell = new Cell(new Chunk(getNf().format(totalePezzeDocumento.getResult()), PdfFontFactory.PDF_fGrandeB)); } else { cell = new Cell(new Chunk(getNf().format(totQuantita.getResult()), PdfFontFactory.PDF_fGrandeB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totaleComplessivo.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_7); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); this.document.newPage(); } catch (Exception e) { handleDebug(e); } return this.document; } public boolean isRata0() { if (isRata0Attiva()) { if (getTotaleDocumento() >= getRatealeImportoMinimo()) return true; return false; } return hasRigheRata0(); } public boolean hasRigheRata0() { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getArticolo().getFlgRateale0() == 0L) return false; } return true; } public long hasRigheConUsato() { Vectumerator vec = findRigheDocumento(0, 0, 0); boolean hasUsatoRm = false; boolean hasUsatoIva = false; boolean hasIvaStd = false; long l_id_iva_rm = getCodiceIvaRegimeMargine(); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getArticolo().getFlgUsato() > 0L) { if (row.getArticolo().getId_iva() == l_id_iva_rm) { hasUsatoRm = true; continue; } hasUsatoIva = true; continue; } if (getTipoDocumento().getFlgUsato() == 1L) { hasUsatoRm = true; continue; } hasIvaStd = true; } if ((!hasUsatoIva ? true : false) & (!hasUsatoRm ? true : false)) return 0L; if (!hasIvaStd) { if (hasUsatoIva && hasUsatoRm) return 5L; if (hasUsatoIva && !hasUsatoRm) return 3L; if (hasUsatoRm && !hasUsatoIva) return 1L; } else { if (hasUsatoIva && hasUsatoRm) return 6L; if (hasUsatoIva && !hasUsatoRm) return 4L; if (hasUsatoRm && !hasUsatoIva) return 2L; } return 0L; } public double getRatealeImportoMinimo() { return getParm("SELLA_P_CREDIT_IMPORTO_MINIMO").getNumeroDouble(); } public boolean hasRigheDocumento2() { Vectumerator vec = findRigheDocumento2(1, 1, 0); if (vec.hasMoreElements()) return true; return false; } protected void creaDocumentoDisposizioneTaglioXDispositoreElencoOrdini(Table l_pdfCorpo) { try { int cellLeading = 10; SimpleDateFormat df = getDataFormat(); Cell blankRow = new Cell(); blankRow.setVerticalAlignment(4); blankRow.setHorizontalAlignment(0); blankRow.setLeading((float)cellLeading); blankRow.setBorder(0); blankRow.setColspan(40); float imgLogoWidth = getDocLogoWidth() / 4.0F; Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); if (imgLogoWidth > 0.0F) imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); Cell cell = new Cell(); String desc = getArticolo().getDescrizioneCompleta(getCurrentLang()); cell.addElement(new Chunk(desc, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrandissimoXB, getCurrentLang()))); if (getId_taglia() > 0L) { desc = desc + desc + ": " + translate("taglia", getCurrentLang()); cell.addElement(new Chunk(desc, PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fMedio, getCurrentLang()))); } if (!getArticolo().getNotaArticolo().isEmpty()) cell.addElement(new Chunk("\n" + DBAdapter.convertHtmlToString(getArticolo().getNotaArticolo()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); if (!getArticolo().getNoteTessutiBaseHtml(getCurrentLang()).isEmpty()) cell.addElement(new Chunk("\n" + getArticolo().getNoteTessutiBase(getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); l_pdfCorpo.addCell(cell); String imgFileName = getDocBase() + getDocBase() + getArticolo().getPathImg(); if (new File(imgFileName).exists()) { imgLogoWidth = 60.0F; Image imgArt = Image.getInstance(imgFileName); if (imgLogoWidth > 0.0F) imgArt.scaleToFit(imgLogoWidth, imgLogoWidth); cell = new Cell(); cell.addElement(new Chunk(imgArt, 0.0F, 0.0F)); } else { cell = new Cell(); } cell.setBorder(0); cell.setColspan(8); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getNumeroDocumentoCompleto(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, getCurrentLang()))); cell.addElement(new Chunk(" " + getDataFormat().format(getDataDocumento()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, getCurrentLang()))); if (!getRiferimento().isEmpty()) { cell.addElement(new Chunk("\nRIF. ", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, getCurrentLang()))); cell.addElement(new Chunk(getRiferimento() + " " + getRiferimento(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrande, getCurrentLang()))); } cell.addElement(new Chunk("\n", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, getCurrentLang()))); cell.addElement(new Chunk(getClifor().getDescrizioneCompleta(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("N. CAPI", getCurrentLang()) + "\n\n" + translate("N. CAPI", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fGrandeB, getCurrentLang()))); cell.addElement(new Chunk("\n", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fMedio, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.LIGHT_GRAY); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Rif. Ordini", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.addElement(new Chunk("\n" + getDescDocFiglioPadreByPadre(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(30); l_pdfCorpo.addCell(cell); l_pdfCorpo.addCell(blankRow); Vectumerator vecOrdini = new DocFiglioPadre(getApFull()).findByPadre(getId_documento()); while (vecOrdini.hasMoreElements()) { DocFiglioPadre rowDFP = (DocFiglioPadre)vecOrdini.nextElement(); StringBuilder temp = new StringBuilder(translate("Ordine: ", getCurrentLang())); temp.append(rowDFP.getDocumentoFiglio().getNumeroDocumentoCompleto()); temp.append(" "); temp.append(df.format(rowDFP.getDocumentoFiglio().getDataDocumento())); temp.append(" "); temp.append(rowDFP.getDocumentoFiglio().getClifor().getDescrizioneCompleta()); cell = new Cell(); cell.addElement(new Chunk(temp.toString(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(40); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Descrizione", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(translate("Q.tà", getCurrentLang()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBackgroundColor(Color.lightGray); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolissimoB, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBorder(0); cell.setColspan(10); l_pdfCorpo.addCell(cell); Vectumerator vecDispo = rowDFP.getDocumentoFiglio().findRigheDocumento(0, 0, 0); while (vecDispo.hasMoreElements()) { RigaDocumento rowDispo = (RigaDocumento)vecDispo.nextElement(); cell = new Cell(); cell.addElement(new Chunk(rowDispo.getDescrizioneRigaCompleta(), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(getNf().format(rowDispo.getNr()), PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setColspan(10); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("", PdfFontFactory.getInstance(getApFull()).getPdfFont(PdfFontFactory.PDF_fPiccolo, getCurrentLang()))); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setRowspan(2); cell.setBorder(0); cell.setColspan(10); l_pdfCorpo.addCell(cell); } l_pdfCorpo.addCell(blankRow); } } catch (Exception e) { handleDebug(e); } } public boolean isDocumentoTrasporto() { long l_codice = getTipoDocumento().getTipologiaDocumento().getCodice(); if (l_codice == 0L || l_codice == 1L || l_codice == 2L || l_codice == 3L) return true; return false; } public long getFlgBartolini() { return this.flgBartolini; } public void setFlgBartolini(long flgBartolini) { this.flgBartolini = flgBartolini; } public long getFlgTipoRitiro() { return this.flgTipoRitiro; } public void setFlgTipoRitiro(long flgTipoRitiro) { this.flgTipoRitiro = flgTipoRitiro; } public long getFlgAvvisoConsegna() { return this.flgAvvisoConsegna; } public void setFlgAvvisoConsegna(long flgAvvisoConsegna) { this.flgAvvisoConsegna = flgAvvisoConsegna; } public Date getDataSpedizione() { return this.dataSpedizione; } public void setDataSpedizione(Date dataSpedizione) { this.dataSpedizione = dataSpedizione; } public Date getDataInvioMailSped() { return this.dataInvioMailSped; } public void setDataInvioMailSped(Date dataInvioMailSped) { this.dataInvioMailSped = dataInvioMailSped; } public double getValoreDichiarato() { return this.valoreDichiarato; } public void setValoreDichiarato(double valoreDichiarato) { this.valoreDichiarato = valoreDichiarato; } public double getCostoEffettivoSped() { return this.costoEffettivoSped; } public void setCostoEffettivoSped(double costoEffettivoSped) { this.costoEffettivoSped = costoEffettivoSped; } public long getFlgModoAccredito() { return this.flgModoAccredito; } public void setFlgModoAccredito(long flgModoAccredito) { this.flgModoAccredito = flgModoAccredito; } public boolean isEmailSpedInviabile() { if (getDBState() == 1 && getFlgStato() == 1L && getNColli() > 0L && getId_vettore() > 0L) return true; return false; } public ResParm exportFileBartolini(DocumentoCR CR) { SimpleDateFormat df = new SimpleDateFormat("ddMMyy_hhmm"); String targetDir = getPathTmpFull(); String prefissoFile = "BART_" + df.format(DBAdapter.getToday()); if (CR.getFlgSimulazione() == 1L) prefissoFile = "SIMUL_" + prefissoFile; String FNVAB00R = targetDir + targetDir + "_FNVAB00R.dat"; String filePdf = targetDir + targetDir + "_Spedizione.pdf"; String FNVAT00R = targetDir + targetDir + "_FNVAT00R.dat"; ResParm rp = new ResParm(false, "Errore in export: " + FNVAT00R + "
"); try { int numRecord = 0; StringBuffer errMsg = new StringBuffer(); CR.setFileName(prefissoFile + "_FNVAB00R.dat," + prefissoFile + "_FNVAT00R.dat," + prefissoFile + "_Spedizione.pdf"); File dirCli = new File(targetDir); boolean dirOk = true; if (!dirCli.exists()) dirOk = dirCli.mkdirs(); if (dirOk) { new File(FNVAB00R).delete(); new File(FNVAT00R).delete(); new File(filePdf).delete(); FileWr f_FNVAB00R = new FileWr(FNVAB00R, "UTF-8", false); FileWr f_FNVAT00R = new FileWr(FNVAT00R, "UTF-8", false); CR.setFlgBartolini(1L); Vectumerator vec = findByCR(CR, 0, 0); boolean flgErr = false; while (vec.hasMoreElements()) { Documento rowbean = (Documento)vec.nextElement(); numRecord++; if (rowbean.getNColli() <= 0L) { flgErr = true; errMsg.append("Ft. " + rowbean.getNumeroDocumentoCompleto() + ": n. colli errato"); continue; } String s1 = rowbean.getRecordBartoliniFNVAB00R(); f_FNVAB00R.writeLine(s1); if (rowbean.getFlgDeliveryType() == 2L && rowbean.getPudoId().isEmpty()) { flgErr = true; errMsg.append(rowbean.getNumeroDocumentoCompleto() + " " + rowbean.getNumeroDocumentoCompleto() + " Impostato delivery type pudo ma pudo non selezionato!!"); } for (int i = 0; (long)i < rowbean.getNColli(); i++) { s1 = rowbean.getRecordBartoliniFNVAT00R((long)(i + 1)); f_FNVAT00R.writeLine(s1); } if (!rowbean.getPudoId().isEmpty()) { s1 = rowbean.getRecordBartoliniFNVAT00RPudo(); f_FNVAT00R.writeLine(s1); } s1 = rowbean.getRecordBartoliniFNVAT00REmail(); f_FNVAT00R.writeLine(s1); if (!rowbean.getClifor().getCellulare().isEmpty() || !rowbean.getClifor().getTelefono().isEmpty()) { s1 = rowbean.getRecordBartoliniFNVAT00RSms(); f_FNVAT00R.writeLine(s1); } } f_FNVAB00R.closeFile(); f_FNVAT00R.closeFile(); rp.setStatus(true); if (flgErr) { rp.setStatus(false); rp.setMsg("Generazione file export BARTOLINI CON ERRORI!!!.
Numero Record: " + numRecord + "
" + errMsg.toString()); } else { createFileFromByteArray(creaReportBartoliniPdf(CR), filePdf); if (CR.getFlgSimulazione() == 0L && !flgErr) { vec.moveFirst(); while (vec.hasMoreElements()) { Documento rowbean = (Documento)vec.nextElement(); rowbean.aggiornaFlgBartolini(2L); } } rp.setMsg("Generazione file export BARTOLINI avvenuta con successo.
Numero Record: " + numRecord); } } } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } return rp; } private String getRecordBartoliniFNVAB00R() { StringBuffer temp = new StringBuffer(); SimpleDateFormat df = new SimpleDateFormat("yyyy MMdd"); NumberFormat nf3 = NumberFormat.getInstance(Locale.ITALY); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf1 = NumberFormat.getInstance(Locale.ITALY); nf1.setMaximumFractionDigits(1); nf1.setMinimumFractionDigits(1); Date today = getToday(); temp.append(" "); temp.append(" "); temp.append(spaceRight(getParm("BART_COD_CLI").getTesto(), 7)); temp.append(" "); temp.append(spaceRight(getParm("BART_P_OPER").getTesto(), 3)); temp.append(" "); temp.append(df.format(today)); temp.append(" "); temp.append("00"); temp.append(" "); temp.append(String.valueOf(getId_esercizio()).substring(2, 4)); temp.append(zeroLeft(String.valueOf(getProgDocumento()), 5)); if (getId_tipoPagamento() == 1L) { temp.append("4 "); } else { temp.append("1 "); } temp.append(" "); temp.append("000"); String desc = getClifor().getCognomeNome(); if (!getPresso().isEmpty()) desc = getPresso() + " Sig. " + getPresso(); desc = desc.replace("’", "'"); desc = DBAdapter.convertStringToStringNoAccenti(desc); temp.append(spaceRight(desc, 70)); if (getIndirizzoSped().isEmpty()) { desc = getClifor().getIndirizzo() + " n." + getClifor().getIndirizzo() + " "; } else { desc = getIndirizzoSped() + " n." + getIndirizzoSped(); } desc = DBAdapter.convertStringToStringNoAccenti(desc); temp.append(spaceRight(desc, 35)); if (getIndirizzoSped().isEmpty()) { String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); temp.append(spaceRight(capComune, 9)); } else { temp.append(spaceRight(getCapSped(), 9)); } if (getIndirizzoSped().isEmpty()) { desc = getClifor().getDescrizioneComune(); desc = DBAdapter.convertStringToStringNoAccenti(desc); temp.append(spaceRight(desc, 35)); } else { desc = getCittaSped(); desc = DBAdapter.convertStringToStringNoAccenti(desc); temp.append(spaceRight(desc, 35)); } if (getClifor().getNazione().getCodice().isEmpty() || getClifor().getNazione().getCodice().toLowerCase().equals("it")) { if (getIndirizzoSped().isEmpty()) { temp.append(spaceRight(getClifor().getProvinciaComune(), 2)); } else { temp.append(spaceRight(getProvinciaSped(), 2)); } } else { temp.append(spaceRight("", 2)); } System.out.println(getClifor().getCognomeNome() + " id: " + getClifor().getCognomeNome() + " idn:" + getClifor().getId_nazione() + " code:" + getClifor().getNazione().getId_nazione()); if (getClifor().getNazione().getCodice().isEmpty() || getClifor().getNazione().getCodice().toLowerCase().equals("it")) { temp.append(" "); } else { temp.append(spaceRight(getClifor().getNazione().getCodice(), 3)); } temp.append(" "); temp.append(" "); temp.append(" "); if (!getPudoId().isEmpty()) { temp.append(spaceRight("309", 3)); } else { temp.append(spaceRight("000", 3)); } temp.append(spaceRight(getParm("BART_TIPO_SERVIZIO").getTesto(), 1)); temp.append(" "); if (getFlgTrasportoAssicurato() == 1L) { desc = nf3.format(getValoreDichiarato()); desc = desc.replace(".", ""); temp.append(zeroLeft(desc, 14)); } else { temp.append(zeroLeft("0,000", 14)); } if (getFlgTrasportoAssicurato() == 1L) { temp.append("EUR"); } else { temp.append(" "); } temp.append(spaceRight("MATERIALE FOTOGRAFICO", 15)); temp.append(" "); temp.append(zeroLeft(String.valueOf(getNColli()), 5)); temp.append(" "); temp.append(zeroLeft(nf1.format(getKgLordo()), 8)); temp.append(" "); temp.append(zeroLeft(String.valueOf("0,000"), 6)); temp.append(" "); temp.append(zeroLeft("0,000", 14)); temp.append(" "); if (getId_tipoPagamento() == 1L) { desc = nf3.format(getTotaleDocumento()); desc = desc.replace(".", ""); temp.append(zeroLeft(desc, 14)); } else { temp.append(zeroLeft(String.valueOf("0,000"), 14)); } if (getId_tipoPagamento() != 1L) { temp.append(" "); } else { switch ((int)getFlgModoAccredito()) { case 2: temp.append(" "); break; case 3: temp.append("BM"); break; case 4: temp.append("CM"); break; default: temp.append(" "); break; } } if (getId_tipoPagamento() == 1L) { temp.append("EUR"); } else { temp.append(" "); } if (getId_tipoPagamento() == 1L) { temp.append(spaceRight(getParm("BART_GEST_CONTRASS").getTesto(), 2)); } else { temp.append(" "); } temp.append(" "); temp.append(zeroLeft(String.valueOf(getId_esercizio()) + String.valueOf(getId_esercizio()), 15)); temp.append(spaceLeft(getNumeroDocumentoCompleto(), 15)); temp.append(" "); temp.append(zeroLeft("0", 7)); temp.append(" "); temp.append(zeroLeft("0", 7)); temp.append(" "); desc = "Tel.: " + getClifor().getTelefono() + " " + getClifor().getCellulare() + " " + getNotaSpedizione(); if (desc.length() > 70) desc = desc.substring(0, 70); temp.append(spaceRight(desc, 70)); temp.append(" "); temp.append("00"); if (getClifor().getNazione().getCodice().isEmpty() || getClifor().getNazione().getCodice().toLowerCase().equals("it")) { temp.append("7Q"); } else { temp.append("7R"); } temp.append(" "); temp.append(" "); temp.append("00000000"); temp.append(" "); temp.append(" "); temp.append("0000"); temp.append(" "); temp.append(" "); temp.append(" "); temp.append(zeroLeft("0,000", 14)); temp.append(" "); if (getFlgTipoRitiro() == 1L) { temp.append("RC"); } else { temp.append(" "); } temp.append(" "); temp.append(" "); if (getFlgAvvisoConsegna() == 1L) { temp.append("A"); } else if (getFlgAvvisoConsegna() == 2L) { temp.append("F"); } else if (getFlgAvvisoConsegna() == 4L) { temp.append("S"); } else if (getFlgAvvisoConsegna() == 3L) { temp.append("P"); } else { temp.append(" "); } temp.append(" "); temp.append(" "); temp.append(" "); temp.append(zeroLeft("00", 9)); temp.append(spaceLeft(" ", 25)); temp.append(spaceLeft(" ", 9)); temp.append(spaceLeft(" ", 3)); temp.append("\r"); return temp.toString(); } private String getRecordBartoliniFNVAT00R(long l_nCollo) { SimpleDateFormat dfY = new SimpleDateFormat("yyyy"); NumberFormat nf3 = NumberFormat.getInstance(Locale.ITALY); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf1 = NumberFormat.getInstance(Locale.ITALY); nf1.setMaximumFractionDigits(1); nf1.setMinimumFractionDigits(1); Date today = getToday(); StringBuffer temp = new StringBuffer(); temp.append(" "); temp.append(" "); temp.append(spaceRight(getParm("BART_COD_CLI").getTesto(), 7)); temp.append(" "); temp.append(spaceRight(getParm("BART_P_OPER").getTesto(), 3)); temp.append(" "); temp.append(dfY.format(today)); temp.append(" "); temp.append("00"); temp.append(" "); temp.append(String.valueOf(getId_esercizio()).substring(2, 4)); temp.append(zeroLeft(String.valueOf(getProgDocumento()), 5)); temp.append("E"); temp.append(spaceRight(getCodeBar(l_nCollo), 35)); temp.append("\r"); return temp.toString(); } private String getRecordBartoliniFNVAT00RPudo() { SimpleDateFormat dfY = new SimpleDateFormat("yyyy"); NumberFormat nf3 = NumberFormat.getInstance(Locale.ITALY); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf1 = NumberFormat.getInstance(Locale.ITALY); nf1.setMaximumFractionDigits(1); nf1.setMinimumFractionDigits(1); Date today = getToday(); StringBuffer temp = new StringBuffer(); temp.append(" "); temp.append(" "); temp.append(spaceRight(getParm("BART_COD_CLI").getTesto(), 7)); temp.append(" "); temp.append(spaceRight(getParm("BART_P_OPER").getTesto(), 3)); temp.append(" "); temp.append(dfY.format(today)); temp.append(" "); temp.append("00"); temp.append(" "); temp.append(String.valueOf(getId_esercizio()).substring(2, 4)); temp.append(zeroLeft(String.valueOf(getProgDocumento()), 5)); temp.append("U"); temp.append(spaceRight(getPudoId(), 35)); temp.append("\r"); return temp.toString(); } private String getRecordBartoliniFNVAT00REmail() { StringBuffer temp = new StringBuffer(); SimpleDateFormat dfY = new SimpleDateFormat("yyyy"); NumberFormat nf3 = NumberFormat.getInstance(Locale.ITALY); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf1 = NumberFormat.getInstance(Locale.ITALY); nf1.setMaximumFractionDigits(1); nf1.setMinimumFractionDigits(1); Date today = getToday(); temp.append(" "); temp.append(" "); temp.append(spaceRight(getParm("BART_COD_CLI").getTesto(), 7)); temp.append(" "); temp.append(spaceRight(getParm("BART_P_OPER").getTesto(), 3)); temp.append(" "); temp.append(dfY.format(today)); temp.append(" "); temp.append("00"); temp.append(" "); temp.append(String.valueOf(getId_esercizio()).substring(2, 4)); temp.append(zeroLeft(String.valueOf(getProgDocumento()), 5)); temp.append("I"); temp.append(spaceRight(getClifor().getEMail(), 35)); temp.append("\r"); return temp.toString(); } public ByteArrayOutputStream creaReportBartoliniPdf(DocumentoCR CR) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); String titoloReport = ""; try { this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 20.0F); titoloReport = "Report Bartolini"; SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); prepareNewPdfCorpoDocument(); int rowCellLeading = 6; int col1 = 4, col2 = 16, col3 = 2, col4 = 2, col5 = 4, col6 = 4, col7 = 8; int cellLeading = 8; Cell cell = new Cell(); Paragraph paragraph = creaParagrafoConGrassetto("\n" + getHeaderDoocumento(1) + "\n" + getHeaderDoocumento(2), PDF_fPiccolo, PDF_fPiccoloB); paragraph.setLeading(10.0F); cell.addElement((Element)paragraph); cell.setLeading(10.0F); cell.setMaxLines(7); cell.setBorder(0); cell.setColspan(24); this.pdfcorpo.addCell(cell); Vettore vettore = new Vettore(getApFull()); vettore.findByPrimaryKey(3L); String descVettore = vettore.getDescrizione(); descVettore = descVettore + "\nData Stampa: " + descVettore; cell = new Cell(); cell.add(new Chunk("\n\nSPETT.LE\n\n", PDF_fPiccolissimo)); cell.add(new Chunk(descVettore, PDF_fGrande)); cell.setVerticalAlignment(4); cell.setLeading(12.0F); cell.setBorder(0); cell.setColspan(16); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Numero Sped.", PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Destinatario", PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col2); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Colli", PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col3); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Kg", PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col4); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Contrass.", PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col5); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Assic", PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col6); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Note", PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col7); this.pdfcorpo.addCell(cell); CR.setFlgBartolini(1L); Vectumerator vec = findByCR(CR, 0, 0); long nColliTot = 0L; while (vec.hasMoreElements()) { Documento rowBean = (Documento)vec.nextElement(); nColliTot += rowBean.getNColli(); String temp = String.valueOf(rowBean.getId_esercizio()).substring(2, 4) + String.valueOf(rowBean.getId_esercizio()).substring(2, 4); cell = new Cell(new Chunk(temp, PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col1); this.pdfcorpo.addCell(cell); temp = rowBean.getClifor().getCognomeNome(); if (!rowBean.getPresso().isEmpty()) temp = temp + " c/o " + temp; if (rowBean.getIndirizzoSped().isEmpty()) { temp = temp + " " + temp + " n." + rowBean.getClifor().getIndirizzo() + " "; } else { temp = temp + " " + temp + " n." + rowBean.getIndirizzoSped(); } if (rowBean.getIndirizzoSped().isEmpty()) { String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); temp = temp + " " + temp; } else { temp = temp + " " + temp; } if (rowBean.getIndirizzoSped().isEmpty()) { temp = temp + " " + temp; } else { temp = temp + " " + temp; } if (rowBean.getIndirizzoSped().isEmpty()) { temp = temp + " " + temp; } else { temp = temp + " " + temp; } if (!rowBean.getPudoId().isEmpty()) temp = temp + " (Pudo: " + temp + ")"; cell = new Cell(new Chunk(temp, PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col2); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(String.valueOf(rowBean.getNColli()), PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col3); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(String.valueOf(rowBean.getKgLordo()), PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col4); this.pdfcorpo.addCell(cell); if (rowBean.getId_tipoPagamento() == 1L) { temp = getNf2().format(rowBean.getTotaleDocumento()); switch ((int)rowBean.getFlgModoAccredito()) { case 3: temp = temp + " Ass. Banc. Int. Mittente"; break; case 4: temp = temp + " Ass. Circ. Int. Mittente"; break; } } else { temp = ""; } cell = new Cell(new Chunk(temp, PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col5); this.pdfcorpo.addCell(cell); if (rowBean.getFlgTrasportoAssicurato() == 1L) { temp = "si: " + getNf2().format(rowBean.getValoreDichiarato()); } else { temp = "no"; } cell = new Cell(new Chunk(temp, PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col6); this.pdfcorpo.addCell(cell); if (rowBean.getFlgTipoRitiro() == 0L) { temp = "Tel.: " + rowBean.getClifor().getTelefono() + " " + rowBean.getClifor().getCellulare() + "\n" + rowBean.getNotaSpedizione(); } else { temp = "Tel.: " + rowBean.getClifor().getTelefono() + "\nTipo Ritiro: " + rowBean.getTipoRitiro() + "\n" + rowBean.getNotaSpedizione(); } if (rowBean.getFlgAvvisoConsegna() != 0L) temp = temp + "\n" + temp; if (temp.length() > 70) temp = temp.substring(0, 70) + " (ATTENZIONE!! SOPRA 70 CARATTERI!!)"; cell = new Cell(new Chunk(temp, PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col7); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("TOT COLLI: ", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setColspan(col1 + col2); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(String.valueOf(nColliTot), PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col3); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("TOT SPED.: ", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setColspan(col4 + col5); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(String.valueOf(vec.getTotNumberOfRecords()), PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col6); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col7); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public ResParm aggiornaFlgBartolini(long l_flg) { setFlgBartolini(l_flg); return super.save(); } private String getCodeBar(long l_nCollo) { StringBuffer codeBar = new StringBuffer(); codeBar.append(String.valueOf(getId_esercizio())); codeBar.append(zeroLeft(String.valueOf(getProgDocumento()), 6)); codeBar.append(zeroLeft(String.valueOf(l_nCollo), 3)); return codeBar.toString(); } private String getCodeBarCkDigit(long l_nCollo) { String temp = getCodeBar(l_nCollo); long sumDispari = 0L; long sumPari = 0L; boolean isPari = false; for (int i = 0; i < temp.length(); i++) { if (isPari) { sumPari += Long.parseLong(temp.substring(i, i + 1)); } else { sumDispari += Long.parseLong(temp.substring(i, i + 1)) * 3L; } isPari = !isPari; } long tot = sumPari + sumDispari; long decSup = (tot / 10L + 1L) * 10L; if (decSup - tot == 10L) return "0"; return String.valueOf(decSup - tot); } public ResParm sendSpeditoMailMessage(String lang) { Documento ordine = getDocumentoPadreUno(); if (ordine.getId_documento() > 0L) return ordine.sendOrderMailMessageTuttofoto(getClifor().getUserWww(), false, true, false, true); return new ResParm(false, "Errore! Tentativo di invio mail spedizione su un documento che non ha un ordine allegato"); } public Documento getDocumentoPadreUno() { if (this.documentoPadreUno == null) { Vectumerator vec = findDocumentiPadre(); if (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); this.documentoPadreUno = row; } } return (this.documentoPadreUno == null) ? new Documento(getApFull()) : this.documentoPadreUno; } public void setDocumentoPadreUno(Documento documentoPadreUno) { this.documentoPadreUno = documentoPadreUno; } public ResParm sendOrderEbayWarningMessage() { ResParm rp = new ResParm(true); if (getId_ordine() == 0L) { rp.setStatus(false); rp.setMsg("ERRORE! Codice Ordine nullo! contattare l'amministratore del sito"); handleDebug(rp.getMsg(), 0); return rp; } rp = controlloArticoliEbay(); if (!rp.getStatus()) { String elencoArticoliEbay = convertStringToHtml(rp.getMsg()); try { String subject = "Ordine " + getId_ordine() + " - Articoli ebay a zero!"; String to = getMailToSfx("EBAY"); if (to.isEmpty()) { to = getMailTo(); subject = subject + " PARAMETRO TO_EBAY NON IMPOSTATO!"; } NumberFormat nf = getNf(); MailMessage mfAdm = new MailMessage(getApFull(), getDocBase() + getDocBase()); mfAdm.setQuestionMark(false); mfAdm.setString("id_ordine", String.valueOf(getProgOrdineWww())); mfAdm.setString("dataOrdine", getDataFormat().format(getDataDocumento())); mfAdm.setString("elencoArticoliEbay", elencoArticoliEbay); rp = mfAdm.sendMailMessageSystem(to, subject, false); } catch (Exception e) { handleDebug(e); rp.setStatus(false); rp.setMsg(e); System.out.println("ERRORE INVIO EMAIL:"); e.printStackTrace(); } } else { rp.setMsg("Articoli ebay non trovati o con giacenza >0"); } if (!rp.getStatus()) { handleDebug(rp.getMsg(), 2); System.out.println("ERRORE INVIO EMAIL:" + rp.getMsg()); } return rp; } public ResParm controlloArticoliEbay() { Vectumerator vec = findRigheDocumento(0, 0, 0); StringBuilder sb = new StringBuilder(); ResParm rp = new ResParm(true); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getArticolo().isEbayGiacenza0()) { if (sb.length() > 0) sb.append("\n"); sb.append(row.getArticolo().getCodice()); sb.append(" - "); sb.append(row.getArticolo().getDescrizione()); sb.append(" q.ta: "); sb.append(row.getArticolo().getQuantita()); rp.setStatus(false); } } rp.setMsg(sb.toString()); return rp; } public long getFlgInEsaurimento() { return this.flgInEsaurimento; } public void setFlgInEsaurimento(long flgInEsaurimento) { this.flgInEsaurimento = flgInEsaurimento; } protected void creaDocumentoCorpoFtAcquistoBollaCarico(Document l_document, Table l_pdfCorpo) { int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); if (righePerPagina <= 0) righePerPagina = 10; int maxCarDesc = (int)getTipoDocumento().getMaxCarDesc(); if (maxCarDesc == 0) maxCarDesc = 35; int riga = 0; int cellLeadingRow = getDocLeadRow(); if (cellLeadingRow == 0) cellLeadingRow = 12; Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowSmall = getTipoDocumento().getPdfFontRowSmall(); NumberFormat nf = getNf(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); int[] colSpanNota = { 40 }; try { long resHasUsato = hasRigheConUsato(); String s_note = getNote(); if (resHasUsato == 1L || resHasUsato == 2L || resHasUsato == 5L || resHasUsato == 6L) { Iva ivaRM = new Iva(getApFull()); ivaRM.findByPrimaryKey(getCodiceIvaRegimeMargine()); s_note = s_note + "\n" + s_note; } ArrayList alNote = RigaDocumentoItemPdf.getArrayListNota(s_note, 0, colSpanNota, PDF_frow); if (getDocPosizioneNota() == 0L) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); while (vec.hasMoreElements()) { String desc, descQta; double imponibile, importo; String scontoS; RigaDocumento row = (RigaDocumento)vec.nextElement(); double quantita = row.getQuantita(); if (row.getSconto() > 0.0D) { scontoS = nf.format(row.getSconto()); } else { scontoS = ""; } if (!row.getIva().getFlgTipo().equals("R")) { if (row.getCodiceArticolo().isEmpty()) { desc = row.getDescrizioneRiga(); } else { desc = row.getCodiceArticolo() + " - " + row.getCodiceArticolo(); } if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + " S/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } else { if (row.getCodiceArticolo().isEmpty()) { desc = row.getDescrizioneRiga(); } else { desc = row.getCodiceArticolo() + " - " + row.getCodiceArticolo(); } if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + " S/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } if (row.getSeriale().isEmpty() && !row.getArticolo().getNMatricola().isEmpty()) desc = desc + " Mat. N. " + desc; if (!row.getNotaBarcode().isEmpty()) desc = desc + " - " + desc; String codIva = row.getIva().getDescrizioneRigaStampaAuto(); if (!row.getNotaRigaDocumento().isEmpty()) desc = desc + " " + desc; if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() != 1L) { if (isQuantitaMagazzinoIntere()) { descQta = row.getUdm() + " " + row.getUdm(); } else { descQta = row.getUdm() + " " + row.getUdm(); } } else if (isQuantitaMagazzinoIntere()) { descQta = getNf0().format(quantita); } else { descQta = nf.format(quantita); } ArrayList dati = new ArrayList<>(); dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[0], desc, PDF_frow)); dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[1], row.getArticolo().getCodiciAlternativi(), PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[2], row.getArticolo().getScaffale(), PDF_frow, 2)); if (getParm("USA_MAGAZZINO").isTrue()) { if (isQuantitaMagazzinoIntere()) { dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[3], getNf0().format(row.getArticolo().getQuantita()), PDF_frow, 2)); } else { dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[3], getNf2().format(row.getArticolo().getQuantita()), PDF_frow, 2)); } } else { dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[3], row.getArticolo().getQuantitaMagazzinoMovimentoHtml(), PDF_frow, 2)); } dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[4], nf.format(row.getArticolo().getRicaricoEffettivoDaCostoNetto()), PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[5], descQta, PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[7], nf.format(imponibile), PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[7], scontoS, PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[8], nf.format(importo), PDF_frow, 2)); if (codIva.length() >= 10) { dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[9], codIva, PDF_frowSmall, 2)); } else { dati.add(new RigaDocumentoItemPdf(cols_FT_ACQ_BOLLA_CARICO_[9], codIva, PDF_frow, 2)); } riga = inserisciRigaDocumento(dati, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); } if (getDocPosizioneNota() == 1L && !s_note.isEmpty()) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); if (righePerPagina - riga > 0) riga = inserisciRigheVuote(righePerPagina - riga, colSpanNota, riga, l_document, l_pdfCorpo, cellLeadingRow); } catch (Exception e) { handleDebug(e); } } protected void creaDocumentoIntestazioneCorpoFtAcquisto(Table l_pdfCorpo) { int cellLeading = 8; int col1 = 20, col2 = 3, col3 = 2, col4 = 2, col5 = 2, col6 = 2, col7 = 2, col8 = 2, col9 = 2, col10 = 3; try { Cell cell = new Cell(); cell.addElement(new Chunk("DESCRIZIONE", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[0]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Cod. For.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[1]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Scaff.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[2]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Giac.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[3]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Ric.%", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[4]); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("QUAN.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[5]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("PREZZO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[6]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("SC.", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[7]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IMPORTO", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[8]); l_pdfCorpo.addCell(cell); cell = new Cell(new Chunk("IVA", PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(cols_FT_ACQ_BOLLA_CARICO_[9]); l_pdfCorpo.addCell(cell); } catch (Exception e) { handleDebug(e); } } private long calcolaProgOrdineWww() { try { String s_sql = "select max(progOrdineWww) as _max from DOCUMENTO"; WcString wc = new WcString(); wc.addWc("id_tipoDocumento =" + getId_docOrdineWWW()); wc.addWc("id_documento !=" + getId_documento()); PreparedStatement ps = getConn().prepareStatement(s_sql + s_sql); long numOrdiniWwwGiorno = getParm("CC_N_ORDINI_WWW_AL_GIORNO").getNumeroLong(); if (numOrdiniWwwGiorno > 0L) { long ultimoOrdine = (long)getMax(ps, true); Documento doc = new Documento(getApFull()); doc.findByProgOrdineWww(ultimoOrdine); long giorni = getDateDiff(doc.getDataDocumento(), getDataDocumento()); if (giorni < 0L) giorni = 0L; long nuovoOrdineWww = ultimoOrdine + 1L + giorni * numOrdiniWwwGiorno + (long)(Math.random() * (double)numOrdiniWwwGiorno); return nuovoOrdineWww; } return (long)getMax(ps, true) + 1L; } catch (Exception e) { return 0L; } } private String getRecordContabSeiSoft(double l_totFattura, double l_imponibile, double l_iva, String l_aliquota, String sottoConto) { StringBuffer temp = new StringBuffer(); String sep = "\t"; SimpleDateFormat df = new SimpleDateFormat("dd/MM/yy"); temp.append(spaceLeft(String.valueOf(getProgDocumento()), 6)); temp.append(sep); temp.append(spaceLeft(df.format(getDataDocumento()), 8)); temp.append(sep); temp.append(spaceLeft(" ", 5)); temp.append(sep); if (getClifor().getFlgAzienda() == 1L) { if (getClifor().getCognome().isEmpty()) { temp.append(spaceRight(getClifor().getNome(), 35)); } else { temp.append(spaceRight(getClifor().getCognome(), 35)); } temp.append(sep); temp.append(spaceRight(getClifor().getCognome(), 35)); temp.append(sep); temp.append(spaceRight(getClifor().getNome(), 35)); temp.append(sep); } else { temp.append(spaceRight("", 35)); temp.append(sep); temp.append(spaceRight(getClifor().getCognome(), 35)); temp.append(sep); temp.append(spaceRight(getClifor().getNome(), 35)); temp.append(sep); } temp.append(spaceRight(getClifor().getIndirizzo(), 35)); temp.append(sep); temp.append(spaceRight(getClifor().getNumeroCivico(), 10)); temp.append(sep); if (getClifor().getCapZona().isEmpty()) { temp.append(spaceRight(getClifor().getCapComune(), 35)); } else { temp.append(spaceRight(getClifor().getCapZona(), 35)); } temp.append(sep); temp.append(spaceRight(getClifor().getDescrizioneComune(), 35)); temp.append(sep); temp.append(spaceRight(getClifor().getProvinciaComune(), 35)); temp.append(sep); temp.append(spaceRight(getClifor().getId_nazione(), 4)); temp.append(sep); temp.append(spaceLeft(String.valueOf(l_totFattura), 9)); temp.append(sep); temp.append(spaceLeft(String.valueOf(l_imponibile), 9)); temp.append(sep); temp.append(spaceLeft(String.valueOf(l_iva), 9)); temp.append(sep); temp.append(spaceLeft(l_aliquota, 4)); temp.append(sep); temp.append(spaceLeft(sottoConto, 4)); temp.append(sep); temp.append(spaceLeft(getClifor().getPIva(), 16)); temp.append(sep); temp.append(spaceLeft(getId_tipoPagamento(), 4)); temp.append(sep); temp.append(spaceLeft(df.format(getDataDocumento()), 8)); temp.append(sep); temp.append(spaceLeft(getClifor().getCodFisc(), 16)); temp.append("\r"); return temp.toString(); } public ResParm exportFileContabSeiSoft(DocumentoCR CR) { ResParm rp = new ResParm(true); try { int numRecordFatt = 0, numRecordNc = 0, numRecordFattUsato = 0, numRecordNcUsato = 0; String contoVenditaPrivati = getParm("SEISOFT_CONTO_VEND_PRIV").getTesto(); String contoVenditaPrivatiUsato = getParm("SEISOFT_CONTO_VEND_PRIV_USATO").getTesto(); String contoVenditaAziende = getParm("SEISOFT_CONTO_VEND_AZ").getTesto(); String contoVenditaAziendeUsato = getParm("SEISOFT_CONTO_VEND_AZ_USATO").getTesto(); String contoVenditaPrivatiNoleggio = getParm("SEISOFT_CONTO_NOL_PRIV").getTesto(); String contoVenditaAziendeNoleggio = getParm("SEISOFT_CONTO_NOL_AZ").getTesto(); String contoSpese = getParm("SEISOFT_CONTO_SPESE").getTesto(); String contoRMIvaEsente = getParm("SEISOFT_CONTO_RM_IVA_ESENTE").getTesto(); String contoRMIva = getParm("SEISOFT_CONTO_RM_IVA_VEND").getTesto(); if (CR.getFlgSimulazione() == 1L) { CR.setFileName("SIMUL_EXPORT_CONTAB.txt"); } else { Calendar cal = Calendar.getInstance(); String temp = String.valueOf(cal.getTimeInMillis()); CR.setFileName("sei_export_" + temp + ".txt"); } String filename = CR.getFileName(); String filenameUsato = "USATO_" + CR.getFileName(); String target = getPathTmpFull(); new File(target + target).delete(); new File(target + target).delete(); FileWr outFileFatt = new FileWr(target + target, "UTF-8", false); FileWr outFileFattUsato = new FileWr(target + target, "UTF-8", false); String temp2 = System.getProperty("line.separator"); if (temp2.equals("\n")); CR.setFlgTipologia(20L); Vectumerator vec = findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Documento currentFattura = (Documento)vec.nextElement(); if (currentFattura.getClifor().getCodFisc().length() != 11 && currentFattura.getClifor().getCodFisc().length() != 16) { rp.setStatus(false); rp.setMsg("ERRORE! Impossibile esportare le fatture. La fattura n. " + currentFattura.getNumeroDocumentoCompleto() + " " + currentFattura.getClifor().getCognomeNome() + " non ha una codice fiscale valido."); break; } RigheRegistroIva rri = currentFattura.getRigaRegistroIva(); DoubleOperator totaleSconti = new DoubleOperator(); if (currentFattura.getScontoIncondizionato() > 0.0D) totaleSconti.add(currentFattura.getScontoIncondizionato()); if (currentFattura.getAbbuono() > 0.0D) totaleSconti.add(currentFattura.getAbbuono()); if (totaleSconti.getResult() > 0.0D) { DoubleOperator dop = new DoubleOperator(conIva(totaleSconti.getResult(), (double)getIvaDoc().getAliquota())); dop.subtract(totaleSconti.getResult()); rri.addRigaDocumento(currentFattura.getIvaDoc(), -totaleSconti.getResult(), -dop.getResult(), false, false); } Enumeration enuRrri = rri.elements(); while (enuRrri.hasMoreElements()) { String contoVendita, codIva; RigaRegistroIvaItem rrii = enuRrri.nextElement(); double imponibile = rrii.getImponibile2(); double iva = rrii.getImportoIva2(); if (currentFattura.getTipoDocumento().getFlgUsato() == 1L && rrii.isRegimeDelMargine()) { if (rrii.getIva().getFlgTipo().equals("R")) { codIva = contoRMIvaEsente; } else { codIva = contoRMIva; } } else { codIva = String.valueOf(rrii.getIva().getAliquota()); } if (currentFattura.getId_tipoDocumento() == getId_docFtNoleggio()) { if (currentFattura.getClifor().getFlgAzienda() == 1L) { contoVendita = contoVenditaAziendeNoleggio; } else { contoVendita = contoVenditaPrivatiNoleggio; } } else if (currentFattura.getTipoDocumento().getFlgUsato() == 1L) { if (!rrii.isRegimeDelMargine()) { contoVendita = contoVenditaAziendeUsato; } else { contoVendita = contoVenditaPrivatiUsato; } } else if (currentFattura.getClifor().getFlgAzienda() == 1L) { contoVendita = contoVenditaAziende; } else { contoVendita = contoVenditaPrivati; } if (currentFattura.getTipoDocumento().getFlgUsato() == 0L) { if (currentFattura.getTipoDocumento().getFlgTipologia() == 1L) { System.out.println("FT: " + currentFattura.getNumeroDocumentoCompleto()); outFileFatt.writeLine(currentFattura.getRecordContabSeiSoft(currentFattura.getTotaleDocumento(), imponibile, iva, codIva, contoVendita)); numRecordFatt++; continue; } outFileFatt.writeLine(currentFattura.getRecordContabSeiSoft(-currentFattura.getTotaleDocumento(), -imponibile, -iva, codIva, contoVendita)); numRecordNc++; continue; } if (currentFattura.getTipoDocumento().getFlgTipologia() == 1L) { System.out.println("FT USATO: " + currentFattura.getNumeroDocumentoCompleto()); outFileFattUsato.writeLine(currentFattura.getRecordContabSeiSoft(currentFattura.getTotaleDocumento(), imponibile, iva, codIva, contoVendita)); numRecordFattUsato++; continue; } if (currentFattura.getTipoDocumento().getFlgTipologia() == 2L) { System.out.println("nc USATO: " + currentFattura.getNumeroDocumentoCompleto()); outFileFattUsato.writeLine(currentFattura.getRecordContabSeiSoft(-currentFattura.getTotaleDocumento(), -imponibile, -iva, codIva, contoVendita)); numRecordNcUsato++; } } if (currentFattura.getSpeseTrasporto() > 0.0D) { DoubleOperator csi = new DoubleOperator(currentFattura.getSpeseTrasporto()); csi.setScale(4, 5); csi.multiply(currentFattura.getIvaDoc().getAliquota()); csi.divide(100.0F); csi.setScale(2, 5); double ivaSpeseSpedizione = csi.getResult(); if (currentFattura.getTipoDocumento().getFlgUsato() == 0L) { if (currentFattura.getTipoDocumento().getFlgTipologia() == 1L) { outFileFatt.writeLine(currentFattura.getRecordContabSeiSoft(currentFattura.getTotaleDocumento(), currentFattura.getSpeseTrasporto(), ivaSpeseSpedizione, String.valueOf(currentFattura.getIvaDoc().getAliquota()), contoSpese)); numRecordFattUsato++; } else { outFileFatt.writeLine(currentFattura.getRecordContabSeiSoft(-currentFattura.getTotaleDocumento(), -currentFattura.getSpeseTrasporto(), -ivaSpeseSpedizione, String.valueOf(currentFattura.getIvaDoc().getAliquota()), contoSpese)); numRecordNc++; } } else if (currentFattura.getTipoDocumento().getFlgTipologia() == 1L) { outFileFattUsato.writeLine(currentFattura.getRecordContabSeiSoft(currentFattura.getTotaleDocumento(), currentFattura.getSpeseTrasporto(), ivaSpeseSpedizione, String.valueOf(currentFattura.getIvaDoc().getAliquota()), contoSpese)); numRecordFatt++; } else { outFileFatt.writeLine(currentFattura.getRecordContabSeiSoft(-currentFattura.getTotaleDocumento(), -currentFattura.getSpeseTrasporto(), -ivaSpeseSpedizione, String.valueOf(currentFattura.getIvaDoc().getAliquota()), contoSpese)); numRecordNcUsato++; } } if (CR.getFlgSimulazione() == 0L) currentFattura.aggiornaExportRecord(); } outFileFatt.closeFile(); outFileFattUsato.closeFile(); if (rp.getStatus()) { rp.setMsg("Generazione file export avvenuta con successo.
Fatture: " + numRecordFatt + " Note di Credito: " + numRecordNc + "
USATO: Fatture: " + numRecordFattUsato + " Note di Credito: " + numRecordNcUsato); } else { rp.setMsg("Errore in export: " + target + filename + "
" + rp.getMsg()); } } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } return rp; } public ResParm aggiornaExportRecord() { setFlgExport(1L); return super.save(); } public ByteArrayOutputStream creaPdfEtichetteConfezione(String l_printer) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); int NUMERO_ETICHETTE = 4; int cellLeading = 6; try { String dim = getParm("LABEL_PK_LIST_SIZE").getTesto(); long xx = Long.parseLong(dim.substring(0, dim.indexOf(','))); long yy = Long.parseLong(dim.substring(dim.indexOf(',') + 1)); Rectangle label = new Rectangle(getPdfPointSize(20L), getPdfPointSize(200L)); this.document = new Document(label.rotate(), 2.0F, 2.0F, 2.0F, 2.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); prepareNewPdfCorpoDocument(); int numColli = 0; long numTotColli = 0L; Vectumerator vec = findRigheDocumento(0, 0, 0); String sp = " "; Font pdfTagliando = new Font(2, 14.0F, 1); Chunk madeInItaly = new Chunk(sp + "PRODOTTO IN ITALIA\n", pdfTagliando); Chunk descConfezione = new Chunk(sp + "via yuri gagarin ...\nC.H. PIVA 00000000", pdfTagliando); vec.moveFirst(); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); for (int i = 0; i < NUMERO_ETICHETTE; i++) { if (row.getId_articolo() > 0L) { String descrizioneArticolo = row.getArticolo().getNome(); numColli++; Paragraph p = new Paragraph(); p.add(madeInItaly); p.add("COMPOSIZIONE"); p.add("SIMBOLI"); p.add(descrizioneArticolo); Cell cell = new Cell((Element)p); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); this.pdfcorpo.addCell(cell); } if ((double)i < row.getQuantita() - 1.0D) { this.document.add((Element)this.pdfcorpo); this.document.newPage(); prepareNewPdfCorpoDocument(); } } if (vec.hasMoreElements()) { this.document.add((Element)this.pdfcorpo); this.document.newPage(); prepareNewPdfCorpoDocument(); } } this.document.add((Element)this.pdfcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public Timestamp getTmstInvioMailOrdine() { return this.tmstInvioMailOrdine; } public void setTmstInvioMailOrdine(Timestamp tmstInvioMailOrdine) { this.tmstInvioMailOrdine = tmstInvioMailOrdine; } public long getFlgStatoOrdineWwwPrecedente() { return this.flgStatoOrdineWwwPrecedente; } public void setFlgStatoOrdineWwwPrecedente(long flgStatoOrdineWwwPrecedente) { this.flgStatoOrdineWwwPrecedente = flgStatoOrdineWwwPrecedente; } private static final synchronized ResParm aggiornaRigheDocumentoMagArticolo(DocumentoInterface doc, boolean isTipoMovimentoInverso) { ResParm rp = new ResParm(); Vectumerator vec = doc.findRigheDocumento(0L, 0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento rd = (RigaDocumento)vec.nextElement(); if (rd.getArticolo().usaMagazzino() && doc.getTipoDocumento().getFlgMovMagazzino() != 0L) { DoubleOperator dop = new DoubleOperator(rd.getArticolo().getQuantita()); if ((doc.getTipoDocumento().getFlgMovMagazzino() == 1L && isTipoMovimentoInverso) || ( doc.getTipoDocumento().getFlgMovMagazzino() == -1L && !isTipoMovimentoInverso)) { dop.subtract(rd.getNr()); } else { dop.add(rd.getNr()); } rd.getArticolo().setQuantita(dop.getResult()); if (rd.getArticolo().getQuantita() <= 0.0D) { if (rd.getArticolo().getFlgUsato() > 0L || rd.getArticolo().getFlgStockOfferte() == 2L || rd.getArticolo().getFlgStockOfferte() == 3L || rd.getArticolo().getFlgEbay() == 1L) rd.getArticolo().setFlgEscludiWebArt(1L); } else { rd.getArticolo().setFlgEscludiWebArt(0L); } rd.getArticolo().handleQuantitaDebugBeforeSave("documento.addRigaDocumentoMagArticolo"); rp.append(rd.getArticolo().superSave()); } } return rp; } public String getTrackingSpedizione() { if (getParm("WEB_SEND_ORDER_MAIL_CODE").getNumeroLong() == 2L && ( this.trackingSpedizione == null || this.trackingSpedizione.isEmpty()) && getFlgStato() == 1L) this.trackingSpedizione = String.valueOf(getId_esercizio()) + String.valueOf(getId_esercizio()); return (this.trackingSpedizione == null) ? "" : this.trackingSpedizione.trim(); } public void setTrackingSpedizione(String trackingSpedizione) { this.trackingSpedizione = trackingSpedizione; } public void findByProgOrdineWww(long l_ProgOrdineWww) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.dataDocumento desc, A.progOrdineWww,A.id_esercizio desc, A.progDocumento desc"; WcString wc = new WcString(); wc.addWc("A.flgStato=1"); wc.addWc("A.progOrdineWww=" + l_ProgOrdineWww); wc.addWc("A.id_tipoDocumento=" + getId_docOrdineWWW()); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } private Document creaLabelBartoliniPdfUno(Documento bean, Document l_document, int pageNumber) { try { String descCliente, descDestinazione; Table l_pdfCorpo = getNewPdfCorpoDocument(); bean.setNumPagDocumento(1L); int cellLeading = 8; SimpleDateFormat df = getDataFormat(); float imgLogoWidth = getDocLogoWidth(); Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); if (imgLogoWidth > 0.0F) imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); Cell cell = new Cell(); cell.addElement(new Chunk(imgLogo, 0.0F, 0.0F)); Paragraph paragraph = creaParagrafoConGrassetto("\n" + getHeaderDoocumento(1) + "\n" + getHeaderDoocumento(2), PDF_fPiccolo, PDF_fPiccoloB); paragraph.setLeading(10.0F); cell.addElement((Element)paragraph); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(22); l_pdfCorpo.addCell(cell); if (bean.getId_clifor() > 0L) { descCliente = ""; if (bean.getClifor().getpIva().isEmpty() && bean.getClifor().getCodFisc().isEmpty() && bean.getClifor().getCognome().isEmpty()) { descCliente = "AUTOFATTURA\n"; descCliente = descCliente + descCliente; } else { descCliente = descCliente + descCliente + "\n"; descCliente = descCliente + descCliente; String capComune = bean.getClifor().getCapComune(); if (!bean.getClifor().getCapZona().isEmpty()) capComune = bean.getClifor().getCapZona(); if (!bean.getClifor().getNumeroCivico().isEmpty()) descCliente = descCliente + " n." + descCliente; descCliente = descCliente + "\n" + descCliente + " " + capComune; if (!bean.getClifor().getProvinciaComune().isEmpty()) descCliente = descCliente + " (" + descCliente + ")"; if (!bean.getClifor().getId_nazione().isEmpty()) descCliente = descCliente + " " + descCliente; } } else { descCliente = bean.getNominativoDocumento(); } if (!bean.getIndirizzoSped().isEmpty() && !bean.getPresso().isEmpty()) { descDestinazione = ""; descDestinazione = descDestinazione + "c/o " + descDestinazione + "\n"; descDestinazione = descDestinazione + descDestinazione + " n." + bean.getIndirizzoSped() + "\n" + bean.getNumeroCivicoSped() + " " + bean.getCapSped() + " (" + bean.getCittaSped() + ")"; if (!bean.getId_nazioneSped().isEmpty()) descDestinazione = descDestinazione + " " + descDestinazione; } else if (bean.getId_destinazioneDiversa() == 0L) { if (getParm("DESTINAZIONE").getNumeroLong() == 1L) { descDestinazione = "IDEM\n\n"; } else { descDestinazione = ""; } } else { descDestinazione = ""; if (!bean.getDestinazioneDiversa().getPressoDD().isEmpty()) descDestinazione = descDestinazione + "c/o " + descDestinazione + "\n"; descDestinazione = descDestinazione + descDestinazione + " n." + bean.getDestinazioneDiversa().getIndirizzoDD() + "\n" + bean.getDestinazioneDiversa().getNumeroCivicoDD() + " " + bean.getDestinazioneDiversa().getCapComuneDD() + " (" + bean.getDestinazioneDiversa().getDescrizioneComuneDD() + ")"; if (!bean.getDestinazioneDiversa().getId_nazioneDD().isEmpty()) descDestinazione = descDestinazione + " " + descDestinazione; } cell = new Cell(); cell.addElement(new Chunk("\n\nSPETT.LE\n\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(descCliente, PdfFontFactory.PDF_fGrande)); if (!descDestinazione.isEmpty()) { cell.addElement(new Chunk("\nDESTINAZIONE\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(descDestinazione, PdfFontFactory.PDF_fGrande)); } cell.setVerticalAlignment(4); cell.setLeading(12.0F); cell.setBorder(0); cell.setRowspan(3); cell.setColspan(18); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("TIPO DOCUMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk("\n", PdfFontFactory.PDF_fMedio)); if (getFlgStato() == 0L) cell.addElement(new Chunk("(B) ", PdfFontFactory.PDF_fMedioB)); if (getFlgStato() == 2L) { cell.addElement(new Chunk("FATTURA PROFORMA\n", PdfFontFactory.PDF_fGrandeB)); } else { cell.addElement(new Chunk(bean.getTipoDocumento().getDescrizioneStampa() + "\n", PdfFontFactory.PDF_fGrandeB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(12); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("N. DOC.\n\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(String.valueOf(bean.getNumeroDocumento()), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("DATA\n\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(df.format(bean.getDataDocumento()), PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(4); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("xx", PdfFontFactory.PDF_fMedioBianco)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(2); cell.setRowspan(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("RIF. INTERNO \n", PdfFontFactory.PDF_fPiccolissimo)); if (!bean.getDescrizioneDocumentiPadre().isEmpty()) { if (getParm("ORDINI_WWW_USA_PROG_WWW").isTrue()) { cell.addElement(new Chunk(getNf0().format(bean.getDocumentoPadreUno().getProgOrdineWww()), PdfFontFactory.PDF_fMedioB)); } else { cell.addElement(new Chunk(bean.getDescrizioneDocumentiPadre(), PdfFontFactory.PDF_fPiccolissimo4)); } } else { cell.addElement(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimoB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(6); cell.setMaxLines(2); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("COD. C/F\t\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(String.valueOf(bean.getClifor().getId_clifor()), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(3); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("PARTITA IVA/CF\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(bean.getClifor().getPIva() + " / " + bean.getClifor().getPIva(), PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(11); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Telefoni\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk( bean.getClifor().getTelefono() + " " + bean.getClifor().getTelefono(), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(20); l_pdfCorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("CONDIZIONI DI PAGAMENTO\n", PdfFontFactory.PDF_fPiccolissimo)); cell.addElement(new Chunk(bean.getTipoPagamento().getDescrizione(), PdfFontFactory.PDF_fPiccolissimoB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(20); l_pdfCorpo.addCell(cell); if (!bean.getPudoId().isEmpty()) { cell = new Cell(); cell.addElement(new Chunk("CONSEGNA PRESSO FERMOPOINT ", PdfFontFactory.PDF_fGrandeB)); cell.addElement(new Chunk(bean.getPudoDesc(), PdfFontFactory.PDF_fGrandeBlu)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(40); l_pdfCorpo.addCell(cell); } l_document.add((Element)l_pdfCorpo); } catch (Exception e) { e.printStackTrace(); } return l_document; } public ByteArrayOutputStream creaBartoliniCodBarrePdf(DocumentoCR CR) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { this.document = new Document(PageSize.A4, 0.0F, 0.0F, 0.0F, 0.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); int altezzaCod = 50; int larghezzaCod = 120; int labelNumber = 0; int nCol = 3; int nRow = 8; CR.setFlgBartolini(2L); Vectumerator vec = findByCR(CR, 0, 0); float[] widths = { 0.33F, 0.33F, 0.33F }; PdfPTable corpo = new PdfPTable(widths); corpo.setWidthPercentage(100.0F); if (CR.getBlankLabels() > 0L) { PdfPCell pdfPCell = new PdfPCell(); pdfPCell.setFixedHeight(PageSize.A4.getHeight() / (float)nRow); pdfPCell.setBorder(0); for (int i = 0; (long)i < CR.getBlankLabels(); i++) { labelNumber++; corpo.addCell(pdfPCell); } } PdfContentByte cb = this.writer.getDirectContent(); Barcode128 codeBar = new Barcode128(); codeBar.setCodeType(9); while (vec.hasMoreElements()) { Documento rowBean = (Documento)vec.nextElement(); for (int i = 0; (long)i < rowBean.getNColli(); i++) { labelNumber++; PdfPCell pdfPCell = new PdfPCell(); pdfPCell.setBorder(0); codeBar.setCode(rowBean.getCodeBar((long)(i + 1))); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); pdfPCell.addElement(new Chunk(imgBarcode, 30.0F, (float)(-altezzaCod + 10))); pdfPCell.addElement(new Chunk("\n\n\n TuttoFoto - Ft. n. " + rowBean.getNumeroDocumento() + " collo n. " + i + 1 + " di " + rowBean.getNColli(), PDF_fPiccoloB)); pdfPCell.setVerticalAlignment(4); pdfPCell.setFixedHeight(PageSize.A4.getHeight() / (float)nRow); pdfPCell.setIndent(20.0F); corpo.addCell(pdfPCell); } if (CR.getFlgSimulazione() == 0L) rowBean.aggiornaFlgBartolini(3L); } int numberBlankCell = nCol - labelNumber % nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight(PageSize.A4.getHeight() / (float)nRow); cell.setBorder(0); if (numberBlankCell != 3) for (int i = 0; i < numberBlankCell; i++) corpo.addCell(cell); this.document.add((Element)corpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public ByteArrayOutputStream creaBartoliniLabelPdf(DocumentoCR CR) { boolean creaFile = false; ByteArrayOutputStream ba = new ByteArrayOutputStream(); int pageNumber = 1; try { if (CR.getId_documentoS() > 0L) { Documento bean = null; bean = new Documento(getApFull()); bean.findByPrimaryKey(CR.getId_documentoS()); bean.setCurrentLang(getCurrentLang()); this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 10.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); this.document = creaLabelBartoliniPdfUno(bean, this.document, pageNumber); CR.setFilePdf(bean.getPathStampaDocumentoFull()); setDescDocumenti(bean.getDescDocumenti()); } else { String temp = ""; Vectumerator vec = new Documento(getApFull()).findByCR(CR, 0, 0); System.out.println("" + vec.getTotNumberOfRecords() + " " + vec.getTotNumberOfRecords()); boolean firstrecord = true; while (vec.hasMoreElements()) { System.out.println("dengtro: " + vec.getTotNumberOfRecords() + " " + vec.hasMoreElements()); pageNumber = 1; Documento row = (Documento)vec.nextElement(); if (firstrecord) { this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 10.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); firstrecord = false; } System.out.println("Creazione pdf doc. n. " + row.getNumeroDocumentoCompleto()); this.document = creaLabelBartoliniPdfUno(row, this.document, pageNumber); if (vec.hasMoreElements()) this.document.newPage(); } CR.setFilePdf(getDocBase() + getDocBase() + "_" + getPathStampeDocumenti() + "docs.pdf"); } this.document.close(); this.document = null; if (creaFile) { createFileFromByteArray(ba, CR.getFilePdf()); System.out.println("Creato file label bartolini " + CR.getFilePdf()); } } catch (Exception e) { e.printStackTrace(); } return ba; } public ResParm saveOLD() { boolean debug = false; ResParm rp = new ResParm(); if (getFlgStato() == 0L && getFlgDocumentoPrelevato() == 1L) { rp.setStatus(false); rp.setMsg("ERRORE! Impossibile salvare una bozza con stato prelevamento chiuso!"); return rp; } rp = calcoloStatoLavorazione(); if (!rp.getStatus()) return rp; boolean salvaAgenti = false; long statoPrecedente = getFlgStatoPrecedente(); long statoOrdineWwwPrecedente = getFlgStatoOrdineWwwPrecedente(); long statoPrelevatoPrecedente = getFlgDocumentoPrelevatoPrecedente(); long statoPrenotazionePrecedente = getFlgStatoPrenotazionePrecedene(); long l_id_cliforPrecedente = getId_cliforPrecedente(); String currentPdfFile = getPathStampaDocumentoFull(); File pdfFile = new File(currentPdfFile); if (pdfFile.exists()) pdfFile.delete(); setTmstFilePdf(null); synchronized (this) { try { rp = checkEMSTA(); if (!rp.getStatus()) { Documento documento = (Documento)clone(); findByPrimaryKey(documento.getId_documento()); setNote(documento.getNote()); setNotaAggiuntiva(documento.getNotaAggiuntiva()); logDebug(debug, "Documento.save:save note"); superSave(); return rp; } if (rp.getStatus() && hasScadenzeSuRiba()) { rp.setStatus(false); rp.setMsg("ERRORE! Esistono delle distinte riba già legate alle scadenze"); return rp; } if (getFlgStato() != statoPrecedente && new DocumentoPagamento( getApFull()).hasPagamentiEffettuatiByDocumento(getId_documento())) return new ResParm(false, "ERRORE! Non posso cambiare stato documento in " + getStato() + ": sono stati inseriti dei pagamenti."); if (getDBState() == 0) salvaAgenti = true; Documento doc = new Documento(getApFull()); doc.findByPrimaryKey(getId_documento()); if (doc.getId_clifor() != getId_clifor()) salvaAgenti = true; if (getTipoDocumento().getFlgTipologia() == 4L) { if (getId_documentoXpay() == null || getId_documentoXpay().isEmpty()) setId_documentoXpay(getNuovoProgressivoDocumentoXpay()); } else { setId_documentoXpay(null); } if (getDBState() == 1) if (getTipoDocumento().getFlgCorrispettivi() == 0L) { RigaDocumento rf = new RigaDocumento(getApFull()); RigheRegistroIva rri = getRigaRegistroIva(); setImponibileRighe(rri.getTotImponibile()); setImportoIvaRighe(rri.getTotIva()); rri = getRigaRegistroIvaCompleto(); setImponibileTotale(rri.getTotImponibile()); setImportoIvaTotale(rri.getTotIva()); setImportoRMRighe(rf.getTotImportoRMRighe(getId_documento())); } else { double importoTotale = getImportoTotaleRigheCorrispettivi(); setImportoTotale(importoTotale); } if (hasDocumentiPadre()) { setFlgHaDocumentoPadre(1L); } else { setFlgHaDocumentoPadre(0L); } if (hasDocumentiFiglio()) { setFlgEmettiFatturaScontrino(1L); } else { setFlgEmettiFatturaScontrino(0L); } if (isFatturaONotaDiCredito() && l_id_cliforPrecedente != 0L && l_id_cliforPrecedente != getId_clifor()) if (getId_documento() > 0L) new DocumentoAgente(getApFull()).deleteAgentiByDocumento(getId_documento()); if (isFatturaONotaDiCredito() && l_id_cliforPrecedente != getId_clifor()) { if (getClifor().getId_agente() > 0L) { DocumentoAgente da = new DocumentoAgente(getApFull()); da.setId_documento(getId_documento()); da.setId_cliforDA(getClifor().getId_agente()); da.setPercDocumentoAgente(getClifor().getPercAgente()); logDebug(debug, "Documento.save:save documento agente1"); da.save(); } if (getClifor().getId_respCommerciale() > 0L) { DocumentoAgente da = new DocumentoAgente(getApFull()); da.setId_documento(getId_documento()); da.setId_cliforDA(getClifor().getId_respCommerciale()); da.setPercDocumentoAgente(getClifor().getPercRespCommerciale()); logDebug(debug, "Documento.save:save documento agente2"); da.save(); } } if (getId_destinazioneDiversa() > 0L && getIndirizzoSped().isEmpty()) { setPresso(getDestinazioneDiversa().getPressoDD()); setIndirizzoSped(getDestinazioneDiversa().getIndirizzoDD()); setNumeroCivicoSped(getDestinazioneDiversa().getNumeroCivicoDD()); setCittaSped(getDestinazioneDiversa().getDescrizioneComuneDD()); setProvinciaSped(getDestinazioneDiversa().getProvinciaComuneDD()); if (getDestinazioneDiversa().getCapZonaDD().isEmpty()) { setCapSped(getDestinazioneDiversa().getCapComuneDD()); } else { setCapSped(getDestinazioneDiversa().getCapZonaDD()); } setId_nazioneSped(getDestinazioneDiversa().getId_nazioneDD()); } logDebug(debug, "Documento.save:super save"); rp = super.save(); if (rp.getStatus()) { if (getParm("USA_MAGAZZINO").isTrue()) if ((statoPrecedente != 0L && getFlgStato() == 0L && getFlgStatoOrdineWww() != 99L) || (statoPrecedente == 0L && getFlgStato() != 0L && getFlgStatoOrdineWww() != 99L) || (statoOrdineWwwPrecedente != 99L && getFlgStatoOrdineWww() == 99L && statoPrecedente != 0L) || (statoOrdineWwwPrecedente == 99L && getFlgStatoOrdineWww() != 99L && statoPrecedente != 0L)) { boolean isTipoMovimentoInverso = false; if (getFlgStato() == 0L || getFlgStatoOrdineWww() == 99L) isTipoMovimentoInverso = true; boolean isStatoOrdineWwwAnnullato = (getFlgStatoOrdineWww() == 99L); aggiornaRigheDocumentoMagArticolo(this, isTipoMovimentoInverso); } if (getId_tipoDocumento() == getId_docPrenotazione() && statoPrenotazionePrecedente != getFlgStatoPrenotazione()) checkStatoPrenotazioneByDocumento(); if (isFatturaONotaDiCredito()) { DocumentoScadenza ds = new DocumentoScadenza(getApFull()); rp = ds.deleteByDocumento(getId_documento()); if (getFlgStato() == 1L) { DocumentoPagamento dp = new DocumentoPagamento(getApFull()); dp.findRecordDocumentoByDocumento(getId_documento()); dp.delete(); dp.setId_documento(getId_documento()); dp.setId_tipoPagamento(0L); dp.setFlgTipoMovimento(1L); dp.setData(getDataDocumento()); if (getClifor().getFlgSplitPayment() == 0L) { dp.setImporto(getTotaleDocumento()); } else { dp.setImporto(getImponibileTotale()); } dp.setNota("Emissione fattura."); logDebug(debug, "Documento.save: documento pagamento"); dp.save(); if (rp.getStatus()) { TipoPagamento tipoPagamento = new TipoPagamento(getApFull()); Vectumerator vec = tipoPagamento.getScadenzeDocumento(getId_documento()); while (vec.hasMoreElements()) { ds = (DocumentoScadenza)vec.nextElement(); logDebug(debug, "Documento.save:save documento scadenza"); rp = ds.save(); } } } else { DocumentoPagamento dp = new DocumentoPagamento(getApFull()); dp.findRecordDocumentoByDocumento(getId_documento()); dp.delete(); } } else { DocumentoScadenza ds = new DocumentoScadenza(getApFull()); rp = ds.deleteByDocumento(getId_documento()); DocumentoPagamento dp = new DocumentoPagamento(getApFull()); dp.findRecordDocumentoByDocumento(getId_documento()); dp.delete(); } if (statoPrelevatoPrecedente != getFlgDocumentoPrelevato()) if (getFlgDocumentoPrelevato() == 0L) { Vectumerator vec = new RigaDocumento(getApFull()) .findRigheNonPrelevatePreChiusuraByDocumento(getId_documento()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); row.setFlgRigaPrelevata(0L); row.superSave(); } } else if (getFlgDocumentoPrelevato() == 1L) { Vectumerator vec = new RigaDocumento(getApFull()) .findRigheNonPrelevateByDocumento(getId_documento()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); row.settaRigaPrelevata(); } } if (getFlgPagata() == 1L) { impostaPagato(getDataPagamento()); if (hasDocumentiPadre()) { Vectumerator vecPadri = findDocumentiPadre(); while (vecPadri.hasMoreElements()) { Documento row = (Documento)vecPadri.nextElement(); row.setFlgPagata(1L); row.impostaPagato(getDataPagamento()); } } } else { impostaNonPagato(); } } } catch (Exception e) { rp.setMsg(e.getMessage()); } } return rp; } public double getDeliveryCostOrdine(Clifor clifor) { double delivCost = 0.0D, moreCost = 0.0D, warnCost = 0.0D; if (clifor != null && clifor.getDBState() == 1) { DestinazioneDiversa dd = clifor.getCurrentDD(); if (!dd.getId_nazioneDD().isEmpty()) { delivCost = dd.getNazioneDD().getCostoSpedizione(); } else { delivCost = clifor.getNazione().getCostoSpedizione(); } if (delivCost == 0.0D) delivCost = getParm(Cart.P_DELIVERY_COST).getNumeroDouble(); } else { delivCost = getParm(Cart.P_DELIVERY_COST).getNumeroDouble(); } long l_flgTipoPagamento = getId_tipoPagamento(); if (getTipoPagamento().getFlgAbilitatoNegozio() == 1L) { delivCost = 0.0D; } else { if (getTipoPagamento().getFlgAbilitatoCorriere() == 1L) { moreCost = getParm(Cart.P_MORE_COST).getNumeroDouble(); } else { moreCost = 0.0D; } if (getFlgAvvisoConsegna() == 1L) { warnCost = getParm(Cart.P_DELIVERY_WARN_COST).getNumeroDouble(); } else { warnCost = 0.0D; } } DoubleOperator dop = new DoubleOperator(delivCost); dop.add(moreCost); dop.add(warnCost); return dop.getResult(); } private void creaDocumentoCorpoFt(Document l_document, Table l_pdfCorpo, long tipoCorpoFattura) { int righePerPagina = (int)getTipoDocumento().getRighePerPagina(); if (righePerPagina <= 0) righePerPagina = 10; int maxCarDesc = (int)getTipoDocumento().getMaxCarDesc(); if (maxCarDesc == 0) maxCarDesc = 35; int riga = 0; int cellLeadingRow = getDocLeadRow(); if (cellLeadingRow == 0) cellLeadingRow = 12; Font PDF_frow = getTipoDocumento().getPdfFontRow(); Font PDF_frowSmall = getTipoDocumento().getPdfFontRowSmall(); NumberFormat nf = getNf(); int ordineInverso = (getTipoDocumento().getFlgOrdinamentoRigheStampa() == 1L) ? 1 : 0; Vectumerator vec = findRigheDocumento(0, 0, ordineInverso); int colSpanDescrizione = cols_FT_STD_[0]; if (tipoCorpoFattura == 1L || tipoCorpoFattura == 2L) colSpanDescrizione = cols_FT_STD_[0] + cols_FT_STD_[1] + cols_FT_STD_[2] + cols_FT_STD_[3]; try { long resHasUsato = hasRigheConUsato(); String s_note = getNote(); if (resHasUsato == 1L || resHasUsato == 2L || resHasUsato == 5L || resHasUsato == 6L) { Iva ivaRM = new Iva(getApFull()); ivaRM.findByPrimaryKey(getCodiceIvaRegimeMargine()); s_note = s_note + "\n" + s_note; } ArrayList alNote = RigaDocumentoItemPdf.getArrayListNota(s_note, 0, cols_FT_STD_, PDF_frow); if (getDocPosizioneNota() == 0L) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); while (vec.hasMoreElements()) { String desc, descQta; double imponibile, importo; String scontoS; RigaDocumento row = (RigaDocumento)vec.nextElement(); double quantita = row.getQuantita(); if (row.getSconto() > 0.0D) { scontoS = nf.format(row.getSconto()); } else { scontoS = ""; } if (!row.getIva().getFlgTipo().equals("R")) { desc = row.getDescrizioneRiga(); if (!row.getSeriale().isEmpty()) { String temp = row.getSeriale().replace("\n", ""); temp = temp.replace("\r", ""); desc = desc + "\nS/N " + desc; } if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } else { desc = row.getDescrizioneRiga(); if (row.getArticolo().isSuperGaranzia()) desc = desc + " - Supergaranzia"; imponibile = row.getImponibile(); importo = row.getTotImponibileRigaConSconto(); } if (row.getSeriale().isEmpty() && !row.getArticolo().getNMatricola().isEmpty()) desc = desc + " Mat. N. " + desc; if (!row.getNotaBarcode().isEmpty()) desc = desc + " - " + desc; String codIva = row.getIva().getDescrizioneRigaStampaAuto(); if (!row.getNotaRigaDocumento().isEmpty()) desc = desc + " " + desc; if (row.getArticolo().getTipo().getTipologiaArticolo().getFlgUdm() != 1L) { if (isQuantitaMagazzinoIntere()) { descQta = row.getUdm() + " " + row.getUdm(); } else { descQta = row.getUdm() + " " + row.getUdm(); } } else if (isQuantitaMagazzinoIntere()) { descQta = getNf0().format(quantita); } else { descQta = nf.format(quantita); } ArrayList dati = new ArrayList<>(); dati.add(new RigaDocumentoItemPdf(colSpanDescrizione, desc, PDF_frow)); if (tipoCorpoFattura == 0L) { dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[1], descQta, PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[2], nf.format(imponibile), PDF_frow, 2)); dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[3], scontoS, PDF_frow, 2)); } if (tipoCorpoFattura == 0L || tipoCorpoFattura == 1L) { dati.add(new RigaDocumentoItemPdf(cols_FT_STD_[4], nf.format(importo), PDF_frow, 2)); if (codIva.length() >= 10) { dati.add(new RigaDocumentoItemPdf(6, codIva, PDF_frowSmall, 2)); } else { dati.add(new RigaDocumentoItemPdf(6, codIva, PDF_frow, 2)); } } else if (tipoCorpoFattura == 2L) { dati.add(new RigaDocumentoItemPdf(10, "€ " + nf.format(importo), PDF_frow, 2)); } riga = inserisciRigaDocumento(dati, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); } if (getDocPosizioneNota() == 1L && !s_note.isEmpty()) riga = inserisciRigaDocumento(alNote, 0, riga, l_document, l_pdfCorpo, cellLeadingRow, vec.hasMoreElements()); if (righePerPagina - riga > 0) riga = inserisciRigheVuote(righePerPagina - riga, cols_FT_STD_, riga, l_document, l_pdfCorpo, cellLeadingRow); } catch (Exception e) { handleDebug(e); } } public ResParm sendSpeditoMailMessageOld(String lang) { ResParm rp = new ResParm(true); try { NumberFormat nf = getNf(); if (getDataSpedizione() == null) { setDataSpedizione(getToday()); save(); } String mmFile = getCheckOutMailMessage(lang); mmFile = mmFile.replace(".html", "_spedito.html"); MailMessage mf = new MailMessage(getApFull(), mmFile); mf.setQuestionMark(false); String descOrdine = "Ordine "; if (getDocumentoPadreUno().getId_ordine() > 0L) { descOrdine = "Ordine n. " + getDocumentoPadreUno().getId_documento() + " del " + getDataFormat().format(getDocumentoPadreUno().getDataDocumento()); mf.setString("descOrdine", descOrdine); mf.setString("codiceOrdine", String.valueOf(getDocumentoPadreUno().getId_ordine())); } mf.setString("nomeCliente", getClifor().getCognomeNome()); mf.setString("dataSpedizione", getDataFormat().format(getDataSpedizione())); mf.setString("corriere", getVettore().getDescrizione()); mf.setString("nColli", String.valueOf(getNColli())); mf.setString("nome", getClifor().getNome()); mf.setString("cognome", getClifor().getCognome()); mf.setString("indirizzo", getClifor().getIndirizzo()); mf.setString("numero", getClifor().getNumeroCivico()); String capComune = getClifor().getCapComune(); if (!getClifor().getCapZona().isEmpty()) capComune = getClifor().getCapZona(); mf.setString("cap", capComune); mf.setString("citta", getClifor().getDescrizioneComune()); mf.setString("provincia", getClifor().getProvinciaComune()); mf.setString("codfisc", getClifor().getCodFisc()); mf.setString("piva", getClifor().getPIva()); mf.setString("email", getClifor().getEMail()); mf.setString("telefono", getClifor().getTelefono()); if (getIndirizzoSped().trim().isEmpty()) { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getClifor().getIndirizzo()); } else { mf.setString("indirizzoSped", getClifor().getIndirizzo() + " c/o " + getClifor().getIndirizzo()); } mf.setString("numeroSped", getClifor().getNumeroCivico()); mf.setString("capSped", capComune); mf.setString("cittaSped", getClifor().getDescrizioneComune()); mf.setString("provinciaSped", getClifor().getProvinciaComune()); } else { if (getPresso().isEmpty()) { mf.setString("indirizzoSped", getIndirizzoSped()); } else { mf.setString("indirizzoSped", getIndirizzoSped() + " c/o " + getIndirizzoSped()); } mf.setString("numeroSped", getNumeroCivicoSped()); mf.setString("capSped", getCapSped()); mf.setString("cittaSped", getCittaSped()); mf.setString("provinciaSped", getProvinciaSped()); } String temp = ""; if (getId_tipoPagamento() == 1L) temp = "La informiamo che alla consegna, il corriere richiedera' l'importo di " + nf.format(getTotaleDocumento()) + " euro del contrassegno"; if (!getNotaSpedizione().isEmpty()) temp = temp + "

" + temp; mf.setString("nota", temp); if (!getVettore().getLinkTracking().isEmpty()) { String track = "Potra' verificare la spedizione da domani mattina al seguente link "; mf.setString("tracking", track); } rp = mf.sendMailMessageSystem(getClifor().getEMail(), "Tuttofoto - Spedizione " + descOrdine, true); if (rp.getStatus()) { setDataInvioMailSped(getToday()); save(); } } catch (Exception e) { handleDebug(e); rp.setStatus(false); rp.setMsg(e); } return rp; } public static synchronized ResParm saveSynchro(Documento bean) { boolean debug = false; ResParm rp = new ResParm(); if (bean.getFlgStato() == 0L && bean.getFlgDocumentoPrelevato() == 1L) { rp.setStatus(false); rp.setMsg("ERRORE! Impossibile salvare una bozza con stato prelevamento chiuso!"); return rp; } rp = bean.calcoloStatoLavorazione(); if (!rp.getStatus()) return rp; boolean salvaAgenti = false; long statoPrecedente = bean.getFlgStatoPrecedente(); long statoOrdineWwwPrecedente = bean.getFlgStatoOrdineWwwPrecedente(); long statoPrelevatoPrecedente = bean.getFlgDocumentoPrelevatoPrecedente(); long statoPrenotazionePrecedente = bean.getFlgStatoPrenotazionePrecedene(); long statoLavorazionePrecedente = bean.getFlgStatoLavorazionePrecedente(); long l_id_cliforPrecedente = bean.getId_cliforPrecedente(); String currentPdfFile = bean.getPathStampaDocumentoFull(); File pdfFile = new File(currentPdfFile); if (pdfFile.exists()) pdfFile.delete(); bean.setTmstFilePdf(null); try { rp = bean.checkEMSTA(); if (!rp.getStatus()) { Documento documento = (Documento)bean.clone(); bean.findByPrimaryKey(documento.getId_documento()); bean.setNote(documento.getNote()); bean.setNotaAggiuntiva(documento.getNotaAggiuntiva()); bean.setNotaMail(documento.getNotaMail()); bean.setFlgPagata(documento.getFlgPagata()); if (bean.getFlgPagata() == 1L) { if (documento.getDataPagamento() == null) { bean.setDataPagamento(getToday()); } else { bean.setDataPagamento(documento.getDataPagamento()); } } else { bean.setDataPagamento(null); } bean.setDataInvioMailSped(documento.getDataInvioMailSped()); bean.setFlgDocumentoPrelevato(documento.getFlgDocumentoPrelevato()); bean.setDataSpedizione(documento.getDataSpedizione()); logDebug(debug, "Documento.save:save note"); String infoMsg = rp.getMsg(); rp = bean.superSave(); if (rp.getStatus()) { rp.setStatus(true); rp.setInfoMsg(infoMsg); } return rp; } if (rp.getStatus() && bean.hasScadenzeSuRiba()) { rp.setStatus(false); rp.setMsg("ERRORE! Esistono delle distinte riba già legate alle scadenze"); return rp; } if (bean.getFlgStato() != statoPrecedente && new DocumentoPagamento( bean.getApFull()).hasPagamentiEffettuatiByDocumento(bean.getId_documento())) return new ResParm(false, "ERRORE! Non posso cambiare stato documento in " + bean.getStato() + ": sono stati inseriti dei pagamenti."); if (bean.getDBState() == 0) salvaAgenti = true; Documento doc = new Documento(bean.getApFull()); doc.findByPrimaryKey(bean.getId_documento()); if (doc.getId_clifor() != bean.getId_clifor()) salvaAgenti = true; if (bean.getTipoDocumento().getFlgTipologia() == 4L) { if (bean.getId_documentoXpay() == null || bean.getId_documentoXpay().isEmpty()) bean.setId_documentoXpay(bean.getNuovoProgressivoDocumentoXpay()); } else { bean.setId_documentoXpay(null); } if (bean.getDBState() == 1) if (bean.getTipoDocumento().getFlgCorrispettivi() == 0L) { RigaDocumento rf = new RigaDocumento(bean.getApFull()); RigheRegistroIva rri = bean.getRigaRegistroIva(); bean.setImponibileRighe(rri.getTotImponibile()); bean.setImportoIvaRighe(rri.getTotIva()); rri = bean.getRigaRegistroIvaCompleto(); bean.setImponibileTotale(rri.getTotImponibile()); bean.setImportoIvaTotale(rri.getTotIva()); bean.setImportoRMRighe(rf.getTotImportoRMRighe(bean.getId_documento())); } else { double importoTotale = bean.getImportoTotaleRigheCorrispettivi(); bean.setImportoTotale(importoTotale); } if (bean.hasDocumentiPadre()) { bean.setFlgHaDocumentoPadre(1L); } else { bean.setFlgHaDocumentoPadre(0L); } if (bean.hasDocumentiFiglio()) { bean.setFlgEmettiFatturaScontrino(1L); } else { bean.setFlgEmettiFatturaScontrino(0L); } if (bean.isFatturaONotaDiCredito() && l_id_cliforPrecedente != 0L && l_id_cliforPrecedente != bean.getId_clifor()) if (bean.getId_documento() > 0L) new DocumentoAgente(bean.getApFull()).deleteAgentiByDocumento(bean.getId_documento()); if (bean.isFatturaONotaDiCredito() && l_id_cliforPrecedente != bean.getId_clifor()) { if (bean.getClifor().getId_agente() > 0L) { DocumentoAgente da = new DocumentoAgente(bean.getApFull()); da.setId_documento(bean.getId_documento()); da.setId_cliforDA(bean.getClifor().getId_agente()); da.setPercDocumentoAgente(bean.getClifor().getPercAgente()); logDebug(debug, "Documento.save:save documento agente1"); da.save(); } if (bean.getClifor().getId_respCommerciale() > 0L) { DocumentoAgente da = new DocumentoAgente(bean.getApFull()); da.setId_documento(bean.getId_documento()); da.setId_cliforDA(bean.getClifor().getId_respCommerciale()); da.setPercDocumentoAgente(bean.getClifor().getPercRespCommerciale()); logDebug(debug, "Documento.save:save documento agente2"); da.save(); } } if (bean.getId_destinazioneDiversa() > 0L && bean.getIndirizzoSped().isEmpty()) { bean.setPresso(bean.getDestinazioneDiversa().getPressoDD()); bean.setIndirizzoSped(bean.getDestinazioneDiversa().getIndirizzoDD()); bean.setNumeroCivicoSped(bean.getDestinazioneDiversa().getNumeroCivicoDD()); bean.setCittaSped(bean.getDestinazioneDiversa().getDescrizioneComuneDD()); bean.setProvinciaSped(bean.getDestinazioneDiversa().getProvinciaComuneDD()); if (bean.getDestinazioneDiversa().getCapZonaDD().isEmpty()) { bean.setCapSped(bean.getDestinazioneDiversa().getCapComuneDD()); } else { bean.setCapSped(bean.getDestinazioneDiversa().getCapZonaDD()); } bean.setId_nazioneSped(bean.getDestinazioneDiversa().getId_nazioneDD()); } rp = bean.superSave(); if (rp.getStatus()) { if (bean.getParm("USA_MAGAZZINO").isTrue()) if ((statoPrecedente != 0L && bean.getFlgStato() == 0L && bean.getFlgStatoOrdineWww() != 99L) || (statoPrecedente == 0L && bean.getFlgStato() != 0L && bean.getFlgStatoOrdineWww() != 99L) || (statoOrdineWwwPrecedente != 99L && bean.getFlgStatoOrdineWww() == 99L && statoPrecedente != 0L) || (statoOrdineWwwPrecedente == 99L && bean.getFlgStatoOrdineWww() != 99L && statoPrecedente != 0L)) { boolean isTipoMovimentoInverso = false; if (bean.getFlgStato() == 0L || bean.getFlgStatoOrdineWww() == 99L) isTipoMovimentoInverso = true; boolean isStatoOrdineWwwAnnullato = (bean.getFlgStatoOrdineWww() == 99L); aggiornaRigheDocumentoMagArticolo(bean, isTipoMovimentoInverso); } if (bean.getId_tipoDocumento() == bean.getId_docPrenotazione() && statoPrenotazionePrecedente != bean.getFlgStatoPrenotazione()) bean.checkStatoPrenotazioneByDocumento(); if (bean.isFatturaONotaDiCredito()) { DocumentoScadenza ds = new DocumentoScadenza(bean.getApFull()); rp = ds.deleteByDocumento(bean.getId_documento()); if (bean.getFlgStato() == 1L) { DocumentoPagamento dp = new DocumentoPagamento(bean.getApFull()); dp.findRecordDocumentoByDocumento(bean.getId_documento()); dp.delete(); dp.setId_documento(bean.getId_documento()); dp.setId_tipoPagamento(0L); dp.setFlgTipoMovimento(1L); dp.setData(bean.getDataDocumento()); if (bean.getClifor().getFlgSplitPayment() == 0L) { dp.setImporto(bean.getTotaleDocumento()); } else { dp.setImporto(bean.getImponibileTotale()); } dp.setNota("Emissione fattura."); logDebug(debug, "Documento.save: documento pagamento"); dp.save(); if (rp.getStatus()) { TipoPagamento tipoPagamento = new TipoPagamento(bean.getApFull()); Vectumerator vec = tipoPagamento.getScadenzeDocumento(bean.getId_documento()); while (vec.hasMoreElements()) { ds = (DocumentoScadenza)vec.nextElement(); logDebug(debug, "Documento.save:save documento scadenza"); rp = ds.save(); } } } else { DocumentoPagamento dp = new DocumentoPagamento(bean.getApFull()); dp.findRecordDocumentoByDocumento(bean.getId_documento()); dp.delete(); } } else { DocumentoScadenza ds = new DocumentoScadenza(bean.getApFull()); rp = ds.deleteByDocumento(bean.getId_documento()); DocumentoPagamento dp = new DocumentoPagamento(bean.getApFull()); dp.findRecordDocumentoByDocumento(bean.getId_documento()); dp.delete(); } if (statoPrelevatoPrecedente != bean.getFlgDocumentoPrelevato()) if (bean.getFlgDocumentoPrelevato() == 0L) { Vectumerator vec = new RigaDocumento(bean.getApFull()) .findRigheNonPrelevatePreChiusuraByDocumento(bean.getId_documento()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); row.setFlgRigaPrelevata(0L); row.superSave(); } } else if (bean.getFlgDocumentoPrelevato() == 1L) { Vectumerator vec = new RigaDocumento(bean.getApFull()) .findRigheNonPrelevateByDocumento(bean.getId_documento()); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); row.settaRigaPrelevata(); } } if (bean.getFlgPagata() == 1L) { bean.impostaPagato(bean.getDataPagamento()); if (bean.hasDocumentiPadre()) { Vectumerator vecPadri = bean.findDocumentiPadre(); while (vecPadri.hasMoreElements()) { Documento row = (Documento)vecPadri.nextElement(); row.setFlgPagata(1L); row.impostaPagato(bean.getDataPagamento()); } } } else { bean.impostaNonPagato(); } if (bean.getTipoDocumento().getTipologiaDocumento().getCodice() == 200L) { Vectumerator vecLp = new LavPezza(bean.getApFull()).findByDocumento(bean.getId_documento()); while (vecLp.hasMoreElements()) { LavPezza row = (LavPezza)vecLp.nextElement(); if (row.getId_clifor() != bean.getId_clifor()) { row.setId_clifor(bean.getId_clifor()); row.superSave(); } } } if (bean.getTipoDocumento().getFlgTipologia() == 201L) if (bean.getFlgStatoLavorazione() != statoLavorazionePrecedente) { Vectumerator vecRT = bean.findRigheDocumento(0L, 0, 0, 0); while (vecRT.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vecRT.nextElement(); rp.append(RigaDocumento.aggiornaDispoTessuto(bean.getApFull(), row.getArticoloTessutoColore().getId_articoloTessuto(), row.getId_articoloTessutoColore(), row.getLastUpdId_user())); } } } } catch (Exception e) { rp.setMsg(e.getMessage()); } return rp; } public double getMtTotaliInviate() { if (getId_documento() == 0L || getTipoDocumento().getFlgTipologia() != 200L) return 0.0D; return new LavPezza(getApFull()).getTotMetriByDocumentoDTESS(getId_documento(), true); } public double getPrezzo1000Colpi() { return this.prezzo1000Colpi; } public void setPrezzo1000Colpi(double prezzo1000Colpi) { this.prezzo1000Colpi = prezzo1000Colpi; } public double getPrezzoAnnodatura() { return this.prezzoAnnodatura; } public void setPrezzoAnnodatura(double prezzoAnnodatura) { this.prezzoAnnodatura = prezzoAnnodatura; } private ResParm creaDocumentoFiglioDaDisposizioniTessitura(long l_id_clifor, long l_id_tipoDocumentoFiglio, Users operatore, boolean creaBozza, long l_flgTipoCreazioneRiga) { return creaDocumentoFiglioDaDisposizioniTessitura(l_id_clifor, l_id_tipoDocumentoFiglio, operatore, creaBozza, l_flgTipoCreazioneRiga, null); } private ResParm creaDocumentoFiglioDaDisposizioniTessituraBasataSuDisposizioneOLD(long l_id_clifor, long l_id_tipoDocumentoFiglio, Users operatore, boolean creaBozza, long l_flgTipoCreazioneRiga) { String SPACE = " "; if (l_id_clifor == 0L) l_id_clifor = getId_clifor(); if (getTipoDocumento().getFlgObbligoPrelievo() == 1L) return new ResParm(false, "ERRORE! Figlio non generabile. Documento con obbligo di prelievo"); long righeCreate = 0L; ResParm rp = new ResParm(); ResParm rpRow = new ResParm(); if (getDBState() == 1) { TipoDocumento tdGen = new TipoDocumento(getApFull()); tdGen.findByPrimaryKey(l_id_tipoDocumentoFiglio); LavPezza lavPezza = new LavPezza(getApFull()); if (!isDocumentoFiglioCreabile()) { rp.setStatus(false); rp.setMsg("Errore! Documento figlio non creabile..."); } else if (!getTipoDocumento().isTipoDocGenerabile(l_id_tipoDocumentoFiglio)) { rp.setStatus(false); rp.setMsg("Errore! Il tipo di documento " + tdGen.getDescrizioneCompleta() + " non è generabile!"); } else { TipoDocumento tdf = new TipoDocumento(getApFull()); tdf.findByPrimaryKey(l_id_tipoDocumentoFiglio); Documento doc = new Documento(getApFull()); if (creaBozza) doc.findDocumentoBozza(l_id_tipoDocumentoFiglio, l_id_clifor); if (doc.getDBState() == 0) { doc.setId_tipoDocumento(l_id_tipoDocumentoFiglio); doc.setId_clifor(l_id_clifor); Clifor clienteDoc = doc.getClifor(); if (operatore != null) doc.setId_users(getId_users()); doc.setNominativoDocumento(getNominativoDocumento()); if (clienteDoc.getId_tipoPagamento() != 0L) { doc.setId_tipoPagamento(clienteDoc.getId_tipoPagamento()); } else { doc.setId_tipoPagamento(getId_tipoPagamento()); } doc.setDataDocumento(getToday()); } if (creaBozza) doc.setFlgStato(0L); double accontiDiff = 0.0D; double importiRighe = 0.0D; double totAcconti = getTotAccontiByDocumentoPadre(getId_documento()); if (getAcconto() > totAcconti) accontiDiff = getAcconto() - totAcconti; doc.setNote(getNote()); doc.setDataScadenzaPagamento(getDataScadenzaPagamento()); doc.setFlgPagamentoDataFissa(getFlgPagamentoDataFissa()); doc.setIban(getIban()); doc.setId_destinazioneDiversa(getId_destinazioneDiversa()); doc.setPresso(getPresso()); doc.setIndirizzoSped(getIndirizzoSped()); doc.setNumeroCivicoSped(getNumeroCivicoSped()); doc.setCittaSped(getCittaSped()); doc.setProvinciaSped(getProvinciaSped()); doc.setCapSped(getCapSped()); doc.setId_nazioneSped(getId_nazioneSped()); doc.setNColli(getNColli()); doc.setKgLordo(getKgLordo()); doc.setKgNetto(getKgNetto()); doc.setVolume(getVolume()); doc.setId_causaleTrasporto(getId_causaleTrasporto()); doc.setId_vettore(getId_vettore()); doc.setFlgTrasporto(getFlgTrasporto()); doc.setId_aspetto(getId_aspetto()); doc.setId_porto(getId_porto()); doc.setNotePagamento(getNotePagamento()); doc.setNotaSpedizione(getNotaSpedizione()); doc.setNote(getNote()); doc.setNotaAggiuntiva(getNotaAggiuntiva()); doc.setNotaMail(getNotaMail()); doc.setRiferimento(getRiferimento()); doc.setDataRiferimento(getDataRiferimento()); DoubleOperator totCosti = new DoubleOperator(); long speseStd = 0L; speseStd = 0L; if (speseStd == 0L) { doc.setSpeseTrasporto(getSpeseTrasporto()); doc.setSpeseIncasso(getSpeseIncasso()); doc.setSpeseAltre(getSpeseAltre()); doc.setDescSpeseAltre(getDescSpeseAltre()); doc.setId_ivaDoc(getId_ivaDoc()); doc.setScontoIncondizionato(getScontoIncondizionato()); doc.setAbbuono(getAbbuono()); } if (speseStd == 1L) { totCosti.add(getSpeseAltreConIva()); totCosti.add(getSpeseIncassoConIva()); totCosti.add(getSpeseTrasportoConIva()); } if (speseStd == 2L); rp = doc.save(); if (rp.getStatus()) if (l_flgTipoCreazioneRiga == 0L) { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements() && rp.getStatus()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getFlgRigaPrelevata() == 0L) { righeCreate++; RigaDocumento rDoc = new RigaDocumento(getApFull()); rDoc.setId_documento(doc.getId_documento()); rDoc.setId_iva(getCodiceIvaVendStd()); rDoc.setId_magFisico(row.getId_magFisico()); rDoc.setSeriale(row.getSeriale()); if (getPrezzo1000Colpi() > 0.0D) { StringBuilder sb = new StringBuilder(getRiferimento()); sb.append(" "); sb.append(row.getDescrizioneRiga()); sb.append(" "); sb.append("Disp. "); sb.append(getNumeroDocumentoCompleto()); sb.append(" Pz. "); sb.append(lavPezza.getTotPezzeByDocumentoDTESS(getId_documento())); sb.append(" Mt. "); sb.append(getNf().format(lavPezza.getTotMetriByDocumentoDTESS(getId_documento(), false))); sb.append(" Prezzo. "); sb.append(getNf().format(getPrezzo1000Colpi())); sb.append(" Rif. "); Vectumerator vecLavPezza = lavPezza.findByDocumento(getId_documento()); HashMap hmBolle = new HashMap<>(); while (vecLavPezza.hasMoreElements()) { LavPezza rowLP = (LavPezza)vecLavPezza.nextElement(); if (!hmBolle.containsKey(Long.valueOf(rowLP.getRigaDocumentoBolla().getId_documento()))) hmBolle.put(Long.valueOf(rowLP.getRigaDocumentoBolla().getId_documento()), rowLP.getRigaDocumentoBolla().getDocumento()); } for (Map.Entry me : hmBolle.entrySet()) { sb.append(me.getValue().getNumeroDocumento()); sb.append(" "); } rDoc.setDescrizioneRiga(sb.toString()); rDoc.setNr((double)(row.getTotColpiRiga() / 1000L)); rDoc.setImponibile(getPrezzo1000Colpi()); importiRighe += row.getTotImportoRigaConSconto(); rDoc.setId_documentoPadre(row.getId_documento()); rDoc.setId_rigaDocumentoPadre(row.getId_rigaDocumento()); rpRow = addRigaDocumento(doc, rDoc); if (rpRow.getStatus()) { rp.append(rpRow); row.setFlgRigaPrelevata(1L); rp.append(row.superSave()); } } } } if (getPrezzoAnnodatura() > 0.0D) { righeCreate++; RigaDocumento rDoc = new RigaDocumento(getApFull()); rDoc.setId_documento(doc.getId_documento()); rDoc.setId_documentoPadre(getId_documento()); rDoc.setDescrizioneRiga("Annodatura"); rDoc.setNr(1.0D); rDoc.setImponibile(getPrezzoAnnodatura()); rpRow = addRigaDocumento(doc, rDoc); if (rpRow.getStatus()) rp.append(rpRow); } } else if (l_flgTipoCreazioneRiga != 1L) { if (l_flgTipoCreazioneRiga == 2L); } rp = doc.save(); if (rp.getStatus()) { if (righeCreate == 0L) { rp = new ResParm(false); rp.setMsg("ERRORE! Nessun rigo prelevabile!"); doc.delete(); } else if (accontiDiff > 0.0D) { if (findTotRigheDocumentoDaPrelevare() == 0L) { doc.setAcconto(accontiDiff); } else if (importiRighe < accontiDiff) { doc.setAcconto(importiRighe); } else { doc.setAcconto(accontiDiff); } doc.save(); } if (operatore != null) { setId_users(operatore.getId_users()); StringBuffer sb = new StringBuffer(); sb.append(getLogRecord()); if (!getLogRecord().equals("")) sb.append("
"); sb.append("Creato Documento figlio "); sb.append(tdGen.getDescrizione()); sb.append(" da "); sb.append(operatore.getCognomeNome()); sb.append(" il "); sb.append(getTimestampFormat().format(getTimestamp())); setLogRecord(sb.toString()); save(); } if (findTotRigheDocumentoDaPrelevare() == 0L) { setFlgStato(1L); setFlgDocumentoPrelevato(1L); setFlgStatoPrenotazione(90L); super.save(); } } } } findByPrimaryKey(getId_documento()); return rp; } public ResParm creaDocumentoFiglioDaDisposizioniTessitura(long l_id_clifor, long l_id_tipoDocumentoFiglio, Users operatore, boolean creaBozza, long l_flgTipoCreazioneRiga, HashMap hsDdtDaFatturare) { if (l_id_clifor == 0L) l_id_clifor = getId_clifor(); String TAG_THREAD_MSG = "CREAZIONE FT TESSITURA"; StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, getClifor().getCognomeNome() + " " + getClifor().getCognomeNome()); if (getTipoDocumento().getFlgObbligoPrelievo() == 1L) return new ResParm(false, "ERRORE! Figlio non generabile. Documento con obbligo di prelievo"); long righeCreate = 0L; ResParm rp = new ResParm(); ResParm rpRow = new ResParm(); if (getDBState() == 1) { TipoDocumento tdGen = new TipoDocumento(getApFull()); tdGen.findByPrimaryKey(l_id_tipoDocumentoFiglio); LavPezza lavPezza = new LavPezza(getApFull()); if (!isDocumentoFiglioCreabile()) { rp.setStatus(false); rp.setMsg("Errore! Documento figlio non creabile..."); } else if (!getTipoDocumento().isTipoDocGenerabile(l_id_tipoDocumentoFiglio)) { rp.setStatus(false); rp.setMsg("Errore! Il tipo di documento " + tdGen.getDescrizioneCompleta() + " non è generabile!"); } else { TipoDocumento tdf = new TipoDocumento(getApFull()); tdf.findByPrimaryKey(l_id_tipoDocumentoFiglio); Documento doc = new Documento(getApFull()); if (creaBozza) doc.findDocumentoBozza(l_id_tipoDocumentoFiglio, l_id_clifor); if (doc.getDBState() == 0) { doc.setId_tipoDocumento(l_id_tipoDocumentoFiglio); doc.setId_clifor(l_id_clifor); Clifor clienteDoc = doc.getClifor(); if (operatore != null) doc.setId_users(getId_users()); doc.setNominativoDocumento(getNominativoDocumento()); if (clienteDoc.getId_tipoPagamento() != 0L) { doc.setId_tipoPagamento(clienteDoc.getId_tipoPagamento()); } else { doc.setId_tipoPagamento(getId_tipoPagamento()); } doc.setDataDocumento(getToday()); } if (creaBozza) doc.setFlgStato(0L); double accontiDiff = 0.0D; double importiRighe = 0.0D; double totAcconti = getTotAccontiByDocumentoPadre(getId_documento()); if (getAcconto() > totAcconti) accontiDiff = getAcconto() - totAcconti; doc.setNote(getNote()); doc.setDataScadenzaPagamento(getDataScadenzaPagamento()); doc.setFlgPagamentoDataFissa(getFlgPagamentoDataFissa()); doc.setIban(getIban()); doc.setId_destinazioneDiversa(getId_destinazioneDiversa()); doc.setPresso(getPresso()); doc.setIndirizzoSped(getIndirizzoSped()); doc.setNumeroCivicoSped(getNumeroCivicoSped()); doc.setCittaSped(getCittaSped()); doc.setProvinciaSped(getProvinciaSped()); doc.setCapSped(getCapSped()); doc.setId_nazioneSped(getId_nazioneSped()); doc.setNColli(getNColli()); doc.setKgLordo(getKgLordo()); doc.setKgNetto(getKgNetto()); doc.setVolume(getVolume()); doc.setId_causaleTrasporto(getId_causaleTrasporto()); doc.setId_vettore(getId_vettore()); doc.setFlgTrasporto(getFlgTrasporto()); doc.setId_aspetto(getId_aspetto()); doc.setId_porto(getId_porto()); doc.setNotePagamento(getNotePagamento()); doc.setNotaSpedizione(getNotaSpedizione()); doc.setNote(getNote()); doc.setNotaAggiuntiva(getNotaAggiuntiva()); doc.setNotaMail(getNotaMail()); doc.setRiferimento(getRiferimento()); doc.setDataRiferimento(getDataRiferimento()); DoubleOperator totCosti = new DoubleOperator(); long speseStd = 0L; speseStd = 0L; if (speseStd == 0L) { doc.setSpeseTrasporto(getSpeseTrasporto()); doc.setSpeseIncasso(getSpeseIncasso()); doc.setSpeseAltre(getSpeseAltre()); doc.setDescSpeseAltre(getDescSpeseAltre()); doc.setId_ivaDoc(getId_ivaDoc()); doc.setScontoIncondizionato(getScontoIncondizionato()); doc.setAbbuono(getAbbuono()); } if (speseStd == 1L) { totCosti.add(getSpeseAltreConIva()); totCosti.add(getSpeseIncassoConIva()); totCosti.add(getSpeseTrasportoConIva()); } if (speseStd == 2L); rp = doc.save(); if (rp.getStatus()) if (l_flgTipoCreazioneRiga == 0L) { RigaDocumento rdAnnodatura = new RigaDocumento(getApFull()); rdAnnodatura.findRigaAnnodaturaByDocumentoPadre(getId_documento()); if (rdAnnodatura.getId_rigaDocumento() == 0L) { if (getPrezzoAnnodatura() > 0.0D) { righeCreate++; RigaDocumento rDoc = new RigaDocumento(getApFull()); rDoc.setId_documento(doc.getId_documento()); rDoc.setId_documentoPadre(getId_documento()); rDoc.setDescrizioneRiga("Annodatura disp. " + getNumeroDocumentoCompleto() + " pezza " + getRiferimento()); rDoc.setRifTipoArticolo(21L); rDoc.setNr(1.0D); rDoc.setImponibile(getPrezzoAnnodatura()); rpRow = addRigaDocumento(doc, rDoc); if (rpRow.getStatus()) rp.append(rpRow); } } else { System.out.println("Annodatura della disposizione " + getNumeroDocumentoCompleto() + " fatturata con ft " + rdAnnodatura.getDocumento().getNumeroDocumentoCompleto()); } DoubleOperator metriTotaliPezza = new DoubleOperator(0.0D, 2); Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements() && rp.getStatus()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getFlgRigaPrelevata() == 0L) { righeCreate++; RigaDocumento rDoc = new RigaDocumento(getApFull()); rDoc.setId_documento(doc.getId_documento()); rDoc.setId_iva(getCodiceIvaVendStd()); rDoc.setId_magFisico(row.getId_magFisico()); rDoc.setSeriale(row.getSeriale()); if (getPrezzo1000Colpi() > 0.0D) { double totPezzeInviateDaFatturare = (double)lavPezza.getTotPezzeInviateDaFatturareByRigaDocumentoDTESS(row.getId_rigaDocumento(), hsDdtDaFatturare); double totMetriInviateDaFatturare = lavPezza.getTotMetriDaFatturareByRigaDocumentoDTESS(row.getId_rigaDocumento(), hsDdtDaFatturare); if (totPezzeInviateDaFatturare > 0.0D && totMetriInviateDaFatturare > 0.0D) { metriTotaliPezza.add(totMetriInviateDaFatturare); StringBuilder sb = new StringBuilder(row.getDescrizioneRiga()); sb.append(" "); sb.append("Tela "); sb.append(getRiferimento()); sb.append(" Pz. "); sb.append(totPezzeInviateDaFatturare); sb.append(" Mt. "); sb.append(getNf().format(totMetriInviateDaFatturare)); sb.append(" Colpi al Dm "); sb.append(row.getNumColpiDM()); sb.append(" Rif. DDT "); Vectumerator vecLavPezza = lavPezza.findPezzeInviateDaFatturareByRIGADocumento(row.getId_rigaDocumento(), hsDdtDaFatturare); HashMap hmBolle = new HashMap<>(); HashMap hmRDBolle = new HashMap<>(); while (vecLavPezza.hasMoreElements()) { LavPezza rowLP = (LavPezza)vecLavPezza.nextElement(); if (!hmBolle.containsKey(Long.valueOf(rowLP.getRigaDocumentoBolla().getId_documento()))) hmBolle.put(Long.valueOf(rowLP.getRigaDocumentoBolla().getId_documento()), rowLP.getRigaDocumentoBolla().getDocumento()); if (!hmRDBolle.containsKey(Long.valueOf(rowLP.getId_rigaDocumentoBolla()))) hmRDBolle.put(Long.valueOf(rowLP.getId_rigaDocumentoBolla()), rowLP.getRigaDocumentoBolla()); } for (Map.Entry me : hmBolle.entrySet()) { sb.append(me.getValue().getNumeroDocumento()); sb.append(" "); } rDoc.setDescrizioneRiga(sb.toString()); DoubleOperator numeroColpi = new DoubleOperator(totMetriInviateDaFatturare); numeroColpi.multiply(10); numeroColpi.multiply(row.getNumColpiDM()); numeroColpi.divide(1000.0F); rDoc.setNr(numeroColpi.getResult()); rDoc.setImponibile(getPrezzo1000Colpi()); importiRighe += row.getTotImportoRigaConSconto(); rDoc.setId_documentoPadre(row.getId_documento()); rDoc.setId_rigaDocumentoPadre(row.getId_rigaDocumento()); rDoc.setRifTipoArticolo(20L); rpRow = addRigaDocumento(doc, rDoc); if (rpRow.getStatus()) { rp.append(rpRow); for (Map.Entry me : hmRDBolle.entrySet()) { me.getValue().setId_rigaDocumentoPadre(rDoc.getId_rigaDocumento()); me.getValue().setId_documentoPadre(rDoc.getId_documento()); rp.append(me.getValue().save()); } } } } } } RigaDocumento rdCatena = new RigaDocumento(getApFull()); if (rdCatena.getId_rigaDocumento() != 0L); if (getPrezzoCatenaAlMt() > 0.0D) { righeCreate++; RigaDocumento rDoc = new RigaDocumento(getApFull()); rDoc.setId_documento(doc.getId_documento()); rDoc.setId_documentoPadre(getId_documento()); rDoc.setDescrizioneRiga("Vendita Catena disp. " + getNumeroDocumentoCompleto() + " pezza " + getRiferimento() + " mt. " + getNf().format(metriTotaliPezza.getResult()) + " " + getNf().format(getPrezzoCatenaAlMt()) + "/mt"); rDoc.setRifTipoArticolo(22L); rDoc.setFlgUdm(3L); rDoc.setMt(metriTotaliPezza.getResult()); rDoc.setImponibile(getPrezzoCatenaAlMt()); System.out.println("" + rDoc.getTotImponibileRiga() + " " + rDoc.getTotImponibileRiga() + " " + rDoc.getUdm()); rpRow = addRigaDocumento(doc, rDoc); if (rpRow.getStatus()) rp.append(rpRow); } } else if (l_flgTipoCreazioneRiga != 1L) { if (l_flgTipoCreazioneRiga == 2L); } rp = doc.save(); if (rp.getStatus()) { if (righeCreate == 0L) { rp = new ResParm(false); rp.setMsg("ERRORE! Nessun rigo prelevabile!"); doc.delete(); } else if (accontiDiff > 0.0D) { if (findTotRigheDocumentoDaPrelevare() == 0L) { doc.setAcconto(accontiDiff); } else if (importiRighe < accontiDiff) { doc.setAcconto(importiRighe); } else { doc.setAcconto(accontiDiff); } doc.save(); } if (operatore != null) { setId_users(operatore.getId_users()); StringBuffer sb = new StringBuffer(); sb.append(getLogRecord()); if (!getLogRecord().equals("")) sb.append("
"); sb.append("Creato Documento figlio "); sb.append(tdGen.getDescrizione()); sb.append(" da "); sb.append(operatore.getCognomeNome()); sb.append(" il "); sb.append(getTimestampFormat().format(getTimestamp())); setLogRecord(sb.toString()); save(); } if (findTotRigheDocumentoDaPrelevare() == 0L) { setFlgStato(1L); setFlgDocumentoPrelevato(1L); setFlgStatoPrenotazione(90L); super.save(); } } } } findByPrimaryKey(getId_documento()); StatusMsg.deleteMsgByTag(getApFull(), TAG_THREAD_MSG); return rp; } public final ResParm startInvioMailClifor(DocumentoCR CR, String path, String testoAgg) { if (!isThreadAttivo()) { new ThreadSendMailClifor(CR, path, testoAgg); return new ResParm(true, "Thread Invio Mail a clienti avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public ResParm cCaggiornaOrdineWwwByTipoPagamento(TipoPagamento l_tipoPagamento) { ResParm rp = new ResParm(true); if (getId_documento() > 0L && getId_tipoDocumento() == getId_docOrdineWWW()) { if (l_tipoPagamento.getPercWwwSconto() != getTipoPagamento().getPercWwwSconto()) { DoubleOperator dop = new DoubleOperator(l_tipoPagamento.getPercWwwSconto()); dop.add(getPercScontoIncondizionato()); double nuovoSconto = dop.getResult(); Vectumerator row = findRigheDocumento(0, 0, 0); while (row.hasMoreElements()) { RigaDocumento rd = (RigaDocumento)row.nextElement(); rd.setSconto(nuovoSconto); rp = addRigaDocumento(this, rd); if (!rp.getStatus()) return rp; } } if (l_tipoPagamento.getFlgAbilitatoNegozio() != getTipoPagamento().getFlgAbilitatoNegozio()) if (l_tipoPagamento.getFlgAbilitatoNegozio() == 1L) { setSpeseTrasporto(0.0D); } else { double totaleRigheConIva = getImportoTotaleRigheCorrispettivi(); if (getParm(Cart.P_DELIVERY_FREE_ABOVE).getNumeroDouble() >= 0.0D && totaleRigheConIva >= getParm(Cart.P_DELIVERY_FREE_ABOVE).getNumeroDouble()) { System.out.println("free above: " + getParm(Cart.P_DELIVERY_FREE_ABOVE).getNumeroDouble() + " totCart:" + totaleRigheConIva); setSpeseTrasporto(0.0D); } else { double delivCost = 0.0D; if (!getId_nazioneSped().isEmpty()) { delivCost = getNazioneSped().getCostoSpedizione(); } else { DestinazioneDiversa dd = getClifor().getCurrentDD(); if (!dd.getId_nazioneDD().isEmpty()) { delivCost = dd.getNazioneDD().getCostoSpedizione(); } else { delivCost = getClifor().getNazione().getCostoSpedizione(); } if (delivCost == 0.0D) delivCost = getParm(Cart.P_DELIVERY_COST).getNumeroDouble(); } setSpeseAltre(delivCost); } } if (rp.getStatus()) { setId_tipoPagamento(l_tipoPagamento.getId_tipoPagamento()); rp = save(); } } return rp; } public boolean isSpeseSpedizioneWwwPreventivo() { if (getFlgProcediPagamento() == 1L) return false; if (!getId_nazioneSped().isEmpty()) { if (getNazioneSped().getFlgPreventivoWww() == 0L) return false; return true; } if (getClifor().getNazione().getFlgPreventivoWww() == 0L) return false; return true; } public String getNotaMail() { return (this.notaMail == null) ? "" : this.notaMail.trim(); } public void setNotaMail(String notaMail) { this.notaMail = notaMail; } public long getFlgWwwTipoOrdine() { return this.flgWwwTipoOrdine; } public void setFlgWwwTipoOrdine(long flgWwwTipoOrdine) { this.flgWwwTipoOrdine = flgWwwTipoOrdine; } public double getWwwCostoOrdine() { return this.wwwCostoOrdine; } public double getWwwTotaleCosti() { DoubleOperator dop = new DoubleOperator(getWwwCostoOrdine()); dop.add(getWwwCostoSpedizione()); dop.add(getWwwCostoTariffa()); return dop.getResult(); } public double getWwwNettoOrdine() { DoubleOperator dop = new DoubleOperator(getImponibileTotale()); dop.subtract(getWwwTotaleCosti()); return dop.getResult(); } public double getWwwNettoOrdinePerc() { if (getWwwTotaleCosti() > 0.0D) { DoubleOperator dop = new DoubleOperator(getImponibileTotale()); dop.setScale(4, 5); dop.divide(getWwwTotaleCosti()); dop.subtract(1); dop.multiply(100); return dop.getResult(); } return 0.0D; } public void calcolaCostiWww() { if (getWwwCostoSpedizione() == 0.0D) setWwwCostoSpedizione(getSpeseTrasporto()); DoubleOperator costoOrdine = new DoubleOperator(); costoOrdine.setScale(4, 5); Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); costoOrdine.add(row.getArticolo().getCostoNetto() * row.getQuantita()); } if (getWwwCostoOrdine() <= 0.0D) setWwwCostoOrdine(costoOrdine.getResult()); if (getWwwCostoTariffa() <= 0.0D) if (getTipoPagamento().getWwwCommissionePercDefault() > 0.0D || getTipoPagamento().getWwwTariffaFissa() > 0.0D) { if (getTipoPagamento().getWwwValoreSoglia() > 0.0D && getTipoPagamento().getWwwPercOltreSoglia() > 0.0D) { if (getTotaleDocumento() > getTipoPagamento().getWwwValoreSoglia()) { DoubleOperator commissione = new DoubleOperator(getTipoPagamento().getWwwValoreSoglia()); commissione.setScale(4, 5); commissione.multiply(getTipoPagamento().getWwwCommissionePercDefault()); commissione.divide(100.0F); DoubleOperator commissioneOltre = new DoubleOperator(getTotaleDocumento()); commissioneOltre.setScale(4, 5); commissioneOltre.subtract(getTipoPagamento().getWwwValoreSoglia()); commissioneOltre.multiply(getTipoPagamento().getWwwPercOltreSoglia()); commissioneOltre.divide(100.0F); commissione.add(commissioneOltre); commissione.add(getTipoPagamento().getWwwTariffaFissa()); setWwwCostoTariffa(scorporaIva(commissione.getResult(), (double)getIvaDoc().getAliquota())); } else { DoubleOperator commissione = new DoubleOperator(getTotaleDocumento()); commissione.setScale(4, 5); commissione.multiply(getTipoPagamento().getWwwCommissionePercDefault()); commissione.divide(100.0F); commissione.add(getTipoPagamento().getWwwTariffaFissa()); setWwwCostoTariffa(scorporaIva(commissione.getResult(), (double)getIvaDoc().getAliquota())); } } else { DoubleOperator commissione = new DoubleOperator(getTotaleDocumento()); commissione.setScale(4, 5); commissione.multiply(getTipoPagamento().getWwwCommissionePercDefault()); commissione.divide(100.0F); commissione.add(getTipoPagamento().getWwwTariffaFissa()); setWwwCostoTariffa(scorporaIva(commissione.getResult(), (double)getIvaDoc().getAliquota())); } } else { setWwwCostoTariffa(0.0D); } } public void setWwwCostoOrdine(double wwwCostoOrdine) { this.wwwCostoOrdine = wwwCostoOrdine; } public double getWwwCostoSpedizione() { return this.wwwCostoSpedizione; } public void setWwwCostoSpedizione(double wwwCostoSpedizione) { this.wwwCostoSpedizione = wwwCostoSpedizione; } public double getWwwCostoTariffa() { return this.wwwCostoTariffa; } public void setWwwCostoTariffa(double wwwCostoTariffa) { this.wwwCostoTariffa = wwwCostoTariffa; } public long getId_rigaBollaAtr() { return this.id_rigaBollaAtr; } public void setId_rigaBollaAtr(long id_rigaBollaAtr) { this.id_rigaBollaAtr = id_rigaBollaAtr; } public void creaFileCvsRigheDocumento(DocumentoCR CR) { try { Vectumerator list = new RigaDocumento(getApFull()).findVenditeServizi(CR); CR.setFileName(getPathTmp() + "reportDocumenti_" + getPathTmp() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "ID;Tipo articolo;Articolo;Operatore;Tipo documento;Numero documento;Data documento;Cliente/Fornitore;Nota documento;Seriale;Q.ta;Importo"; outCvsFile.writeLine(CR.getDescrizioneCR()); outCvsFile.writeLine(s1); while (list.hasMoreElements()) { RigaDocumento row = (RigaDocumento)list.nextElement(); s1 = String.valueOf(row.getId_documento()) + String.valueOf(row.getId_documento()) + "\"" + SEP + "\"" + row.getArticolo().getTipo().getDescrizione() + "\"" + SEP + "\"" + row.getArticolo().getDescrizioneCompleta() + SEP + row.getDocumento().getUsers().getCognomeNome() + SEP + row.getDocumento().getTipoDocumento().getDescrizione() + SEP + row.getDocumento().getNumeroDocumento() + SEP + getApFull().getDataFormat().format(row.getDocumento().getDataDocumento()) + SEP + row.getDocumento().getClifor().getDescrizioneCliente() + SEP + row.getNotaRigaDocumento() + SEP + row.getSeriale() + SEP + getNf().format(row.getQuantita()) + SEP; outCvsFile.writeLine(s1); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public void findByDescTransaction(String l_descTransaction) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.dataDocumento desc, A.progOrdineWww,A.id_esercizio desc, A.progDocumento desc"; WcString wc = new WcString(); wc.addWc("A.descTransaction='" + l_descTransaction + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public long getFlgOrdineWwwAppenaCreato() { return this.flgOrdineWwwAppenaCreato; } public void setFlgOrdineWwwAppenaCreato(long flgOrdineWwwAppenaCreato) { this.flgOrdineWwwAppenaCreato = flgOrdineWwwAppenaCreato; } public long getFlgOrdineWwwAppenaPagato() { return this.flgOrdineWwwAppenaPagato; } public void setFlgOrdineWwwAppenaPagato(long flgOrdineWwwAppenaPagato) { this.flgOrdineWwwAppenaPagato = flgOrdineWwwAppenaPagato; } public boolean hasRigaConScontoTroppoAlto() { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.isScontoTroppoAlto()) return true; } return false; } private String getRecordBartoliniFNVAT00RSms() { StringBuffer temp = new StringBuffer(); SimpleDateFormat dfY = new SimpleDateFormat("yyyy"); NumberFormat nf3 = NumberFormat.getInstance(Locale.ITALY); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf1 = NumberFormat.getInstance(Locale.ITALY); nf1.setMaximumFractionDigits(1); nf1.setMinimumFractionDigits(1); Date today = getToday(); temp.append(" "); temp.append(" "); temp.append(spaceRight(getParm("BART_COD_CLI").getTesto(), 7)); temp.append(" "); temp.append(spaceRight(getParm("BART_P_OPER").getTesto(), 3)); temp.append(" "); temp.append(dfY.format(today)); temp.append(" "); temp.append("00"); temp.append(" "); temp.append(String.valueOf(getId_esercizio()).substring(2, 4)); temp.append(zeroLeft(String.valueOf(getProgDocumento()), 5)); temp.append("S"); if (!getClifor().getCellulare().isEmpty()) { if (getClifor().getCellulare().startsWith("+")) { temp.append(spaceRight(getClifor().getCellulare(), 16)); } else { temp.append(spaceRight(getClifor().getNazione().getPrefissoTel() + getClifor().getNazione().getPrefissoTel(), 16)); } } else if (getClifor().getTelefono().startsWith("+")) { temp.append(spaceRight(getClifor().getTelefono(), 16)); } else { temp.append(spaceRight(getClifor().getNazione().getPrefissoTel() + getClifor().getNazione().getPrefissoTel(), 16)); } temp.append("SN"); temp.append("\r"); return temp.toString(); } public ResParm eliminaRigheAzero() { ResParm rp = new ResParm(true); int numRigheCancellate = 0; if (getId_documento() > 0L) { Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements() && rp.getStatus()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); if (row.getTotImponibileRiga() == 0.0D) { rp = row.delete(); if (rp.getStatus()) numRigheCancellate++; } } } if (rp.getStatus()) { rp.setMsg("Cancellate " + numRigheCancellate + " righe"); } else { rp.setMsg("Errore! Righe Cancellate: " + numRigheCancellate + ". " + rp.getMsg()); } return rp; } public String getStripeClientSecret() { return (this.stripeClientSecret == null) ? "" : this.stripeClientSecret.trim(); } public void setStripeClientSecret(String stripeClientSecret) { this.stripeClientSecret = stripeClientSecret; } public void findByStripeClientSecret(long l_stripeClientSecret) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.dataDocumento desc, A.progOrdineWww,A.id_esercizio desc, A.progDocumento desc"; WcString wc = new WcString(); wc.addWc("A.stripeClientSecret=" + l_stripeClientSecret); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public static final synchronized ResParm riordinaRigheDocPerRiferimento(DocumentoInterface doc) { ResParm rp = new ResParm(true); String TAG_THREAD_MSG = "RIORDINO RIGHE"; StatusMsg.updateMsgByTag(doc.getApFull(), "RIORDINO RIGHE", "...inizio ..."); doc.annullaOrdinamentoRighe(); Vectumerator vecRD = doc.findRigheDocumentoOBRiferimento(0, 0); int i = 0; int totRighe = vecRD.getTotNumberOfRecords(); while (vecRD.hasMoreElements() && rp.getStatus()) { RigaDocumento row = (RigaDocumento)vecRD.nextElement(); StatusMsg.updateMsgByTag(doc.getApFull(), "RIORDINO RIGHE", "riga " + i + " su " + totRighe); row.setOrdine((long)i); rp = row.superSave(); i++; } if (rp.getStatus()) rp.setMsg("Riordino righe per riferimento completato"); StatusMsg.deleteMsgByTag(doc.getApFull(), "RIORDINO RIGHE"); return rp; } public ResParm annullaOrdinamentoRighe() { if (getId_documento() > 0L) return update("update RIGA_ORDINE SET ordine=0 where id_documento=" + getId_documento()); return new ResParm(true, "niente da fare..Documento."); } public String getFERiferimentoTesto() { return (this.FERiferimentoTesto == null) ? "" : this.FERiferimentoTesto.trim(); } public void setFERiferimentoTesto(String fERiferimentoTesto) { this.FERiferimentoTesto = fERiferimentoTesto; } public double getFERiferimentoNumero() { return this.FERiferimentoNumero; } public void setFERiferimentoNumero(double fERiferimentoNumero) { this.FERiferimentoNumero = fERiferimentoNumero; } public Date getFERiferimentoData() { return this.FERiferimentoData; } public void setFERiferimentoData(Date fERiferimentoData) { this.FERiferimentoData = fERiferimentoData; } public long getId_lavorazione() { return this.id_lavorazione; } public void setId_lavorazione(long id_lavorazione) { this.id_lavorazione = id_lavorazione; setLavorazione(null); } public Lavorazione getLavorazione() { this.lavorazione = (Lavorazione)getSecondaryObject(this.lavorazione, Lavorazione.class, getId_lavorazione()); return this.lavorazione; } public void setLavorazione(Lavorazione lavorazione) { this.lavorazione = lavorazione; } public String getDescTransactionStripe() { return (this.descTransactionStripe == null) ? "" : this.descTransactionStripe.trim(); } public void setDescTransactionStripe(String descTransactionStripe) { this.descTransactionStripe = descTransactionStripe; } public void findByDescTransactionStripe(String l_descTransaction) { String s_Sql_Find = "select A.* from DOCUMENTO AS A"; String s_Sql_Order = " order by A.dataDocumento desc, A.progOrdineWww,A.id_esercizio desc, A.progDocumento desc"; WcString wc = new WcString(); wc.addWc("A.descTransactionStripe='" + l_descTransaction + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public long getFlgStatoLavorazionePrecedente() { return this.flgStatoLavorazionePrecedente; } public void setFlgStatoLavorazionePrecedente(long flgStatoLavorazionePrecedente) { this.flgStatoLavorazionePrecedente = flgStatoLavorazionePrecedente; } public void calcolaCostiWwwOLD() { if (getWwwCostoSpedizione() == 0.0D) setWwwCostoSpedizione(getSpeseTrasporto()); DoubleOperator costoOrdine = new DoubleOperator(); Vectumerator vec = findRigheDocumento(0, 0, 0); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); costoOrdine.add(row.getArticolo().getCostoNetto() * row.getQuantita()); } if (getWwwCostoOrdine() <= 0.0D) setWwwCostoOrdine(costoOrdine.getResult()); if (getFlgWwwTipoOrdine() == 0L) { if (getTipoPagamento().getWwwCommissionePercDefault() > 0.0D || getTipoPagamento().getWwwTariffaFissa() > 0.0D) { DoubleOperator commissione = new DoubleOperator(getTotaleDocumento()); commissione.multiply(getTipoPagamento().getWwwCommissionePercDefault()); commissione.divide(100.0F); commissione.add(getTipoPagamento().getWwwTariffaFissa()); if (getWwwCostoTariffa() <= 0.0D) setWwwCostoTariffa(commissione.getResult()); } else { setWwwCostoTariffa(0.0D); } } else if (getFlgWwwTipoOrdine() == 1L) { setId_tipoPagamento(TipoPagamento.getTipoPagamentoEbay(getApFull()).getId_tipoPagamento()); DoubleOperator commissione = new DoubleOperator(); vec.moveFirst(); double tariffaFissa = getTipoPagamento().getWwwTariffaFissa(); while (vec.hasMoreElements()) { getTipoPagamento(); RigaDocumento row = (RigaDocumento)vec.nextElement(); DoubleOperator comRow = new DoubleOperator(row.getTotImportoRigaConSconto()); if (row.getArticolo().getTipo().getEbayCommissione() > 0.0D) { comRow.multiply(row.getArticolo().getTipo().getEbayCommissione()); } else { comRow.multiply(getTipoPagamento().getWwwCommissionePercDefault()); } comRow.divide(100.0F); commissione.add(comRow); if (row.getArticolo().getTipo().getEbayFissa() > 0.0D) tariffaFissa = row.getArticolo().getTipo().getEbayFissa(); } commissione.add(tariffaFissa); if (getWwwCostoTariffa() <= 0.0D) setWwwCostoTariffa(commissione.getResult()); } else if (getFlgWwwTipoOrdine() == 2L) { setId_tipoPagamento(TipoPagamento.getTipoPagamentoAmazon(getApFull()).getId_tipoPagamento()); DoubleOperator commissione = new DoubleOperator(); double tariffaFissa = getTipoPagamento().getWwwTariffaFissa(); vec.moveFirst(); while (vec.hasMoreElements()) { getTipoPagamento(); RigaDocumento row = (RigaDocumento)vec.nextElement(); DoubleOperator comRow = new DoubleOperator(row.getTotImportoRigaConSconto()); if (row.getArticolo().getTipo().getAmazonCommissione() > 0.0D) { comRow.multiply(row.getArticolo().getTipo().getAmazonCommissione()); } else { comRow.multiply(getTipoPagamento().getWwwCommissionePercDefault()); } comRow.divide(100.0F); commissione.add(comRow); if (row.getArticolo().getTipo().getAmazonFissa() > 0.0D) tariffaFissa = row.getArticolo().getTipo().getAmazonFissa(); } commissione.add(tariffaFissa); if (getWwwCostoTariffa() <= 0.0D) setWwwCostoTariffa(commissione.getResult()); } else { setWwwCostoTariffa(0.0D); } } public String getNotaAtr() { if (getId_documento() > 0L) { StringBuilder sb = new StringBuilder(); sb.append("Pagamento: "); sb.append(getTipoPagamento().getDescrizione()); sb.append("
"); sb.append("N.B. LA FATTURA LA INVIO IO!!!! "); sb.append("
"); sb.append(getClifor().getCognomeNome()); sb.append("
"); sb.append(getClifor().getIndirizzoCompletoHtml()); sb.append("
"); sb.append("CF: " + getClifor().getCodFisc()); sb.append("
"); sb.append("P.IVA: " + getClifor().getPIva()); sb.append("
"); sb.append("Email (usa la mia..mettila nelle note): " + getClifor().getEMail()); sb.append(" "); sb.append("Cell.: " + getClifor().getCellulare()); sb.append("
"); sb.append("Cod. SDI: " + getClifor().getCodiceIdentificativoFE()); sb.append(" "); sb.append("Pec: " + getClifor().getPec()); sb.append("
"); if (!getPresso().isEmpty() || !getIndirizzoSped().isEmpty()) { sb.append("Indirizzo Spedizione
"); sb.append("Presso:" + getPresso()); sb.append("
"); sb.append(getIndirizzoSped() + " n. " + getIndirizzoSped()); sb.append("
"); sb.append(getCapSped() + " - " + getCapSped() + " (" + getCittaSped() + ")"); sb.append("
"); } Vectumerator vec = findRigheDocumento(0, 0, 0); sb.append(""); StringBuilder descArt = new StringBuilder(); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); descArt.append(row.getDescrizioneRiga() + " "); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); } sb.append(""); sb.append(""); sb.append(""); sb.append("
Desc.Imp.qtaSc%IvaTot
"); sb.append(row.getDescrizioneRiga()); sb.append(""); sb.append(getNf().format(row.getImponibile())); sb.append(""); sb.append(row.getQuantita()); sb.append(""); sb.append(getNf().format(row.getSconto())); sb.append(""); sb.append(row.getIva().getDescrizione()); sb.append(""); sb.append(getNf().format(row.getTotImponibileRigaConSconto())); sb.append("
Spese spedizione " + getNf().format(getSpeseTrasporto()) + "
TOT IMPONIBILE ORDINE " + getNf().format(getImponibileTotale()) + "
TOT FATTURA COMPRESO IVA " + getNf().format(getTotaleDocumento()) + "
"); return sb.toString(); } return ""; } public String getDescrizioneArticoloAtr() { if (getId_documento() > 0L) { String temp = (getClifor().getFlgAzienda() == 1L) ? "Bus. " : "Priv. "; Vectumerator vec = findRigheDocumento(0, 0, 0); StringBuilder descArt = new StringBuilder(); while (vec.hasMoreElements()) { RigaDocumento row = (RigaDocumento)vec.nextElement(); descArt.append(row.getDescrizioneRiga() + " "); } temp = temp + temp + " " + getTipoPagamento().getDescrizione() + descArt.toString() + " " + getNumeroDocumento() + " " + getWwwTipoOrdine() + " "; return temp; } return ""; } public String getPathImg() { return getDocBase() + getDocBase(); } public String getPathAttach() { return getDocBase() + getDocBase(); } public double getPrezzoCatenaAlMt() { return this.prezzoCatenaAlMt; } public void setPrezzoCatenaAlMt(double prezzoCatenaAlMt) { this.prezzoCatenaAlMt = prezzoCatenaAlMt; } public Date getDataCambioStatoLavorazione() { return this.dataCambioStatoLavorazione; } public void setDataCambioStatoLavorazione(Date dataCambioStatoLavorazione) { this.dataCambioStatoLavorazione = dataCambioStatoLavorazione; } public long getFlgGRS() { return this.flgGRS; } public void setFlgGRS(long flgGRS) { this.flgGRS = flgGRS; } private Document creaReportUnoGiornalieroXNazione(DocumentoCR CR, boolean soloCompatto) { long l_id_tipoDocumento = CR.getId_tipoDocumento(); if (l_id_tipoDocumento == 0L) l_id_tipoDocumento = getId_docCassa(); int rowCellLeading = 6; NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col_1 = 5, col_2 = 3, col_3 = 3, col_4 = 19, col_5 = 5, col_6 = 5; int cellLeading = 12; String descCliente = "", descDocumento = ""; DoubleOperator totGiorno = new DoubleOperator(); DoubleOperator totaleComplessivo = new DoubleOperator(); DoubleOperator totaleNazione = new DoubleOperator(); SimpleDateFormat df = getDataFormat(); Color currentColor = Color.ORANGE; try { Cell rigaVuota = new Cell(new Chunk(" ", PdfFontFactory.PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); Nazione nazione = new Nazione(getApFull()); Vectumerator veNaz = nazione.findByCR(new NazioneCR(), 0, 0); CR.setFlgOrderBy(1L); while (veNaz.hasMoreElements()) { Nazione rowNazione = (Nazione)veNaz.nextElement(); CR.setId_nazione(rowNazione.getId_nazione()); Vectumerator vec = new Documento(getApFull()).findByCR(CR, 0, 0); totGiorno = new DoubleOperator(); if (vec.hasMoreElements()) { totaleNazione = new DoubleOperator(); String intestazioneReport = rowNazione.getDescrizione_it() + " - Data: dal " + rowNazione.getDescrizione_it() + " al " + df.format(CR.getDataDocumentoDa()); if (CR.getId_tipo() != 0L) intestazioneReport = intestazioneReport + " - Tipo: " + intestazioneReport; creaIntestazioneReport(CR.getTipoReport(), intestazioneReport); Cell cell = new Cell(new Chunk("Doc.", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Data", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Tipo", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Intestazione", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Importo", PdfFontFactory.PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); Date currentData = null; while (vec.hasMoreElements()) { descCliente = ""; descDocumento = ""; Documento row = (Documento)vec.nextElement(); if (currentData == null) { currentData = row.getDataDocumento(); } else if (DBAdapter.getDateDiff(currentData, row.getDataDocumento()) != 0L) { cell = new Cell(new Chunk("TOTALE " + getDataFormat().format(currentData), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totGiorno.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); currentData = row.getDataDocumento(); totGiorno = new DoubleOperator(); } totGiorno.add(row.getTotaleDocumentoConSegno()); totaleComplessivo.add(row.getTotaleDocumentoConSegno()); totaleNazione.add(row.getTotaleDocumentoConSegno()); String nDoc = row.getNumeroDocumentoCompleto(); descCliente = row.getClifor().getDescrizioneCompleta(); descDocumento = row.getTipoDocumento().getDescrizioneStampa(); String descPag = row.getStatoCompleto(); cell = new Cell(new Chunk(nDoc, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getDataFormat().format(row.getDataDocumento()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descDocumento, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(descCliente, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)rowCellLeading); cell.setColspan(col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getTotaleDocumentoConSegno()), PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)rowCellLeading); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("TOTALE " + getDataFormat().format(currentData), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totGiorno.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(currentColor); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("TOTALE " + rowNazione.getDescrizione_it() + " da " + getDataFormat().format(CR.getDataDocumentoDa()) + " a " + getDataFormat().format(CR.getDataDocumentoA()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.green); cell.setColspan(col_1 + col_2 + col_3 + col_4 + col_5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totaleNazione.getResult()), PdfFontFactory.PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.green); cell.setColspan(col_6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); this.document.newPage(); prepareNewPdfCorpoDocument(); } } this.document.add((Element)this.pdfcorpo); Paragraph pTotInt = new Paragraph(new Chunk("Totale Complessivo", PdfFontFactory.PDF_fGrandeB)); Paragraph pTot = new Paragraph(new Chunk(getNf().format(totaleComplessivo.getResult()), PdfFontFactory.PDF_fGrandeB)); this.document.add((Element)pTotInt); this.document.add((Element)pTot); } catch (Exception e) { handleDebug(e); } return this.document; } public String getFERiferimentoTipoDato() { return (this.FERiferimentoTipoDato == null) ? "" : this.FERiferimentoTipoDato.trim(); } public void setFERiferimentoTipoDato(String fERiferimentoTipoDato) { this.FERiferimentoTipoDato = fERiferimentoTipoDato; } public void setTotaleDocumento(double totaleDocumento) { this.totaleDocumento = totaleDocumento; } public double getImponibileTotaleConSegno() { return (double)getTipoDocumento().fixDocumentoConImportiNegativi() * getImponibileTotale(); } public double getTotaleDocumentoConSegno() { return (double)getTipoDocumento().fixDocumentoConImportiNegativi() * getTotaleDocumento(); } public long getFlgDeliveryType() { return this.flgDeliveryType; } public void setFlgDeliveryType(long flgDeliveryType) { this.flgDeliveryType = flgDeliveryType; } public String getPudoId() { return (this.pudoId == null) ? "" : this.pudoId.trim(); } public void setPudoId(String pudoId) { this.pudoId = pudoId; } public static String getDeliveryType(long l_flgDeliveryType) { switch ((int)l_flgDeliveryType) { case 0: return "Spedizione Std"; case 1: return "Ritiro in negozio"; case 2: return "Fermo Point"; } return "????"; } public String getDeliveryType() { return getDeliveryType(getFlgDeliveryType()); } public String getPudoDesc() { return (this.pudoDesc == null) ? "" : this.pudoDesc.trim(); } public void setPudoDesc(String pudoDesc) { this.pudoDesc = pudoDesc; } public PudoAddress getPudoAddress() { String indirizzo = getClifor().getIndirizzo() + ", " + getClifor().getIndirizzo(); String zipCode = getClifor().getCapZona().isEmpty() ? getClifor().getCapComune() : getClifor().getCapZona(); String city = getClifor().getDescrizioneComune(); if (!getIndirizzoSped().isEmpty()) { indirizzo = getIndirizzoSped() + ", " + getIndirizzoSped(); zipCode = getCapSped(); city = getCittaSped().isEmpty() ? getComuneSped().getDescrizione() : getCittaSped(); } PudoAddress pa = new PudoAddress(indirizzo, zipCode, city); return pa; } public String getDescTransactionUser() { if (getDescTransactionStripe().isEmpty()) { if (getDescTransaction().isEmpty()) return ""; return getDescTransaction(); } return getDescTransactionStripe().replaceFirst("^((?:[^_]+_){2}).*", "$1").replaceAll("_$", ""); } }