Example usage for com.lowagie.text Document add

List of usage examples for com.lowagie.text Document add

Introduction

In this page you can find the example usage for com.lowagie.text Document add.

Prototype


public boolean add(Element element) throws DocumentException 

Source Link

Document

Adds an Element to the Document.

Usage

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addMachineTimeBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph3", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> operationsTimeTableHeader = Lists.newArrayList();

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedDuration", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredTime", locale));
    operationsTimeTableHeader/*from   w  ww . java  2  s.  c om*/
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable machineTimeTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationTimeComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_TIME_COMPONENTS);

    if (!operationTimeComponents.isEmpty()) {
        for (Entity operationTimeComponent : operationTimeComponents) {
            machineTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            machineTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.PLANNED_MACHINE_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(
                            operationTimeComponent.getIntegerField(OperationTimeComponentFields.MACHINE_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.MACHINE_TIME_BALANCE)),
                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    machineTimeTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_MACHINE_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME_BALANCE)),
            FontUtils.getDejavuRegular9Dark()));

    document.add(machineTimeTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addLaborTimeBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph4", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> operationsTimeTableHeader = Lists.newArrayList();

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedDuration", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredTime", locale));
    operationsTimeTableHeader//  w  w  w. j av a  2  s .co m
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable laborTimeTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationTimeComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_TIME_COMPONENTS);

    if (!operationTimeComponents.isEmpty()) {
        for (Entity operationTimeComponent : operationTimeComponents) {
            laborTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            laborTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.PLANNED_LABOR_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(
                            operationTimeComponent.getIntegerField(OperationTimeComponentFields.LABOR_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.LABOR_TIME_BALANCE)),
                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    laborTimeTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_LABOR_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService
                    .convertTimeToString(productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME_BALANCE)),
            FontUtils.getDejavuRegular9Dark()));

    document.add(laborTimeTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addPieceworkBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph5", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> operationsTimeTableHeader = Lists.newArrayList();

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedCycles", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredCycles", locale));
    operationsTimeTableHeader//w  w w .ja  v a 2s . c  om
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable pieceworkTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationPieceworkComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_PIECEWORK_COMPONENTS);

    BigDecimal totalPlannedCycles = BigDecimal.ZERO;
    BigDecimal totalCycles = BigDecimal.ZERO;
    BigDecimal totalCyclesBalance = BigDecimal.ZERO;

    if (!operationPieceworkComponents.isEmpty()) {
        for (Entity operationPieceworkComponent : operationPieceworkComponents) {
            BigDecimal plannedCycles = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.PLANNED_CYCLES);
            BigDecimal cycles = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.CYCLES);
            BigDecimal cyclesBalance = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.CYCLES_BALANCE);

            pieceworkTable
                    .addCell(new Phrase(
                            operationPieceworkComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            pieceworkTable
                    .addCell(new Phrase(
                            operationPieceworkComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(
                    new Phrase(numberService.format(plannedCycles), FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(new Phrase(numberService.format(cycles), FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(
                    new Phrase(numberService.format(cyclesBalance), FontUtils.getDejavuRegular9Dark()));

            totalPlannedCycles = totalPlannedCycles.add(plannedCycles, numberService.getMathContext());
            totalCycles = totalPlannedCycles.add(cycles, numberService.getMathContext());
            totalCyclesBalance = totalPlannedCycles.add(cyclesBalance, numberService.getMathContext());
        }
    }

    pieceworkTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    pieceworkTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    pieceworkTable
            .addCell(new Phrase(numberService.format(totalPlannedCycles), FontUtils.getDejavuRegular9Dark()));
    pieceworkTable.addCell(new Phrase(numberService.format(totalCycles), FontUtils.getDejavuRegular9Dark()));
    pieceworkTable
            .addCell(new Phrase(numberService.format(totalCyclesBalance), FontUtils.getDejavuRegular9Dark()));

    document.add(pieceworkTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addTimeBalanceAsPanel(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(/*from  w ww .j  a  va 2 s  .  co  m*/
            new Paragraph(
                    translationService.translate(
                            "productionCounting.productionBalanceDetails.window.productionTime", locale),
                    FontUtils.getDejavuBold11Dark()));

    PdfPTable timePanel = pdfHelper.createPanelTable(3);

    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.plannedMachineTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_MACHINE_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.machineTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.machineTimeBalance",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME_BALANCE)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.plannedLaborTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_LABOR_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.laborTime",
            locale) + ":",
            timeConverterService
                    .convertTimeToString(productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.laborTimeBalance",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME_BALANCE)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);

    timePanel.setSpacingBefore(10);
    document.add(timePanel);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionTrackingReportPdfService.java

License:Open Source License

@Override
protected void buildPdfContent(final Document document, final Entity productionTrackingReport,
        final Locale locale) throws DocumentException {
    final String documentTitle = translationService
            .translate("productionCounting.productionTrackingReport.report.title", locale) + " "
            + productionTrackingReport.getId().toString();
    final String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label",
            locale);/*from   w  w w . j  av a  2s.  co m*/
    pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor,
            productionTrackingReport.getDateField(ProductionTrackingReportFields.DATE));

    final PdfPTable leftPanel = createLeftPanel(productionTrackingReport, locale);
    final PdfPTable rightPanel = createRightPanel(productionTrackingReport, locale);

    final PdfPTable panelTable = pdfHelper.createPanelTable(2);
    panelTable.addCell(leftPanel);
    panelTable.addCell(rightPanel);
    panelTable.setSpacingAfter(20);
    panelTable.setSpacingBefore(20);
    document.add(panelTable);

    Entity order = productionTrackingReport.getBelongsToField(ProductionTrackingReportFields.ORDER);

    final List<Entity> productionTrackings = productionCountingService.getProductionTrackingsForOrder(order);

    Collections.sort(productionTrackings, new EntityProductionTrackingComparator());

    for (Entity productionTracking : productionTrackings) {
        addProductionTracking(document, productionTracking, locale);
    }
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionTrackingReportPdfService.java

License:Open Source License

private void addProductionTracking(final Document document, final Entity productionTracking,
        final Locale locale) throws DocumentException {
    Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER);

    document.add(new Paragraph(
            translationService.translate("productionCounting.productionTrackingReport.report.paragraph", locale)
                    + " " + productionTracking.getStringField(ProductionTrackingFields.NUMBER),
            FontUtils.getDejavuBold19Dark()));

    PdfPTable panelTable = pdfHelper.createPanelTable(2);
    addTableCellAsTable(panelTable,/*from   w  w  w . j a  v  a2s  . co  m*/
            translationService
                    .translate("productionCounting.productionTrackingReport.report.panel.trackingType", locale),
            productionTracking.getBooleanField(ProductionTrackingFields.LAST_TRACKING)
                    ? translationService.translate(
                            "productionCounting.productionTrackingReport.report.panel.trackingType.final",
                            locale)
                    : translationService.translate(
                            "productionCounting.productionTrackingReport.report.panel.trackingType.partial",
                            locale),
            null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    if (productionCountingService.isTypeOfProductionRecordingCumulated(
            order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING))) {
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.operationAndLevel", locale),
                L_N_A, null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    } else {
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.operationAndLevel", locale),
                productionTracking.getBelongsToField(ProductionTrackingFields.TECHNOLOGY_OPERATION_COMPONENT)
                        .getStringField(TechnologyOperationComponentFields.NODE_NUMBER)
                        + " "
                        + productionTracking
                                .getBelongsToField(ProductionTrackingFields.TECHNOLOGY_OPERATION_COMPONENT)
                                .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                .getStringField(OperationFields.NAME),
                null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.dateAndTime", locale),
                new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, locale)
                        .format(productionTracking.getHasManyField(ProductionTrackingFields.STATE_CHANGES)
                                .get(0).getDateField(ProductionTrackingStateChangeFields.DATE_AND_TIME)),
                null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
        if (order.getBooleanField(OrderFieldsPC.REGISTER_PRODUCTION_TIME)) {
            addTableCellAsTable(panelTable, translationService.translate(
                    "productionCounting.productionTrackingReport.report.panel.machineOperationTime", locale),
                    timeConverterService.convertTimeToString(
                            productionTracking.getIntegerField(ProductionTrackingFields.MACHINE_TIME)),
                    null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
        } else {
            addTableCellAsTable(panelTable, translationService.translate(
                    "productionCounting.productionTrackingReport.report.panel.machineOperationTime", locale),
                    L_N_A, null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
        }
    }
    addTableCellAsTable(panelTable,
            translationService.translate("productionCounting.productionTrackingReport.report.panel.worker",
                    locale),
            productionTracking.getHasManyField(ProductionTrackingFields.STATE_CHANGES).get(0)
                    .getStringField(ProductionTrackingStateChangeFields.WORKER),
            null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    if (order.getBooleanField(OrderFieldsPC.REGISTER_PRODUCTION_TIME)) {
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.laborOperationTime", locale),
                timeConverterService.convertTimeToString(
                        productionTracking.getIntegerField(ProductionTrackingFields.LABOR_TIME)),
                null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    } else {
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.laborOperationTime", locale),
                L_N_A, null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    }
    panelTable.setSpacingBefore(10);
    document.add(panelTable);

    Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);

    if (order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_IN_PRODUCT)) {
        addInputProducts(document, productionTracking, technology, locale);
    }

    if (order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_OUT_PRODUCT)) {
        addOutputProducts(document, productionTracking, technology, locale);
    }
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionTrackingReportPdfService.java

License:Open Source License

private void addInputProducts(final Document document, final Entity productionTracking, final Entity technology,
        final Locale locale) throws DocumentException {
    document.add(
            new Paragraph(
                    translationService/*w  w  w. j  a  v a 2  s.  c  om*/
                            .translate("productionCounting.productionTrackingReport.report.paragraph2", locale),
                    FontUtils.getDejavuBold11Dark()));

    List<String> inputProductsTableHeader = Lists.newArrayList();

    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.number", locale));
    inputProductsTableHeader.add(translationService.translate(
            "productionCounting.productionTrackingReport.report.columnHeader.productionName", locale));
    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.type", locale));
    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.quantity", locale));
    inputProductsTableHeader.add(translationService.translate("basic.product.unit.label", locale));

    PdfPTable inputProductsTable = pdfHelper.createTableWithHeader(5, inputProductsTableHeader, false);

    if (productionTracking
            .getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS) != null) {
        List<Entity> trackingOperationProductInComponents = Lists.newArrayList(productionTracking
                .getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS));
        Collections.sort(trackingOperationProductInComponents, new EntityProductInOutComparator());
        for (Entity trackingOperationProductInComponent : trackingOperationProductInComponents) {
            inputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductInComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductInComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NUMBER),
                                    FontUtils.getDejavuRegular9Dark()));
            inputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductInComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductInComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NAME),
                                    FontUtils.getDejavuRegular9Dark()));

            String type = technologyService.getProductType(trackingOperationProductInComponent
                    .getBelongsToField(TrackingOperationProductInComponentFields.PRODUCT), technology);
            inputProductsTable.addCell(new Phrase(
                    translationService.translate("basic.product.globalTypeOfMaterial.value." + type, locale),
                    FontUtils.getDejavuRegular9Dark()));

            inputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            if (trackingOperationProductInComponent
                    .getField(TrackingOperationProductInComponentFields.USED_QUANTITY) == null) {
                inputProductsTable.addCell(new Phrase(L_N_A, FontUtils.getDejavuRegular9Dark()));
            } else {
                inputProductsTable.addCell(new Phrase(
                        numberService.format(trackingOperationProductInComponent
                                .getField(TrackingOperationProductInComponentFields.USED_QUANTITY)),
                        FontUtils.getDejavuRegular9Dark()));
            }
            inputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            inputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductInComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductInComponentFields.PRODUCT)
                                            .getStringField(ProductFields.UNIT),
                                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    document.add(inputProductsTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionTrackingReportPdfService.java

License:Open Source License

private void addOutputProducts(final Document document, final Entity productionTracking,
        final Entity technology, final Locale locale) throws DocumentException {
    document.add(
            new Paragraph(
                    translationService/*from  w w  w. j av a2  s .  c om*/
                            .translate("productionCounting.productionTrackingReport.report.paragraph3", locale),
                    FontUtils.getDejavuBold11Dark()));

    List<String> outputProductsTableHeader = Lists.newArrayList();

    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.number", locale));
    outputProductsTableHeader.add(translationService.translate(
            "productionCounting.productionTrackingReport.report.columnHeader.productionName", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.type", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.quantity", locale));
    outputProductsTableHeader.add(translationService.translate("basic.product.unit.label", locale));

    PdfPTable outputProductsTable = pdfHelper.createTableWithHeader(5, outputProductsTableHeader, false);

    if (productionTracking
            .getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS) != null) {
        List<Entity> trackingOperationProductOutComponents = Lists.newArrayList(productionTracking
                .getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS));
        Collections.sort(trackingOperationProductOutComponents, new EntityProductInOutComparator());
        for (Entity trackingOperationProductOutComponent : trackingOperationProductOutComponents) {
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductOutComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NUMBER),
                                    FontUtils.getDejavuRegular9Dark()));
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductOutComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NAME),
                                    FontUtils.getDejavuRegular9Dark()));

            String type = technologyService.getProductType(trackingOperationProductOutComponent
                    .getBelongsToField(TrackingOperationProductOutComponentFields.PRODUCT), technology);
            outputProductsTable.addCell(new Phrase(
                    translationService.translate("basic.product.globalTypeOfMaterial.value." + type, locale),
                    FontUtils.getDejavuRegular9Dark()));

            outputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            if (trackingOperationProductOutComponent
                    .getField(TrackingOperationProductOutComponentFields.USED_QUANTITY) == null) {
                outputProductsTable.addCell(new Phrase(L_N_A, FontUtils.getDejavuRegular9Dark()));
            } else {
                outputProductsTable.addCell(new Phrase(
                        numberService.format(trackingOperationProductOutComponent
                                .getField(TrackingOperationProductOutComponentFields.USED_QUANTITY)),
                        FontUtils.getDejavuRegular9Dark()));
            }
            outputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductOutComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.UNIT),
                                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    document.add(outputProductsTable);
}

