Search in sources :

Example 1 with SimplePDFViewer

use of org.adempiere.webui.window.SimplePDFViewer in project adempiere by adempiere.

the class WHRPayPrint method cmd_print.

//  cmd_EFT
/**
	 *  Print Checks and/or Remittance
	 */
private void cmd_print() {
    if (fPaymentRule.getSelectedItem() == null)
        return;
    String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
    log.info(PaymentRule);
    if (!getChecks(PaymentRule))
        return;
    //	for all checks
    List<File> pdfList = new ArrayList<File>();
    for (MHRPaySelectionCheck check : m_checks) {
        //	ReportCtrl will check BankAccountDoc for PrintFormat
        ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.HR_CHECK, check.get_ID());
        try {
            File file = File.createTempFile("WHRPayPrint", null);
            re.getPDF(file);
            pdfList.add(file);
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
            return;
        }
    }
    SimplePDFViewer chequeViewer = null;
    try {
        File outFile = File.createTempFile("WHRPayPrint", null);
        AEnv.mergePdf(pdfList, outFile);
        chequeViewer = new SimplePDFViewer(form.getFormName(), new FileInputStream(outFile));
        chequeViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
        chequeViewer.setWidth("100%");
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        return;
    }
    //	Update BankAccountDoc
    int lastDocumentNo = MHRPaySelectionCheck.confirmPrint(m_checks, m_batch);
    if (lastDocumentNo != 0) {
        StringBuffer sb = new StringBuffer();
        sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(++lastDocumentNo).append(" WHERE C_BankAccount_ID=").append(m_C_BankAccount_ID).append(" AND PaymentRule='").append(PaymentRule).append("'");
        DB.executeUpdate(sb.toString(), null);
    }
    SimplePDFViewer remitViewer = null;
    if (FDialog.ask(m_WindowNo, form, "VPayPrintPrintRemittance")) {
        pdfList = new ArrayList<File>();
        for (MHRPaySelectionCheck check : m_checks) {
            ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.HR_REMITTANCE, check.get_ID());
            try {
                File file = File.createTempFile("WHRPayPrint", null);
                re.getPDF(file);
                pdfList.add(file);
            } catch (Exception e) {
                log.log(Level.SEVERE, e.getLocalizedMessage(), e);
            }
        }
        try {
            File outFile = File.createTempFile("WHRPayPrint", null);
            AEnv.mergePdf(pdfList, outFile);
            String name = Msg.translate(Env.getCtx(), "Remittance");
            remitViewer = new SimplePDFViewer(form.getFormName() + " - " + name, new FileInputStream(outFile));
            remitViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
            remitViewer.setWidth("100%");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    }
    dispose();
    if (chequeViewer != null)
        SessionManager.getAppDesktop().showWindow(chequeViewer);
    if (remitViewer != null)
        SessionManager.getAppDesktop().showWindow(remitViewer);
}
Also used : ReportEngine(org.compiere.print.ReportEngine) SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) ArrayList(java.util.ArrayList) MHRPaySelectionCheck(org.eevolution.model.MHRPaySelectionCheck) File(java.io.File) FileInputStream(java.io.FileInputStream) HRPayPrint(org.eevolution.service.HRPayPrint)

Example 2 with SimplePDFViewer

use of org.adempiere.webui.window.SimplePDFViewer in project adempiere by adempiere.

the class WPayPrint method cmd_print.

/**
	 *  Print Checks and/or Remittance
	 */
