1 package org.kuali.ole.deliver.controller;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.ole.OLEConstants;
5 import org.kuali.ole.deliver.controller.checkin.CheckinItemController;
6 import org.kuali.ole.deliver.drools.CheckedInItem;
7 import org.kuali.ole.deliver.drools.DroolsExchange;
8 import org.kuali.ole.deliver.form.CheckinForm;
9 import org.kuali.ole.deliver.util.OleItemRecordForCirc;
10 import org.kuali.ole.deliver.util.printSlip.OlePrintSlipUtil;
11 import org.kuali.ole.deliver.util.printSlip.OnHoldRecieptPrintSlipUtil;
12 import org.kuali.ole.deliver.util.printSlip.OnHoldRegularPrintSlipUtil;
13 import org.kuali.rice.krad.util.GlobalVariables;
14 import org.kuali.rice.krad.web.form.UifFormBase;
15 import org.springframework.stereotype.Controller;
16 import org.springframework.validation.BindingResult;
17 import org.springframework.web.bind.annotation.ModelAttribute;
18 import org.springframework.web.bind.annotation.RequestMapping;
19
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
22 import java.util.List;
23
24
25
26
27 @Controller
28 @RequestMapping(value = "/printBillcontroller")
29 public class PrintBillController extends CheckinItemController {
30
31
32 @RequestMapping(params = "methodToCall=printBill")
33 public void printBill(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
34 HttpServletRequest request, HttpServletResponse response) {
35 String formKey = request.getParameter("checkinFormKey");
36 CheckinForm checkinForm = (CheckinForm) GlobalVariables.getUifFormManager().getSessionForm(formKey);
37 if (null != checkinForm) {
38 printSlip(checkinForm, response);
39 }
40 }
41
42 public void printSlip(CheckinForm checkinForm, HttpServletResponse response) {
43 DroolsExchange droolsExchange = checkinForm.getDroolsExchange();
44 if(null != droolsExchange){
45 OleItemRecordForCirc oleItemRecordForCirc = (OleItemRecordForCirc) droolsExchange.getFromContext("oleItemRecordForCirc");
46 if(null != oleItemRecordForCirc){
47 OlePrintSlipUtil oleRegularPrintSlipUtil = getCheckinUIController(checkinForm).getOlePrintSlipUtil(oleItemRecordForCirc);
48 if (null != oleRegularPrintSlipUtil) {
49 oleRegularPrintSlipUtil.createPdfForPrintingSlip(oleItemRecordForCirc, response);
50 }
51 }
52 }
53 }
54
55 @RequestMapping(params = "methodToCall=printSlipForEndSession")
56 public void printSlipForEndSession (@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
57 HttpServletRequest request, HttpServletResponse response){
58 String formKey = request.getParameter("checkinFormKey");
59 CheckinForm checkinForm = (CheckinForm) GlobalVariables.getUifFormManager().getSessionForm(formKey);
60 if(null != checkinForm && null != checkinForm.getPrintFormat()){
61 List<CheckedInItem> checkedInItemList = checkinForm.getCheckedInItemList();
62 OlePrintSlipUtil olePrintSlipUtil = null;
63 if (checkinForm.getPrintFormat().equals(OLEConstants.RECEIPT_PRINTER)) {
64 olePrintSlipUtil = new OnHoldRecieptPrintSlipUtil();
65 } else {
66 olePrintSlipUtil = new OnHoldRegularPrintSlipUtil();
67 }
68 olePrintSlipUtil.createPdfForEndSessionPrintSlip(checkedInItemList,response);
69 checkinForm.resetAll();
70 }
71 }
72
73 }