/** * AddReportDetail to Grid */
  @Override
  public void addReportDetail(ActionEvent actionEvent) {

    logger.trace("addReportDetail... {}", inputReport014Detail);

    if (!validateReportDetail()) {
      return;
    }

    if (report014Details == null || report014Details.isEmpty()) {

      report014Details = new ArrayList<>();
      inputReport014Detail.setKey(1);

    } else {

      inputReport014Detail.setKey(report014Details.get(report014Details.size() - 1).getKey() + 1);
    }

    inputReport014Detail.setReportId(report014);

    report014Details.add(inputReport014Detail);

    JsfUtil.hidePopup("REPORT_014dlgAddReportDetail");
  }
  /**
   * * Row Edit
   *
   * @param event
   */
  @Override
  public void onEdit(RowEditEvent event) {

    Report014Detail editRow = ((Report014Detail) event.getObject());

    logger.trace("Edit Row : {}", editRow);

    for (int i = 0; i < report014Details.size(); i++) {

      if (report014Details.get(i).getKey() == editRow.getKey()) {

        report014Details.remove(i);
        report014Details.add(i, editRow);

        logger.trace("After Edit Row : {}", editRow);
      }

      break;
    }

    JsfUtil.addSuccessMessage("แก้ใขข้อมูลสำเร็จ!!");
  }
  private void initForm() {

    initTitle();

    report014Details = new ArrayList<>();

    Report014Detail report014Detail1 = new Report014Detail();
    report014Detail1.setInstitution("สำนักกิจการพรรคการเมืองและการออกเสียงประชามติ");
    //        report014Detail1.setAtCenter(0);
    //        report014Detail1.setAtEctProvince(0);
    //        report014Detail1.setEctResolve(0);
    //        report014Detail1.setAnalystRemain(0);
    //        report014Detail1.setOfferEct(0);
    //        report014Detail1.setAccessCommittee(0);
    //        report014Detail1.setOnAgenda(0);
    //        report014Detail1.setSendRequest(0);
    report014Detail1.setReportId(report014);

    //        Report014Detail report014Detail2 = new Report014Detail();
    //        report014Detail2.setInstitution("สำนักสืบสวนสอบสวนและวิจัย 2");
    //        report014Detail2.setAtCenter(0);
    //        report014Detail2.setAtEctProvince(0);
    //        report014Detail2.setEctResolve(0);
    //        report014Detail2.setAnalystRemain(0);
    //        report014Detail2.setOfferEct(0);
    //        report014Detail2.setAccessCommittee(0);
    //        report014Detail2.setOnAgenda(0);
    //        report014Detail2.setSendRequest(0);
    //        report014Detail2.setReportId(report014);
    //
    //        Report014Detail report014Detail3 = new Report014Detail();
    //        report014Detail3.setInstitution("สำนักสืบสวนสอบสวนและวิจัย 3");
    //        report014Detail3.setAtCenter(0);
    //        report014Detail3.setAtEctProvince(0);
    //        report014Detail3.setEctResolve(0);
    //        report014Detail3.setAnalystRemain(0);
    //        report014Detail3.setOfferEct(0);
    //        report014Detail3.setAccessCommittee(0);
    //        report014Detail3.setOnAgenda(0);
    //        report014Detail3.setSendRequest(0);
    //        report014Detail3.setReportId(report014);
    //
    //        Report014Detail report014Detail4 = new Report014Detail();
    //        report014Detail4.setInstitution("สำนักสืบสวนสอบสวนและวิจัย 4");
    //        report014Detail4.setAtCenter(0);
    //        report014Detail4.setAtEctProvince(0);
    //        report014Detail4.setEctResolve(0);
    //        report014Detail4.setAnalystRemain(0);
    //        report014Detail4.setOfferEct(0);
    //        report014Detail4.setAccessCommittee(0);
    //        report014Detail4.setOnAgenda(0);
    //        report014Detail4.setSendRequest(0);
    //        report014Detail4.setReportId(report014);
    //
    //        Report014Detail report014Detail5 = new Report014Detail();
    //        report014Detail5.setInstitution("สำนักสืบสวนสอบสวนและวิจัย 5");
    //        report014Detail5.setAtCenter(0);
    //        report014Detail5.setAtEctProvince(0);
    //        report014Detail5.setEctResolve(0);
    //        report014Detail5.setAnalystRemain(0);
    //        report014Detail5.setOfferEct(0);
    //        report014Detail5.setAccessCommittee(0);
    //        report014Detail5.setOnAgenda(0);
    //        report014Detail5.setSendRequest(0);
    //        report014Detail5.setReportId(report014);

    report014Details.add(report014Detail1);

    report014.setReport014DetailList(report014Details);
    report014.setReportMonth(reportMonth);
    report014.setReportYear(reportYear);
  }
  public void calSum() {

    for (Report014Detail report014Detail : report014Details) {
      logger.trace("report014Detail : {}", report014Detail);
      report014Detail.setAtCenter(
          NumberUtils.convertNUllToZero(report014Detail.getOnAgenda())
              + NumberUtils.convertNUllToZero(report014Detail.getAccessCommittee())
              + NumberUtils.convertNUllToZero(report014Detail.getOfferEct())
              + NumberUtils.convertNUllToZero(report014Detail.getAnalystRemain())
              + NumberUtils.convertNUllToZero(report014Detail.getSendRequest()));

      report014Detail.setAllAmount(
          NumberUtils.convertNUllToZero(report014Detail.getAtCenter())
              + NumberUtils.convertNUllToZero(report014Detail.getAtEctProvince())
              + NumberUtils.convertNUllToZero(report014Detail.getEctResolve()));
    }
  }