private void createPOSelectItemList() {
   try {
     poSelectItemList.clear();
     ArrayList<PurchaseOrder> openPrList = poController.getOpenPurchaseOrders(warehouseCode);
     poSelectItemList.add(new SelectItem(Long.valueOf(-1), "àÅ×Í¡ãºÊÑ觫×éÍ"));
     SelectItem selectItem;
     for (PurchaseOrder po : openPrList) {
       selectItem = new SelectItem();
       selectItem.setValue(po.getId());
       selectItem.setLabel(po.getFormattedPoNumber());
       poSelectItemList.add(selectItem);
     }
   } catch (ControllerException e) {
     FacesUtils.reportError(FacesContext.getCurrentInstance(), e.getMessage(), e.getMessage(), e);
     e.printStackTrace();
   }
 }
 public void poComboBoxSelected() {
   try {
     /*
     if(selectedPOType == null || selectedPOType.equalsIgnoreCase("-1")) {
     	selectedPrID = Long.valueOf(-1);
     	throw new ControllerException("¡ÃسÒàÅ×Í¡»ÃÐàÀ·¡ÒèѴ«×éÍ/¨éÒ§");
     }
     */
     // newGR();
     editPO = poController.getPurchaseOrder(selectedPoID);
     if (editPO == null) return;
     // ÊÃéÒ§ PO â´Â copy ¢éÍÁÙÅÁÒ¨Ò¡ PR
     editGR.setPurchaseOrder(editPO);
     editGR.setReason(editPO.getReason());
     editGR.setRecipientName(editPO.getReceiverName());
     GoodsReceiptItem grItem;
     grItemList.clear();
     for (PurchaseOrderItem poItem : editPO.getPurchaseOrderItems()) {
       if (poItem.getRemainQty().doubleValue() > 0) {
         grItem = new GoodsReceiptItem();
         grItem.setGoodsReceipt(editGR);
         grItem.setItemNumber(poItem.getItemNumber());
         grItem.setMaterial(poItem.getMaterial());
         grItem.setOtherMaterial(poItem.getOtherMaterial());
         grItem.setBudgetItem(poItem.getBudgetItem());
         grItem.setReceivedQty(poItem.getRemainQty());
         grItem.setOrderQty(poItem.getRemainQty());
         grItem.setOrderUnitPrice(poItem.getUnitPrice());
         grItem.setReceiveUnit(poItem.getOrderUnit());
         grItem.setUnitPrice(poItem.getUnitPrice());
         grItem.setTotalprice(poItem.getRemainQty().multiply(poItem.getUnitPrice()));
         grItem.setNetPrice(poItem.getRemainQty().multiply(poItem.getUnitPrice()));
         grItem.setAvgPrice(poItem.getUnitPrice());
         grItemList.add(grItem);
       }
     }
   } catch (ControllerException e) {
     FacesUtils.reportError(FacesContext.getCurrentInstance(), e.getMessage(), e.getMessage(), e);
     e.printStackTrace();
   }
 }
  public void printGR() {
    LogManager log = new LogManager();
    try {
      JasperReport report = null;
      report =
          (JasperReport)
              JRLoader.loadObject(this.getClass().getResource("/welfare/reports/grForm.jasper"));
      // report = (JasperReport)JRLoader.loadObject("D:/grForm.jasper");

      ArrayList<PurchasingGRReportData> grReportList = new ArrayList<PurchasingGRReportData>();

      for (GoodsReceiptItem goodsReceiptItem : grItemList) {
        PurchasingGRReportData grReport = new PurchasingGRReportData();

        grReport.setItemNo(goodsReceiptItem.getItemNumber());
        grReport.setOrderQty(goodsReceiptItem.getOrderQty());
        grReport.setReceivedQty(goodsReceiptItem.getReceivedQty());
        grReport.setUnit(goodsReceiptItem.getReceiveUnit());
        grReport.setUnitPrice(goodsReceiptItem.getUnitPrice());

        String material = "";
        if (goodsReceiptItem.getMaterial() == null) {
          material = goodsReceiptItem.getOtherMaterial();
        } else {
          material = goodsReceiptItem.getMaterial().getDescription();
        }
        grReport.setMaterial(material);
        grReportList.add(grReport);
      }

      vendor = poController.getVendorForReport(editGR.getPurchaseOrder().getId());
      String text = "";
      if (editGR.getStatus().toString().equals("GR-FULL")) {
        text = "ÃѺàµçÁ¨Ó¹Ç¹";
      }
      if (editGR.getStatus().toString().equals("GR-PAR")) {
        text = "ÃѺäÁèàµçÁ¨Ó¹Ç¹";
      }

      HashMap grReportHashMap = new HashMap();
      grReportHashMap.put("grNo", editGR.getFormattedGrNumber());
      grReportHashMap.put("receivedDate", editGR.getReceivedDate());
      grReportHashMap.put("poNo", editGR.getPurchaseOrder().getFormattedPoNumber());
      grReportHashMap.put("status", editGR.getStatus().toString());
      grReportHashMap.put("invoiceNo", editGR.getInvoiceNumber());
      if (vendor != null) {
        grReportHashMap.put("vendor", vendor.getName());
      } else {
        grReportHashMap.put("vendor", editGR.getPurchaseOrder().getOtherVendor());
      }
      grReportHashMap.put("text", text);
      grReportHashMap.put("recipientName", editGR.getRecipientName());
      grReportHashMap.put("entryName", editGR.getEntryName());
      grReportHashMap.put("recipientPos", editGR.getRecipientPos());
      grReportHashMap.put("entryPos", editGR.getEntryPos());
      grReportHashMap.put("totalPrice", editGR.getTotalPrice());
      grReportHashMap.put("totalDiscount", editGR.getTotalDiscountAmount());
      grReportHashMap.put("LOGO", this.getClass().getResource("/welfare/reports/logo.gif"));
      grReportHashMap.put("logo", this.getClass().getResource("/welfare/reports/aerologo.png"));

      JasperPrint jasperPrint =
          JasperFillManager.fillReport(
              report, grReportHashMap, new JRBeanCollectionDataSource(grReportList));

      // JasperExportManager.exportReportToPdfFile(jasperPrint,"D:/testGR.pdf");
      byte[] bytes = JasperExportManager.exportReportToPdf(jasperPrint);
      ReportUtils.displayPdfReport(bytes);
      log.recordPrintGr(editGR.getFormattedGrNumber());

    } catch (JRException e) {
      // TODO: handle exception
      e.printStackTrace();
      e.getMessage();
    } catch (ControllerException e) {
      FacesUtils.reportError(FacesContext.getCurrentInstance(), e.getMessage(), e.getMessage(), e);
      e.printStackTrace();
    } catch (IOException e) {
      // TODO: handle exception
      e.printStackTrace();
    }
  }