1 package org.kuali.ole.deliver.util.printSlip;
2
3 import com.itextpdf.text.Chunk;
4 import com.itextpdf.text.Font;
5 import com.itextpdf.text.Paragraph;
6 import com.itextpdf.text.pdf.PdfPTable;
7 import org.apache.log4j.Logger;
8 import org.kuali.ole.deliver.bo.OleCirculationDesk;
9 import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
10 import org.kuali.ole.deliver.util.*;
11
12 import java.text.DateFormat;
13 import java.text.SimpleDateFormat;
14 import java.util.Calendar;
15 import java.util.Date;
16
17
18
19
20 public class OnHoldRecieptPrintSlipUtil extends OleRecieptPrintSlipUtil {
21
22 private static final Logger LOG = Logger.getLogger(OnHoldRecieptPrintSlipUtil.class);
23
24 @Override
25 public PdfFormatUtil getPdfFormatUtil() {
26 return new ReceiptPdfFormatUtil();
27 }
28
29 @Override
30 protected void populateHeader(Paragraph paraGraph) {
31 paraGraph.add(new Chunk("Hold Slip", getPdfFormatUtil().getBoldFont()));
32 }
33
34 @Override
35 protected void populateBody(PdfPTable pdfTable) {
36 boolean missingPieceCheck = getOleItemRecordForCirc().getItemRecord().isMissingPieceFlag();
37 OleCirculationDesk oleCirculationDesk = null != getOleItemRecordForCirc() ? getOleItemRecordForCirc().getCheckinLocation() : null;
38 OleDeliverRequestBo oleDeliverRequestBo = getOleItemRecordForCirc().getOleDeliverRequestBo();
39 String patronName = oleDeliverRequestBo != null ? oleDeliverRequestBo.getOlePatron().getPatronName() : null;
40 try {
41 pdfTable.addCell(getPdfFormatUtil().getPdfPCellInJustified(patronName));
42 if (oleCirculationDesk != null) {
43 int noDays = Integer.parseInt(oleCirculationDesk.getOnHoldDays());
44 Calendar calendar = Calendar.getInstance();
45 calendar.add(Calendar.DATE, noDays);
46 Date date = calendar.getTime();
47 if (date != null) {
48 DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
49 String dateString = date == null ? "" : df.format(date);
50 pdfTable.addCell(getPdfFormatUtil().getPdfPCellInJustified(dateString));
51 }
52 }
53 pdfTable.addCell(getPdfFormatUtil().getEmptyCell());
54 if (!missingPieceCheck) {
55 pdfTable.addCell(getPdfFormatUtil().getPdfPCellInJustified(oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : ""));
56 pdfTable.addCell(getPdfFormatUtil().getPdfPCellInJustified(getOleItemRecordForCirc().getItemRecord().getBarCode()));
57 pdfTable.addCell(getPdfFormatUtil().getPdfPCellInJustified(getOleItemSearch().getTitle()));
58 pdfTable.addCell(getPdfFormatUtil().getPdfPCellInJustified(getOleItemSearch().getCallNumber()));
59 pdfTable.addCell(getPdfFormatUtil().getPdfPCellInJustified(getOleItemSearch().getCopyNumber()));
60 pdfTable.addCell(getPdfFormatUtil().getPdfPCellInJustified(getOleItemSearch().getVolumeNumber()));
61 }
62 } catch (Exception e) {
63 LOG.error("Exception while creating pdf for printing slip", e);
64 }
65 }
66 }