private void cmd_print() {
    if (fPaymentRule.getSelectedItem() == null)
        return;
    String paymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
    log.info(paymentRule);
    if (!getChecks(paymentRule))
        return;
    //	for all checks
    pdfList = new ArrayList<File>();
    paySelectionChecks.stream().filter(paySelectionCheck -> paySelectionCheck != null).forEach(paySelectionCheck -> {
        ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.CHECK, paySelectionCheck.get_ID());
        try {
            File file = File.createTempFile("WPayPrint", null);
            re.getPDF(file);
            addPDFFile(file);
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
            return;
        }
    });
    SimplePDFViewer chequeViewer = null;
    try {
        File outFile = File.createTempFile("WPayPrint", null);
        AEnv.mergePdf(pdfList, outFile);
        chequeViewer = new SimplePDFViewer(form.getFormName(), new FileInputStream(outFile));
        chequeViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
        chequeViewer.setWidth("100%");
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        return;
    }
    //	Update BankAccountDoc
    int lastDocumentNo = MPaySelectionCheck.confirmPrint(paySelectionChecks, paymentBatch);
    if (lastDocumentNo != 0) {
        StringBuffer sb = new StringBuffer();
        sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(++lastDocumentNo).append(" WHERE C_BankAccount_ID=").append(bankAccountId).append(" AND PaymentRule='").append(paymentRule).append("'");
        DB.executeUpdate(sb.toString(), null);
    }
    SimplePDFViewer remitViewer = null;
    if (FDialog.ask(windowNo, form, "VPayPrintPrintRemittance")) {
        pdfList = new ArrayList<File>();
        paySelectionChecks.stream().filter(paySelectionCheck -> paySelectionCheck != null).forEach(paySelectionCheck -> {
            ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.REMITTANCE, paySelectionCheck.get_ID());
            try {
                File file = File.createTempFile("WPayPrint", null);
                re.getPDF(file);
                addPDFFile(file);
            } catch (Exception e) {
                log.log(Level.SEVERE, e.getLocalizedMessage(), e);
            }
        });
        try {
            File outFile = File.createTempFile("WPayPrint", null);
            AEnv.mergePdf(pdfList, outFile);
            String name = Msg.translate(Env.getCtx(), "Remittance");
            remitViewer = new SimplePDFViewer(form.getFormName() + " - " + name, new FileInputStream(outFile));
            remitViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
            remitViewer.setWidth("100%");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    }
    //	remittance
    pdfList = new ArrayList<>();
    dispose();
    if (chequeViewer != null)
        SessionManager.getAppDesktop().showWindow(chequeViewer);
    if (remitViewer != null)
        SessionManager.getAppDesktop().showWindow(remitViewer);
}
Also used : Grid(org.adempiere.webui.component.Grid) ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) CustomForm(org.adempiere.webui.panel.CustomForm) Center(org.zkoss.zul.Center) Filedownload(org.zkoss.zul.Filedownload) Env(org.compiere.util.Env) PayPrint(org.compiere.apps.form.PayPrint) MLookupFactory(org.compiere.model.MLookupFactory) ValueNamePair(org.compiere.util.ValueNamePair) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Rows(org.adempiere.webui.component.Rows) FDialog(org.adempiere.webui.window.FDialog) AEnv(org.adempiere.webui.apps.AEnv) Panel(org.adempiere.webui.component.Panel) IFormController(org.adempiere.webui.panel.IFormController) MLookupInfo(org.compiere.model.MLookupInfo) DB(org.compiere.util.DB) Event(org.zkoss.zk.ui.event.Event) Msg(org.compiere.util.Msg) DisplayType(org.compiere.util.DisplayType) Borderlayout(org.zkoss.zul.Borderlayout) Label(org.adempiere.webui.component.Label) Window(org.adempiere.webui.component.Window) ADForm(org.adempiere.webui.panel.ADForm) WSearchEditor(org.adempiere.webui.editor.WSearchEditor) PaymentExportList(org.compiere.util.PaymentExportList) MPaySelectionCheck(org.compiere.model.MPaySelectionCheck) GridFactory(org.adempiere.webui.component.GridFactory) SessionManager(org.adempiere.webui.session.SessionManager) MPaymentBatch(org.compiere.model.MPaymentBatch) Button(org.adempiere.webui.component.Button) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) FileInputStream(java.io.FileInputStream) File(java.io.File) Listbox(org.adempiere.webui.component.Listbox) MLookup(org.compiere.model.MLookup) ReportEngine(org.compiere.print.ReportEngine) List(java.util.List) ValueChangeListener(org.adempiere.exceptions.ValueChangeListener) SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) Row(org.adempiere.webui.component.Row) South(org.zkoss.zul.South) PaymentExport(org.compiere.util.PaymentExport) ListboxFactory(org.adempiere.webui.component.ListboxFactory) EventListener(org.zkoss.zk.ui.event.EventListener) WNumberEditor(org.adempiere.webui.editor.WNumberEditor) ReportEngine(org.compiere.print.ReportEngine) SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) File(java.io.File) FileInputStream(java.io.FileInputStream) PayPrint(org.compiere.apps.form.PayPrint)

