예제 #1
0
  public PdfOrderGuideSwiss(HttpServletRequest pRequest, String pCatalogLocaleCd) {
    super();
    if (pCatalogLocaleCd == null) {
      mCatalogLocaleCd = "fr_CH";
    } else {
      mCatalogLocaleCd = pCatalogLocaleCd;
    }
    mCatalogLocale = new Locale(pCatalogLocaleCd);

    mRequest = pRequest;
    try {
      mFormatter = ClwI18nUtil.getInstance(pRequest, mCatalogLocaleCd, -1);
    } catch (Exception exc) {
    }
    ;
    if (mFormatter == null) {
      try {
        mFormatter = ClwI18nUtil.getInstance(pRequest, "fr_CH", -1);
      } catch (Exception exc) {
      }
      ;
    }

    try {
      initFontsUnicode();
    } catch (Exception exc) {
      exc.printStackTrace();
    }
  }
예제 #2
0
  public void init(HttpServletRequest pRequest, String pCatalogLocaleCd) {
    mCatalogLocale = new Locale(pCatalogLocaleCd);
    mRequest = pRequest;
    try {
      mFormatter = ClwI18nUtil.getInstance(pRequest, pCatalogLocaleCd, -1);
    } catch (Exception exc) {
    }
    ;
    if (mFormatter == null) {
      try {
        mFormatter = ClwI18nUtil.getInstance(pRequest, "fr_CH", -1);
      } catch (Exception exc) {
      }
      ;
    }

    try {
      initFontsUnicode();
    } catch (Exception exc) {
      exc.printStackTrace();
    }
  }
