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