Example 3 with SimplePDFViewer

use of org.adempiere.webui.window.SimplePDFViewer in project adempiere by adempiere.

the class WGenForm method onPrint.

public void onPrint() {
    //		Loop through all items
    List<File> pdfList = new ArrayList<File>();
    for (int i = 0; i < m_ids.length; i++) {
        int RecordID = m_ids[i];
        ReportEngine re = null;
        if (genForm.getPrintFormat() != null) {
            MPrintFormat format = genForm.getPrintFormat();
            MTable table = MTable.get(Env.getCtx(), format.getAD_Table_ID());
            MQuery query = new MQuery(table.getTableName());
            query.addRestriction(table.getTableName() + "_ID", MQuery.EQUAL, RecordID);
            //	Engine
            PrintInfo info = new PrintInfo(table.getTableName(), table.get_Table_ID(), RecordID);
            re = new ReportEngine(Env.getCtx(), format, query, info);
        } else {
            re = ReportEngine.get(Env.getCtx(), genForm.getReportEngineType(), RecordID);
        }
        if (re != null)
            pdfList.add(re.getPDF());
    }
    if (pdfList.size() > 1) {
        try {
            File outFile = File.createTempFile(genForm.getClass().getName(), ".pdf");
            AEnv.mergePdf(pdfList, outFile);
            Clients.clearBusy();
            Window win = new SimplePDFViewer(getFormName(), new FileInputStream(outFile));
            SessionManager.getAppDesktop().showWindow(win, "center");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    } else if (pdfList.size() > 0) {
        Clients.clearBusy();
        try {
            Window win = new SimplePDFViewer(getFormName(), new FileInputStream(pdfList.get(0)));
            SessionManager.getAppDesktop().showWindow(win, "center");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    }
}
Also used : Window(org.adempiere.webui.component.Window) SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) ArrayList(java.util.ArrayList) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) FileInputStream(java.io.FileInputStream) ReportEngine(org.compiere.print.ReportEngine) MPrintFormat(org.compiere.print.MPrintFormat) MTable(org.compiere.model.MTable) File(java.io.File)

Example 4 with SimplePDFViewer

use of org.adempiere.webui.window.SimplePDFViewer in project adempiere by adempiere.

the class InvoicePrint method doIt.

//	prepare
/**
	 *  Perrform process.
	 *  @return Message
	 *  @throws Exception
	 */
