Example usage for com.lowagie.text Element ALIGN_LEFT

List of usage examples for com.lowagie.text Element ALIGN_LEFT

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_LEFT.

Prototype

int ALIGN_LEFT

To view the source code for com.lowagie.text Element ALIGN_LEFT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java

License:Open Source License

protected PdfPTable createContractorTable() {
    final PdfPTable contractorTable = new PdfPTable(11);
    contractorTable.getDefaultCell().setBorderWidth(1);
    contractorTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    contractorTable.getDefaultCell().setColspan(7);
    contractorTable.addCell(pdfLabel.get("contractorbill.pdf.contractoraddress") + newLine + contactorName
            + newLine + contractorAddress + newLine);
    contractorTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    contractorTable.getDefaultCell().setColspan(4);
    contractorTable.addCell(pdfLabel.get("contractorbill.pdf.billno") + billGenNumber + newLine
            + pdfLabel.get("contractorbill.pdf.dateofbill") + billDate + newLine
            + pdfLabel.get("contractorbill.pdf.typeofbill") + billType + newLine);
    return contractorTable;
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

public void generatePDF() {
    try {//  w ww .jav a  2  s. co m
        final Paragraph headerTextPara = new Paragraph(
                new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        String projectCode;
        final String oldEstNo = "";
        HeaderFooter hf;
        headerTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(headerTextPara);
        document.add(makePara("Executing Department:" + estimate.getExecutingDepartment().getName(),
                Element.ALIGN_LEFT));
        if (estimate.getUserDepartment() != null)
            document.add(
                    makePara("User Department:" + estimate.getUserDepartment().getName(), Element.ALIGN_LEFT));

        final CFinancialYear estimateFinancialYear = estimate.getMultiYearEstimates().get(0).getFinancialYear();
        addZoneYearHeader(estimate, estimateFinancialYear);

        document.add(makePara("Name of Work: " + estimate.getName(), Element.ALIGN_LEFT));
        document.add(makePara("Description: " + estimate.getDescription(), Element.ALIGN_LEFT));

        if (estimate.getProjectCode() != null) {
            projectCode = "Project Code : " + estimate.getProjectCode().getCode();
            document.add(makePara(projectCode, Element.ALIGN_LEFT));
            hf = new HeaderFooter(new Phrase("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                    + headerText.concat("\n")
                            .concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                            .concat("\n\n").concat("Name of Work: " + estimate.getName()).concat("\n")
                            .concat("Description: " + estimate.getDescription()).concat("\n")
                            .concat("Estimate Number: " + estimate.getEstimateNumber()).concat(oldEstNo)
                            .concat("\n").concat(projectCode)),
                    false);
        } else
            hf = new HeaderFooter(new Phrase("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                    + headerText.concat("\n")
                            .concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                    + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                            .concat("\n\n").concat("Name of Work: " + estimate.getName()).concat("\n")
                            .concat("Description: " + estimate.getDescription()).concat("\n")
                            .concat("Estimate Number: " + estimate.getEstimateNumber()).concat(oldEstNo)),
                    false);

        hf.disableBorderSide(Rectangle.TOP);
        hf.disableBorderSide(Rectangle.BOTTOM);
        hf.setLeft(Element.ALIGN_LEFT);
        document.setHeader(hf);
        final PdfPTable overheadsTable = createOverheadsTable(estimate);
        document.add(spacer());
        document.add(overheadsTable);
        document.add(spacer());
        final PdfPTable multiyearTable = createMultiYearTable(estimate);
        document.add(makePara("Year-wise Estimate"));
        document.add(spacer());
        document.add(multiyearTable);
        document.add(spacer());
        document.add(makePara("Estimate Created By: " + estimate.getCreatedBy().getName()));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara("Checked By: "));
        document.newPage();
        addZoneYearHeaderWithOutEstimateNo(estimate, estimateFinancialYear);
        document.add(createActivitiesTable(estimate));
        document.add(spacer());

        final PdfPTable approvaldetailsTable = createApprovalDetailsTable(estimate);
        // TODO:Fixme - commented final out workflow history final details since ordering final of approval is final not
        // getting final listed properly
        /*
         * if (approvaldetailsTable.getRows().size() != 1) { document.add(makePara("Approval Details"));
         * document.add(spacer()); document.add(approvaldetailsTable); }
         */

        final String appropriationNumber = abstractEstimateService
                .getLatestEstimateAppropriationNumber(estimate);

        if (isSkipBudgetCheck()) {
            final PdfPTable depositWorksAppropriationTable = createDepositAppropriationTable(estimate,
                    appropriationNumber);
            if (depositWorksAppropriationTable.getRows().size() != 1)
                if (appropriationNumber != null) {
                    document.newPage();
                    document.add(spacer());
                    document.add(makePara("Deposit Code Appropriation Details"));
                    document.add(spacer());
                    document.add(depositWorksAppropriationTable);
                }
        } else {
            final PdfPTable BudgetaryAppropriationTable = createBudgetaryAppropriationTable(estimate,
                    appropriationNumber);
            final String estimateNumber = estimate.getEstimateNumber();
            if (BudgetaryAppropriationTable.getRows().size() != 1)
                if (!getBudgetDetailUsage(estimateNumber).isEmpty() && appropriationNumber != null) {
                    document.newPage();
                    document.add(spacer());
                    document.add(makePara("Budgetary Appropriation"));
                    document.add(spacer());
                    document.add(BudgetaryAppropriationTable);
                }
        }

        document.newPage();
        document.add(spacer());
        document.add(makePara(
                "EXECUTIVE ENGINEER'S OFFICE,  ZONE.......................................................................",
                Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara(
                "Est No.                                                Unit:                                                 Dept.",
                Element.ALIGN_LEFT));
        document.add(spacer());
        final Paragraph budgetheadTextPara = new Paragraph(
                new Chunk("BUDGET HEAD", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        budgetheadTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(budgetheadTextPara);
        document.add(spacer());
        document.add(makePara("____________________________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Rs.                                            ", Element.ALIGN_LEFT));
        document.add(makePara("____________________________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Works:                                          ", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(spacer());
        final Paragraph memoTextPara = new Paragraph(
                new Chunk("MEMO", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        memoTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(memoTextPara);
        document.add(makePara("Budget Grant                               ", Element.ALIGN_LEFT));
        document.add(makePara("Amount Appropriated:__________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(makePara("Balance on Hand:                                ", Element.ALIGN_LEFT));
        document.add(
                makePara("Amount of this estimate_________________________________________________________",
                        Element.ALIGN_LEFT));
        document.add(makePara("Balance forward_______________________________________________________________",
                Element.ALIGN_LEFT));
        document.add(
                makePara("Submitted for favour of sanction                           ", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(spacer());
        document.add(
                makePara("A.E.E.Unit " + space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t \t \t \t \t \t"
                        + "Exe.Eng.Zone.....................", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara("Sanctioned", Element.ALIGN_CENTER));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara("DATE:" + space1
                + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                + "Asst.Commissioner Zone...............", Element.ALIGN_LEFT));
        document.add(spacer());
        document.add(makePara(
                space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                        + "APPROPRIATION No.",
                Element.ALIGN_LEFT));
        document.add(makePara(space1 + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t"
                + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t \t \t" + "Date:", Element.ALIGN_LEFT));

        // WF for signature -----
        if (approvaldetailsTable.getRows().size() != 1)
            if (shouldShowApprovalNumber) {
                document.resetHeader();
                document.newPage();
                document.add(
                        makePara("\t  \t  \t  \t \t \t  \t  \t  \t \t \t  \t  \t  \t \t"
                                + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                + "\t  \t  \t  \t \t\t  \t  \t  \t \t"
                                + headerText.concat("\n").concat("\t  \t  \t  \t \t \t  \t  \t  \t \t"
                                        + "\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  \t \t\t  \t  \t  "
                                        + "\t  \t  \t  \t \t\t  \t  \t  \t \t ABSTRACT ESTIMATE")
                                        .concat("\n\n")));
                document.add(
                        makePara(
                                "File Current Number :" + space1
                                        + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t \t   " + "Date: \t \t",
                                Element.ALIGN_LEFT));
                document.add(makePara(space1
                        + "\t  \t  \t  \t \t \t  \t  \t  \t \t \t \t\t  \t  \t  \t \t \t \t \t  \t  \t  \t "
                        + "Department : ", Element.ALIGN_LEFT));
                document.add(spacer());
                final Paragraph headingPara1 = new Paragraph(
                        new Chunk("NOTE FOR ADMINISTRATIVE SANCTION AS PER RULE 78 OF ",
                                new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                headingPara1.setAlignment(Element.ALIGN_CENTER);
                document.add(headingPara1);
                final Paragraph headingPara2 = new Paragraph(
                        new Chunk("MCMC ACT 1919 ", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                headingPara2.setAlignment(Element.ALIGN_CENTER);
                document.add(headingPara2);

                document.add(spacer());
                final PdfPTable estimateDetailsTable1 = createEstimateDetailsTable1(estimate);
                document.add(estimateDetailsTable1);
                final PdfPTable budgetDetailsTableFourCols = createBudgetDetailsForEstimateTable(estimate);
                document.add(budgetDetailsTableFourCols);
                final PdfPTable estimateDetailsTable2 = createBalanceAmtCalculationTable(estimate);
                document.add(estimateDetailsTable2);
                document.add(spacer());
                final Paragraph endTextPara = new Paragraph(
                        new Chunk("** END **", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
                endTextPara.setAlignment(Element.ALIGN_CENTER);
                document.add(endTextPara);
            }

        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException("estimate.pdf.error", e);
    }
}

From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java

License:Open Source License

private void addZoneYearHeader(final AbstractEstimate estimate, final CFinancialYear financialYear)
        throws DocumentException {
    document.add(spacer());// w  w  w  .  j a  va 2  s  .  c om
    final PdfPTable headerTable = new PdfPTable(2);
    headerTable.setWidthPercentage(100);
    headerTable.setWidths(new float[] { 1f, 1f });
    Paragraph financialYearPara = new Paragraph();
    if (financialYear != null)
        financialYearPara = makePara("Budget Year: " + financialYear.getFinYearRange(), Element.ALIGN_RIGHT);
    addRow(headerTable, false, makePara("Estimate Number: " + estimate.getEstimateNumber(), Element.ALIGN_LEFT),
            financialYearPara);

    document.add(headerTable);
    if (estimate.getWard() != null && "Ward".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName())
            && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null)
        document.add(makePara("Ward: " + estimate.getWard().getName() + " / Zone: "
                + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT));
    else if (estimate.getWard() != null
            && "Zone".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName())
            && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null)
        document.add(makePara("Zone: " + estimate.getWard().getName() + " / Region: "
                + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT));
    else if (estimate.getWard() != null)
        document.add(makePara("Jurisdiction: " + estimate.getWard().getName() + "("
                + estimate.getWard().getBoundaryType().getName() + ")", Element.ALIGN_RIGHT));
    document.add(spacer());
}

From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java

License:Open Source License

public void generatePDF() {
    final String headerText = pdfLabel.get("mbpdf.header");
    try {/*  w w w  .ja  v  a 2 s .  c  o m*/
        // start header Part
        final Paragraph headerTextPara = new Paragraph(
                new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        headerTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(headerTextPara);
        document.add(spacer());
        if (mbHeader != null) {
            String toPageno = "";
            if (mbHeader.getToPageNo() == null || mbHeader.getToPageNo().intValue() == 0)
                toPageno = mbHeader.getFromPageNo().toString();
            else
                toPageno = mbHeader.getToPageNo().toString();

            document.add(makeParaWithFont(8, " \t  \t  \t  \t \t " + pdfLabel.get("mbpdf.refno")
                    + mbHeader.getMbRefNo()
                    + " \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t "
                    + pdfLabel.get("mbpdf.pageno") + " : " + mbHeader.getFromPageNo() + " to " + toPageno
                    + " \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t  \t \t  \t  \t "
                    + pdfLabel.get("mbpdf.date") + sdf.format(mbHeader.getMbDate()), Element.ALIGN_LEFT));

        }
        document.add(spacer());
        includeRevisionTypeColumn = false;
        // /Find if revision type Non tendered and Lump sum items are there
        areNTOrLSItemsPresent(mbHeader);
        // creating label row
        PdfPTable mbTable = createMbTable();
        if (mbHeader != null)
            mbTable = createMbData(mbTable, mbHeader);
        document.add(mbTable);
        document.add(spacer());
        document.newPage();
        // approval details table

        PdfPTable approvaldetailsTable = null;
        if (mbHeader != null)
            approvaldetailsTable = createApprovalDetailsTable(mbHeader);
        document.add(makePara(8, pdfLabel.get("mbpdf.approvaldetails")));
        document.add(spacer());
        document.add(approvaldetailsTable);

        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException(MEASUREMENTBOOK_PDF_ERROR, e);
    }
}

From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java

License:Open Source License

private PdfPTable createMbData(final PdfPTable mbTable, final MBHeader mbHeader) {
    Integer i = 0;/*from   w ww .ja va  2s .co m*/
    double uomFactor = 0.0;

    // iterating mbdetails
    for (final MBDetails mbDetails : mbHeader.getMbDetails()) {
        String description = "";
        String per = "";
        String schNo = "";
        double currentMeasurement;
        currentMeasurement = mbDetails.getQuantity();
        ++i;
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        mbTable.addCell(rightPara(8, i.toString()));
        final WorkOrderActivity workOrderActivity = mbDetails.getWorkOrderActivity();
        final Activity activity = workOrderActivity.getActivity();
        if (activity != null) {
            if (activity.getSchedule() != null && activity.getSchedule().getCode() != null)
                schNo = activity.getSchedule().getCode();
            mbTable.addCell(rightPara(8, schNo));

            // start sor/non sor description
            if (activity.getSchedule() != null && activity.getSchedule().getDescription() != null)
                description = activity.getSchedule().getDescription();

            if (activity.getNonSor() != null && activity.getNonSor().getDescription() != null)
                description = activity.getNonSor().getDescription();

            mbTable.addCell(makeParaWithFont(8, description, Element.ALIGN_LEFT));
            // end sor/non sor description
        }
        // for completedMeasurement area --------------->Cumulative quantity
        // including current entry= Cumulative upto previous entry + Current
        // MB entry
        // ( cumulative MB measurement for line item) for selected MB
        // including MB entry

        if (includeRevisionTypeColumn) {
            if (activity.getRevisionType() == null)
                mbTable.addCell(makePara(8, ""));
            if (activity.getRevisionType() != null && activity.getRevisionType().toString()
                    .equalsIgnoreCase(RevisionType.NON_TENDERED_ITEM.toString()))
                mbTable.addCell(makePara(8, "Non Tendered"));
            if (activity.getRevisionType() != null && activity.getRevisionType().toString()
                    .equalsIgnoreCase(RevisionType.LUMP_SUM_ITEM.toString()))
                mbTable.addCell(makePara(8, "Lump Sum"));
        }

        double completedMeasurement;
        double cumlPrevMb;
        try {

            long woaId = 0l;
            if (workOrderActivity.getId() != null)
                woaId = workOrderActivity.getId();

            cumlPrevMb = measurementBookService.prevCumulativeQuantityIncludingCQ(woaId, mbHeader.getId(),
                    workOrderActivity.getActivity().getId(), mbHeader.getWorkOrder());

        } catch (final Exception e) {
            cumlPrevMb = 0.0;
        }
        completedMeasurement = cumlPrevMb + currentMeasurement;
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        mbTable.addCell(rightPara(8, completedMeasurement));

        double approveRateWo = workOrderActivity.getApprovedRate();
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        mbTable.addCell(rightPara(8, formatter.format(approveRateWo)));

        // start unit
        if (activity != null) {
            // umofactor for conversion of rate and amount
            uomFactor = activity.getConversionFactor();
            if (logger.isDebugEnabled())
                logger.debug("----------uomFactor------------" + uomFactor);

            mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
            if (activity.getSchedule() != null && activity.getSchedule().getUom() != null
                    && activity.getSchedule().getUom().getUom() != null)
                per = activity.getSchedule().getUom().getUom();
            if (activity.getNonSor() != null && activity.getNonSor().getUom() != null
                    && activity.getNonSor().getUom().getUom() != null)
                per = activity.getNonSor().getUom().getUom();
            mbTable.addCell(centerPara(8, per));
            // end start unit
        } // end of if activity

        /*
         * measurementBookService.prevCumulativeAmount(workOrderActivity.getId ()); total work completed------->(completed
         * mesurement(col 5) * rate) here rate is wo.getAprovedrate added uom factor on april4th 2010
         */
        final double workCompleted = completedMeasurement * approveRateWo * uomFactor;
        mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        mbTable.addCell(rightPara(8, formatter.format(workCompleted)));

        // previous measurements a)pageno and b)measurements
        // a)Page no: for last MB entry for forline item---->page-no call
        // api
        Integer frompageNo = null;
        Integer topageNo = null;

        final MBHeader resultHeader = workOrderService.findLastMBPageNoForLineItem(workOrderActivity,
                mbHeader.getId());
        if (resultHeader != null) {
            frompageNo = resultHeader.getFromPageNo();
            topageNo = resultHeader.getToPageNo();
        }

        String pageNoInfo = "";
        if (frompageNo != null)
            pageNoInfo = resultHeader.getMbRefNo() + "/" + frompageNo.toString();
        if (topageNo != null)
            pageNoInfo = pageNoInfo + "-" + topageNo;

        mbTable.addCell(rightPara(8, pageNoInfo));
        // b)Cumulative measurement recorded for the previous MB entry for
        // line item( Cumulative measurements-current MB entry)
        mbTable.addCell(rightPara(8, cumlPrevMb));

        // Current Finalised Measurements a)Current MB entry and b) Column6
        // Estimate Percentage
        // a)Current MB entry---->Measurements (Col5-8) i.e (area-previous
        // measurement)

        mbTable.addCell(rightPara(8, currentMeasurement));

        // current cost
        double currentCost;
        currentCost = currentMeasurement * approveRateWo * uomFactor;
        mbTable.addCell(rightPara(8, formatter.format(currentCost)));
        // } //end of if mbDetails
    } // end of for loop
    return mbTable;
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

public void generatePDF() {
    nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(10);/*from ww w.j  a  v  a 2s .  c om*/
    final List<String> tenderTypeList = worksService.getTendertypeList();
    if (tenderTypeList != null && !tenderTypeList.isEmpty())
        percTenderType = tenderTypeList.get(0);
    final String headerText = pdfLabel.get("tenderNegotiationpdf.header");
    try {
        final Paragraph headerTextPara = new Paragraph(
                new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD)));
        headerTextPara.setAlignment(Element.ALIGN_CENTER);
        document.add(headerTextPara);
        document.add(makePara(cityName, Element.ALIGN_RIGHT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getWorksPackage() != null) {
            worksPackgeReq = YES;
            worksPackage = tenderResponse.getTenderEstimate().getWorksPackage();
        }
        String deptName = "";
        if (YES.equalsIgnoreCase(worksPackgeReq)) {
            deptName = tenderResponse.getTenderEstimate().getWorksPackage().getDepartment().getName();
            document.add(makePara(deptName, Element.ALIGN_RIGHT));
            if (getWardList(worksPackage) != null)
                document.add(makePara(
                        pdfLabel.get("tenderNegotiationpdf.ward") + "/"
                                + pdfLabel.get("tenderNegotiationpdf.zone") + getWardList(worksPackage),
                        Element.ALIGN_LEFT));
        } else {
            if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment()
                            .getName() != null)
                deptName = tenderResponse.getTenderEstimate().getAbstractEstimate().getExecutingDepartment()
                        .getName();
            document.add(makePara(deptName, Element.ALIGN_RIGHT));
            if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getParent() != null
                    && tenderResponse.getTenderEstimate().getAbstractEstimate().getWard() != null)
                document.add(makePara(pdfLabel.get("tenderNegotiationpdf.ward") + "/"
                        + pdfLabel.get("tenderNegotiationpdf.zone")
                        + tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getName() + "/"
                        + tenderResponse.getTenderEstimate().getAbstractEstimate().getWard().getParent()
                                .getName(),
                        Element.ALIGN_LEFT));
        }
        if (YES.equalsIgnoreCase(worksPackgeReq))
            document.add(makePara(
                    pdfLabel.get("tenderNegotiationpdf.nameofwork")
                            + tenderResponse.getTenderEstimate().getWorksPackage().getName(),
                    Element.ALIGN_LEFT));
        else if (tenderResponse != null && tenderResponse.getTenderEstimate() != null)
            document.add(makePara(
                    pdfLabel.get("tenderNegotiationpdf.nameofwork")
                            + tenderResponse.getTenderEstimate().getAbstractEstimate().getName(),
                    Element.ALIGN_LEFT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getTenderHeader() != null
                && tenderResponse.getTenderEstimate().getTenderHeader().getTenderNo() != null)
            document.add(makePara(
                    pdfLabel.get("tenderNumber")
                            + tenderResponse.getTenderEstimate().getTenderHeader().getTenderNo(),
                    Element.ALIGN_LEFT));
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getWorksPackage() != null)
            document.add(makePara(
                    pdfLabel.get("tenderFileNo")
                            + tenderResponse.getTenderEstimate().getWorksPackage().getTenderFileNumber(),
                    Element.ALIGN_LEFT));
        document.add(spacer());
        String tenderDate = "";
        if (tenderResponse != null && tenderResponse.getTenderEstimate() != null
                && tenderResponse.getTenderEstimate().getTenderHeader() != null
                && tenderResponse.getTenderEstimate().getTenderHeader().getTenderDate() != null)
            tenderDate = sdf.format(tenderResponse.getTenderEstimate().getTenderHeader().getTenderDate());
        document.add(
                makePara(pdfLabel.get("tenderNegotiationpdf.tenderdate") + tenderDate, Element.ALIGN_RIGHT));
        document.add(spacer());
        PdfPTable contractorTable = null;
        if (tenderResponse != null) {
            contractorTable = createContractorTable(tenderResponse);
            document.add(contractorTable);
        }
        document.add(spacer());

        if (tenderResponse != null
                && tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType)) {
            PdfPTable negotiationTable = null;
            negotiationTable = createNegotiationTable(tenderResponse,
                    tenderResponse.getTenderResponseContractors().get(0).getContractor());
            document.add(negotiationTable);
            document.add(spacer());
            if (negotiationTable != null && negotiationTable.getRows().size() > 8)
                document.newPage();

        } else if (tenderResponse != null
                && !tenderResponse.getTenderEstimate().getTenderType().equalsIgnoreCase(percTenderType))
            createNegotiationTableForContractors(tenderResponse);

        if (tenderResponse != null && tenderResponse.getNegotiationPreparedBy() != null
                && tenderResponse.getNegotiationPreparedBy().getEmployeeName() != null)
            document.add(makePara(pdfLabel.get("tenderNegotiationpdf.preparedby") + " "
                    + tenderResponse.getNegotiationPreparedBy().getEmployeeName()));
        document.add(spacer());
        document.add(spacer());
        document.add(makePara(pdfLabel.get("tenderNegotiationpdf.checkedby")));
        document.newPage();

        PdfPTable approvaldetailsTable = null;
        if (tenderResponse != null)
            approvaldetailsTable = createApprovalDetailsTable(tenderResponse);

        if (approvaldetailsTable != null && approvaldetailsTable.getRows().size() != 1) {
            document.add(makePara(pdfLabel.get("tenderNegotiationpdf.approvaldetails")));
            document.add(spacer());
            document.add(approvaldetailsTable);
        }
        document.close();
    } catch (final DocumentException e) {
        throw new ApplicationRuntimeException(TENDER_PDF_ERROR, e);
    }
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

/**
 * view workpackage pdf//  ww  w . j a  v a2s. co m
 */
public void createNegotiationTableDataForWp(final TenderResponse tenderResponse,
        final PdfPTable negotiationTable, final Contractor contractor) {
    Date asOnDate = null;
    if (tenderResponse.getNegotiationDate() != null)
        asOnDate = tenderResponse.getNegotiationDate();

    int i = 0;
    final Map<String, Integer> exceptionaSorMap = worksService.getExceptionSOR();
    totalBefNegAmt = 0;
    totalAmt = 0;
    totalAftNegAmt = 0;
    totalMarketRateAmt = 0;
    for (final TenderResponseActivity tenderResponseActivity : tenderResponse.getTenderResponseActivities()) {
        String schNo;
        String description;
        Double quantity = 0.0;
        double rate;
        String per;
        double befNegRate = 0.0;
        double befNegAmount;
        double aftNegRate = 0.0;
        double aftNegAmount;
        MarketRate marketRateObj;
        double marketRate = 0.0;
        double marketRateAmount = 0.0;
        double uomFactor = 1;

        if (tenderResponseActivity != null) {
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getCode() != null
                    && exceptionaSorMap.containsKey(tenderResponseActivity.getActivity().getUom().getUom()))
                uomFactor = exceptionaSorMap.get(tenderResponseActivity.getActivity().getUom().getUom());

            final Map<String, Object> rateQtyMap = processLatestRateAndQtyForLineItem(
                    worksPackage.getActivitiesForEstimate(), tenderResponseActivity.getActivity());
            if (rateQtyMap != null && !rateQtyMap.isEmpty()) {
                negotiationTable.addCell(makePara(++i));
                schNo = (String) rateQtyMap.get("sorcode");
                negotiationTable.addCell(centerPara(schNo));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                description = (String) rateQtyMap.get("desc");
                negotiationTable.addCell(makePara(description, Element.ALIGN_LEFT));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                quantity = (Double) rateQtyMap.get("qty");
                negotiationTable.addCell(centerPara(formatter.format(quantity)));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
                rate = (Double) rateQtyMap.get("rate");
                negotiationTable.addCell(rightPara(formatter.format(rate)));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                per = (String) rateQtyMap.get("per");
                negotiationTable.addCell(centerPara(per));
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
                final double amount = (Double) rateQtyMap.get("amt");
                negotiationTable.addCell(rightPara(formatter.format(amount)));
                totalAmt = totalAmt + amount;
            }

            if (rateQtyMap != null && rateQtyMap.get("slno") != null) {
                /**
                 * before negotiation
                 */
                negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
                for (final TenderResponseQuotes tenderResponseQuotes : tenderResponseActivity
                        .getTenderResponseQuotes())
                    if (tenderResponseQuotes.getContractor().getId() == contractor.getId()) {
                        if (tenderResponseQuotes.getQuotedRate() != 0.0)
                            befNegRate = tenderResponseQuotes.getQuotedRate();
                        negotiationTable.addCell(rightPara(formatter.format(befNegRate)));

                        befNegAmount = quantity * befNegRate / uomFactor;
                        totalBefNegAmt = totalBefNegAmt + befNegAmount;
                        negotiationTable.addCell(rightPara(formatter.format(befNegAmount)));
                    }
                if (tenderResponseActivity.getNegotiatedRate() != 0.0)
                    aftNegRate = tenderResponseActivity.getNegotiatedRate();
                negotiationTable.addCell(rightPara(formatter.format(aftNegRate)));

                aftNegAmount = quantity * aftNegRate / uomFactor;
                totalAftNegAmt = totalAftNegAmt + aftNegAmount;
                negotiationTable.addCell(rightPara(formatter.format(aftNegAmount)));

                if (tenderResponseActivity.getActivity() != null
                        && tenderResponseActivity.getActivity().getSchedule() != null && asOnDate != null
                        && tenderResponseActivity.getActivity().getSchedule().hasValidMarketRateFor(asOnDate)) {
                    marketRateObj = tenderResponseActivity.getActivity().getSchedule()
                            .getMarketRateOn(asOnDate);
                    marketRate = marketRateObj.getMarketRate().getValue();
                    marketRateAmount = quantity * marketRate / uomFactor;
                }

                if (tenderResponseActivity.getActivity() != null
                        && tenderResponseActivity.getActivity().getSchedule() != null && asOnDate != null
                        && !tenderResponseActivity.getActivity().getSchedule()
                                .hasValidMarketRateFor(asOnDate)) {
                    marketRate = tenderResponseActivity.getActivity().getRate();
                    marketRateAmount = quantity * marketRate;
                }

                if (tenderResponseActivity.getActivity() != null
                        && tenderResponseActivity.getActivity().getNonSor() != null) {
                    marketRate = tenderResponseActivity.getActivity().getRate();
                    final double marketQty = tenderResponseActivity.getActivity().getQuantity();
                    marketRateAmount = marketQty * marketRate;
                }
                negotiationTable.addCell(rightPara(formatter.format(marketRate)));
                totalMarketRateAmt = totalMarketRateAmt + marketRateAmount;
                negotiationTable.addCell(rightPara(formatter.format(marketRateAmount)));
            }

        }
    }
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

/**
 * view estimate pdf/*from  w  w w .  ja  v a2  s. com*/
 */
public void createNegotiationTableData(final TenderResponse tenderResponse, final PdfPTable negotiationTable,
        final Contractor contractor) {

    Date asOnDate = null;
    if (tenderResponse.getNegotiationDate() != null)
        asOnDate = tenderResponse.getNegotiationDate();
    int i = 0;
    final Map<String, Integer> exceptionaSorMap = worksService.getExceptionSOR();

    for (final TenderResponseActivity tenderResponseActivity : tenderResponse.getTenderResponseActivities()) {
        String schNo = "";
        String description = "";
        Double quantity = 0.0;
        double rate = 0.0;
        String per = "";
        double befNegRate = 0.0;
        double befNegAmount;
        double aftNegRate = 0.0;
        double aftNegAmount;
        MarketRate marketRateObj;
        double marketRate = 0.0;
        double marketRateAmount = 0.0;
        negotiationTable.addCell(makePara(++i));
        double uomFactor = 1;

        if (tenderResponseActivity != null) {
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getCode() != null
                    && exceptionaSorMap.containsKey(tenderResponseActivity.getActivity().getUom().getUom()))
                uomFactor = exceptionaSorMap.get(tenderResponseActivity.getActivity().getUom().getUom());

            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getCode() != null)
                schNo = tenderResponseActivity.getActivity().getSchedule().getCode();
            negotiationTable.addCell(centerPara(schNo));
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getDescription() != null)
                description = tenderResponseActivity.getActivity().getSchedule().getDescription();
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getNonSor() != null
                    && tenderResponseActivity.getActivity().getNonSor().getDescription() != null)
                description = tenderResponseActivity.getActivity().getNonSor().getDescription();
            negotiationTable.addCell(makePara(description, Element.ALIGN_LEFT));
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getQuantity() != 0)
                quantity = tenderResponseActivity.getActivity().getQuantity();
            negotiationTable.addCell(centerPara(quantity));
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getRate() != 0
                    && tenderResponseActivity.getActivity().getSORCurrentRate() != null)
                rate = tenderResponseActivity.getActivity().getSORCurrentRate().getValue();
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getNonSor() != null
                    && tenderResponseActivity.getActivity().getRate() != 0)
                rate = tenderResponseActivity.getActivity().getRate();
            negotiationTable.addCell(rightPara(formatter.format(rate)));
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
            if (tenderResponseActivity.getActivity().getSchedule() != null
                    && tenderResponseActivity.getActivity().getSchedule().getUom() != null
                    && tenderResponseActivity.getActivity().getSchedule().getUom().getUom() != null)
                per = tenderResponseActivity.getActivity().getSchedule().getUom().getUom();
            if (tenderResponseActivity.getActivity().getNonSor() != null
                    && tenderResponseActivity.getActivity().getNonSor().getUom() != null
                    && tenderResponseActivity.getActivity().getNonSor().getUom().getUom() != null)
                per = tenderResponseActivity.getActivity().getNonSor().getUom().getUom();
            negotiationTable.addCell(centerPara(per));
            final double amount = quantity * rate / uomFactor;
            totalAmt = totalAmt + amount;
            negotiationTable.addCell(rightPara(formatter.format(amount)));
            /** before negotiation */
            negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            for (final TenderResponseQuotes tenderResponseQuotes : tenderResponseActivity
                    .getTenderResponseQuotes())
                if (tenderResponseQuotes.getContractor().getId() == contractor.getId()) {
                    if (tenderResponseQuotes.getQuotedRate() != 0.0)
                        befNegRate = tenderResponseQuotes.getQuotedRate();
                    final double quotedQty = tenderResponseQuotes.getQuotedQuantity();
                    negotiationTable.addCell(rightPara(formatter.format(befNegRate)));
                    befNegAmount = quotedQty * befNegRate / uomFactor;
                    totalBefNegAmt = totalBefNegAmt + befNegAmount;
                    negotiationTable.addCell(rightPara(formatter.format(befNegAmount)));

                }
            if (tenderResponseActivity.getNegotiatedRate() != 0.0)
                aftNegRate = tenderResponseActivity.getNegotiatedRate();
            final double negotiatedQty = tenderResponseActivity.getNegotiatedQuantity();
            negotiationTable.addCell(rightPara(formatter.format(aftNegRate)));
            aftNegAmount = negotiatedQty * aftNegRate / uomFactor;
            totalAftNegAmt = totalAftNegAmt + aftNegAmount;
            negotiationTable.addCell(rightPara(formatter.format(aftNegAmount)));
            if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null && asOnDate != null
                    && tenderResponseActivity.getActivity().getSchedule().hasValidMarketRateFor(asOnDate)) {
                marketRateObj = tenderResponseActivity.getActivity().getSchedule().getMarketRateOn(asOnDate);
                marketRate = marketRateObj.getMarketRate().getValue();
                marketRateAmount = quantity * marketRate / uomFactor;
            } else if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getSchedule() != null) {
                marketRate = tenderResponseActivity.getActivity().getSORCurrentRate().getValue();
                final double marketQty = tenderResponseActivity.getActivity().getQuantity();
                marketRateAmount = marketQty * marketRate / uomFactor;
            } else if (tenderResponseActivity.getActivity() != null
                    && tenderResponseActivity.getActivity().getNonSor() != null) {
                marketRate = tenderResponseActivity.getActivity().getRate();
                final double marketQty = tenderResponseActivity.getActivity().getQuantity();
                marketRateAmount = marketQty * marketRate;
            }
            negotiationTable.addCell(rightPara(formatter.format(marketRate)));
            totalMarketRateAmt = totalMarketRateAmt + marketRateAmount;
            negotiationTable.addCell(rightPara(formatter.format(marketRateAmount)));
        }
    }
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

public PdfPTable createTenderPercentageTable() {
    final PdfPTable tenderPercentageTable = new PdfPTable(5);
    tenderPercentageTable.getDefaultCell().setBorderWidth(1);
    tenderPercentageTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    tenderPercentageTable.getDefaultCell().setColspan(5);
    tenderPercentageTable.addCell(pdfLabel.get("tenderNegotiationpdf.percentage"));
    return tenderPercentageTable;
}

From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java

License:Open Source License

public PdfPTable createTotalQuotedValueTable() {
    final PdfPTable tenderQuotedTable = new PdfPTable(5);
    tenderQuotedTable.getDefaultCell().setBorderWidth(1);
    tenderQuotedTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    tenderQuotedTable.getDefaultCell().setColspan(5);
    tenderQuotedTable.addCell(pdfLabel.get("tenderNegotiationpdf.quoted.total"));
    return tenderQuotedTable;
}