public void create(HttpServletRequest request, HttpServletResponse response) throws Exception {
    // HttpSession session = request.getSession();
    // UserSession us = (UserSession)session.getValue(Constants.USER_SESSION);

    pre(request, response);
    Stockout so = new Stockout(this.db);
    String job_no = so.genJobNo(String.valueOf(offcode));
    so.setJob_no(job_no);
    so.setOffName(offname);
    so.setStockout_date(new Date());
    so.setTransfer_by(uData.getIdCard());
    request.setAttribute("so", so);
    request.setAttribute("staff_name2", uData.getFullName());
    this.tranLogSave(TRAN_LOG_MSG_CREATE);
    forward(JSP_FORM_PAGE, request, response);
  }
  public void edit(HttpServletRequest request, HttpServletResponse response) throws Exception {
    pre(request, response);
    Long id = ServletRequestUtils.getLongParameter(request, "id", -1);
    if (id != -1) {
      Stockout so = new Stockout(this.db).findByPk(id);
      log.debug("so list=" + so);
      so.setOffName(offname);
      request.setAttribute("so", so);

      Staff report_staff = so.getReportStaff();
      if (report_staff != null) {
        request.setAttribute("staff_name", report_staff.getFullName());
        request.setAttribute("report_to_posname", report_staff.getReport_to_posname());
      }
      Staff transfer_staff = so.getTransferByStaff();
      if (transfer_staff != null) request.setAttribute("staff_name2", transfer_staff.getFullName());
      EdOffice office_to = so.getOfficeTo();
      // log.debug(so.toString());
      if (office_to != null) request.setAttribute("offname_to", office_to.getOffname());
      this.setStockoutItemList(request, so);
    }
    String reset = ServletRequestUtils.getStringParameter(request, "reset", "");
    if (!"".equals(reset)) {
      this.tranLogSave(TRAN_LOG_MSG_RESET);
    }
    String display = ServletRequestUtils.getStringParameter(request, "display", "");
    if (!"".equals(display)) {
      this.tranLogSave(TRAN_LOG_MSG_DISPLAY);
    }
    Unit unit = new Unit(this.db);
    String uSql = "select u.unit_code, u.thname, du.group_id ";
    uSql += " from unit u";
    uSql += " inner join duty_unit du on du.unit_code=u.unit_code ";
    uSql += " where du.used_for in ('A','S') ";
    uSql +=
        " and to_date(sysdate) between to_date(du.begin_date) and to_date(nvl(du.end_date,sysdate)) ";
    uSql += " order by u.thname";
    log.debug("Transfer Unit List " + uSql);
    List<Map<String, Object>> unitlist = unit.findBySql(uSql);

    if (request.getParameter("SaveMsg") != null) request.setAttribute("SaveMsg", "1");
    forward(JSP_FORM_PAGE, request, response);
  }