protected String doIt() throws java.lang.Exception {
    //	Need to have Template
    if (p_EMailPDF && p_R_MailText_ID == 0)
        throw new AdempiereUserError("@NotFound@: @R_MailText_ID@");
    log.info("C_BPartner_ID=" + m_C_BPartner_ID + ", C_Invoice_ID=" + m_C_Invoice_ID + ", EmailPDF=" + p_EMailPDF + ",R_MailText_ID=" + p_R_MailText_ID + ", DateInvoiced=" + m_dateInvoiced_From + "-" + m_dateInvoiced_To + ", DocumentNo=" + m_DocumentNo_From + "-" + m_DocumentNo_To);
    MMailText mText = null;
    if (p_R_MailText_ID != 0) {
        mText = new MMailText(getCtx(), p_R_MailText_ID, get_TrxName());
        if (mText.get_ID() != p_R_MailText_ID)
            throw new AdempiereUserError("@NotFound@: @R_MailText_ID@ - " + p_R_MailText_ID);
    }
    //	Too broad selection
    if (m_C_BPartner_ID == 0 && m_C_Invoice_ID == 0 && m_dateInvoiced_From == null && m_dateInvoiced_To == null && m_DocumentNo_From == null && m_DocumentNo_To == null)
        throw new AdempiereUserError("@RestrictSelection@");
    MClient client = MClient.get(getCtx());
    //	Get Info
    StringBuffer sql = new StringBuffer(//	1..3
    "SELECT i.C_Invoice_ID,bp.AD_Language,c.IsMultiLingualDocument," + //	Prio: 1. BPartner 2. DocType, 3. PrintFormat (Org)	//	see ReportCtl+MInvoice
    " COALESCE(bp.Invoice_PrintFormat_ID, dt.AD_PrintFormat_ID, pf.Invoice_PrintFormat_ID)," + //	4 
    " dt.DocumentCopies+bp.DocumentCopies," + //	5
    " bpc.AD_User_ID, i.DocumentNo," + //	6..7
    " bp.C_BPartner_ID " + //	8
    "FROM C_Invoice i" + " INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID)" + " LEFT OUTER JOIN AD_User bpc ON (i.AD_User_ID=bpc.AD_User_ID)" + " INNER JOIN AD_Client c ON (i.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN AD_PrintForm pf ON (i.AD_Client_ID=pf.AD_Client_ID)" + " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)" + " WHERE i.AD_Client_ID=? AND i.AD_Org_ID=? AND i.isSOTrx='Y' AND " + //	more them 1 PF
    "       pf.AD_Org_ID IN (0,i.AD_Org_ID) AND ");
    boolean needAnd = false;
    if (m_C_Invoice_ID != 0)
        sql.append("i.C_Invoice_ID=").append(m_C_Invoice_ID);
    else {
        if (m_C_BPartner_ID != 0) {
            sql.append("i.C_BPartner_ID=").append(m_C_BPartner_ID);
            needAnd = true;
        }
        if (m_dateInvoiced_From != null && m_dateInvoiced_To != null) {
            if (needAnd)
                sql.append(" AND ");
            sql.append("TRUNC(i.DateInvoiced, 'DD') BETWEEN ").append(DB.TO_DATE(m_dateInvoiced_From, true)).append(" AND ").append(DB.TO_DATE(m_dateInvoiced_To, true));
            needAnd = true;
        } else if (m_dateInvoiced_From != null) {
            if (needAnd)
                sql.append(" AND ");
            sql.append("TRUNC(i.DateInvoiced, 'DD') >= ").append(DB.TO_DATE(m_dateInvoiced_From, true));
            needAnd = true;
        } else if (m_dateInvoiced_To != null) {
            if (needAnd)
                sql.append(" AND ");
            sql.append("TRUNC(i.DateInvoiced, 'DD') <= ").append(DB.TO_DATE(m_dateInvoiced_To, true));
            needAnd = true;
        } else if (m_DocumentNo_From != null && m_DocumentNo_To != null) {
            if (needAnd)
                sql.append(" AND ");
            sql.append("i.DocumentNo BETWEEN ").append(DB.TO_STRING(m_DocumentNo_From)).append(" AND ").append(DB.TO_STRING(m_DocumentNo_To));
        } else if (m_DocumentNo_From != null) {
            if (needAnd)
                sql.append(" AND ");
            if (m_DocumentNo_From.indexOf('%') == -1)
                sql.append("i.DocumentNo >= ").append(DB.TO_STRING(m_DocumentNo_From));
            else
                sql.append("i.DocumentNo LIKE ").append(DB.TO_STRING(m_DocumentNo_From));
        }
        if (p_EMailPDF) {
            if (needAnd) {
                sql.append(" AND ");
            }
            /* if emailed to customer only select COmpleted & CLosed invoices */
            sql.append("i.DocStatus IN ('CO','CL') ");
        }
    }
    //	more than 1 PF record
    sql.append(" ORDER BY i.C_Invoice_ID, pf.AD_Org_ID DESC");
    log.fine(sql.toString());
    MPrintFormat format = null;
    int old_AD_PrintFormat_ID = -1;
    int old_C_Invoice_ID = -1;
    int C_BPartner_ID = 0;
    int count = 0;
    int errors = 0;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    List<File> pdfList = new ArrayList<File>();
    try {
        pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
        pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
        pstmt.setInt(2, Env.getAD_Org_ID(Env.getCtx()));
        rs = pstmt.executeQuery();
        while (rs.next()) {
            int C_Invoice_ID = rs.getInt(1);
            if (//	multiple pf records
            C_Invoice_ID == old_C_Invoice_ID)
                continue;
            old_C_Invoice_ID = C_Invoice_ID;
            //	Set Language when enabled
            //	Base Language
            Language language = Language.getLoginLanguage();
            String AD_Language = rs.getString(2);
            if (AD_Language != null && "Y".equals(rs.getString(3)))
                language = Language.getLanguage(AD_Language);
            //
            int AD_PrintFormat_ID = rs.getInt(4);
            int copies = rs.getInt(5);
            if (copies == 0)
                copies = 1;
            int AD_User_ID = rs.getInt(6);
            MUser to = new MUser(getCtx(), AD_User_ID, get_TrxName());
            String DocumentNo = rs.getString(7);
            C_BPartner_ID = rs.getInt(8);
            //
            String documentDir = client.getDocumentDir();
            if (documentDir == null || documentDir.length() == 0)
                documentDir = ".";
            //
            if (p_EMailPDF && (to.get_ID() == 0 || to.getEMail() == null || to.getEMail().length() == 0)) {
                addLog(C_Invoice_ID, null, null, DocumentNo + " @RequestActionEMailNoTo@");
                errors++;
                continue;
            }
            if (AD_PrintFormat_ID == 0) {
                addLog(C_Invoice_ID, null, null, DocumentNo + " No Print Format");
                errors++;
                continue;
            }
            //	Get Format & Data
            if (AD_PrintFormat_ID != old_AD_PrintFormat_ID) {
                format = MPrintFormat.get(getCtx(), AD_PrintFormat_ID, false);
                old_AD_PrintFormat_ID = AD_PrintFormat_ID;
            }
            format.setLanguage(language);
            format.setTranslationLanguage(language);
            //	query
            MQuery query = new MQuery("C_Invoice_Header_v");
            query.addRestriction("C_Invoice_ID", MQuery.EQUAL, new Integer(C_Invoice_ID));
            //	Engine
            PrintInfo info = new PrintInfo(DocumentNo, X_C_Invoice.Table_ID, C_Invoice_ID, C_BPartner_ID);
            info.setCopies(copies);
            ReportEngine re = new ReportEngine(getCtx(), format, query, info);
            boolean printed = false;
            if (p_EMailPDF) {
                String subject = mText.getMailHeader() + " - " + DocumentNo;
                EMail email = client.createEMail(to.getEMail(), subject, null);
                if (!email.isValid()) {
                    addLog(C_Invoice_ID, null, null, DocumentNo + " @RequestActionEMailError@ Invalid EMail: " + to);
                    errors++;
                    continue;
                }
                //	Context
                mText.setUser(to);
                //	Context
                mText.setBPartner(C_BPartner_ID);
                mText.setPO(new MInvoice(getCtx(), C_Invoice_ID, get_TrxName()));
                String message = mText.getMailText(true);
                if (mText.isHtml())
                    email.setMessageHTML(subject, message);
                else {
                    email.setSubject(subject);
                    email.setMessageText(message);
                }
                //
                File invoice = null;
                if (!Ini.isClient())
                    invoice = new File(MInvoice.getPDFFileName(documentDir, C_Invoice_ID));
                File attachment = re.getPDF(invoice);
                log.fine(to + " - " + attachment);
                email.addAttachment(attachment);
                //
                String msg = email.send();
                MUserMail um = new MUserMail(mText, getAD_User_ID(), email);
                um.saveEx();
                if (msg.equals(EMail.SENT_OK)) {
                    addLog(C_Invoice_ID, null, null, DocumentNo + " @RequestActionEMailOK@ - " + to.getEMail());
                    count++;
                    printed = true;
                } else {
                    addLog(C_Invoice_ID, null, null, DocumentNo + " @RequestActionEMailError@ " + msg + " - " + to.getEMail());
                    errors++;
                }
            } else {
                if (re != null)
                    pdfList.add(re.getPDF());
                count++;
                printed = true;
            }
            //	Print Confirm
            if (printed) {
                StringBuffer sb = new StringBuffer("UPDATE C_Invoice " + "SET DatePrinted=SysDate, IsPrinted='Y' WHERE C_Invoice_ID=").append(C_Invoice_ID);
                DB.executeUpdateEx(sb.toString(), get_TrxName());
            }
        }
    //	for all entries						
    } catch (Exception e) {
        log.log(Level.SEVERE, "doIt - " + sql, e);
        throw new Exception(e);
    } finally {
        DB.close(rs, pstmt);
    }
    if (pdfList.size() > 1) {
        try {
            File outFile = File.createTempFile("InvoicePrint", ".pdf");
            AEnv.mergePdf(pdfList, outFile);
            Clients.clearBusy();
            Window win = new SimplePDFViewer(this.getName(), new FileInputStream(outFile));
            win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
            SessionManager.getAppDesktop().showWindow(win, "center");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    } else if (pdfList.size() > 0) {
        Clients.clearBusy();
        try {
            Window win = new SimplePDFViewer(this.getName(), new FileInputStream(pdfList.get(0)));
            win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
            SessionManager.getAppDesktop().showWindow(win, "center");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    }
    //
    if (p_EMailPDF)
        return "@Sent@=" + count + " - @Errors@=" + errors;
    return "@Printed@=" + count;
}
Also used : SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) ArrayList(java.util.ArrayList) Window(org.adempiere.webui.component.Window) org.compiere.print(org.compiere.print)

Example 5 with SimplePDFViewer

use of org.adempiere.webui.window.SimplePDFViewer in project adempiere by adempiere.

the class WPrintDocument method print.

public void print(PO document, String printFormantName, int windowNo) {
    boolean retValue = true;
    if (FDialog.ask(windowNo, SessionManager.getAppDesktop().getComponent(), "PrintShipments")) {
        do {
            try {
                String keyColumnName = document.get_KeyColumns()[0];
                MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID(printFormantName, document.get_Table_ID(), 0), false);
                MQuery query = new MQuery(document.get_TableName());
                query.addRestriction(keyColumnName, MQuery.EQUAL, document.get_ValueAsInt(keyColumnName));
                //	Engine
                PrintInfo info = new PrintInfo(document.get_TableName(), document.get_Table_ID(), document.get_ValueAsInt(keyColumnName));
                ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
                if (re != null) {
                    SimplePDFViewer win = new SimplePDFViewer(printFormantName, new FileInputStream(re.getPDF()));
                    SessionManager.getAppDesktop().showWindow(win, "center");
                }
            } catch (Exception e) {
            } finally {
                retValue = FDialog.ask(windowNo, SessionManager.getAppDesktop().getComponent(), Msg.getMsg(Env.getCtx(), "PrintoutOK?"));
            }
        } while (!retValue);
    }
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) FileInputStream(java.io.FileInputStream)

Aggregations

SimplePDFViewer (org.adempiere.webui.window.SimplePDFViewer)5 FileInputStream (java.io.FileInputStream)4 ArrayList (java.util.ArrayList)4 ReportEngine (org.compiere.print.ReportEngine)4 File (java.io.File)3 Window (org.adempiere.webui.component.Window)3 MQuery (org.compiere.model.MQuery)2 PrintInfo (org.compiere.model.PrintInfo)2 MPrintFormat (org.compiere.print.MPrintFormat)2 List (java.util.List)1 Level (java.util.logging.Level)1 ValueChangeEvent (org.adempiere.exceptions.ValueChangeEvent)1 ValueChangeListener (org.adempiere.exceptions.ValueChangeListener)1 AEnv (org.adempiere.webui.apps.AEnv)1 Button (org.adempiere.webui.component.Button)1 ConfirmPanel (org.adempiere.webui.component.ConfirmPanel)1 Grid (org.adempiere.webui.component.Grid)1 GridFactory (org.adempiere.webui.component.GridFactory)1 Label (org.adempiere.webui.component.Label)1 Listbox (org.adempiere.webui.component.Listbox)1