From source file:com.qcadoo.mes.productionCountingWithCosts.pdf.ProductionBalanceWithCostsPdfService.java

License:Open Source License

@Override
protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    String documentTitle = translationService.translate("productionCounting.productionBalance.report.title",
            locale);//w  w w .  ja  va  2 s.c  o m
    String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale);
    pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor,
            productionBalance.getDateField(ProductionBalanceFields.DATE));

    PdfPTable topTable = pdfHelper.createPanelTable(2);
    topTable.addCell(productionBalancePdfService.createLeftPanel(productionBalance, locale));
    topTable.addCell(productionBalancePdfService.createRightPanel(productionBalance, locale));
    topTable.setSpacingBefore(20);
    document.add(topTable);

    PdfPTable parametersForCostsPanel = createParametersForCostsPanel(productionBalance, locale);
    parametersForCostsPanel.setSpacingBefore(20);
    document.add(parametersForCostsPanel);

    Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER);
    String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    String calculateOperationCostMode = productionBalance
            .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE);

    final boolean isTypeOfProductionRecordingCumulated = productionCountingService
            .isTypeOfProductionRecordingCumulated(typeOfProductionRecording);
    final boolean isTypeOfProductionRecordingForEach = productionCountingService
            .isTypeOfProductionRecordingForEach(typeOfProductionRecording);
    final boolean isCalculateOperationCostModeHourly = productionCountingService
            .isCalculateOperationCostModeHourly(calculateOperationCostMode);
    final boolean isCalculateOperationCostModePiecework = productionCountingService
            .isCalculateOperationCostModePiecework(calculateOperationCostMode);

    if (isCalculateOperationCostModeHourly && isTypeOfProductionRecordingCumulated) {
        PdfPTable assumptionForCumulatedRecordsPanel = createAssumptionsForCumulatedRecordsPanel(
                productionBalance, locale);
        assumptionForCumulatedRecordsPanel.setSpacingBefore(20);
        document.add(assumptionForCumulatedRecordsPanel);
    }

    PdfPTable bottomTable = pdfHelper.createPanelTable(2);
    bottomTable.addCell(createCostsPanel(productionBalance, locale));
    bottomTable.addCell(createOverheadsAndSummaryPanel(productionBalance, locale));
    bottomTable.setSpacingBefore(20);
    bottomTable.setSpacingAfter(20);
    document.add(bottomTable);

    productionBalancePdfService.addInputProductsBalance(document, productionBalance, locale);
    addMaterialCost(document, productionBalance, locale);
    productionBalancePdfService.addOutputProductsBalance(document, productionBalance, locale);

    if (isCalculateOperationCostModeHourly) {
        if (isTypeOfProductionRecordingCumulated) {
            productionBalancePdfService.addTimeBalanceAsPanel(document, productionBalance, locale);
            addProductionCosts(document, productionBalance, locale);
        } else if (isTypeOfProductionRecordingForEach) {
            productionBalancePdfService.addMachineTimeBalance(document, productionBalance, locale);
            addCostsBalance("machine", document, productionBalance, locale);

            productionBalancePdfService.addLaborTimeBalance(document, productionBalance, locale);
            addCostsBalance("labor", document, productionBalance, locale);
        }
    } else if (isCalculateOperationCostModePiecework) {
        productionBalancePdfService.addPieceworkBalance(document, productionBalance, locale);
        addCostsBalance("cycles", document, productionBalance, locale);
    }

    costCalculationPdfService.printMaterialAndOperationNorms(document, productionBalance, locale);
}

From source file:com.qcadoo.mes.productionCountingWithCosts.pdf.ProductionBalanceWithCostsPdfService.java

License:Open Source License

private void addProductionCosts(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(//from  ww  w. ja  v  a  2 s.  com
            new Paragraph(
                    translationService.translate(
                            "productionCounting.productionBalance.report.panel.productionCosts", locale),
                    FontUtils.getDejavuBold11Dark()));

    PdfPTable costsPanel = pdfHelper.createPanelTable(3);

    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machinePlanned",
            productionBalance.getField(ProductionBalanceFieldsPCWC.PLANNED_MACHINE_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machineRegistered",
            productionBalance.getField(ProductionBalanceFieldsPCWC.MACHINE_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machineBalance",
            productionBalance.getField(ProductionBalanceFieldsPCWC.MACHINE_COSTS_BALANCE), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborPlanned",
            productionBalance.getField(ProductionBalanceFieldsPCWC.PLANNED_LABOR_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborRegistered",
            productionBalance.getField(ProductionBalanceFieldsPCWC.LABOR_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborBalance",
            productionBalance.getField(ProductionBalanceFieldsPCWC.LABOR_COSTS_BALANCE), locale);

    costsPanel.setSpacingBefore(10);
    document.add(costsPanel);
}