1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.pdf;
17
18 import com.lowagie.text.*;
19 import com.lowagie.text.pdf.BaseFont;
20 import com.lowagie.text.pdf.PdfPCell;
21 import com.lowagie.text.pdf.PdfPTable;
22 import com.lowagie.text.pdf.PdfWriter;
23 import org.apache.commons.lang.StringUtils;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.kuali.ole.module.purap.PurapConstants;
27 import org.kuali.ole.module.purap.PurapPropertyConstants;
28 import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem;
29 import org.kuali.ole.module.purap.businessobject.PurchaseOrderQuoteLanguage;
30 import org.kuali.ole.module.purap.businessobject.PurchaseOrderVendorQuote;
31 import org.kuali.ole.module.purap.businessobject.PurchaseOrderVendorStipulation;
32 import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
33 import org.kuali.ole.module.purap.exception.PurError;
34 import org.kuali.ole.module.purap.util.PurApDateFormatUtils;
35 import org.kuali.ole.sys.OLEConstants;
36 import org.kuali.ole.sys.OLEPropertyConstants;
37 import org.kuali.ole.sys.context.SpringContext;
38 import org.kuali.ole.vnd.businessobject.CampusParameter;
39 import org.kuali.ole.vnd.businessobject.ContractManager;
40 import org.kuali.rice.core.api.util.RiceConstants;
41 import org.kuali.rice.krad.service.BusinessObjectService;
42 import org.kuali.rice.krad.util.ObjectUtils;
43
44 import java.io.ByteArrayOutputStream;
45 import java.io.FileNotFoundException;
46 import java.io.FileOutputStream;
47 import java.text.NumberFormat;
48 import java.text.ParseException;
49 import java.text.SimpleDateFormat;
50 import java.util.*;
51 import java.util.List;
52
53
54
55
56
57 public class PurchaseOrderQuotePdf extends PurapPdf {
58 private static Log LOG = LogFactory.getLog(PurchaseOrderQuotePdf.class);
59
60 public PurchaseOrderQuotePdf() {
61 super();
62 }
63
64
65
66
67
68
69
70
71
72 public void onOpenDocument(PdfWriter writer, Document document) {
73 LOG.debug("onOpenDocument() started.");
74 try {
75 float[] headerWidths = {0.20f, 0.60f, 0.20f};
76 headerTable = new PdfPTable(headerWidths);
77 headerTable.setWidthPercentage(100);
78 headerTable.setHorizontalAlignment(Element.ALIGN_CENTER);
79
80 headerTable.getDefaultCell().setBorderWidth(0);
81 headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
82 headerTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_CENTER);
83
84 if (StringUtils.isNotBlank(logoImage)) {
85 logo = Image.getInstance(logoImage);
86 logo.scalePercent(3, 3);
87 headerTable.addCell(new Phrase(new Chunk(logo, 0, 0)));
88 } else {
89
90 headerTable.addCell(new Phrase(new Chunk("")));
91 }
92 PdfPCell cell;
93 cell = new PdfPCell(new Paragraph("REQUEST FOR QUOTATION\nTHIS IS NOT AN ORDER", ver_17_normal));
94 cell.setBorderWidth(0);
95 cell.setHorizontalAlignment(Element.ALIGN_CENTER);
96 headerTable.addCell(cell);
97
98 Paragraph p = new Paragraph();
99 p.add(new Chunk("\n R.Q. Number: ", ver_8_bold));
100 p.add(new Chunk(po.getPurapDocumentIdentifier() + "\n", cour_10_normal));
101 cell = new PdfPCell(p);
102 cell.setBorderWidth(0);
103 headerTable.addCell(cell);
104
105
106 tpl = writer.getDirectContent().createTemplate(100, 100);
107
108 helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
109 } catch (Exception e) {
110 throw new ExceptionConverter(e);
111 }
112 }
113
114
115
116
117
118
119 public PurchaseOrderQuotePdf getPageEvents() {
120 LOG.debug("getPageEvents() started.");
121 return new PurchaseOrderQuotePdf();
122 }
123
124
125
126
127
128
129
130
131
132
133
134
135
136 public void generatePOQuotePDF(PurchaseOrderDocument po, PurchaseOrderVendorQuote poqv, String campusName, String contractManagerCampusCode, String logoImage, ByteArrayOutputStream byteArrayOutputStream, String environment) {
137 if (LOG.isDebugEnabled()) {
138 LOG.debug("generatePOQuotePDF() started for po number " + po.getPurapDocumentIdentifier());
139 }
140
141 Collection errors = new ArrayList();
142
143 try {
144 Document doc = getDocument(9, 9, 70, 36);
145 PdfWriter writer = PdfWriter.getInstance(doc, byteArrayOutputStream);
146 this.createPOQuotePdf(po, poqv, campusName, contractManagerCampusCode, logoImage, doc, writer, environment);
147 } catch (DocumentException de) {
148 LOG.error(de.getMessage(), de);
149 throw new PurError("Document Exception when trying to save a Purchase Order Quote PDF", de);
150 }
151 }
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166 public void savePOQuotePDF(PurchaseOrderDocument po, PurchaseOrderVendorQuote poqv, PurchaseOrderParameters transmitParameters, String environment) {
167 if (LOG.isDebugEnabled()) {
168 LOG.debug("savePOQuotePDF() started for po number " + po.getPurapDocumentIdentifier());
169 }
170
171 try {
172 PurchaseOrderTransmitParameters orderTransmitParameters = (PurchaseOrderTransmitParameters) transmitParameters;
173 CampusParameter deliveryCampus = orderTransmitParameters.getCampusParameter();
174 if (deliveryCampus == null) {
175 throw new RuntimeException(" delivery campus is null");
176 }
177 String campusName = deliveryCampus.getCampus().getName();
178 if (campusName == null) {
179
180 throw new RuntimeException("Campus Information is missing - campusName: " + campusName);
181 }
182 Document doc = this.getDocument(9, 9, 70, 36);
183 PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(orderTransmitParameters.getPdfFileLocation() + orderTransmitParameters.getPdfFileName()));
184 this.createPOQuotePdf(po, poqv, campusName, orderTransmitParameters.getContractManagerCampusCode(), orderTransmitParameters.getLogoImage(), doc, writer, environment);
185 } catch (DocumentException de) {
186 LOG.error(de.getMessage(), de);
187 throw new PurError("Document Exception when trying to save a Purchase Order Quote PDF", de);
188 } catch (FileNotFoundException f) {
189 LOG.error(f.getMessage(), f);
190 throw new PurError("FileNotFound Exception when trying to save a Purchase Order Quote PDF", f);
191 }
192 }
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207 private void createPOQuotePdf(PurchaseOrderDocument po, PurchaseOrderVendorQuote poqv, String campusName, String contractManagerCampusCode, String logoImage, Document document, PdfWriter writer, String environment) throws DocumentException {
208 if (LOG.isDebugEnabled()) {
209 LOG.debug("createQuotePdf() started for po number " + po.getPurapDocumentIdentifier());
210 }
211
212
213 this.campusName = campusName;
214 this.po = po;
215 this.logoImage = logoImage;
216 this.environment = environment;
217
218 NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.US);
219
220 SimpleDateFormat sdf = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE, Locale.getDefault());
221
222 CampusParameter campusParameter = getCampusParameter(contractManagerCampusCode);
223 String purchasingAddressFull = getPurchasingAddressFull(campusParameter);
224
225
226 PurchaseOrderQuotePdf events = new PurchaseOrderQuotePdf().getPageEvents();
227 writer.setPageEvent(this);
228
229 document.open();
230
231 PdfPCell cell;
232 Paragraph p = new Paragraph();
233
234
235 LOG.debug("createQuotePdf() info table started.");
236 float[] infoWidths = {0.45f, 0.55f};
237 PdfPTable infoTable = new PdfPTable(infoWidths);
238 infoTable.setWidthPercentage(100);
239 infoTable.setHorizontalAlignment(Element.ALIGN_CENTER);
240 infoTable.setSplitLate(false);
241
242 p = new Paragraph();
243 ContractManager contractManager = po.getContractManager();
244 p.add(new Chunk("\n Return this form to:\n", ver_8_bold));
245 p.add(new Chunk(purchasingAddressFull + "\n", cour_10_normal));
246 p.add(new Chunk("\n", cour_10_normal));
247 p.add(new Chunk(" Fax #: ", ver_6_normal));
248 p.add(new Chunk(contractManager.getContractManagerFaxNumber() + "\n", cour_10_normal));
249 p.add(new Chunk(" Contract Manager: ", ver_6_normal));
250 p.add(new Chunk(contractManager.getContractManagerName() + " " + contractManager.getContractManagerPhoneNumber() + "\n", cour_10_normal));
251 p.add(new Chunk("\n", cour_10_normal));
252 p.add(new Chunk(" To:\n", ver_6_normal));
253 StringBuffer vendorInfo = new StringBuffer();
254 if (StringUtils.isNotBlank(poqv.getVendorAttentionName())) {
255 vendorInfo.append(" ATTN: " + poqv.getVendorAttentionName().trim() + "\n");
256 }
257 vendorInfo.append(" " + poqv.getVendorName() + "\n");
258 if (StringUtils.isNotBlank(poqv.getVendorLine1Address())) {
259 vendorInfo.append(" " + poqv.getVendorLine1Address() + "\n");
260 }
261 if (StringUtils.isNotBlank(poqv.getVendorLine2Address())) {
262 vendorInfo.append(" " + poqv.getVendorLine2Address() + "\n");
263 }
264 if (StringUtils.isNotBlank(poqv.getVendorCityName())) {
265 vendorInfo.append(" " + poqv.getVendorCityName());
266 }
267 if ((StringUtils.isNotBlank(poqv.getVendorStateCode())) && (!poqv.getVendorStateCode().equals("--"))) {
268 vendorInfo.append(", " + poqv.getVendorStateCode());
269 }
270 if (StringUtils.isNotBlank(poqv.getVendorAddressInternationalProvinceName())) {
271 vendorInfo.append(", " + poqv.getVendorAddressInternationalProvinceName());
272 }
273 if (StringUtils.isNotBlank(poqv.getVendorPostalCode())) {
274 vendorInfo.append(" " + poqv.getVendorPostalCode() + "\n");
275 } else {
276 vendorInfo.append("\n");
277 }
278
279 if (!OLEConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(poqv.getVendorCountryCode()) && poqv.getVendorCountryCode() != null) {
280 vendorInfo.append(" " + poqv.getVendorCountry().getName() + "\n\n");
281 } else {
282 vendorInfo.append(" \n\n");
283 }
284
285 p.add(new Chunk(vendorInfo.toString(), cour_10_normal));
286 cell = new PdfPCell(p);
287 cell.setHorizontalAlignment(Element.ALIGN_LEFT);
288 infoTable.addCell(cell);
289
290 p = new Paragraph();
291 p.add(new Chunk("\n R.Q. Number: ", ver_8_bold));
292 p.add(new Chunk(po.getPurapDocumentIdentifier() + "\n", cour_10_normal));
293 java.sql.Date requestDate = getDateTimeService().getCurrentSqlDate();
294 if (poqv.getPurchaseOrderQuoteTransmitTimestamp() != null) {
295 try {
296 requestDate = getDateTimeService().convertToSqlDate(poqv.getPurchaseOrderQuoteTransmitTimestamp());
297 } catch (ParseException e) {
298 throw new RuntimeException("ParseException thrown when trying to convert from Timestamp to SqlDate.", e);
299 }
300 }
301 p.add(new Chunk(" R.Q. Date: ", ver_8_bold));
302 p.add(new Chunk(sdf.format(requestDate) + "\n", cour_10_normal));
303 p.add(new Chunk(" RESPONSE MUST BE RECEIVED BY: ", ver_8_bold));
304 if (po.getPurchaseOrderQuoteDueDate() != null) {
305 p.add(new Chunk(sdf.format(po.getPurchaseOrderQuoteDueDate()) + "\n\n", cour_10_normal));
306 } else {
307 p.add(new Chunk("N/A\n\n", cour_10_normal));
308 }
309
310
311 StringBuffer quoteStipulations = getPoQuoteLanguage();
312
313 p.add(new Chunk(quoteStipulations.toString(), ver_6_normal));
314 p.add(new Chunk("\n ALL QUOTES MUST BE TOTALED", ver_12_normal));
315 cell = new PdfPCell(p);
316 infoTable.addCell(cell);
317
318 document.add(infoTable);
319
320
321
322
323
324
325 PdfPTable notesStipulationsTable = new PdfPTable(1);
326 notesStipulationsTable.setWidthPercentage(100);
327 notesStipulationsTable.setSplitLate(false);
328
329 p = new Paragraph();
330 p.add(new Chunk(" Vendor Stipulations and Information\n\n", ver_6_normal));
331 if ((po.getPurchaseOrderBeginDate() != null) && (po.getPurchaseOrderEndDate() != null)) {
332 p.add(new Chunk(" Order in effect from " + sdf.format(po.getPurchaseOrderBeginDate()) + " to " + sdf.format(po.getPurchaseOrderEndDate()) + ".\n", cour_10_normal));
333 }
334 Collection<PurchaseOrderVendorStipulation> vendorStipulationsList = po.getPurchaseOrderVendorStipulations();
335 if (vendorStipulationsList.size() > 0) {
336 StringBuffer vendorStipulations = new StringBuffer();
337 for (PurchaseOrderVendorStipulation povs : vendorStipulationsList) {
338 vendorStipulations.append(" " + povs.getVendorStipulationDescription() + "\n");
339 }
340 p.add(new Chunk(" " + vendorStipulations.toString(), cour_10_normal));
341 }
342
343 PdfPCell tableCell = new PdfPCell(p);
344 tableCell.setHorizontalAlignment(Element.ALIGN_LEFT);
345 tableCell.setVerticalAlignment(Element.ALIGN_TOP);
346 notesStipulationsTable.addCell(tableCell);
347 document.add(notesStipulationsTable);
348
349
350 LOG.debug("createQuotePdf() items table started.");
351 float[] itemsWidths = {0.07f, 0.1f, 0.07f, 0.50f, 0.13f, 0.13f};
352 PdfPTable itemsTable = new PdfPTable(6);
353
354
355
356 itemsTable.setWidthPercentage(100);
357 itemsTable.setWidths(itemsWidths);
358 itemsTable.setSplitLate(false);
359
360 tableCell = createCell("Item\nNo.", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
361 itemsTable.addCell(tableCell);
362 tableCell = createCell("Quantity", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
363 itemsTable.addCell(tableCell);
364 tableCell = createCell("UOM", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
365 itemsTable.addCell(tableCell);
366 tableCell = createCell("Description", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
367 itemsTable.addCell(tableCell);
368 tableCell = createCell("Unit Cost\n(Required)", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
369 itemsTable.addCell(tableCell);
370 tableCell = createCell("Extended Cost\n(Required)", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
371 itemsTable.addCell(tableCell);
372
373 if (StringUtils.isNotBlank(po.getPurchaseOrderQuoteVendorNoteText())) {
374
375 itemsTable.addCell(" ");
376 itemsTable.addCell(" ");
377 itemsTable.addCell(" ");
378 tableCell = createCell(po.getPurchaseOrderQuoteVendorNoteText(), false, false, false, false, Element.ALIGN_LEFT, cour_10_normal);
379 itemsTable.addCell(tableCell);
380 itemsTable.addCell(" ");
381 itemsTable.addCell(" ");
382 }
383
384 for (PurchaseOrderItem poi : (List<PurchaseOrderItem>) po.getItems()) {
385 if ((poi.getItemType() != null) && (StringUtils.isNotBlank(poi.getItemDescription())) && (poi.getItemType().isLineItemIndicator() || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE))) {
386
387 String description = "";
388 description = (StringUtils.isNotBlank(poi.getItemCatalogNumber())) ? poi.getItemCatalogNumber().trim() + " - " : "";
389 description = description + ((StringUtils.isNotBlank(poi.getItemDescription())) ? poi.getItemDescription().trim() : "");
390
391
392
393 if (StringUtils.isNotBlank(poi.getItemDescription())) {
394 if (poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE)) {
395 description = poi.getItemType().getItemTypeDescription() + " - " + description;
396 }
397 }
398
399
400 String itemLineNumber = new String();
401 if (poi.getItemType().isLineItemIndicator()) {
402 itemLineNumber = poi.getItemLineNumber().toString();
403 } else {
404 itemLineNumber = "";
405 }
406 tableCell = createCell(itemLineNumber, false, false, false, false, Element.ALIGN_CENTER, cour_10_normal);
407 itemsTable.addCell(tableCell);
408 String quantity = (poi.getItemQuantity() != null) ? poi.getItemQuantity().toString() : " ";
409 tableCell = createCell(quantity, false, false, false, false, Element.ALIGN_CENTER, cour_10_normal);
410 itemsTable.addCell(tableCell);
411 tableCell = createCell(poi.getItemUnitOfMeasureCode(), false, false, false, false, Element.ALIGN_CENTER, cour_10_normal);
412 itemsTable.addCell(tableCell);
413
414 tableCell = createCell(description, false, false, false, false, Element.ALIGN_LEFT, cour_10_normal);
415 itemsTable.addCell(tableCell);
416 itemsTable.addCell(" ");
417 itemsTable.addCell(" ");
418
419 }
420 }
421
422
423 createBlankRowInItemsTable(itemsTable);
424
425
426 itemsTable.addCell(" ");
427 itemsTable.addCell(" ");
428 itemsTable.addCell(" ");
429 tableCell = createCell("Total: ", false, false, false, false, Element.ALIGN_RIGHT, ver_10_normal);
430 itemsTable.addCell(tableCell);
431 itemsTable.addCell(" ");
432 itemsTable.addCell(" ");
433
434 createBlankRowInItemsTable(itemsTable);
435
436 document.add(itemsTable);
437
438 LOG.debug("createQuotePdf() vendorFillsIn table started.");
439 float[] vendorFillsInWidths = {0.50f, 0.50f};
440 PdfPTable vendorFillsInTable = new PdfPTable(vendorFillsInWidths);
441 vendorFillsInTable.setWidthPercentage(100);
442 vendorFillsInTable.setHorizontalAlignment(Element.ALIGN_CENTER);
443 vendorFillsInTable.setSplitLate(false);
444 vendorFillsInTable.getDefaultCell().setBorderWidth(0);
445 vendorFillsInTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
446 vendorFillsInTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_CENTER);
447
448
449 String important = new String("\nIMPORTANT: The information and signature below MUST BE COMPLETED or your offer may be rejected.\n");
450 cell = createCell(important, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
451 cell.setColspan(2);
452 vendorFillsInTable.addCell(cell);
453
454 String cashDiscount = new String("Terms of Payment: Cash discount_________%_________Days-Net________Days\n");
455 cell = createCell(cashDiscount, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
456 cell.setColspan(2);
457 vendorFillsInTable.addCell(cell);
458
459 String fob = new String(" FOB: __ Destination (Title)\n");
460 cell = createCell(fob, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
461 vendorFillsInTable.addCell(cell);
462 String freightVendor = new String(" __ Freight Vendor Paid (Allowed)\n");
463 cell = createCell(freightVendor, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
464 vendorFillsInTable.addCell(cell);
465
466 String shipping = new String(" __ Shipping Point (Title)\n");
467 cell = createCell(shipping, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
468 vendorFillsInTable.addCell(cell);
469 String freightPrepaid = new String(" __ Freight Prepaid & Added Amount $_________\n");
470 cell = createCell(freightPrepaid, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
471 vendorFillsInTable.addCell(cell);
472
473 String commonCarrier = new String(" If material will ship common carrier, please provide the following:\n");
474 cell = createCell(commonCarrier, true, false, false, false, Element.ALIGN_LEFT, ver_8_bold);
475 cell.setColspan(2);
476 vendorFillsInTable.addCell(cell);
477
478 String origin = new String(" Point of origin and zip code: ______________________ Weight: _________ Class: _________\n");
479 cell = createCell(origin, true, false, false, false, Element.ALIGN_LEFT, ver_8_bold);
480 cell.setColspan(2);
481 vendorFillsInTable.addCell(cell);
482
483 p = new Paragraph();
484 p.add(new Chunk(" Unless otherwise stated, all material to be shipped to ", ver_8_normal));
485 String purchasingAddressPartial;
486 if (po.getAddressToVendorIndicator())
487 purchasingAddressPartial = po.getReceivingCityName() + ", " + po.getReceivingStateCode() + " " + po.getReceivingPostalCode();
488 else
489 purchasingAddressPartial = po.getDeliveryCityName() + ", " + po.getDeliveryStateCode() + " " + po.getDeliveryPostalCode();
490 p.add(new Chunk(purchasingAddressPartial + "\n", cour_10_normal));
491 cell = new PdfPCell(p);
492 cell.setColspan(2);
493 cell.setHorizontalAlignment(Element.ALIGN_LEFT);
494 cell.setBorderWidth(0);
495 vendorFillsInTable.addCell(cell);
496
497 String offerEffective = new String(" Offer effective until (Date):_____________\n");
498 cell = createCell(offerEffective, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
499 vendorFillsInTable.addCell(cell);
500 String deliverBy = new String(" Delivery can be made by (Date):_____________\n");
501 cell = createCell(deliverBy, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
502 vendorFillsInTable.addCell(cell);
503
504 String sign = new String(" SIGN HERE:____________________________\n");
505 cell = createCell(sign, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
506 vendorFillsInTable.addCell(cell);
507 String date = new String(" DATE:____________________________\n");
508 cell = createCell(date, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
509 vendorFillsInTable.addCell(cell);
510
511 String name = new String(" PRINT NAME:____________________________\n");
512 cell = createCell(name, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
513 vendorFillsInTable.addCell(cell);
514 String phone = new String(" PHONE:____________________________\n");
515 cell = createCell(phone, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
516 vendorFillsInTable.addCell(cell);
517
518 String company = new String(" COMPANY:____________________________\n");
519 cell = createCell(company, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
520 vendorFillsInTable.addCell(cell);
521 String fax = new String(" FAX:____________________________\n");
522 cell = createCell(fax, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
523 vendorFillsInTable.addCell(cell);
524
525 document.add(vendorFillsInTable);
526 document.close();
527 LOG.debug("createQuotePdf()pdf document closed.");
528 }
529
530
531
532
533
534
535
536
537 private StringBuffer getPoQuoteLanguage() {
538
539 StringBuffer quoteLanguage = new StringBuffer();
540 Map<String, Object> criteria = new HashMap<String, Object>();
541
542
543 Collection<PurchaseOrderQuoteLanguage> poqlList = SpringContext.getBean(BusinessObjectService.class).findMatchingOrderBy(PurchaseOrderQuoteLanguage.class, criteria, PurapPropertyConstants.PURCHASE_ORDER_QUOTE_LANGUAGE_ID, true);
544
545
546 for (PurchaseOrderQuoteLanguage poql : poqlList) {
547 quoteLanguage.append(poql.getPurchaseOrderQuoteLanguageDescription());
548 quoteLanguage.append("\n");
549 }
550
551 return quoteLanguage;
552
553 }
554
555
556
557
558
559
560 private void createBlankRowInItemsTable(PdfPTable itemsTable) {
561
562
563 for (int i = 0; i < 6; i++) {
564 itemsTable.addCell(" ");
565 }
566 }
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581 private PdfPCell createCell(String content, boolean borderless, boolean noBottom, boolean noRight, boolean noTop, int horizontalAlignment, Font font) {
582 PdfPCell tableCell = new PdfPCell(new Paragraph(content, font));
583 if (borderless) {
584 tableCell.setBorder(0);
585 }
586 if (noBottom) {
587 tableCell.setBorderWidthBottom(0);
588 }
589 if (noTop) {
590 tableCell.setBorderWidthTop(0);
591 }
592 if (noRight) {
593 tableCell.setBorderWidthRight(0);
594 }
595 tableCell.setHorizontalAlignment(horizontalAlignment);
596 return tableCell;
597 }
598
599
600
601
602
603
604
605
606 private CampusParameter getCampusParameter(String contractManagerCampusCode) {
607 Map<String, Object> criteria = new HashMap<String, Object>();
608 criteria.put(OLEPropertyConstants.CAMPUS_CODE, po.getDeliveryCampusCode());
609 CampusParameter campusParameter = (CampusParameter) ((List) SpringContext.getBean(BusinessObjectService.class).findMatching(CampusParameter.class, criteria)).get(0);
610
611 return campusParameter;
612 }
613
614
615
616
617
618
619
620 private String getPurchasingAddressFull(CampusParameter campusParameter) {
621 String indent = " ";
622 StringBuffer addressBuffer = new StringBuffer();
623 addressBuffer.append(indent + campusParameter.getPurchasingInstitutionName() + "\n");
624 addressBuffer.append(indent + campusParameter.getPurchasingDepartmentName() + "\n");
625 addressBuffer.append(indent + campusParameter.getPurchasingDepartmentLine1Address() + "\n");
626 if (ObjectUtils.isNotNull(campusParameter.getPurchasingDepartmentLine2Address()))
627 addressBuffer.append(indent + campusParameter.getPurchasingDepartmentLine2Address() + "\n");
628 addressBuffer.append(indent + campusParameter.getPurchasingDepartmentCityName() + ", ");
629 addressBuffer.append(campusParameter.getPurchasingDepartmentStateCode() + " ");
630 addressBuffer.append(campusParameter.getPurchasingDepartmentZipCode() + " ");
631 addressBuffer.append((ObjectUtils.isNotNull(campusParameter.getPurchasingDepartmentCountryCode()) ? campusParameter.getPurchasingDepartmentCountryCode() : ""));
632
633 return addressBuffer.toString();
634 }
635
636
637
638
639
640
641
642 private String getPurchasingAddressPartial(CampusParameter campusParameter) {
643 StringBuffer purchasingAddressPartial = new StringBuffer();
644
645 purchasingAddressPartial.append(campusParameter.getPurchasingInstitutionName() + ", ");
646 purchasingAddressPartial.append(campusParameter.getPurchasingDepartmentCityName() + ", ");
647 purchasingAddressPartial.append(campusParameter.getPurchasingDepartmentStateCode() + " ");
648 purchasingAddressPartial.append(campusParameter.getPurchasingDepartmentZipCode());
649
650 return purchasingAddressPartial.toString();
651 }
652 }