예제 #3
0
  private void drawOGHeader(
      Document document, UserShopForm sForm, String pImageName, boolean personal)
      throws DocumentException {

    // add the logo
    try {
      Image i = Image.getInstance(pImageName);
      float x = document.leftMargin();
      float y = document.getPageSize().getHeight() - i.getHeight() - 5;
      i.setAbsolutePosition(x, y);
      document.add(i);
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (catalogOnly) {
      return;
    }

    // unfortuanately this means we are limited to PDF rendering only.
    // get the user's personal info
    PdfPTable personalInfo;
    if (personal) {
      personalInfo = getPersonalized(sForm);
    } else {
      personalInfo = getNonPersonalized(sForm);
    }

    if (null != sForm.getAppUser().getUserAccount()
        && null != sForm.getAppUser().getUserAccount().getSkuTag()) {
      String t = sForm.getAppUser().getUserAccount().getSkuTag().getValue();
      if (t != null && t.length() > 0) {
        mSkuTag = t;
      }
    }

    // Display the contact info
    PdfPTable contactInfo = new PdfPTable(2);
    contactInfo.setWidthPercentage(50);
    contactInfo.setWidths(sizes);
    contactInfo.getDefaultCell().setBorder(borderType);
    contactInfo.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    String orderOnlineStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.orderOnLine:", null);
    contactInfo.addCell(makePhrase(orderOnlineStr + " ", smallHeading, false));
    contactInfo.addCell(
        makePhrase(
            sForm.getAppUser().getUserStore().getStorePrimaryWebAddress().getValue(),
            smallHeading,
            true));

    ContactUsInfo contact = null;
    if (sForm.getAppUser().getContactUsList().size() == 1) {
      contact = (ContactUsInfo) sForm.getAppUser().getContactUsList().get(0);
    }

    String orderFaxNumber = null, bscdesc = null;
    if (sForm.getAppUser().getSite().getBSC() != null
        && sForm.getAppUser().getSite().getBSC().getFaxNumber() != null
        && sForm.getAppUser().getSite().getBSC().getFaxNumber().getPhoneNum() != null) {
      orderFaxNumber = sForm.getAppUser().getSite().getBSC().getFaxNumber().getPhoneNum();
      bscdesc = sForm.getAppUser().getSite().getBSC().getBusEntityData().getLongDesc();
    }
    if (orderFaxNumber == null && contact != null) {
      orderFaxNumber = contact.getFax();
    }

    if (orderFaxNumber != null) {
      String faxOrderStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.faxOrder:", null);
      contactInfo.addCell(makePhrase(faxOrderStr + " ", smallHeading, false));
      contactInfo.addCell(makePhrase(orderFaxNumber, smallHeading, true));
    }

    if (null != bscdesc && bscdesc.length() > 0) {
      // if there is a BSC descripton set, then show
      // that information.
      PdfPCell cell = new PdfPCell(new Paragraph(bscdesc, smallHeading));
      cell.disableBorderSide(PdfPCell.LEFT);
      cell.disableBorderSide(PdfPCell.RIGHT);
      cell.disableBorderSide(PdfPCell.TOP);
      cell.disableBorderSide(PdfPCell.BOTTOM);
      cell.setColspan(2);
      cell.setPaddingTop(6);
      contactInfo.addCell(cell);
    } else {

      // otherwise show the standard contact us information
      // request for dmsi - dhl for eric.  durval 11/1/2005.

      if (contact != null) {
        contactInfo.addCell(makePhrase(" ", smallHeading, false));
        contactInfo.addCell(makePhrase(" ", smallHeading, true));
        String contactUsStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.contactUs", null);
        contactInfo.addCell(makePhrase(contactUsStr + " ", smallHeading, false));
        contactInfo.addCell(makePhrase("", smallHeading, true));

        String phoneStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.phone:", null);
        contactInfo.addCell(makePhrase(phoneStr + " ", smallHeading, false));
        contactInfo.addCell(
            makePhrase(
                "" + contact.getPhone() + "  " + contact.getCallHours(), smallHeading, true));

        String emailStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.email:", null);
        contactInfo.addCell(makePhrase(emailStr + " ", smallHeading, false));
        contactInfo.addCell(makePhrase(contact.getEmail(), smallHeading, true));
      }
    }

    // make the two tables into one
    PdfPTable wholeTable = new PdfPTable(2);
    wholeTable.setWidthPercentage(100);

    wholeTable.setWidths(halves);
    wholeTable.getDefaultCell().setBorder(borderType);

    wholeTable.addCell(personalInfo);
    wholeTable.addCell(contactInfo);
    document.add(wholeTable);

    String ogcomments = "";

    if (null != sForm.getAppUser().getSite()
        && null != sForm.getAppUser().getSite().getComments()) {
      ogcomments = sForm.getAppUser().getSite().getComments().getValue();
    }

    if (null == ogcomments || ogcomments.length() == 0) {
      if (null != sForm.getAppUser().getUserAccount()) {
        ogcomments = sForm.getAppUser().getUserAccount().getComments().getValue();
      }
    }

    // add the comments if there are any
    if (ogcomments != null && ogcomments.length() > 0) {
      document.add(makeBlankLine());
      String commentsStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.comments:", null);
      document.add(makePhrase(commentsStr + " " + ogcomments, smallHeading, true));
    }

    document.add(makeBlankLine());
    String commentsStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.comments:", null);
    document.add(
        makePhrase(
            commentsStr
                + " "
                + "__________________________________________"
                + "__________________________________________"
                + "__________",
            smallHeading,
            true));
    document.add(
        makePhrase(
            "__________"
                + "__________________________________________"
                + "__________________________________________"
                + "__________",
            smallHeading,
            true));
    document.add(
        makePhrase(
            "__________"
                + "__________________________________________"
                + "__________________________________________"
                + "__________",
            smallHeading,
            true));

    // Add an order guide note in the next page if a note is present.
    if (null != sForm.getAppUser().getUserAccount()
        && null != sForm.getAppUser().getUserAccount().getOrderGuideNote()) {
      String t = sForm.getAppUser().getUserAccount().getOrderGuideNote().getValue();
      if (t != null && t.length() > 0) {
        document.newPage();
        pageNumber = pageNumber + 1;
        // document.add(makeBlankLine());
        document.add(makePhrase(t, smallHeading, true));
      }
    }

    PdfPTable sort = new PdfPTable(1);
    sort.setWidthPercentage(100);
    sort.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    sort.getDefaultCell().setBorder(borderType);
    if (sForm.getOrderBy() == Constants.ORDER_BY_CATEGORY) {
      String sortedByCategoryStr =
          ClwI18nUtil.getMessage(mRequest, "shop.og.text.sortedBy:Category", null);
      sort.addCell(makePhrase(sortedByCategoryStr + " ", smallHeading, false));
    } else if (sForm.getOrderBy() == Constants.ORDER_BY_CUST_SKU) {
      String sortedByOurSkuNumStr =
          ClwI18nUtil.getMessage(mRequest, "shop.og.text.sortedBy:OurSkuNum", null);
      sort.addCell(makePhrase(sortedByOurSkuNumStr, smallHeading, false));
    } else {
      String sortedByProductNameStr =
          ClwI18nUtil.getMessage(mRequest, "shop.og.text.sortedBy:ProductName", null);
      sort.addCell(makePhrase(sortedByProductNameStr, smallHeading, false));
    }
    document.add(sort);
  }
예제 #4
0
  // utility function to make an item Element.
  private Table makeItemElement(ShoppingCartItemData pItm) throws DocumentException {

    Table itmTbl = new PTable(mColumnCount);
    itmTbl.setWidth(100);
    itmTbl.setWidths(itmColumnWidth);
    itmTbl.getDefaultCell().setBorderColor(java.awt.Color.black);
    itmTbl.getDefaultCell().setVerticalAlignment(Cell.ALIGN_TOP);
    itmTbl.setOffset(0);
    itmTbl.setBorder(Table.NO_BORDER);

    if (!catalogOnly) {
      String t0 = "";
      if (pItm.getIsaInventoryItem()) {
        t0 = "i";
      }

      if (null != mSiteData
          && mSiteData.isAnInventoryAutoOrderItem(pItm.getProduct().getProductId())) {
        t0 += "a";
      }

      Cell tpc0 = new Cell(makePhrase(t0, small, true));
      if (!pItm.getIsaInventoryItem()) {
        tpc0.setBorder(0);
      }
      itmTbl.addCell(tpc0);
    }

    Cell tpc01 = new Cell(makePhrase("", normal, true));
    itmTbl.addCell(tpc01);

    String t = "";
    if (pItm.getProduct().isPackProblemSku()) {
      t += "*";
    }
    if (t.length() > 0) t += " ";
    Cell tpc1 = new Cell(makePhrase(t + pItm.getActualSkuNum(), normal, true));
    itmTbl.addCell(tpc1);

    itmTbl.addCell(makePhrase(pItm.getProduct().getCatalogProductShortDesc(), normal, true));
    if (mShowSize) {
      itmTbl.addCell(makePhrase(pItm.getProduct().getSize(), normal, true));
    }
    // itmTbl.addCell(makePhrase(pItm.getProduct().getPack(), normal, true));
    // itmTbl.addCell(makePhrase(pItm.getProduct().getUom(), normal, true));
    // itmTbl.addCell(makePhrase(pItm.getProduct().getManufacturerName(),normal,true));

    if (mShowPrice) {
      BigDecimal price = new BigDecimal(pItm.getPrice());
      String priceStr = "";
      try {
        priceStr = mFormatter.priceFormatWithoutCurrency(price);
      } catch (Exception exc) {
        exc.printStackTrace();
      }
      Cell pcell = new Cell(makePhrase(priceStr, normal, true));
      pcell.setHorizontalAlignment(Element.ALIGN_RIGHT);
      itmTbl.addCell(pcell);
    }

    if (catalogOnly) {
      if (pItm.getProduct() != null
          && pItm.getProduct().getCatalogDistrMapping() != null
          && Utility.isTrue(pItm.getProduct().getCatalogDistrMapping().getStandardProductList())) {
        String yStr = ClwI18nUtil.getMessage(mRequest, "shoppingItems.text.y", null);
        itmTbl.addCell(makePhrase(yStr, normal, true));
      } else {
        String nStr = ClwI18nUtil.getMessage(mRequest, "shoppingItems.text.n", null);
        itmTbl.addCell(makePhrase(nStr, normal, true));
      }
    }

    if (!catalogOnly) {
      // BigDecimal amount = new BigDecimal(pItm.getAmount());
      itmTbl.addCell(makePhrase("", normal, true));
    }

    return itmTbl;
  }